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

controller for child process: receive input parameters from root and send output tables. More...

Inheritance diagram for openm::ChildController:
Collaboration diagram for openm::ChildController:

Public Member Functions

 ChildController (int i_processCount, const ArgReader &i_argStore, IMsgExec *i_msgExec)
 create new child run controller
 
virtual ~ChildController (void) noexcept
 last cleanup
 
virtual int nextRun (void) override
 create new run and input parameters in database. More...
 
virtual void readParameter (const char *i_name, int i_subId, const type_info &i_type, size_t i_size, void *io_valueArr) override
 read input parameter values. More...
 
virtual void writeAccumulators (const RunOptions &i_runOpts, bool i_isLastTable, const char *i_name, size_t i_size, forward_list< unique_ptr< double[]> > &io_accValues) override
 send output table accumulators to root process. More...
 
virtual void shutdownRun (int i_runId) override
 model run shutdown: save results and update run status.
 
virtual void shutdownWaitAll (void) override
 model process shutdown: cleanup resources.
 
virtual void shutdownOnExit (ModelStatus i_status) override
 model process shutdown if exiting without completion (ie: exit on error).
 
virtual bool childExchange (void) override
 exchange between root and child process to send and receive status update.
 
- Public Member Functions inherited from openm::RunController
virtual ~RunController (void) noexcept=0
 last cleanup
 
int parameterIdByName (const char *i_name) const override
 return index of parameter by name
 
int parameterSubCount (int i_paramId) const override
 number of parameter sub-values for current model run
 
int parameterSelfSubCount (int i_paramId) const override
 number of parameter sub-values for current process
 
int parameterSubValueIndex (int i_paramId, int i_subId) const override
 return index of parameter sub-value in the storage array of sub-values
 
bool isUseSubValue (int i_subId) const override
 return true if sub-value used by current process
 
RunStateHolderrunStateStore (void)
 return holder of all sub-values modeling run states
 
bool isOptionExist (const char *i_key) const noexcept override
 return true if run option found by i_key in run_option table for the current run id.
 
string strOption (const char *i_key, const string &i_default="") const noexcept override
 return string value of run option by i_key or default value if not found.
 
bool boolOption (const char *i_key) const noexcept override
 return boolean value of run option by i_key or false if not found or value is not "yes", "1", "true" or empty "" string.
 
int boolOptionToInt (const char *i_key) const noexcept override
 search for boolean value of run option by i_key and return one of:
return 1 if key found and value is one of: "yes", "1", "true" or empty value,
return 0 if key found and value is one of: "no", "0", "false",
return -1 if key not found,
return -2 otherwise.
 
int intOption (const char *i_key, int i_default) const noexcept override
 return int value of run option by i_key or default if not found or can not be converted to int.
 
long long longOption (const char *i_key, long long i_default) const noexcept override
 return long value of run option by i_key or default if not found or can not be converted to long.
 
double doubleOption (const char *i_key, double i_default) const noexcept override
 return double value of run option by i_key or default if not found or can not be converted to double.
 
vector< pair< string, string > > allOptions (void) const noexcept override
 return a copy of all run options as [key, value] pairs, ordered by key.
 
- Public Member Functions inherited from openm::MetaLoader
virtual ~MetaLoader (void) noexcept=0
 last cleanup
 
const ArgReaderargOpts (void) const
 arguments from command line and ini-file
 
const MetaHoldermeta (void) const
 model metadata tables
 
const RunOptions modelRunOptions (int i_subCount, int i_subId) const
 return basic model run options
 
int parameterSubCount (int i_paramId) const
 return sub-values count by parameter id
 
int parameterIdByName (const char *i_name) const
 return index of parameter by name More...
 
int tableIdByName (const char *i_name) const
 return id of output table by name
 
bool isSuppressed (const char *i_name) const
 check by name if output table suppressed
 
bool isSuppressed (int i_tableId) const
 check by id if output table suppressed
 
- Public Member Functions inherited from openm::IRunBase
virtual void readParameter (const char *i_name, int i_subId, const std::type_info &i_type, size_t i_size, void *io_valueArr)=0
 read model parameter
 
- Public Member Functions inherited from openm::IRunOptions
virtual std::string strOption (const char *i_key, const std::string &i_default="") const noexcept=0
 return string value of run option by i_key or default value if not found.
 

Additional Inherited Members

- Static Public Member Functions inherited from openm::RunController
static RunControllercreate (const ArgReader &i_argOpts, bool i_isMpiUsed, IDbExec *i_dbExec, IMsgExec *i_msgExec)
 create run controller, load metadata tables and broadcast it to all modeling processes.
 
- Static Public Member Functions inherited from openm::MetaLoader
static const ArgReader getRunOptions (int argc, char **argv)
 initialize run options from command line and ini-file More...
 
