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

Public Member Functions

 DynamicLib (DynamicLib &&other) noexcept
 
std::set< std::string > getModelNames () override
 
virtual std::unique_ptr< FunctorGenericModel< Base > > modelFunctor (const std::string &modelName)=0
 
std::unique_ptr< GenericModel< Base > > model (const std::string &modelName) override final
 
virtual unsigned long getAPIVersion ()
 
virtual void * loadFunction (const std::string &functionName, bool required=true)=0
 
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 validate ()
 

Protected Attributes

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 )()
 

Detailed Description

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

Abstract class used to load compiled models in a dynamic library

Author
Joao Leal

Definition at line 157 of file declare_cg.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 >
virtual void* CppAD::cg::FunctorModelLibrary< Base >::loadFunction ( const std::string &  functionName,
bool  required = true 
)
pure virtualinherited

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

Implemented in CppAD::cg::LlvmModelLibrary3_2< Base >, CppAD::cg::LlvmModelLibrary3_4< Base >, CppAD::cg::LlvmModelLibrary3_6< Base >, CppAD::cg::LlvmModelLibrary3_8< Base >, CppAD::cg::LlvmModelLibrary4_0< Base >, and CppAD::cg::LlvmModelLibraryImpl< Base >.

Referenced by CppAD::cg::FunctorModelLibrary< Base >::getAPIVersion(), CppAD::cg::LlvmModel< Base >::LlvmModel(), and CppAD::cg::FunctorModelLibrary< Base >::validate().

◆ 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 >
virtual std::unique_ptr<FunctorGenericModel<Base> > CppAD::cg::FunctorModelLibrary< Base >::modelFunctor ( const std::string &  modelName)
pure virtualinherited

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.

Implemented in CppAD::cg::LlvmModelLibrary< Base >.

Referenced by CppAD::cg::FunctorModelLibrary< Base >::getModelNames(), and CppAD::cg::FunctorModelLibrary< Base >::model().

◆ 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 files: