mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 12:54:50 +01:00
refactor: In SimParams, relocate trivial getter/setters to header file
refactor: change vector data types of dht_signif_vector and dht_prop_type_vector to both uint32
This commit is contained in:
parent
fc79d1d0a8
commit
a493054f9d
@ -31,8 +31,8 @@
|
||||
#include <Rcpp.h>
|
||||
// BSD-licenced
|
||||
|
||||
/** Standard DHT Size (Defaults to 1 GiB) */
|
||||
#define DHT_SIZE_PER_PROCESS 1073741824
|
||||
/** Standard DHT Size. Defaults to 1 GB (1000 MB) */
|
||||
constexpr uint32_t DHT_SIZE_PER_PROCESS_MB = 1E3;
|
||||
/** Standard work package size */
|
||||
#define WORK_PACKAGE_SIZE_DEFAULT 5
|
||||
|
||||
@ -167,16 +167,6 @@ public:
|
||||
*/
|
||||
void initVectorParams(RInside &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
|
||||
*
|
||||
@ -185,7 +175,7 @@ public:
|
||||
*
|
||||
* @return t_simparams Parameter struct
|
||||
*/
|
||||
t_simparams getNumParams() const;
|
||||
auto getNumParams() const { return this->simparams; };
|
||||
|
||||
/**
|
||||
* @brief Get the DHT_Signif_Vector
|
||||
@ -196,7 +186,7 @@ public:
|
||||
* @return std::vector<int> Vector of integers containing information about
|
||||
* significant digits
|
||||
*/
|
||||
std::vector<int> getDHTSignifVector() const;
|
||||
auto getDHTSignifVector() const { return this->dht_signif_vector; };
|
||||
|
||||
/**
|
||||
* @brief Get the DHT_Prop_Type_Vector
|
||||
@ -206,7 +196,7 @@ public:
|
||||
* @return std::vector<std::string> Vector if strings defining a type of a
|
||||
* variable
|
||||
*/
|
||||
std::vector<std::string> getDHTPropTypeVector() const;
|
||||
auto getDHTPropTypeVector() const { return this->dht_prop_type_vector; };
|
||||
|
||||
/**
|
||||
* @brief Return name of DHT snapshot.
|
||||
@ -216,7 +206,7 @@ public:
|
||||
*
|
||||
* @return std::string Absolute paht to the DHT snapshot
|
||||
*/
|
||||
std::string_view getDHTFile() const;
|
||||
auto getDHTFile() const { return this->dht_file; };
|
||||
|
||||
/**
|
||||
* @brief Get the filesim name
|
||||
@ -226,7 +216,7 @@ public:
|
||||
*
|
||||
* @return std::string Absolute path to R file
|
||||
*/
|
||||
std::string_view getFilesim() const;
|
||||
auto getFilesim() const { return this->filesim; };
|
||||
|
||||
/**
|
||||
* @brief Get the output directory
|
||||
@ -236,71 +226,23 @@ public:
|
||||
*
|
||||
* @return std::string Absolute path to output path
|
||||
*/
|
||||
std::string_view getOutDir() const;
|
||||
auto getOutDir() const { return this->out_dir; };
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Validate program parameters and flags
|
||||
*
|
||||
* Therefore this function iterates over the list of flags and parameters and
|
||||
* compare them to the class member flagList and paramList. If a program
|
||||
* argument is not included it is put to a list. This list will be returned.
|
||||
*
|
||||
* @return std::list<std::string> List with all unknown parameters. Might be
|
||||
* empty.
|
||||
*/
|
||||
std::list<std::string> validateOptions(argh::parser cmdl);
|
||||
|
||||
/**
|
||||
* @brief Contains all valid program flags.
|
||||
*
|
||||
*/
|
||||
std::set<std::string> flaglist{"ignore-result", "dht", "dht-nolog"};
|
||||
|
||||
/**
|
||||
* @brief Contains all valid program parameters.
|
||||
*
|
||||
*/
|
||||
std::set<std::string> paramlist{"work-package-size", "dht-signif",
|
||||
const std::set<std::string> flaglist{"ignore-result", "dht", "dht-nolog"};
|
||||
const std::set<std::string> paramlist{"work-package-size", "dht-signif",
|
||||
"dht-strategy", "dht-size",
|
||||
"dht-snaps", "dht-file"};
|
||||
|
||||
/**
|
||||
* @brief Struct containing all simulation parameters
|
||||
*
|
||||
* Contains only those values which are standard arithmetic C types.
|
||||
*
|
||||
*/
|
||||
t_simparams simparams;
|
||||
|
||||
/**
|
||||
* @brief Defines significant digits for each variable of a grid cell
|
||||
*
|
||||
*/
|
||||
std::vector<int> dht_signif_vector;
|
||||
std::vector<uint32_t> dht_signif_vector;
|
||||
std::vector<uint32_t> dht_prop_type_vector;
|
||||
|
||||
/**
|
||||
* @brief Defines the type of a variable
|
||||
*
|
||||
*/
|
||||
std::vector<std::string> 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
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
** Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "poet/DHT_Types.hpp"
|
||||
#include <bits/stdint-uintn.h>
|
||||
#include <poet/SimParams.hpp>
|
||||
|
||||
@ -130,7 +131,7 @@ int SimParams::parseFromCmdl(char *argv[], RInside &R) {
|
||||
// cout << "CPP: DHT logarithm before rounding: " << ( dht_logarithm ? "ON"
|
||||
// : "OFF" ) << endl;
|
||||
|
||||
cmdl("dht-size", DHT_SIZE_PER_PROCESS) >> simparams.dht_size_per_process;
|
||||
cmdl("dht-size", DHT_SIZE_PER_PROCESS_MB) >> simparams.dht_size_per_process;
|
||||
// cout << "CPP: DHT size per process (Byte) = " << dht_size_per_process <<
|
||||
// endl;
|
||||
|
||||
@ -196,17 +197,30 @@ void SimParams::initVectorParams(RInside &R, int col_count) {
|
||||
/*Load significance vector from R setup file (or set default)*/
|
||||
bool signif_vector_exists = R.parseEval("exists('signif_vector')");
|
||||
if (signif_vector_exists) {
|
||||
dht_signif_vector = as<std::vector<int>>(R["signif_vector"]);
|
||||
} else {
|
||||
dht_signif_vector.assign(col_count, simparams.dht_significant_digits);
|
||||
dht_signif_vector = as<std::vector<uint32_t>>(R["signif_vector"]);
|
||||
}
|
||||
|
||||
/*Load property type vector from R setup file (or set default)*/
|
||||
bool prop_type_vector_exists = R.parseEval("exists('prop_type')");
|
||||
if (prop_type_vector_exists) {
|
||||
dht_prop_type_vector = as<std::vector<string>>(R["prop_type"]);
|
||||
} else {
|
||||
dht_prop_type_vector.assign(col_count, "act");
|
||||
std::vector<std::string> prop_type_R =
|
||||
as<std::vector<string>>(R["prop_type"]);
|
||||
this->dht_prop_type_vector.clear();
|
||||
this->dht_prop_type_vector.reserve(prop_type_R.size());
|
||||
|
||||
for (const auto &type : prop_type_R) {
|
||||
if (type == "act") {
|
||||
this->dht_prop_type_vector.push_back(DHT_TYPE_ACT);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (type == "ignore") {
|
||||
this->dht_prop_type_vector.push_back(DHT_TYPE_IGNORE);
|
||||
continue;
|
||||
}
|
||||
|
||||
this->dht_prop_type_vector.push_back(DHT_TYPE_DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
if (simparams.world_rank == 0) {
|
||||
@ -228,21 +242,6 @@ void SimParams::initVectorParams(RInside &R, int col_count) {
|
||||
}
|
||||
}
|
||||
|
||||
void SimParams::setDtDiffer(bool dt_differ) { simparams.dt_differ = dt_differ; }
|
||||
|
||||
t_simparams SimParams::getNumParams() const { return this->simparams; }
|
||||
|
||||
std::vector<int> SimParams::getDHTSignifVector() const {
|
||||
return this->dht_signif_vector;
|
||||
}
|
||||
std::vector<std::string> SimParams::getDHTPropTypeVector() const {
|
||||
return this->dht_prop_type_vector;
|
||||
}
|
||||
std::string_view SimParams::getDHTFile() const { return this->dht_file; }
|
||||
|
||||
std::string_view SimParams::getFilesim() const { return this->filesim; }
|
||||
std::string_view SimParams::getOutDir() const { return this->out_dir; }
|
||||
|
||||
std::list<std::string> SimParams::validateOptions(argh::parser cmdl) {
|
||||
/* store all unknown parameters here */
|
||||
std::list<std::string> retList;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user