RE: [CINT] Re: Embedding CINT in C++ application

From: Borse, Ganesh <ganesh.borse_at_credit-suisse.com>
Date: Thu, 6 Dec 2007 13:33:25 +0800

  1. Why do we need to put the expressions in a file for compiling? Can we not have the parsing, etc directly from memory? Is this a limitation?
  2. Also, the Execute function takes an char* array of input arguments to the called function, what happens if the called function takes float or long argument? E.g the function "MyFunction" I shown below takes 3 ints, then will Execute convert the corresponding variables to int when calling that function?
  3. Are there any limitations in terms of the functions we can use: e.g. is it possible to use different functions such as strstr, strcmp, index, rindex, etc?

-----Original Message-----
From: Axel Naumann [mailto:Axel.Naumann_at_cern.ch] Sent: 05 December 2007 18:03
To: Borse, Ganesh
Cc: Rene Brun; roottalk_at_root.cern.ch; 'cint_at_root.cern.ch' Subject: Re: [CINT] Re: [ROOT] Embedding CINT in C++ application

Hi,

the bytecode never goes to file - it is generated and stays in memory. The C++ code does, but the OS should cache it, so disk latency should not matter.

Cheers, Axel.

Borse, Ganesh wrote:
> What about disk latency when accessing the byte code from the file?
>
> -----Original Message-----
> From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch]
> On Behalf Of Axel Naumann
> Sent: 05 December 2007 17:46
> To: Borse, Ganesh
> Cc: Rene Brun; roottalk_at_root.cern.ch; 'cint_at_root.cern.ch'
> Subject: Re: [CINT] Re: [ROOT] Embedding CINT in C++ application
>
> Hi,
>
> you could write it to a temporary file. If you call it e.g.
> "tempAHGHJGJ.C" and wrap your code in a function "tempAHGHJGJ()" you can simply do gInterpreter->ProcessLine(".x tempAHGHJGJ.C"). This file will be run with bytecode optimization.
>
> Cheers, Axel.
>
> Borse, Ganesh wrote:

>> ProcessLine would be slower because every call to ProcessLine will parse the expression & then execute it.
>>
>> Is it possible to do the onetime parsing (& compile) of such expression & then execute that byte code later multiple times?
>>
>> E.g. I wrap this expression in a function like below:
>>
>> const char *myFuncSrc=\
>> "int MyFunction(int size, int vol, int ADV,char* prod, char* 
>> ordClient)\ {\
>>   if((size < 1000) && (vol < (0.001 * ADV)) && (prod == "Stock") && strstr("ABCD,EFGH,HIJK,NEWONE,song,JUNK,DONE",ordClient))\
>>     return 1;\
>>   else\
>>       return 0;\
>> }"
>> // Parse & Compile this function
>> gInterpreter->ProcessLine(myFuncSrc);
>> while(1){
>>    // --- data for variables come in from client application over a socket connection
>>    char* argv[]=; // populate the input arguments....
>>    Int result=0;
>>    gInterpreter->Execute("MyFunction",argv,&result);
>>    printf("result %d\n",result);
>> }
>>
>> How do we do this kind of actions with Tinterpreter or other APIs of cint?
>> Sorry for long list of questions.
>>
>> Thanks & Regards,
>> Ganesh
>> -----Original Message-----
>> From: Axel Naumann [mailto:Axel.Naumann_at_cern.ch]
>> Sent: 05 December 2007 17:09
>> To: Rene Brun
>> Cc: Borse, Ganesh; roottalk_at_root.cern.ch; 'cint_at_root.cern.ch'
>> Subject: Re: [CINT] Re: [ROOT] Embedding CINT in C++ application
>>
>> ...or, for more of C++ including variable declaration etc, pass your C++ code as a string to ROOT's gInterpreter>ProcessLine(). gInterpreter is ROOT's global TCint object; a high level interface to CINT. See <http://root.cern.ch/root/html/TCint#TCint:ProcessLine> If you weant to do the same with CINT stand-alone then please let us know.
>>
>> Cheers, Axel.
>>
>> Rene Brun wrote:
>>> ROOT provides two classes (TFormula and TTreeFormula) for doing 
>>> exactly what you want to do.
>>> see examples of use with ROOT Trees in the Users Guide
>>>   ftp://root.cern.ch/root/doc/12Trees.pdf
>>> at section "Simple Analysis using Trees" at page 213 and following
>>>
>>> Rene Brun
>>>
>>> Borse, Ganesh wrote:
>>>> Hi,
>>>> Is it possible to embed ROOT CINT in C++ application & use it for 
>>>> doing dynamic expressions parsing, compilation and then multiple 
>>>> run time evaluations those expressions?
>>>>
>>>> I can see the root/bin/cint has all its logic in 
>>>> root/lib/libCint.so, with ldd command.
>>>>
>>>> E.g, I have the expressions as below:
>>>> ((size < 1000) && (vol < (0.001 * ADV)) && (prod == "Stock") &&
>>>> strstr("ABCD,EFGH,HIJK,NEWONE,song,JUNK,DONE",ordClient))
>>>>
>>>> The variables size, ADV, vol, etc. will be changing at runtime.
>>>> So, I would like to create function which will take these variables 
>>>> as input arguments & return the result of evaluated expression.
>>>>
>>>> Since, these expressions, the number & type of these variables is 
>>>> not at compilation time, I cannot create & compile these function 
>>>> at compiling my application.
>>>>
>>>> Hence, I need to use some kind of interpreter which can take these 
>>>> expressions, etc as source code & compile them.
>>>>
>>>> I tried to use Python & Perl interpreters for embedding them in C++ 
>>>> application. But they don't provide the required performance level.
>>>>
>>>> Also, the syntax of the expressions is to be same that in these 
>>>> scripting languages. Hence, it is little tedious to use them.
>>>>
>>>> May you please guide me, if I can use cint for this?
>>>> What are the functions, APIs & include headers, etc. I need to use 
>>>> for this?
>>>>
>>>> A sample program of the same thing which I am doing with Cpython 
>>>> API (embedding Python in C) is attached here.
>>>>
>>>> Thanks and Regards,
>>>> Ganesh
>>>> <<testeval.cpp>>
>>>>
>>>> ===================================================================
>>>> =
>>>> =
>>>> =========
>>>>
>>>> Please access the attached hyperlink for an important electronic 
>>>> communications disclaimer:
>>>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>>>> ===================================================================
>>>> =
>>>> =
>>>> =========
>>>>
>>>>   
>> =====================================================================
>> = ======== Please access the attached hyperlink for an important 
>> electronic communications disclaimer:
>>
>> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
>> =====================================================================
>> =
>> ========
>>
>>

>
>
> ======================================================================
> ======== Please access the attached hyperlink for an important
> electronic communications disclaimer:
>
> http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
> ======================================================================
> ========
>
>


Please access the attached hyperlink for an important electronic communications disclaimer:

http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html


Received on Thu Dec 06 2007 - 06:34:17 CET

This archive was generated by hypermail 2.2.0 : Thu Dec 06 2007 - 11:50:02 CET