CppADCodeGen 2.4.3
A C++ Algorithmic Differentiation Package with Source Code Generation
Loading...
Searching...
No Matches
CppAD::cg::ModelLibraryCSourceGen< Base > Class Template Reference

#include <model_library_c_source_gen.hpp>

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 28 of file model_library_c_source_gen.hpp.

Constructor & Destructor Documentation

◆ ModelLibraryCSourceGen() [1/2]

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.

◆ ModelLibraryCSourceGen() [2/2]

template<class Base >
template<class... Ms>
CppAD::cg::ModelLibraryCSourceGen< Base >::ModelLibraryCSourceGen ( ModelCSourceGen< Base > &  headModel,
Ms &...  rest 
)
inline

Definition at line 89 of file model_library_c_source_gen.hpp.

Member Function Documentation

◆ addCustomFunctionSource()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::addCustomFunctionSource ( const std::string &  filename,
const std::string &  source 
)
inline

Definition at line 121 of file model_library_c_source_gen.hpp.

◆ addListener()

void CppAD::cg::JobTimer::addListener ( JobListener l)
inlineinherited

Definition at line 252 of file job_timer.hpp.

◆ 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.

◆ finishedJob()

void CppAD::cg::JobTimer::finishedJob ( )
inlineinherited

Definition at line 298 of file job_timer.hpp.

◆ generateModelsSource()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::generateModelsSource ( std::map< std::string, std::string > &  sources)
protectedvirtual

Definition at line 147 of file model_library_c_source_gen_impl.hpp.

◆ generateOnCloseSource()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::generateOnCloseSource ( std::map< std::string, std::string > &  sources)
protectedvirtual

Definition at line 169 of file model_library_c_source_gen_impl.hpp.

◆ generateThreadPoolSources()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::generateThreadPoolSources ( std::map< std::string, std::string > &  sources)
protectedvirtual

Definition at line 194 of file model_library_c_source_gen_impl.hpp.

◆ generateVersionSource()

template<class Base >
void CppAD::cg::ModelLibraryCSourceGen< Base >::generateVersionSource ( std::map< std::string, std::string > &  sources)
protectedvirtual

Definition at line 137 of file model_library_c_source_gen_impl.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.

◆ 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.

◆ getMaxLineWidth()

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

Definition at line 235 of file job_timer.hpp.

◆ getModels()

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

Definition at line 117 of file model_library_c_source_gen.hpp.

◆ 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.

◆ isVerbose()

bool CppAD::cg::JobTimer::isVerbose ( ) const
inlineinherited

Definition at line 227 of file job_timer.hpp.

◆ removeListener()

bool CppAD::cg::JobTimer::removeListener ( JobListener l)
inlineinherited

Definition at line 256 of file job_timer.hpp.

◆ saveSources() [1/2]

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.

◆ saveSources() [2/2]

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

Definition at line 93 of file model_library_c_source_gen_impl.hpp.

◆ setMaxLineWidth()

void CppAD::cg::JobTimer::setMaxLineWidth ( size_t  width)
inlineinherited

Definition at line 239 of file job_timer.hpp.

◆ 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.

◆ setVerbose()

void CppAD::cg::JobTimer::setVerbose ( bool  verbose)
inlineinherited

Definition at line 231 of file job_timer.hpp.

◆ startingJob()

void CppAD::cg::JobTimer::startingJob ( const std::string &  jobName,
const JobType type = JobTypeHolder<>::DEFAULT,
const std::string &  prefix = "" 
)
inlineinherited

Definition at line 260 of file job_timer.hpp.

Friends And Related Symbol Documentation

◆ ModelLibraryProcessor< Base >

template<class Base >
friend class ModelLibraryProcessor< Base >
friend

Definition at line 189 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.

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

◆ _models

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

◆ _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(), and CppAD::cg::ModelLibraryCSourceGen< Base >::setMultiThreading().

◆ _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.

◆ API_VERSION

template<class Base >
const unsigned long CppAD::cg::ModelLibraryCSourceGen< Base >::API_VERSION = 7
static

Definition at line 45 of file model_library_c_source_gen.hpp.

◆ ASSEMBLE_STATIC_LIBRARY

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::ASSEMBLE_STATIC_LIBRARY
staticinherited

Definition at line 78 of file job_timer.hpp.

◆ COMPILING

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::COMPILING
staticinherited

Definition at line 74 of file job_timer.hpp.

◆ COMPILING_DYNAMIC_LIBRARY

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::COMPILING_DYNAMIC_LIBRARY
staticinherited

Definition at line 75 of file job_timer.hpp.

