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

Public Member Functions

 ModelLibraryCSourceGen (ModelCSourceGen< Base > &model)
 
template<class... Ms>
 ModelLibraryCSourceGen (ModelCSourceGen< Base > &headModel, Ms &... rest)
 
 ModelLibraryCSourceGen (const ModelLibraryCSourceGen &)=delete
 
ModelLibraryCSourceGenoperator= (const ModelLibraryCSourceGen &)=delete
 
void addModel (ModelCSourceGen< Base > &model)
 
const std::map< std::string, ModelCSourceGen< Base > * > & getModels () const
 
void addCustomFunctionSource (const std::string &filename, const std::string &source)
 
const std::map< std::string, std::string > & getCustomSources () const
 
MultiThreadingType getMultiThreading () const
 
void setMultiThreading (MultiThreadingType multiThreading)
 
void saveSources (const std::string &sourcesFolder)
 
virtual const std::map< std::string, std::string > & getLibrarySources ()
 
bool isVerbose () const
 
void setVerbose (bool verbose)
 
size_t getMaxLineWidth () const
 
void setMaxLineWidth (size_t width)
 
size_t getJobCount () const
 
void addListener (JobListener &l)
 
bool removeListener (JobListener &l)
 
void startingJob (const std::string &jobName, const JobType &type=JobTypeHolder<>::DEFAULT, const std::string &prefix="")
 
void finishedJob ()
 

Static Public Attributes

static const std::string FUNCTION_VERSION = "cppad_cg_version"
 
static const std::string FUNCTION_MODELS = "cppad_cg_models"
 
static const std::string FUNCTION_ONCLOSE = "cppad_cg_on_close"
 
static const std::string FUNCTION_SETTHREADPOOLDISABLED = "cppad_cg_set_thread_pool_disabled"
 
static const std::string FUNCTION_ISTHREADPOOLDISABLED = "cppad_cg_is_thread_pool_disabled"
 
static const std::string FUNCTION_SETTHREADS = "cppad_cg_set_thread_number"
 
static const std::string FUNCTION_GETTHREADS = "cppad_cg_get_thread_number"
 
static const std::string FUNCTION_SETTHREADSCHEDULERSTRAT = "cppad_cg_thpool_set_scheduler_strategy"
 
static const std::string FUNCTION_GETTHREADSCHEDULERSTRAT = "cppad_cg_thpool_get_scheduler_strategy"
 
static const std::string FUNCTION_SETTHREADPOOLVERBOSE = "cppad_cg_thpool_set_verbose"
 
static const std::string FUNCTION_ISTHREADPOOLVERBOSE = "cppad_cg_thpool_is_verbose"
 
static const std::string FUNCTION_SETTHREADPOOLGUIDEDMAXGROUPWORK = "cppad_cg_thpool_set_guided_maxgroupwork"
 
static const std::string FUNCTION_GETTHREADPOOLGUIDEDMAXGROUPWORK = "cppad_cg_thpool_get_guided_maxgroupwork"
 
static const std::string FUNCTION_SETTHREADPOOLNUMBEROFTIMEMEAS = "cppad_cg_thpool_set_number_of_time_meas"
 
static const std::string FUNCTION_GETTHREADPOOLNUMBEROFTIMEMEAS = "cppad_cg_thpool_get_number_of_time_meas"
 
static const unsigned long API_VERSION = 7
 
static const JobType DEFAULT
 
static const JobType LOOP_DETECTION
 
static const JobType GRAPH
 
static const JobType SOURCE_FOR_MODEL
 
static const JobType SOURCE_GENERATION
 
static const JobType COMPILING_FOR_MODEL
 
static const JobType COMPILING
 
static const JobType COMPILING_DYNAMIC_LIBRARY
 
static const JobType DYNAMIC_MODEL_LIBRARY
 
static const JobType STATIC_MODEL_LIBRARY
 
static const JobType ASSEMBLE_STATIC_LIBRARY
 
static const JobType JIT_MODEL_LIBRARY
 

Protected Member Functions

virtual void generateVersionSource (std::map< std::string, std::string > &sources)
 
virtual void generateModelsSource (std::map< std::string, std::string > &sources)
 
virtual void generateOnCloseSource (std::map< std::string, std::string > &sources)
 
virtual void generateThreadPoolSources (std::map< std::string, std::string > &sources)
 

Static Protected Member Functions

static void saveSources (const std::string &sourcesFolder, const std::map< std::string, std::string > &sources)
 

Protected Attributes

std::map< std::string, ModelCSourceGen< Base > * > _models
 
std::map< std::string, std::string > _customSource
 
std::map< std::string, std::string > _libSources
 
MultiThreadingType _multiThreading
 
std::ostringstream _cache
 
bool _verbose
 

Static Protected Attributes

static const std::string CONST = "const"
 

Friends

class ModelLibraryProcessor< Base >
 

Detailed Description

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

Generates C source code for a bundle of models.

Author
Joao Leal

Definition at line 163 of file declare_cg.hpp.

Constructor & Destructor Documentation

◆ ModelLibraryCSourceGen()

