From 991f825dc64a7c57d2f49d0cb22390e0768667fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20L=C3=BCbke?= Date: Tue, 2 Feb 2021 14:14:22 +0100 Subject: [PATCH] Documenting SimParams --- src/util/SimParams.cpp | 41 ------------------ src/util/SimParams.h | 94 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 41 deletions(-) diff --git a/src/util/SimParams.cpp b/src/util/SimParams.cpp index fdf95e685..d97734354 100644 --- a/src/util/SimParams.cpp +++ b/src/util/SimParams.cpp @@ -129,19 +129,6 @@ int SimParams::parseFromCmdl(char *argv[], RRuntime &R) { void SimParams::initVectorParams(RRuntime &R, int col_count) { if (simparams.dht_enabled) { - // cout << "\nCreating DHT\n"; - // determine size of dht entries - // int dht_data_size = grid.getCols() * sizeof(double); - // int dht_key_size = - // grid.getCols() * sizeof(double) + (params.dt_differ * - // sizeof(double)); - - // // // determine bucket count for preset memory usage - // // // bucket size is key + value + 1 byte for status - // int dht_buckets_per_process = - // params.dht_size_per_process / (1 + dht_data_size + dht_key_size); - - // MDL : following code moved here from worker.cpp /*Load significance vector from R setup file (or set default)*/ bool signif_vector_exists = R.parseEval("exists('signif_vector')"); if (signif_vector_exists) { @@ -159,12 +146,6 @@ void SimParams::initVectorParams(RRuntime &R, int col_count) { } if (simparams.world_rank == 0) { - // // print only on master, values are equal on all workes - // cout << "CPP: dht_data_size: " << dht_data_size << "\n"; - // cout << "CPP: dht_key_size: " << dht_key_size << "\n"; - // cout << "CPP: dht_buckets_per_process: " << dht_buckets_per_process - // << endl; - // MDL: new output on signif_vector and prop_type if (signif_vector_exists) { cout << "CPP: using problem-specific rounding digits: " << endl; @@ -184,28 +165,6 @@ void SimParams::initVectorParams(RRuntime &R, int col_count) { } } -// void SimParams::parseR(RRuntime &R) { -// // if local_rank == 0 then master else worker -// R["local_rank"] = simparams.world_rank; -// // assign a char* (string) to 'filesim' -// R["filesim"] = wrap(simparams.filesim); -// // assign a char* (string) to 'fileout' -// R["fileout"] = wrap(simparams.out_dir); -// // pass the boolean "store_result" to the R process -// R["store_result"] = simparams.store_result; -// // worker count -// R["n_procs"] = simparams.world_size - 1; -// // work package size -// R["work_package_size"] = simparams.wp_size; -// // dht enabled? -// R["dht_enabled"] = simparams.dht_enabled; -// // log before rounding? -// R["dht_log"] = simparams.dht_log; - -// // eval the init string, ignoring any returns -// R.parseEvalQ("source(filesim)"); -// } - void SimParams::setDtDiffer(bool dt_differ) { simparams.dt_differ = dt_differ; } t_simparams SimParams::getNumParams() { return this->simparams; } diff --git a/src/util/SimParams.h b/src/util/SimParams.h index 9cb70f0eb..3ec3e027f 100644 --- a/src/util/SimParams.h +++ b/src/util/SimParams.h @@ -87,17 +87,88 @@ class SimParams { */ int parseFromCmdl(char *argv[], RRuntime &R); + /** + * @brief Init std::vector values + * + * This will initialize dht_signif_vector and dht_prop_type_vector internally + * depending on whether vectors are defined by R-Simulation file or not. + * 'init_chemistry' must be run beforehand. + * + * @param R R runtime + * @param col_count Count of variables per grid cell (typically the count of + * columns of each grid cell) + */ void initVectorParams(RRuntime &R, int col_count); + /** + * @brief Set if dt differs + * + * Set a boolean variable if the timestep differs between iterations of + * simulation. + * + * @param dt_differ Boolean value, if dt differs + */ void setDtDiffer(bool dt_differ); + /** + * @brief Get the numerical params struct + * + * Returns a struct which contains all numerical or boolean simulation + * parameters. + * + * @return t_simparams Parameter struct + */ t_simparams getNumParams(); + /** + * @brief Get the DHT_Signif_Vector + * + * Returns a vector indicating which significant values are used for each + * variable of a grid cell. + * + * @return std::vector Vector of integers containing information about + * significant digits + */ std::vector getDHTSignifVector(); + + /** + * @brief Get the DHT_Prop_Type_Vector + * + * Returns a vector indicating of which type a variable of a grid cell is. + * + * @return std::vector Vector if strings defining a type of a + * variable + */ std::vector getDHTPropTypeVector(); + + /** + * @brief Return name of DHT snapshot. + * + * Name of the DHT file which is used to initialize the DHT with a previously + * written snapshot. + * + * @return std::string Absolute paht to the DHT snapshot + */ std::string getDHTFile(); + /** + * @brief Get the filesim name + * + * Returns a string containing the absolute path to a R file defining the + * simulation. + * + * @return std::string Absolute path to R file + */ std::string getFilesim(); + + /** + * @brief Get the output directory + * + * Returns the name of an absolute path where all output files should be + * stored. + * + * @return std::string Absolute path to output path + */ std::string getOutDir(); private: @@ -135,11 +206,34 @@ class SimParams { */ t_simparams simparams; + /** + * @brief Defines significant digits for each variable of a grid cell + * + */ std::vector dht_signif_vector; + + /** + * @brief Defines the type of a variable + * + */ std::vector dht_prop_type_vector; + + /** + * @brief Absolute path to a DHT snapshot + * + */ std::string dht_file; + /** + * @brief Absolute path to R file containing simulation definitions + * + */ std::string filesim; + + /** + * @brief Absolute path to output dir + * + */ std::string out_dir; }; } // namespace poet