roadrunner
2.6.0
Fast simulator for SBML models
|
superclass of all Jit types. More...
#include <Jit.h>
Public Member Functions | |
Jit (std::uint32_t options) | |
instantiate a Jit object with some options. More... | |
Jit () | |
default constructor. More... | |
virtual void | mapFunctionsToJitSymbols ()=0 |
adds functions that are declared and defined in C++ to the jit engine. More... | |
virtual | ~Jit ()=default |
Add support for libsbml distrib functions. More... | |
virtual std::uint64_t | lookupFunctionAddress (const std::string &name)=0 |
virtual void | addObjectFile (rrOwningBinary owningObject)=0 |
add an in-memory representation of an object file to the current jit module. More... | |
virtual void | addObjectFile (std::unique_ptr< llvm::object::ObjectFile > objectFile)=0 |
add an in-memory representation of an object file to the current jit module. | |
virtual void | addObjectFile (std::unique_ptr< llvm::MemoryBuffer > obj)=0 |
add an in-memory representation of an object file to the current jit module. | |
virtual void | addModule (llvm::Module *M)=0 |
add a module More... | |
virtual void | addModule (std::unique_ptr< llvm::Module > M, std::unique_ptr< llvm::LLVMContext > ctx)=0 |
add a module More... | |
virtual void | addModule ()=0 |
add the module and context which are member variables of the Jit instance to the current Jit engine. More... | |
virtual const llvm::DataLayout & | getDataLayout () const =0 |
get the DataLayout currently in use in the Jit | |
virtual std::unique_ptr< llvm::MemoryBuffer > | getCompiledModelFromCache (const std::string &sbmlMD5)=0 |
lookup the sbml with the md5 More... | |
virtual void | transferObjectsToResources (std::shared_ptr< rrllvm::ModelResources > modelResources) |
Moves objects over to ModelResources ptr | |
virtual void | mapLLVMGeneratedFunctionsToSymbols (ModelResources *modelResources, std::uint32_t options) |
Map the Jit'd functions that collectively represent a roadrunner compiled sbml model to symbols in the ModelResources. More... | |
virtual llvm::Module * | getModuleNonOwning () |
returns a non owning pointer to the llvm::Module instance | |
virtual llvm::LLVMContext * | getContextNonOwning () |
returns a non owning pointer to the llvm::LLVMContext instance | |
virtual llvm::IRBuilder * | getBuilderNonOwning () |
returns a non owning pointer to the llvm::LLVMContext instance | |
virtual std::string | emitToString () |
Write the Jit::module in its current state to string as LLVM IR. | |
llvm::raw_svector_ostream & | getCompiledModuleStream () |
get the stream that stores a compiled module as binary. | |
std::string | getDefaultTargetTriple () const |
void | setModuleIdentifier (const std::string &id) |
virtual std::string | mangleName (const std::string &unmangledName) const |
virtual std::string | getModuleAsString (std::string sbmlMD5)=0 |
get a binary string representation of the current module. More... | |
Public Attributes | |
std::unique_ptr< llvm::raw_svector_ostream > | compiledModuleBinaryStream |
MCJit compiles the generated LLVM IR to this binary stream which is then used both for adding to the Jit as a module and for saveState. More... | |
llvm::SmallVector< char, 10 > | moduleBuffer |
The buffer used by compiledModuleBinaryStream. | |
Protected Member Functions | |
std::string | getProcessTriple () const |
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the current process, e.g. More... | |
const llvm::Target * | getDefaultTargetMachine () const |
use llvm calls to work out which TargetMachine is currently being used. | |
FnMap | externalFunctionSignatures () const |
returns a mapping between function names and function signatures | |
superclass of all Jit types.
Builds the machinery necessary to compile a sbml model on the fly to machine code.
|
explicit |
instantiate a Jit object with some options.
options | LoadSBMLOptions::modelGeneratorOpt. The options are stored by bit masks and can be manipulated by either modifying LoadSBMLOptions or Config. |
rrllvm::Jit::Jit | ( | ) |
default constructor.
delegates to Jit(std::uint32_t options). The options argument is the default constructed from LoadSBMLOptions.modelGeneratorOpt. Note, that LoadSBMLOptions is influenced by the global Config.
|
virtualdefault |
Add support for libsbml distrib functions.
similar to Jit::mapFunctionsToJitSymbols, these are declared and defined in C++. Support for distrib in libsbml must be present for these functions to be jitted, but if distrib is not available there are no adverse consequences other than no being able to simulate models that depend on libsbml distrib.
defaulted virtual destructor
|
pure virtual |
add the module and context which are member variables of the Jit instance to the current Jit engine.
similar to addModule(std::unique_ptr<llvm::Module> M, std::unique_ptr<llvm::LLVMContext> ctx) the references are stolen by the call to construct a ThreadSafeModule which then takes ownership of the module and context.
Implemented in rrllvm::LLJit.
|
pure virtual |
|
pure virtual |
add a module
M | and Context |
ctx | to the current jit engine. |
the parameters M and cts are unique pointers and therefore must be moved, not copied into the module. An llvm ThreadSafeModule is created internalls, which steals the references. For this reason, any code to be added to the module must happen before the call to addModule.
Implemented in rrllvm::LLJit.
|
pure virtual |
add an in-memory representation of an object file to the current jit module.
the rrOwningBinary is a typedef'd llvm::object::OwningBinary<llvm::object::ObjectFile>
Implemented in rrllvm::LLJit.
|
pure virtual |
lookup the sbml with the md5
sbmlMD5 | in the compiled object cache. If it is there, return a memory buffer containing it (which you can turn into an object file). Returns empty (null) unique_ptr if not found. |
Implemented in rrllvm::LLJit.
|
pure virtual |
get a binary string representation of the current module.
This must be called after the module is added to the jit engine. Throws if string is empty.
This interface is moderate abuse of interface design – the parameter sbmlMD5 is only required for the LLJit subclass, as it is used to query the object cache created by llvm. This is of course bad design but we are boxed by not being able to find a way to enable the same cache system with the old MCJit class.
Regardless of the bad design, it works, so lets not spend any more time on it.
Implemented in rrllvm::LLJit.
|
protected |
getProcessTriple() - Return an appropriate target triple for generating code to be loaded into the current process, e.g.
when using the JIT.
|
pure virtual |
adds functions that are declared and defined in C++ to the jit engine.
unlike most functions that are created directly in the llvm IR language these functions are just C++ i.e. tan, arccsh, quotient. In MCJit (llvm 6) these were "mapped" to sbml support functions in addGlobalMappings.
Implemented in rrllvm::LLJit.
|
virtual |
Map the Jit'd functions that collectively represent a roadrunner compiled sbml model to symbols in the ModelResources.
modelResources | the ModelResources to which to map. |
options | bitfield options to use. |
this must be called after a the main roadrunner module has been added to the Jit – otherwise the lookup will fail.
std::unique_ptr<llvm::raw_svector_ostream> rrllvm::Jit::compiledModuleBinaryStream |
MCJit compiles the generated LLVM IR to this binary stream which is then used both for adding to the Jit as a module and for saveState.
MCJit is the only Jit that uses this. (Its bad interface design but works at least.). LLJit uses a caching mechanism which allows us to retrieve object files directly, foregoing the need for this variable.