Valery A.Khamenya
2004-Aug-13 22:18 UTC
[LLVMdev] is this code really JITed and/or optimized ? ..
Hi all, (thanks to Reid, who gave nice advice) the fibonacci function code works now. Please find attached file. but... the performance is adequate, say, for byte-code interpretation mode and not for optimized JITing. fibonacci function of 35 from attached file is more then 100 times slower then the following code compiled with "gcc -O2" : ----------- #include <iostream> int fib(int x) { if(x<=2) return 1; return fib(x-1)+fib(x-2); } int main(int argc, char**argv) { int n = argc > 1 ? atol(argv[1]) : 10; std::cout << fib(n) << "\n"; } ----------- Where's the rake I step at?.. I guess the JIT was not really invoked or code was not optimized.. P.S. My best wishes to all countries at Olympiad 2004. --- Valery A.Khamenya -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: fibonacci.cpp URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20040814/53a5746c/attachment.ksh>
Reid Spencer
2004-Aug-13 22:29 UTC
[LLVMdev] is this code really JITed and/or optimized ? ..
Valery, The line in the file HowToUseJIT.cpp that reads: ExecutionEngine* EE = ExecutionEngine::create( MP, true ); should be ExecutionEngine* EE = ExecutionEngine::create( MP, false); The second parameter is "forceInterpreter" which will always cause interpretation. I left it that way because that's what you had in your original submission. Thought you wanted to compare them. Anyway, the above change will allow JIT to happen. Reid. Chris Lattner wrote:> On Sat, 14 Aug 2004, Valery A.Khamenya wrote: > > >>(thanks to Reid, who gave nice advice) the fibonacci function code >>works now. Please find attached file. >> >>but... the performance is adequate, say, for byte-code >>interpretation mode and not for optimized JITing. >>fibonacci function of 35 from attached file is more >>then 100 times slower then the following code compiled >>with "gcc -O2" : >>----------- >>#include <iostream> >>int fib(int x) { >>if(x<=2) return 1; >>return fib(x-1)+fib(x-2); >>} >> >>int main(int argc, char**argv) { >> int n = argc > 1 ? atol(argv[1]) : 10; >> std::cout << fib(n) << "\n"; >>} >>----------- >> >>Where's the rake I step at?.. >> >>I guess the JIT was not really invoked or code was not optimized.. > > > If it's that slow, you're probably getting the interpreter instead of the > JIT. Try adding -print-machineinstr to the command line, or -debug, and > see what happens. If you're not getting the JIT, try stepping through the > LLVM program to see where it makes the execution engine and decides which > one to use... > > -Chris >
Chris Lattner
2004-Aug-13 22:31 UTC
[LLVMdev] is this code really JITed and/or optimized ? ..
On Sat, 14 Aug 2004, Valery A.Khamenya wrote:> (thanks to Reid, who gave nice advice) the fibonacci function code > works now. Please find attached file. > > but... the performance is adequate, say, for byte-code > interpretation mode and not for optimized JITing. > fibonacci function of 35 from attached file is more > then 100 times slower then the following code compiled > with "gcc -O2" : > ----------- > #include <iostream> > int fib(int x) { > if(x<=2) return 1; > return fib(x-1)+fib(x-2); > } > > int main(int argc, char**argv) { > int n = argc > 1 ? atol(argv[1]) : 10; > std::cout << fib(n) << "\n"; > } > ----------- > > Where's the rake I step at?.. > > I guess the JIT was not really invoked or code was not optimized..If it's that slow, you're probably getting the interpreter instead of the JIT. Try adding -print-machineinstr to the command line, or -debug, and see what happens. If you're not getting the JIT, try stepping through the LLVM program to see where it makes the execution engine and decides which one to use... -Chris -- http://llvm.cs.uiuc.edu/ http://nondot.org/sabre/
Valery A.Khamenya
2004-Aug-13 22:39 UTC
[LLVMdev] is this code really JITed and/or optimized ? ..
> If it's that slow, you're probably getting the interpreter instead of the > JIT. Try adding -print-machineinstr to the command line, or -debug, and > see what happens. If you're not getting the JIT, try stepping through the > LLVM program to see where it makes the execution engine and decides which > one to use...(thanks for quick reply) hm, here is the part of my code starting LLVM function: /////////////////////////// ExistingModuleProvider* MP = new ExistingModuleProvider(M); ExecutionEngine* EE = ExecutionEngine::create( MP, true ); // Call the `foo' function with no arguments: std::vector<GenericValue> noargs; GenericValue gv = EE->runFunction(FooF, noargs); /////////////////////////// for LLVM developers no debuging should be needed to make quick and right diagnosis :) -- Valery
Possibly Parallel Threads
- [LLVMdev] is this code really JITed and/or optimized ? ..
- [LLVMdev] is this code really JITed and/or optimized ? ..
- [LLVMdev] is this code really JITed and/or optimized ? ..
- [LLVMdev] is this code really JITed and/or optimized? ..
- [LLVMdev] Please help with LLVM C++ integration