toon-members
[Top][All Lists]
Advanced

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

Re: [Toon-members] Should dynamic really be this slow?


From: Gerhard Reitmayr
Subject: Re: [Toon-members] Should dynamic really be this slow?
Date: Wed, 20 Jun 2007 19:48:49 +0100

Observed the same on my G4 powerbook.

multiplication with dynamic vector (result of slice() ) produced a dynamic vector temporary which allocates the data on the heap! the profiler shows most time is spend allocating and deleting the data store per loop.

a small fix to linoperators.h rectifies this for your example because the result size is known for the fixed matrix * dyn vec case. that brings it to comparable speed on my machine.

however, combinations really requiring a dynamic temporary are still slow. for example change to:
Matrix<> m2(2,2); Identity(m2);

what about a dedicated memory manager for small double arrays ?

Gerhard

On 20 Jun 2007, at 18:35, Georg Klein wrote:

I was surprised by this:

static.cc:
#include <TooN/numerics.h>
#include <TooN/helpers.h>
int main()
{
  Vector<2> v2;  Zero(v2);
  Matrix<2> m2;  Identity(m2);
  Vector<3> v3((double[]){1.0,1.0,1.0});
  for(int i=0; i<100000000; i++)
      v2 += m2 * v3.slice<0,2>();
  return v2[0];
}

compiling with O3 and running this on my machine takes 0.27 seconds. Pretty cool.

If however I chance the crunchy line to
v2 += m2 * v3.slice(0,2);

it takes 4.3 seconds. That's 16 times slower. That's a lot! Can anyone reproduce this? Compiling with -DNDEBUG to get rid of the assert makes hardly any difference.





_______________________________________________
Toon-members mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/toon-members

--
Gerhard Reitmayr
MIL, Engineering Department, Cambridge University
http://mi.eng.cam.ac.uk/~gr281/






reply via email to

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