lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] overview of C++ expression template libraries


From: Greg Chicares
Subject: Re: [lmi] overview of C++ expression template libraries
Date: Thu, 11 Sep 2008 20:16:08 +0000
User-agent: Thunderbird 2.0.0.16 (Windows/20080708)

On 2007-01-08 14:23Z, Vadim Zeitlin wrote:
> 
>  I don't see anything against PETE except that it doesn't seem clear
> whether it's actively maintained.

There's no recent maintenance activity AFAICT. Yet it's not like some
other projects where people raise issues but nobody replies.

> So the wisest approach would probably be
> to make sure that we can understand its code and, if necessary, debug and
> maintain it ourselves before committing to using it.

http://cvs.savannah.gnu.org/viewvc/lmi/lmi/tools/pete-2.1.1/ChangeLog?view=markup

I was able to fix a defect in its cast function, and to extend it to
accommodate std::unary_function and std::binary_function. This wasn't
difficult because PETE was designed well. Anyone who wants to study it
should read the html documentation in FreePOOMA's pete-2.1.0 tarball.

For lmi, please place copies of (or links to) the locally-modified PETE
sources on some include path. Here's one way that definitely works:

http://cvs.savannah.gnu.org/viewvc/lmi/lmi/install_miscellanea.make?r1=1.13&r2=1.14

At this moment, only 'expression_template_0_test.cpp' requires this,
but soon lmi will require it generally.

With gcc-3.4.4, PETE is noticeably slower than valarray in the unit
test, although it's still faster than calling transform() repeatedly.
With official MinGW gcc-4.3.0, though, PETE and valarray perform just
about as well as a hand-coded C loop. Speed isn't the prime criterion
for lmi, as long as it's not seriously pessimized; maintainability is.
And
  std::vector<double> W, X, Y, Z;
  ...
  W += (1.0 - X) * (Y - Z); // No loop; no lambda; no transform().
is as comprehensible and maintainable as we're going to get.

Here are selected test results that compare
    double v0[N], v1[N], v2[N];
    /* ...initialize vectors with nonzero values... */
    for(int j = 0; j < N; ++j)
        v2[j] += v0[j] - 2.1 * v1[j];
to valarray and PETE equivalents, using gcc-4.3 with '-O2':

  Speed tests: array length 10
  C               : 2.625e-007 s =        262 ns, mean of 38102 iterations
  valarray        : 2.580e-007 s =        258 ns, mean of 38761 iterations
  PETE            : 2.668e-007 s =        267 ns, mean of 37483 iterations

  Speed tests: array length 100
  C               : 4.504e-007 s =        450 ns, mean of 22204 iterations
  valarray        : 4.545e-007 s =        454 ns, mean of 22006 iterations
  PETE            : 4.604e-007 s =        460 ns, mean of 21720 iterations

  Speed tests: array length 1000
  C               : 2.238e-006 s =       2238 ns, mean of 4469 iterations
  valarray        : 2.338e-006 s =       2338 ns, mean of 4277 iterations
  PETE            : 2.307e-006 s =       2307 ns, mean of 4334 iterations




reply via email to

[Prev in Thread] Current Thread [Next in Thread]