Boost logo

Boost :

From: rwgk (rwgk_at_[hidden])
Date: 2002-03-08 04:46:39


--- In boost_at_y..., "David Abrahams" <david.abrahams_at_r...> wrote:
> I think you'd better do some measurements on complex array
expressions
> before making that statement. The whole point of Blitz++ is that the
> library can see and analyze the entire expression before evaluating
it.

I have done some homework.
Here is the code:
http://cci.lbl.gov/~rwgk/shortcuts/cctbx/arraytbx/timing/
File: run_timing.cpp
Platform: Compaq Alpha EV67, 667MHz, 4GB RAM, cxx 6.2 (EDG240)
blitz-20001213.tar.gz does unfortunately not compile with cxx 6.5
(EDG245)
which has a much better optimizer.
Unfortunately our Linux machine is down at the moment.

The code is timing the two most important types of
expressions in scientific code:
a + b
a * b + c

Here are the results:

Expression: a + b
n_iter = 300000
blitz::Array(1000) 1.08329
  af::shared(1000) 1.51661
n_iter = 30000
blitz::Array(10000) 1.58327
  af::shared(10000) 1.58327
n_iter = 3000
blitz::Array(100000) 1.59994
  af::shared(100000) 1.54994
n_iter = 300
blitz::Array(1000000) 6.14975
  af::shared(1000000) 6.13309
n_iter = 30
blitz::Array(10000000) 6.14975
  af::shared(10000000) 6.26642
n_iter = 3
Abort

Expression: a * b + c
n_iter = 300000
blitz::Array(1000) 1.49994
  af::shared(1000) 2.94988
n_iter = 30000
blitz::Array(10000) 2.34991
  af::shared(10000) 3.18321
n_iter = 3000
blitz::Array(100000) 2.41657
  af::shared(100000) 3.11654
n_iter = 300
blitz::Array(1000000) 8.58299
  af::shared(1000000) 12.1995
n_iter = 30
blitz::Array(10000000) 8.66632
  af::shared(10000000) 12.4662
n_iter = 3
Abort

Longer expressions are rare in the real-world code that I
have seen. Given the choice of (a) having to use a GPL
licensed library or (b) writing the few long /and/
time-critical expressions as loops I prefer (b), but
clearly expression-template based algebra with a a free
license would be best. The source code or compile-time
overhead will become less and less of an issue with time.
Maybe one day when I have time I should try out PETE...

Ralf

P.S.: Note that the "Abort" happen in this constructor:
blitz::Array<double, 1> ba(sa.begin(), n, blitz::duplicateData);
This is pure speculation, but one guess is that the crash is
due to the use of int where one would expect std::size_t.
Array(T_numtype* dataFirst, TinyVector<int, N_rank> shape,
    preexistingMemoryPolicy deletePolicy);


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk