Re: The Never Ending Story ... Part (Int_t)341514

Rene Brun (Rene.Brun@cern.ch)
Wed, 12 May 1999 15:32:11 +0000


Hi Jacek,
I suggest you look for an example of efficient calls to interpreted
functions in the TF1 constructors.

Rene Brun

Jacek M. Holeczek wrote:
>
> Hi,
> I have met a CINT problem which I cannot seem to be able to resolve.
> I try to call an "interpreted" function ( loaded interactively by ".L" in
> root ) from a "compiled" shared library. Something like :
> -----------------------
> 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->Loop(test) <- "compiled" code calls "interpreted"
> -----------------------
> The compiled ntuple::Loop function looks like :
> -----------------------
> Int_t ntuple::Loop(Int_t (*p2f)(ntuple *))
> {
> ...
> switch(G__isinterpretedp2f(((void *)p2f)) {
> case G__INTERPRETEDFUNC:
> Char_t temp[200];
> sprintf(temp,"(*%s)(((ntuple *)%ld))",(char*)p2f,((long)this));
> for (Int_t i=0; i<nentries; i++) {
> nevents += GetEvent(i);
> if (G__int(G__calc(temp))) break;
> }
> break;
> case G__COMPILEDINTERFACEMETHOD:
> ...
> ...
> }
> return nevents;
> }
> -----------------------
> The interpreted test function looks like :
> -----------------------
> Int_t test(ntuple *n)
> {
> ...
> h_test->Fill(n->x()); // both h_test histogram and n::x() exist
> ...
> return 0;
> }
> -----------------------
> On principle it works, but ... EXTREMELY slowly.
> The problem is that the G__isinterpretedp2f returns G__INTERPRETEDFUNC,
> instead of G__BYTECODEFUNC. The test.cxx does NOT seem to be "byte
> compiled" when loaded ( ".L" ), and used.
> Then I tried to test how it behaves in case everything is run as an
> "interpreted" code, so I modified the ntuple::Loop :
> -----------------------
> Int_t ntuple::Loop(Int_t (*p2f)(ntuple *))
> {
> ...
> Int_t result;
> for (Int_t i=0; i<nentries; i++) {
> nevents += GetEvent(i);
> result = (*p2f)(this);
> if (result) break;
> }
> }
> -----------------------
> And instead of ".L ntuple.so" I loaded ".L ntuple.cxx".
> The result was ... it was MUCH MORE slowly.
> Thus, the conclusion is - CINT cannot "byte compile" functions if they are
> used as "pointers" ???
> On this occasion I have also met a CINT error. If in "interpreted" version
> of ntuple::Loop I say :
> if ((*p2f)(this)) break;
> instead of :
> result = (*p2f)(this);
> if (result) break;
> the CINT cries :
> -----------------------
> root [4] n->Loop(test)
> Error: No symbol p2f)(this in current scope FILE:/.../ntuple.cxx LINE:96
> Error: Illegal pointer operation (tovalue) FILE:/.../ntuple.cxx LINE:96
> *** Interpreter error recovered ***
> -----------------------
> Can I somehow convince CINT to give me "byte compiled" function(s) ?
> Thanks in advance,
> Jacek.