◆ COMPILING_FOR_MODEL

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::COMPILING_FOR_MODEL
staticinherited

Definition at line 73 of file job_timer.hpp.

◆ CONST

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::CONST = "const"
staticprotected

Definition at line 47 of file model_library_c_source_gen.hpp.

◆ DEFAULT

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::DEFAULT
staticinherited

Definition at line 68 of file job_timer.hpp.

◆ DYNAMIC_MODEL_LIBRARY

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::DYNAMIC_MODEL_LIBRARY
staticinherited

Definition at line 76 of file job_timer.hpp.

◆ FUNCTION_GETTHREADPOOLGUIDEDMAXGROUPWORK

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_GETTHREADPOOLGUIDEDMAXGROUPWORK = "cppad_cg_thpool_get_guided_maxgroupwork"
static

Definition at line 42 of file model_library_c_source_gen.hpp.

◆ FUNCTION_GETTHREADPOOLNUMBEROFTIMEMEAS

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_GETTHREADPOOLNUMBEROFTIMEMEAS = "cppad_cg_thpool_get_number_of_time_meas"
static

Definition at line 44 of file model_library_c_source_gen.hpp.

◆ FUNCTION_GETTHREADS

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_GETTHREADS = "cppad_cg_get_thread_number"
static

Definition at line 36 of file model_library_c_source_gen.hpp.

◆ FUNCTION_GETTHREADSCHEDULERSTRAT

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_GETTHREADSCHEDULERSTRAT = "cppad_cg_thpool_get_scheduler_strategy"
static

Definition at line 38 of file model_library_c_source_gen.hpp.

◆ FUNCTION_ISTHREADPOOLDISABLED

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_ISTHREADPOOLDISABLED = "cppad_cg_is_thread_pool_disabled"
static

Definition at line 34 of file model_library_c_source_gen.hpp.

◆ FUNCTION_ISTHREADPOOLVERBOSE

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_ISTHREADPOOLVERBOSE = "cppad_cg_thpool_is_verbose"
static

Definition at line 40 of file model_library_c_source_gen.hpp.

◆ FUNCTION_MODELS

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_MODELS = "cppad_cg_models"
static

Definition at line 31 of file model_library_c_source_gen.hpp.

◆ FUNCTION_ONCLOSE

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_ONCLOSE = "cppad_cg_on_close"
static

Definition at line 32 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADPOOLDISABLED

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADPOOLDISABLED = "cppad_cg_set_thread_pool_disabled"
static

Definition at line 33 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADPOOLGUIDEDMAXGROUPWORK

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADPOOLGUIDEDMAXGROUPWORK = "cppad_cg_thpool_set_guided_maxgroupwork"
static

Definition at line 41 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADPOOLNUMBEROFTIMEMEAS

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADPOOLNUMBEROFTIMEMEAS = "cppad_cg_thpool_set_number_of_time_meas"
static

Definition at line 43 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADPOOLVERBOSE

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADPOOLVERBOSE = "cppad_cg_thpool_set_verbose"
static

Definition at line 39 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADS

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADS = "cppad_cg_set_thread_number"
static

Definition at line 35 of file model_library_c_source_gen.hpp.

◆ FUNCTION_SETTHREADSCHEDULERSTRAT

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_SETTHREADSCHEDULERSTRAT = "cppad_cg_thpool_set_scheduler_strategy"
static

Definition at line 37 of file model_library_c_source_gen.hpp.

◆ FUNCTION_VERSION

template<class Base >
const std::string CppAD::cg::ModelLibraryCSourceGen< Base >::FUNCTION_VERSION = "cppad_cg_version"
static

Definition at line 30 of file model_library_c_source_gen.hpp.

◆ GRAPH

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::GRAPH
staticinherited

Definition at line 70 of file job_timer.hpp.

◆ JIT_MODEL_LIBRARY

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::JIT_MODEL_LIBRARY
staticinherited

Definition at line 79 of file job_timer.hpp.

◆ LOOP_DETECTION

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::LOOP_DETECTION
staticinherited

Definition at line 69 of file job_timer.hpp.

◆ SOURCE_FOR_MODEL

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::SOURCE_FOR_MODEL
staticinherited

Definition at line 71 of file job_timer.hpp.

◆ SOURCE_GENERATION

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::SOURCE_GENERATION
staticinherited

Definition at line 72 of file job_timer.hpp.

◆ STATIC_MODEL_LIBRARY

template<int T>
const JobType CppAD::cg::JobTypeHolder< T >::STATIC_MODEL_LIBRARY
staticinherited

Definition at line 77 of file job_timer.hpp.


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