CppADCodeGen  HEAD
A C++ Algorithmic Differentiation Package with Source Code Generation
CppAD::cg::LlvmModelLibraryImpl< Base > Class Template Reference
Inheritance diagram for CppAD::cg::LlvmModelLibraryImpl< Base >:
Inheritance graph
Collaboration diagram for CppAD::cg::LlvmModelLibraryImpl< Base >:
Collaboration graph

Public Member Functions

 LlvmModelLibraryImpl (std::unique_ptr< llvm::Module > module, std::shared_ptr< llvm::LLVMContext > context)
 
 LlvmModelLibraryImpl (const LlvmModelLibraryImpl &)=delete
 
LlvmModelLibraryImploperator= (const LlvmModelLibraryImpl &)=delete
 
virtual void preparePassManager ()
 
void * loadFunction (const std::string &functionName, bool required=true) override
 
virtual std::unique_ptr< LlvmModel< Base > > modelLlvm (const std::string &modelName)
 
std::unique_ptr< FunctorGenericModel< Base > > modelFunctor (const std::string &modelName) override final
 
std::set< std::string > getModelNames () override
 
std::unique_ptr< GenericModel< Base > > model (const std::string &modelName) override final
 
virtual unsigned long getAPIVersion ()
 
void setThreadPoolDisabled (bool disabled) override
 
bool isThreadPoolDisabled () const override
 
unsigned int getThreadNumber () const override
 
void setThreadNumber (unsigned int n) override
 
ThreadPoolScheduleStrategy getThreadPoolSchedulerStrategy () const override
 
void setThreadPoolSchedulerStrategy (ThreadPoolScheduleStrategy s) override
 
void setThreadPoolVerbose (bool v) override
 
bool isThreadPoolVerbose () const override
 
void setThreadPoolGuidedMaxWork (float v) override
 
float getThreadPoolGuidedMaxWork () const override
 
void setThreadPoolNumberOfTimeMeas (unsigned int n) override
 
unsigned int getThreadPoolNumberOfTimeMeas () const override
 

Protected Member Functions

void cleanUp ()
 
virtual void destroyed (LlvmModel< Base > *model)
 
void validate ()
 

Protected Attributes

llvm::Module * _module
 
std::shared_ptr< llvm::LLVMContext > _context
 
std::unique_ptr< llvm::ExecutionEngine > _executionEngine
 
std::unique_ptr< llvm::legacy::FunctionPassManager > _fpm
 
std::set< LlvmModel< Base > * > _models
 
std::set< std::string > _modelNames
 
unsigned long _version
 
void(* _onClose )()
 
void(* _setThreadPoolDisabled )(int)
 
int(* _isThreadPoolDisabled )()
 
void(* _setThreads )(unsigned int)
 
unsigned int(* _getThreads )()
 
void(* _setSchedulerStrategy )(int)
 
int(* _getSchedulerStrategy )()
 
void(* _setThreadPoolVerbose )(int v)
 
int(* _isThreadPoolVerbose )()
 
void(* _setThreadPoolGuidedMaxWork )(float v)
 
float(* _getThreadPoolGuidedMaxWork )()
 
void(* _setThreadPoolNumberOfTimeMeas )(unsigned int n)
 
unsigned int(* _getThreadPoolNumberOfTimeMeas )()
 

Friends

class LlvmModel< Base >
 

Detailed Description

template<class Base>
class CppAD::cg::LlvmModelLibraryImpl< Base >

Class used to load JIT'ed models by LLVM 5.0 and 6.0.

Author
Joao Leal

Definition at line 30 of file llvm_model_library_impl.hpp.

Constructor & Destructor Documentation

◆ LlvmModelLibraryImpl()

template<class Base >
CppAD::cg::LlvmModelLibraryImpl< Base >::LlvmModelLibraryImpl ( std::unique_ptr< llvm::Module >  module,
std::shared_ptr< llvm::LLVMContext >  context 
)
inline

Definition at line 38 of file llvm_model_library_impl.hpp.

Member Function Documentation

◆ getAPIVersion()

template<class Base >
virtual unsigned long CppAD::cg::FunctorModelLibrary< Base >::getAPIVersion ( )
inlinevirtualinherited

Provides the API version used to create the model library.

Returns
the API version

Definition at line 89 of file functor_model_library.hpp.

◆ getModelNames()

template<class Base >
std::set<std::string> CppAD::cg::FunctorModelLibrary< Base >::getModelNames ( )
inlineoverridevirtualinherited

Provides the model names in the dynamic library.

Returns
the model names

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 66 of file functor_model_library.hpp.

◆ getThreadNumber()

template<class Base >
unsigned int CppAD::cg::FunctorModelLibrary< Base >::getThreadNumber ( ) const
inlineoverridevirtualinherited

Provides the maximum number of threads used to determine sparse Jacobians and sparse Hessians for the models in this library. This value is only used by the models if they were compiled with multithreading support.

Returns
the maximum number of threads

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 122 of file functor_model_library.hpp.

◆ getThreadPoolNumberOfTimeMeas()

template<class Base >
unsigned int CppAD::cg::FunctorModelLibrary< Base >::getThreadPoolNumberOfTimeMeas ( ) const
inlineoverridevirtualinherited