- Public Attributes inherited from openm::RunController
int subFirstId
 sub-value staring index for current modeling process
 
int selfSubCount
 number of sub-values for current process
 
int processCount
 number of modeling processes: MPI world size
 
- Public Attributes inherited from openm::MetaLoader
int subValueCount
 total number of sub-values
 
int threadCount
 max number of modeling threads
 
- Protected Types inherited from openm::MetaLoader
enum class  KindSubIds : int {
  none = 0 , single = 1 , defaultId = 2 , range =3 ,
  list = 4
}
 
enum class  ImportKind : int {
  none = 0 , modelName = 1 , modelId = 2 , modelDigest = 3 ,
  runName = 4 , runId = 5 , runDigest = 6
}
 
- Protected Member Functions inherited from openm::RunController
 RunController (const ArgReader &i_argStore)
 create run controller
 
int createTaskRun (int i_taskId, IDbExec *i_dbExec)
 create task run entry in database
 
int findTask (IDbExec *i_dbExec)
 find modeling task, if specified
 
tuple< int, int, ModelStatuscreateNewRun (int i_taskRunId, bool i_isWaitTaskRun, IDbExec *i_dbExec)
 create new run, create input parameters and run options for input working sets
 
void doShutdownOnExit (ModelStatus i_status, int i_runId, int i_taskRunId, IDbExec *i_dbExec)
 impelementation of model process shutdown if exiting without completion.
 
void doShutdownRun (int i_runId, int i_taskRunId, IDbExec *i_dbExec)
 implementation of model run shutdown.
 
void doShutdownAll (int i_taskRunId, IDbExec *i_dbExec)
 implementation model process shutdown. More...
 
void doWriteAccumulators (int i_runId, IDbExec *i_dbExec, const RunOptions &i_runOpts, const char *i_name, size_t i_size, forward_list< unique_ptr< double[]> > &io_accValues) const
 write output table accumulators if table is not suppressed.
 
void updateRestartSubValueId (int i_runId, IDbExec *i_dbExec, int i_subRestart) const
 update sub-value index to restart the run
 
void updateRunState (IDbExec *i_dbExec, const map< pair< int, int >, RunState > i_updated) const
 merge updated sub-values run statue into database
 
- Protected Member Functions inherited from openm::MetaLoader
 MetaLoader (const ArgReader &i_argStore)
 create metadata loader.
 
const RunOptionsmodelRunOptions (void) const
 return basic model run options
 
void setRunOptions (const RunOptions &i_opts)
 set basic model run options
 
void loadMessages (IDbExec *i_dbExec)
 read model messages from database. More...
 
void mergeOptions (IDbExec *i_dbExec)
 merge command line and ini-file arguments with profile_option table values. More...
 
void setArgOpt (const string &i_key, const string &i_value)
 insert new or update existing argument option.
 
- Static Protected Member Functions inherited from openm::MetaLoader
static int readMetaTables (IDbExec *i_dbExec, MetaHolder *io_metaStore, const char *i_name, const char *i_digest)
 
- Protected Attributes inherited from openm::MetaLoader
int modelId
 
unique_ptr< MetaHoldermetaStore
 
vector< int > paramIdSubArr
 
vector< int > tableIdSuppressArr
 
map< int, ParamSubOptssubOptsMap
 
map< string, ImportOptsimportOptsMap
 
map< int, ParamImportOptsparamImportOptsMap
 
map< int, pair< string, string > > langOptsMap
 

Detailed Description

controller for child process: receive input parameters from root and send output tables.

Member Function Documentation

◆ nextRun()

int ChildController::nextRun ( void  )
overridevirtual

create new run and input parameters in database.

next run for child process: receive run id, run options and input parameters from root process.

Implements openm::RunController.

◆ readParameter()

void ChildController::readParameter ( const char *  i_name,
int  i_subId,
const type_info &  i_type,
size_t  i_size,
void *  io_valueArr 
)
overridevirtual

read input parameter values.

Parameters
[in]i_nameparameter name
[in]i_subIdparameter sub-value index
[in]i_typeparameter type
[in]i_sizeparameter size (number of parameter values)
[in,out]io_valueArrarray to return parameter values, size must be =i_size

◆ writeAccumulators()

void ChildController::writeAccumulators ( const RunOptions i_runOpts,
bool  i_isLastTable,
const char *  i_name,
size_t  i_size,
forward_list< unique_ptr< double[]> > &  io_accValues 
)
overridevirtual

send output table accumulators to root process.

Parameters
[in]i_runOptsmodel run options
[in]i_isLastTableif true then it is last output table to send
[in]i_nameoutput table name
[in]i_sizenumber of cells for each accumulator
[in,out]io_accValuesaccumulator values

Implements openm::RunController.


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