OpenM++ runtime library (libopenm)
openm::ModelBase Class Reference

model sub-value run base class More...

#include <model.h>

Inheritance diagram for openm::ModelBase:
Collaboration diagram for openm::ModelBase:

Public Member Functions

int subValueCount (void) const noexcept override
 number of sub-values More...
 
int subValueId (void) const noexcept override
 sub-value index of current modeling thread More...
 
int parameterSubValueIndex (const char *i_name) const override
 return index of parameter sub-value in the storage array for current modeling thread More...
 
const RunOptionsrunOptions (void) const override
 return model run options More...
 
int tableIdByName (const char *i_name) const override
 return id of output table by name More...
 
bool isSuppressed (const char *i_name) const override
 check by name if output table suppressed. More...
 
void writeOutputTable (const char *i_name, size_t i_size, forward_list< unique_ptr< double[]> > &io_accValues) override
 write result into output table and release accumulators memory. More...
 
void updateProgress (int i_count, double i_value=0.0) override
 set modeling progress count and value More...
 
virtual void writeDbMicrodata (int i_entityKind, uint64_t i_microdataKey, const void *i_entityThis) override
 write microdata into the database. More...
 
virtual void writeCsvMicrodata (int i_entityKind, uint64_t i_microdataKey, int i_eventId, bool i_isSameEntity, const void *i_entityThis) override
 write microdata into CSV file or into trace More...
 
- Public Member Functions inherited from openm::IModel
virtual ~IModel (void) noexcept=0
 model sub-value run public interface
 
virtual int subValueCount (void) const noexcept=0
 number of sub-values More...
 
virtual int subValueId (void) const noexcept=0
 sub-value index of current modeling thread More...
 
virtual int tableIdByName (const char *i_name) const =0
 return id of output table by name More...
 
virtual bool isSuppressed (const char *i_name) const =0
 check by name if output table suppressed. More...
 
virtual const RunOptionsrunOptions (void) const =0
 return basic model run options More...
 
virtual int parameterSubValueIndex (const char *i_name) const =0
 return index of parameter sub-value in the storage array for current modeling thread More...
 
virtual void writeOutputTable (const char *i_name, size_t i_size, std::forward_list< std::unique_ptr< double[]> > &io_accValues)=0
 write output result table: sub values
 
virtual void updateProgress (int i_count, double i_value=0.0)=0
 set modeling progress count and value More...
 
virtual void writeDbMicrodata (int i_entityKind, uint64_t i_microdataKey, const void *i_entityThis)=0
 write microdata into the database. More...
 
virtual void writeCsvMicrodata (int i_entityKind, uint64_t i_microdataKey, int i_eventId, bool i_isSameEntity, const void *i_entityThis)=0
 write microdata into CSV file or into trace. More...
 

Static Public Member Functions

static ModelBasecreate (int i_runId, int i_subCount, int i_subId, RunController *i_runCtrl, const MetaHolder *i_metaStore)
 model factory: create new model sub-value run. More...
 

Detailed Description

model sub-value run base class

Member Function Documentation

◆ create()

ModelBase * ModelBase::create ( int  i_runId,
int  i_subCount,
int  i_subId,
RunController i_runCtrl,
const MetaHolder i_metaStore 
)
static

model factory: create new model sub-value run.

create new model sub-value run

◆ isSuppressed()

bool openm::ModelBase::isSuppressed ( const char *  i_name) const
inlineoverridevirtual

check by name if output table suppressed.

Implements openm::IModel.

◆ parameterSubValueIndex()

int ModelBase::parameterSubValueIndex ( const char *  i_name) const
overridevirtual

return index of parameter sub-value in the storage array for current modeling thread

Implements openm::IModel.

◆ runOptions()

const RunOptions * openm::ModelBase::runOptions ( void  ) const
inlineoverridevirtual

return model run options

Implements openm::IModel.

◆ subValueCount()

int openm::ModelBase::subValueCount ( void  ) const
inlineoverridevirtualnoexcept

number of sub-values

Implements openm::IModel.

◆ subValueId()

int openm::ModelBase::subValueId ( void  ) const
inlineoverridevirtualnoexcept

sub-value index of current modeling thread

Implements openm::IModel.

◆ tableIdByName()

int openm::ModelBase::tableIdByName ( const char *  i_name) const
inlineoverridevirtual

return id of output table by name

Implements openm::IModel.

◆ updateProgress()

void openm::ModelBase::updateProgress ( int  i_count,
double  i_value = 0.0 
)
inlineoverridevirtual

set modeling progress count and value

Implements openm::IModel.

◆ writeCsvMicrodata()

void ModelBase::writeCsvMicrodata ( int  i_entityKind,
uint64_t  i_microdataKey,
int  i_eventId,
bool  i_isSameEntity,
const void *  i_entityThis 
)
overridevirtual

write microdata into CSV file or into trace

write microdata into the CSV file or into trace.

Parameters
i_entityKindentity kind id: model metadata entity id in database.
i_microdataKeyunique entity instance id.
i_eventIdevent id, if microdata events enabled.
i_isSameEntityif true then event entity the same as microdata entity.
i_entityThisentity class instance this pointer.

Implements openm::IModel.

◆ writeDbMicrodata()

void ModelBase::writeDbMicrodata ( int  i_entityKind,
uint64_t  i_microdataKey,
const void *  i_entityThis 
)
overridevirtual

write microdata into the database.

Parameters
i_entityKindentity kind id: model metadata entity id in database.
i_microdataKeyunique entity instance id.
i_entityThisentity class instance this pointer.

Pair of (i_entityKind, i_microdataKey) must provide a unique key of microdata record for this model run.

Implements openm::IModel.

◆ writeOutputTable()

void ModelBase::writeOutputTable ( const char *  i_name,
size_t  i_size,
forward_list< unique_ptr< double[]> > &  io_accValues 
)
override

write result into output table and release accumulators memory.

Parameters
[in]i_nameoutput table name
[in]i_sizenumber of cells for each accumulator
[in,out]io_accValuesaccumulator values

usage example:

// allocate model output table accumulators: [N_accumulators][N_cells]
double * acc[N_accumulators];
forward_list<unique_ptr<double> > acc_storage;
auto it = acc_storage.before_begin();
for (int k = 0; k < N_accumulators; ++k) {
it = acc_storage.insert_after(it, unique_ptr<double>(new double[N_cells]));
acc[k] = it->get();
}
...
// run the model and calculate accumulator values
for (int k = 0; k < N_accumulators; ++k) {
std::fill(acc[k], &acc[k][N_cells], 0.0);
}
...
// write output table "salaryBySex" into database
i_model->writeOutputTable("salaryBySex", N_cells, acc_storage);
// at this point any kind of table->acc[k][j] will cause memory access violation

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