RE: [ROOT] execution speed of compiled programs using ROOT

From: Valeri Fine (fine@bnl.gov)
Date: Thu Aug 14 2003 - 01:13:52 MEST


Hello I made the simple experiments

  1. Compile the code in question with Optimization
     1.1. #define USE_ROOT
     1.2. #undef USE_ROOT

  2. Compile the code in question with NO Optimization
     2.1. #define USE_ROOT
     2.2. #undef USE_ROOT

  3. Change the loop as follows:
     for(long int i=0; i<100000000; i++) {
        r += 0.5;
        y = sin(r);
     }
     Compile the code in question with NO Optimization
     3.1. #define USE_ROOT
     3.2. #undef USE_ROOT

  4. The code from the point 3 but with Optimization
     4.1. #define USE_ROOT
     4.2. #undef USE_ROOT
   5. remove any ROOT call and replace it with 
      double y = sin(3.5);
       for (int j=0; j < 10;j++) {
         y = sin(y);
      }
      no optimization
------------------------------
     Duration
1.1   340
1.2   340

2.1    921 
2.2   2643 (!!!)

3.1  17265
3.2  19137

4.1    340
4.2    340

5.1   2673
5.2   2633
------------------------------

In other words 
 when  "#define USE_ROOT" is ON the code is FASTER by factor 3 !!!
(see 2.1 and 2.2 )

At least my result does contradict YOUR observation.
I don't go further because the code in question is not good to jump 
to any kind of the conclusions.

Have a fun.

  Valeri



> -----Original Message-----
> From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]
> On Behalf Of Valeri Fine
> Sent: Thursday, August 14, 2003 12:03 AM
> To: 'Philippe Canal'; 'Thomas Nisius'; roottalk@pcroot.cern.ch
> Subject: RE: [ROOT] execution speed of compiled programs using ROOT
> 
> 
> 
> Hello I don't think any second thread is involved here.
> I would have suspected some sort of the compile-time optimization
here.
> 
> I believe compiler may have figured out what is final value of "r"
with
> no real loop implementation in the binary code.
> 
>   for(long int i=0; i<100000000; i++) {
>      r += 0.5;
>    }
> 
> I mean the method above is not correct to measure the performance
> One should take care to break the possible optimization first.
> 
>      Valeri
> 
> >
> > Hi Thomas,
> >
> > I can indeed reproduce the same slowdown by a factor of 2.  I
suspect
> that
> > this is due to the multi-thread nature of the ROOT implementation on
> > Windows.  (I.e. the other thread are probably being run).  We will
> > check further.
> >
> > Cheers,
> > Philippe.
> >
> > -----Original Message-----
> > From: owner-roottalk@pcroot.cern.ch
> > [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Thomas Nisius
> > Sent: Friday, August 08, 2003 7:28 AM
> > To: roottalk@pcroot.cern.ch
> > Subject: [ROOT] execution speed of compiled programs using ROOT
> >
> >
> > Hi,
> >
> > when I compile a program that include some root objects, execution
> speed
> > drops significantly.
> > please see the following example:
> >
> > #include <time.h>
> > #include <iostream>
> > using namespace std;
> >
> > #include <TH2D.h>
> > #define USE_ROOT
> >
> > int main(int argc, char* argv[]) {
> >
> > #ifdef USE_ROOT
> >   TH2D *h = new TH2D("test","test",64,0,1,64,0,1);
> >   h->FillRandom("gaus",1000);
> > #endif
> >
> >   double r=0;
> >   double time = clock(); // save the clock
> >   for(long int i=0; i<100000000; i++) {
> >     r += 0.5;
> >   }
> >   cout << r << endl;
> >   cout << "Duration: " << clock() - time << endl;
> >   return 0;
> > }
> >
> > if in this example 'USE_ROOT' is defined the duration is nearly
twice
> as
> > long as without it.
> > (note, that only the execution of the loop is taken into account,
not
> the
> > histo filling)
> >
> > I'm using Root 3.05/07 (win32gdk-version) on WinXP & Win2000
> > Compiler: MSVC++ 6
> > I link libCore.lib and libHist.lib to my Project
> >
> > Any suggestions?
> >
> > Kind Regards
> > Thomas Nisius
> >
>
________________________________________________________________________
> __
> > Die sicherste Form der Kommunikation: E-Mails verschluesseln,
> Spam-Filter,
> > Adressverifizierung, digitale Unterschrift: http://freemail.web.de



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET