Utopia
2
Framework for studying models of complex & adaptive systems.
|
#include <HdfBench.hh>
Public Types | |
using | Base = Model< HdfBenchModel, HdfBenchModelTypes > |
The base model type. More... | |
using | DataSet = typename Base::DataSet |
Data type for a dataset. More... | |
using | Config = typename Base::Config |
Data type that holds the configuration. More... | |
using | Clock = std::chrono::high_resolution_clock |
Type of clock. More... | |
using | Time = std::chrono::high_resolution_clock::time_point |
Type of a time point, retrieved from the clock. More... | |
using | DurationType = std::chrono::duration< double > |
Type of the duration measure, should be a floating-point type. More... | |
using | BenchFunc = std::function< double(const std::string, Config)> |
Type of a benchmark function pointer. More... | |
Public Types inherited from Utopia::Model< HdfBenchModel, HdfBenchModelTypes > | |
using | Config = typename ModelTypes::Config |
Data type that holds the configuration. More... | |
using | DataManager = DataIO::Default::DefaultDataManager< HdfBenchModel > |
The data manager to use, specialized with the derived model. More... | |
using | DataGroup = typename ModelTypes::DataGroup |
Data type that is used for storing datasets. More... | |
using | DataSet = typename ModelTypes::DataSet |
Data type that is used for storing data. More... | |
using | RNG = typename ModelTypes::RNG |
Data type of the shared RNG. More... | |
using | Space = typename ModelTypes::Space |
Data type of the space this model resides in. More... | |
using | Time = typename ModelTypes::Time |
Data type for the model time. More... | |
using | Monitor = typename ModelTypes::Monitor |
Data type for the monitor. More... | |
using | MonitorManager = typename ModelTypes::MonitorManager |
Data type for the monitor manager. More... | |
using | Level = typename ModelTypes::Level |
Data type for the hierarchical level. More... | |
Public Member Functions | |
template<class ParentModel > | |
HdfBenchModel (const std::string &name, ParentModel &parent_model, const DataIO::Config &custom_cfg={}) | |
Construct the HdfBench model. More... | |
void | perform_step () |
Iterate a single step. More... | |
void | monitor () |
Monitor model information. More... | |
void | write_data () |
Write the result times of each benchmark. More... | |
Public Member Functions inherited from Utopia::Model< HdfBenchModel, HdfBenchModelTypes > | |
Model (const std::string &name, const ParentModel &parent_model, const Config &custom_cfg={}, std::tuple< WriterArgs... > w_args={}, const DataIO::Default::DefaultDecidermap< HdfBenchModel > &w_deciders=DataIO::Default::default_deciders< HdfBenchModel >, const DataIO::Default::DefaultTriggermap< HdfBenchModel > &w_triggers=DataIO::Default::default_triggers< HdfBenchModel >) | |
Constructs a Model instance. More... | |
const std::shared_ptr< Space > & | get_space () const |
Return the space this model resides in. More... | |
Time | get_time () const |
Return the current time of this model. More... | |
Time | get_time_max () const |
Return the maximum time possible for this model. More... | |
Config | get_cfg () const |
Return the config node of this model. More... | |
std::string | get_name () const |
Return the name of this model instance. More... | |
std::string | get_full_name () const |
Return the full name of this model within the model hierarchy. More... | |
std::shared_ptr< DataGroup > | get_hdfgrp () const |
Return a pointer to the HDF group this model stores data in. More... | |
Time | get_write_start () const |
Return the parameter that controls when write_data is called first. More... | |
Time | get_write_every () const |
Return the parameter that controls how often write_data is called. More... | |
DataManager | get_datamanager () const |
return the datamanager More... | |
hsize_t | get_remaining_num_writes () const |
Return the number of remaining write_data calls this model will make. More... | |
std::shared_ptr< RNG > | get_rng () const |
Return a pointer to the shared RNG. More... | |
std::shared_ptr< spdlog::logger > | get_logger () const |
Return a pointer to the logger of this model. More... | |
Monitor | get_monitor () const |
Return the monitor of this model. More... | |
std::shared_ptr< MonitorManager > | get_monitor_manager () const |
Get the monitor manager of the root model. More... | |
Level | get_level () const |
Return the hierarchical level within the model hierarchy. More... | |
virtual void | prolog () |
A function that is called before starting model iteration. More... | |
virtual void | epilog () |
A function that is called after the last iteration of a model. More... | |
void | iterate () |
Iterate one (time) step of this model. More... | |
void | run () |
Run the model from the current time to the maximum time. More... | |
std::shared_ptr< DataSet > | create_dset (const std::string name, const std::shared_ptr< DataGroup > &hdfgrp, std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={}) |
Create a new dataset within the given group. More... | |
std::shared_ptr< DataSet > | create_dset (const std::string name, const std::vector< hsize_t > add_write_shape, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={}) |
Create a new dataset within the model's base data group. More... | |
std::shared_ptr< DataSet > | create_cm_dset (const std::string name, const CellManager &cm, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={}) |
Create a dataset storing data from a CellManager. More... | |
std::shared_ptr< DataSet > | create_am_dset (const std::string name, const AgentManager &am, const std::size_t compression_level=1, const std::vector< hsize_t > chunksize={}) |
Create a dataset storing data from a AgentManager. More... | |
Protected Member Functions | |
template<bool setup = false> | |
double | benchmark (const std::string &bname) |
Carries out the benchmark associated with the given name. More... | |
double | time_since (const Time start) |
Returns the time (in seconds) since the given time point. More... | |
double | time_between (const Time start, const Time end) |
Returns the absolute time (in seconds) between the given time points. More... | |
Protected Member Functions inherited from Utopia::Model< HdfBenchModel, HdfBenchModelTypes > | |
void | __perform_step () |
Perform the computation of a step. More... | |
void | __monitor () |
Monitor information in the terminal. More... | |
void | __write_data () |
Write data; calls the implementation's write_data method. More... | |
void | __write_initial_state () |
Write the initial state. More... | |
void | increment_time (const Time dt=1) |
Increment time. More... | |
void | __prolog () |
The default prolog of a model. More... | |
void | __epilog () |
The default epilog of a model. More... | |
HdfBenchModel & | impl () |
cast to the derived class More... | |
const HdfBenchModel & | impl () const |
const cast to the derived interface More... | |
Protected Attributes | |
BenchFunc | setup_nd |
BenchFunc | setup_nd_with_chunks |
BenchFunc | write_const |
Writes a constant value into the dataset. More... | |
Protected Attributes inherited from Utopia::Model< HdfBenchModel, HdfBenchModelTypes > | |
const std::string | _name |
Name of the model instance. More... | |
const std::string | _full_name |
The full name within the model hierarchy. More... | |
const Level | _level |
The level within the model hierarchy. More... | |
const Config | _cfg |
Config node belonging to this model instance. More... | |
const std::shared_ptr< RNG > | _rng |
The RNG shared between models. More... | |
const std::shared_ptr< spdlog::logger > | _log |
The (model) logger. More... | |
std::shared_ptr< Space > | _space |
The space this model resides in. More... | |
Time | _time |
Model-internal current time stamp. More... | |
const Time | _time_max |
Model-internal maximum time stamp. More... | |
const std::shared_ptr< DataGroup > | _hdfgrp |
The HDF group this model instance should write its data to. More... | |
const Time | _write_start |
First time at which write_data is called. More... | |
const Time | _write_every |
How often to call write_data from iterate. More... | |
Monitor | _monitor |
The monitor. More... | |
DataManager | _datamanager |
Manager object for handling data output; see DataManager. More... | |
Private Member Functions | |
std::map< std::string, Config > | load_benchmarks () |
Load the benchmark configurations into a map. More... | |
Private Attributes | |
std::map< std::string, BenchFunc > | _setup_funcs |
A map of implemented setup functions for datasets. More... | |
std::map< std::string, BenchFunc > | _write_funcs |
A map of implemented write functions. More... | |
const std::vector< std::string > | _benchmarks |
Names of benchmarks. More... | |
const std::map< std::string, Config > | _bench_cfgs |
Configuration for the benchmarks. More... | |
std::map< std::string, double > | _times |
The results of the measurements, stored under the benchmark name. More... | |
std::shared_ptr< DataSet > | _dset_times |
Dataset to store the write times in. More... | |
std::map< std::string, std::shared_ptr< DataSet > > | _dsets |
Dataset to write test data to are stored in a map of dataset pointers. More... | |
const bool | _delete_afterwards |
Whether to delete datasets after the last step. More... | |
const std::chrono::duration< double > | _sleep_step |
Sleep time in seconds at the beginning of each step. More... | |
const std::chrono::duration< double > | _sleep_bench |
Sleep time in seconds before each benchmark. More... | |
Additional Inherited Members | |
Static Protected Attributes inherited from Utopia::Model< HdfBenchModel, HdfBenchModelTypes > | |
static constexpr WriteMode | _write_mode |
Which data-writing mode the base model should use. More... | |
This model implements a benchmark of Utopia's Hdf5 writing capabilities.
It does not implement a manager or a grid but focusses on benchmarking the write times, given iterable data.
The base model type.
using Utopia::Models::HdfBench::HdfBenchModel::BenchFunc = std::function<double(const std::string, Config)> |
Type of a benchmark function pointer.
using Utopia::Models::HdfBench::HdfBenchModel::Clock = std::chrono::high_resolution_clock |
Type of clock.
using Utopia::Models::HdfBench::HdfBenchModel::Config = typename Base::Config |
Data type that holds the configuration.
using Utopia::Models::HdfBench::HdfBenchModel::DataSet = typename Base::DataSet |
Data type for a dataset.
using Utopia::Models::HdfBench::HdfBenchModel::DurationType = std::chrono::duration<double> |
Type of the duration measure, should be a floating-point type.
using Utopia::Models::HdfBench::HdfBenchModel::Time = std::chrono::high_resolution_clock::time_point |
Type of a time point, retrieved from the clock.
|
inline |
Construct the HdfBench model.
This model aims to allow benchmarking of the Utopia Hdf5 library in a setting that is close to the actual use case, i.e.: as means for storing model output.
name | Name of this model instance |
parent_model | The parent model this model instance resides in |
custom_cfg | A custom configuration to use instead of the one extracted from the parent model using the instance name |
|
inlineprotected |
Carries out the benchmark associated with the given name.
|
inlineprivate |
Load the benchmark configurations into a map.
|
inline |
Monitor model information.
Here, functions and values can be supplied to the monitor that are then available to the frontend. The monitor() function is only called if a certain emit interval has passed; thus, the performance hit is small.
|
inline |
Iterate a single step.
The "iteration" in this model is the step that creates the data that is written in the write_data method, i.e.: it carries out the benchmarks and stores the corresponding times in the _times member, to be written out in write_data
|
inlineprotected |
Returns the absolute time (in seconds) between the given time points.
|
inlineprotected |
Returns the time (in seconds) since the given time point.
|
inline |
Write the result times of each benchmark.
|
private |
Configuration for the benchmarks.
|
private |
Names of benchmarks.
|
private |
Whether to delete datasets after the last step.
|
private |
Dataset to store the write times in.
|
private |
Dataset to write test data to are stored in a map of dataset pointers.
|
private |
A map of implemented setup functions for datasets.
|
private |
Sleep time in seconds before each benchmark.
|
private |
Sleep time in seconds at the beginning of each step.
|
private |
The results of the measurements, stored under the benchmark name.
|
private |
A map of implemented write functions.
|
protected |
|
protected |
|
protected |
Writes a constant value into the dataset.