The Never Ending Story ... Part (Int_t)341514 + 4

From: Jacek M. Holeczek (holeczek@us.edu.pl)
Date: Fri May 14 1999 - 10:06:15 MEST


Hi,
Following some advises from Masa and Rene, I looked into the CINT CallFunc
class, and I modified the part of my ntuple::Loop which deals with the
INTERPRETEDFUNC case as follows :
-----------------------
Int_t ntuple::Loop(Int_t (*p2f)(ntuple *))
{
  ...
  char temp[50]; // INTERPRETEDFUNC
  long offset = 0; // INTERPRETEDFUNC
  G__ClassInfo globalscope; // INTERPRETEDFUNC
  G__CallFunc func; // INTERPRETEDFUNC, COMPILEDINTERFACEMETHOD, BYTECODEFUNC
  switch(G__isinterpretedp2f(((void *)p2f)) {
  case G__INTERPRETEDFUNC:
    sprintf(temp,"(ntuple*)%p",(void*)this);
    func.SetFunc(&globalscope,(char *)p2f,temp,&offset);
    for (Int_t i=0; i<nentries; i++) {
      nevents += GetEvent(i);
      if (func.ExecInt((void*)NULL)) break;
    }
    break;
  case G__COMPILEDINTERFACEMETHOD:
    ...
  ...
  }
  return nevents;
}
-----------------------
This, on principle, works ( the CallFunc::SetFunc tries to byte compile
the p2f function prior to use ).
There exist a problem, however. Sometimes the p2f is NOT byte compiled. I
tried to trace it ... seems that the CallFunc::SetFunc calls the
GMethodInfo::GetBytecode which calls the G__compile_bytecode which returns
"bytecodestatus" 2 ( G_BYTECODE_FAILURE ). Sorry, no idea why.
I can easily "produce" such a problem :
-----------------------
root [0] .L ntuple.so <- load the "compiled" shared library
root [1] ntuple *n=new ntuple() <- create an "ntuple" object n
root [2] .L test.cxx <- load the "interpreted" function
root [3] n-Draw("x") <- error, the ntuple class has no Draw method
Error: No symbol Draw("x") in current scope  FILE:/tmp/01521caa LINE:1 (class ntuple*)0x85073d0
*** Interpreter error recovered ***
root [4] n->Loop(test) <- "compiled" code calls "interpreted", BYTECOMPILE IT
                       <- it will NOT be byte compiled after the "error"
-----------------------
Sometimes it helps if, after such an error, I ".L test.cxx" again, but
sometimes not ( sometimes after two ".L test.cxx" it works ).
Any idea why ?
A also repeated some tests, that I showed in my last mail, on a
Pentium/233 64MB RAM, RH5.2 Linux with root 2.21/08.
As before, the "ntuple" itself has 341514 events.
Now come ( total ) execution times :
	3. n->Loop(test) where "Loop" is a "compiled" code, "test" is
	   "interpreted", and IS byte-compiled ( compiled code calls
	   interpreted byte-compiled code ) -> 6.8 sec
	4. n->Loop(test) where "Loop" is an "interpreted" code, "Loop"
	   calls the "interpreted" "test" function ( interpreted code
	   "calls" interpreted code, NOT byte-compiled ) -> 1032 sec
	6. loop(n) where "loop" is an "interpreted" code ( byte compiled
	   after first "use" ), "loop" directly fills the "h_test"
	   histogram ( no function "call" inside "loop" ) -> 6.7 sec
This shows again that this setup is 2.8 +- 0.3 times slower then the
2*PII/450 setup.
Jacek.



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:33 MET