-
Notifications
You must be signed in to change notification settings - Fork 25
LLVM
LLVM is a compiler framework that allows you to generate an intermediate assembly called LLVM IR, which can be optimized efficiently and made to target any platform using the LLVM libraries.
It also supports JIT compilation, which is what roadrunner uses it for. SBML is parsed, resulting in reactions and events. We create code at runtime that evaluates these reactions and events, through LLVM, and then generate machine code targeting the host machine, which can then be directly executed.
The idea here is that for intensive models, generating runtime functions using LLVM will be faster than either baking reaction and event handling into the C++ code itself or generating bytecode and interpreting it.
If you look at LLVMModelGenerator
you will see it parses the SBML by creating
a ModelGeneratorContext
, which is then passed into each of the appropriate
*codeGen
objects, which create LLVM IR with createFunction
. The LLVM IR
generated by codeGen is owned by the executionEngine
, which will only JIT the
code once it is needed, like when getFunctionAddress
or finalizeObject
is called