template<class Base>
CppAD::cg::ModelLibraryCSourceGen< Base >::ModelLibraryCSourceGen ( ModelCSourceGen< Base > &  model)
inline

Creates a new helper class for the generation of dynamic libraries using the C language.

Parameters
modelA model compilation helper (must only be deleted after this object)

Definition at line 80 of file model_library_c_source_gen.hpp.

Member Function Documentation

◆ addModel()

template<class Base>
void CppAD::cg::ModelLibraryCSourceGen< Base >::addModel ( ModelCSourceGen< Base > &  model)
inline

Adds additional models to be compiled into the created library.

Parameters
modela model compilation helper (must only be deleted after this object)

Definition at line 108 of file model_library_c_source_gen.hpp.

◆ getCustomSources()

template<class Base>
const std::map<std::string, std::string>& CppAD::cg::ModelLibraryCSourceGen< Base >::getCustomSources ( ) const
inline

Provides the user defined custom sources.

Returns
maps filenames to the file content for the user defined sources.

Definition at line 133 of file model_library_c_source_gen.hpp.

◆ getJobCount()

size_t CppAD::cg::JobTimer::getJobCount ( ) const
inlineinherited

Provides the number of currently running jobs

Returns
the number of running jobs

Definition at line 248 of file job_timer.hpp.

Referenced by CppAD::cg::AbstractCCompiler< Base >::compileSources().

◆ getLibrarySources()

template<class Base >
const std::map< std::string, std::string > & CppAD::cg::ModelLibraryCSourceGen< Base >::getLibrarySources ( )
virtual

Provides the sources for the model library level. These sources include, for instance, functions to retrieve the list of models contained in the library. This does not include the sources for the models.

Returns
model library sources

Definition at line 106 of file model_library_c_source_gen_impl.hpp.

Referenced by CppAD::cg::ModelLibraryCSourceGen< Base >::setMultiThreading().

◆ getMultiThreading()

template<class Base>
MultiThreadingType CppAD::cg::ModelLibraryCSourceGen< Base >::getMultiThreading ( ) const
inline

Defines whether or not to generate multithreading directives to parallelize the sparse Jacobian and sparse Hessian evaluation. Parallelization can be disabled locally for each model.

Returns
multithreading support type

Definition at line 144 of file model_library_c_source_gen.hpp.

◆ saveSources()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::saveSources ( const std::string &  sourcesFolder)

Saves the generated C source code into several files.

Parameters
sourcesFolderA directory path where the files should be created (any existing files with the same names will be overridden).

Definition at line 75 of file model_library_c_source_gen_impl.hpp.

Referenced by CppAD::cg::ModelLibraryCSourceGen< Base >::setMultiThreading().

◆ setMultiThreading()

template<class Base>
void CppAD::cg::ModelLibraryCSourceGen< Base >::setMultiThreading ( MultiThreadingType  multiThreading)
inline

Defines whether or not to generate multithreading directives to parallelize the sparse Jacobian and sparse Hessian evaluation. Parallelization can be disabled locally for each model. Do not forget to add the appropriate compiler and linker flags when multithreading is enabled.

Parameters
multiThreadingmultithreading support type

Definition at line 157 of file model_library_c_source_gen.hpp.

Member Data Documentation

◆ _cache

template<class Base>
std::ostringstream CppAD::cg::ModelLibraryCSourceGen< Base >::_cache
protected

temporary stream to generate source code

Definition at line 70 of file model_library_c_source_gen.hpp.

◆ _customSource

template<class Base>
std::map<std::string, std::string> CppAD::cg::ModelLibraryCSourceGen< Base >::_customSource
protected

custom functions to be compiled in the dynamic library

Definition at line 56 of file model_library_c_source_gen.hpp.

Referenced by CppAD::cg::ModelLibraryCSourceGen< Base >::getCustomSources().

◆ _libSources

template<class Base>
std::map<std::string, std::string> CppAD::cg::ModelLibraryCSourceGen< Base >::_libSources
protected

Library level generated source files

Definition at line 60 of file model_library_c_source_gen.hpp.

◆ _models

template<class Base>
std::map<std::string, ModelCSourceGen<Base>*> CppAD::cg::ModelLibraryCSourceGen< Base >::_models
protected

Models to be contained whithin the library

Definition at line 52 of file model_library_c_source_gen.hpp.

Referenced by CppAD::cg::ModelLibraryCSourceGen< Base >::addModel().

◆ _multiThreading

template<class Base>
MultiThreadingType CppAD::cg::ModelLibraryCSourceGen< Base >::_multiThreading
protected

Parallelization type for the sparse Jacobian and sparse Hessian (experimental). Parallelization can be disabled locally for each model.

Definition at line 66 of file model_library_c_source_gen.hpp.

Referenced by CppAD::cg::ModelLibraryCSourceGen< Base >::getMultiThreading().

◆ _verbose

bool CppAD::cg::JobTimer::_verbose
protectedinherited

Whether or not to print progress information to the standard output

Definition at line 189 of file job_timer.hpp.


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