Gabi
2010-Mar-18 08:21 UTC
[LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
Hello I have the following scenario, and I am not sure why the performance is so bad (take 30 minutes to complete with very simple generated functions): 1. Create module 2. Do something like EE EngineBuilder(theModule).setEngineKind(EngineKind::JIT).create(); 3. Create a function in the module: theModule->getOrInsertFunction(..) 4. Execute 1000 times the function using EE->runFunction(function, args) with different args in each round. My question - Does section 4 above makes the EE recompile the function 1000 times? If no, why is the performance is so bad? what am I doing wrong ? Maybe I should somehow cache the function's binary code? llvm-version 2.7 OS: Linux 2.6.31 64 bits (intel dual core, 4GB memory) -- Regards, Gabi http://bugspy.net
Olivier Meurant
2010-Mar-18 14:35 UTC
[LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
Hi Gabi, I have no idea why your performances is not as expected with such low level of informations. But, I know that the binary code is cached by the JIT. You can find the code in JIT.cpp to convince yourself : runFunction -> getPointerToFunction ->getPointerToGlobalIfAvailable which returns the native address of the jitted function. You can even try to measure time needed by each runFunction to run to double-convince yourself. :) Olivier. On Thu, Mar 18, 2010 at 9:21 AM, Gabi <bugspynet at gmail.com> wrote:> Hello > I have the following scenario, and I am not sure why the performance > is so bad (take 30 minutes to complete with very simple generated > functions): > > 1. Create module > 2. Do something like EE > EngineBuilder(theModule).setEngineKind(EngineKind::JIT).create(); > 3. Create a function in the module: theModule->getOrInsertFunction(..) > 4. Execute 1000 times the function using EE->runFunction(function, > args) with different args in each round. > > My question - Does section 4 above makes the EE recompile the function > 1000 times? If no, why is the performance is so bad? what am I doing > wrong ? Maybe I should somehow cache the function's binary code? > > > llvm-version 2.7 > OS: Linux 2.6.31 64 bits (intel dual core, 4GB memory) > > -- > Regards, > Gabi > > http://bugspy.net > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100318/b517bd99/attachment.html>
Reid Kleckner
2010-Mar-18 14:48 UTC
[LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
Sure, it caches the code for the function you're calling, but because the JIT doesn't want to get involved in target specific calling conventions, it codegens a little entry point if your function prototype is unfamiliar. I think this is NOT cached, which is why you have slow code. If you statically know your function prototype, I recommend calling getPointerToFunction and casting the return function pointer to the right type and calling it directly from your code. This forces your (static) compiler to generate the right code for the calling convention. Reid On Thu, Mar 18, 2010 at 10:35 AM, Olivier Meurant <meurant.olivier at gmail.com> wrote:> Hi Gabi, > > I have no idea why your performances is not as expected with such low level > of informations. > > But, I know that the binary code is cached by the JIT. You can find the code > in JIT.cpp to convince yourself : > runFunction -> getPointerToFunction ->getPointerToGlobalIfAvailable which > returns the native address of the jitted function. > > You can even try to measure time needed by each runFunction to run to > double-convince yourself. :) > > Olivier. > > > On Thu, Mar 18, 2010 at 9:21 AM, Gabi <bugspynet at gmail.com> wrote: >> >> Hello >> I have the following scenario, and I am not sure why the performance >> is so bad (take 30 minutes to complete with very simple generated >> functions): >> >> 1. Create module >> 2. Do something like EE >> EngineBuilder(theModule).setEngineKind(EngineKind::JIT).create(); >> 3. Create a function in the module: theModule->getOrInsertFunction(..) >> 4. Execute 1000 times the function using EE->runFunction(function, >> args) with different args in each round. >> >> My question - Does section 4 above makes the EE recompile the function >> 1000 times? If no, why is the performance is so bad? what am I doing >> wrong ? Maybe I should somehow cache the function's binary code? >> >> >> llvm-version 2.7 >> OS: Linux 2.6.31 64 bits (intel dual core, 4GB memory) >> >> -- >> Regards, >> Gabi >> >> http://bugspy.net >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
Reasonably Related Threads
- [LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
- [LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
- [LLVMdev] JIT : Does it cache the compiled code of executed functions upon runFunction(..)?
- [LLVMdev] Does it cache the compiled code of executed functions upon runFunction(..)?
- [LLVMdev] How to avoid memory leaks