← Back to team overview

yade-dev team mailing list archive

Note on optimized compilation / optimized coding / profiling results

 

Hi guys

After a carefull inspection of valgrind outputs, I came to the 
conclusion that

(1) this line :

for(InteractionContainer::iterator I=interactions->begin(); 
I!=interactions->end(); ++I)

is not optimized with my compiler. It means that interactions->end() 
will be executed at each iteration, and it needs a lot of time in loops.

(2) Even worse, in this code from PhysicalActionVectorVector.cpp :

shared_ptr<PhysicalAction>& PhysicalActionVectorVector::find(unsigned 
int id , int actionIndex )
{
    if( physicalActions.size() <= id ) // this is very rarely executed, 
only at beginning.
    // somebody is accesing out of bounds, make sure he will find, what 
he needs - a resetted PhysicalAction of his type
    { ....


the size of physicalActions WILL BE COMPUTED each time somebody type 
physicalActions.find(i,j) !!! As a result, size() is executed around 
4500 times per timestep in a TriaxialTest with 400 spheres, which 
represents around 20% of the cost of a function like 
ElasticContactLaw.action().


(3) actionStiffness->getClassIndex() is always executed too. It is 
better to add a member data stiffnessIndex to the engine, then define it 
only once as stiffnessIndex=actionStiffness->getClassIndex() in the 
constructor, and finally use stiffnessIndex for internal tests instead 
of getClassIndex(). 


I'm a bit surprised because I thought the compiler would fix all that 
alone. It looks like it doesn't. I don't know if this is because of 
debug symbols or something else limiting optimization (what is the 
optimization level whith scons flag "optimization=True", is it 
equivalent to -O3?).
Afer fixing things here and there concerning those 3 points above (e.g. 
I added a member data called "size" to the container to avoid computing 
it all the time), I could run the triaxial test around 25% faster.
I can commit those changes soon, I'm curious to know the results on 
other computers.

Bruno







 

-- 
 
_______________
Chareyre Bruno
Maitre de conference

Institut National Polytechnique de Grenoble
Laboratoire 3S (Soils Solids Structures) - bureau E145
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________

_______________________________________________
yade-dev mailing list
yade-dev@xxxxxxxxxxxxxxxx
https://lists.berlios.de/mailman/listinfo/yade-dev



Follow ups