Provides the number of time measurements taken by each computational task during multithreaded model evaluations. This is used to schedule work accross threads. The higher the value the more accurate the time estimations are but it requires additional calls to retrieve times. This value is only used by the models if they were compiled with multithreading support.

Returns
the number of time measurements to take per task.

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 180 of file functor_model_library.hpp.

◆ getThreadPoolSchedulerStrategy()

template<class Base >
ThreadPoolScheduleStrategy CppAD::cg::FunctorModelLibrary< Base >::getThreadPoolSchedulerStrategy ( ) const
inlineoverridevirtualinherited

Provides the thread scheduling strategy used to determine sparse Jacobians and sparse Hessians for the models in this library. This value is only used by the models if they were compiled with multithreading support.

Returns
the thread scheduling strategy

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 135 of file functor_model_library.hpp.

◆ isThreadPoolDisabled()

template<class Base >
bool CppAD::cg::FunctorModelLibrary< Base >::isThreadPoolDisabled ( ) const
inlineoverridevirtualinherited

Determines whether or not multithreaded model evaluations are disabled.

Returns
true if only the current thread is used to evaluate models.

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 115 of file functor_model_library.hpp.

◆ loadFunction()

template<class Base >
void* CppAD::cg::LlvmModelLibraryImpl< Base >::loadFunction ( const std::string &  functionName,
bool  required = true 
)
inlineoverridevirtual

Provides a pointer to a function in the model library.

Parameters
functionNameThe name of the function in the dynamic library
requiredWhether or not the function symbol must exist in the library. If the function is required and does not exist then the CppAD error handler is called, if it is not required and it does not exist then nullptr is return.
Returns
A pointer to the function symbol in the dynamic library if it exists, nullptr otherwise.
Exceptions
CGExceptionIf there is a problem loading the function symbol

Implements CppAD::cg::FunctorModelLibrary< Base >.

Definition at line 87 of file llvm_model_library_impl.hpp.

◆ model()

template<class Base >
std::unique_ptr<GenericModel<Base> > CppAD::cg::FunctorModelLibrary< Base >::model ( const std::string &  modelName)
inlinefinaloverridevirtualinherited

Creates a new GenericModel object that can be used to evaluate the model.

Parameters
modelNameThe model name.
Returns
The model object or nullptr if no model exists with the provided name.

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 80 of file functor_model_library.hpp.

Referenced by CppAD::cg::LlvmModelLibrary< Base >::modelFunctor().

◆ modelFunctor()

template<class Base>
std::unique_ptr<FunctorGenericModel<Base> > CppAD::cg::LlvmModelLibrary< Base >::modelFunctor ( const std::string &  modelName)
inlinefinaloverridevirtualinherited

Creates a new FunctorGenericModel object that can be used to evaluate the model.

Parameters
modelNameThe model name.
Returns
The model object or nullptr if no model exists with the provided name.

Implements CppAD::cg::FunctorModelLibrary< Base >.

Definition at line 51 of file llvm_model_library.hpp.

◆ preparePassManager()

template<class Base >
virtual void CppAD::cg::LlvmModelLibraryImpl< Base >::preparePassManager ( )
inlinevirtual

Set up the optimizer pipeline

Definition at line 80 of file llvm_model_library_impl.hpp.

Referenced by CppAD::cg::LlvmModelLibraryImpl< Base >::LlvmModelLibraryImpl().

◆ setThreadNumber()

template<class Base >
void CppAD::cg::FunctorModelLibrary< Base >::setThreadNumber ( unsigned int  n)
inlineoverridevirtualinherited

Defines the maximum number of threads used to determine sparse Jacobians and sparse Hessians for the models in this library. This value is only used by the models if they were compiled with multithreading support. It should be defined before using the models.

Parameters
nthe maximum number of threads

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 129 of file functor_model_library.hpp.

◆ setThreadPoolDisabled()

template<class Base >
void CppAD::cg::FunctorModelLibrary< Base >::setThreadPoolDisabled ( bool  disabled)
inlineoverridevirtualinherited

Defines whether or not to disable multithreaded model evaluations. This only works if the models if they were compiled with multithreading support.

Parameters
disabledtrue to only use the current thread to evaluate models.

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 109 of file functor_model_library.hpp.

◆ setThreadPoolNumberOfTimeMeas()

template<class Base >
void CppAD::cg::FunctorModelLibrary< Base >::setThreadPoolNumberOfTimeMeas ( unsigned int  n)
inlineoverridevirtualinherited

Defines the number of time measurements taken by each computational task during multithreaded model evaluations. This is used to schedule work across threads. The higher the value the more accurate the time estimations are but it requires additional calls to retrieve times. This value is only used by the models if they were compiled with multithreading support.

Parameters
nthe number of time measurements to take per task.

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 174 of file functor_model_library.hpp.

◆ setThreadPoolSchedulerStrategy()

template<class Base >
void CppAD::cg::FunctorModelLibrary< Base >::setThreadPoolSchedulerStrategy ( ThreadPoolScheduleStrategy  s)
inlineoverridevirtualinherited

Defines the thread scheduling strategy used to determine sparse Jacobians and sparse Hessians for the models in this library. This value is only used by the models if they were compiled with multithreading support. It should be defined before using the models.

Parameters
sthe thread scheduling strategy

Implements CppAD::cg::ModelLibrary< Base >.

Definition at line 142 of file functor_model_library.hpp.

◆ validate()


The documentation for this class was generated from the following file: