From f4330adeb710484a762725104b4cd0ef67c822fd Mon Sep 17 00:00:00 2001 From: Max Luebke Date: Fri, 21 Jul 2023 17:22:52 +0200 Subject: [PATCH] refactor: remove DHT prop type from input script --- R_lib/kin_r_library.R | 6 +-- app/poet.cpp | 3 -- include/poet/ChemistryModule.hpp | 11 +----- include/poet/DHT_Types.hpp | 2 +- include/poet/DHT_Wrapper.hpp | 1 - include/poet/SimParams.hpp | 11 ------ src/ChemistryModule/ChemistryModule.cpp | 17 --------- src/ChemistryModule/DHT_Wrapper.cpp | 19 ++-------- src/ChemistryModule/WorkerFunctions.cpp | 9 +---- src/SimParams.cpp | 50 +------------------------ 10 files changed, 12 insertions(+), 117 deletions(-) diff --git a/R_lib/kin_r_library.R b/R_lib/kin_r_library.R index e350ac35e..e0634c153 100644 --- a/R_lib/kin_r_library.R +++ b/R_lib/kin_r_library.R @@ -264,9 +264,9 @@ StoreSetup <- function(setup) { if (dht_enabled) { to_store$DHT <- list( enabled = dht_enabled, - log = dht_log, - signif = dht_final_signif, - proptype = dht_final_proptype + log = dht_log + #signif = dht_final_signif, + #proptype = dht_final_proptype ) } else { to_store$DHT <- FALSE diff --git a/app/poet.cpp b/app/poet.cpp index bc47c2c2f..93f301c4b 100644 --- a/app/poet.cpp +++ b/app/poet.cpp @@ -141,9 +141,6 @@ inline double RunMasterLoop(SimParams ¶ms, RInside &R, if (!chem_params.dht_signif.empty()) { chem.SetDHTSignifVector(chem_params.dht_signif); } - if (!params.getDHTPropTypeVector().empty()) { - chem.SetDHTPropTypeVector(params.getDHTPropTypeVector()); - } if (!params.getDHTFile().empty()) { chem.ReadDHTFile(params.getDHTFile()); } diff --git a/include/poet/ChemistryModule.hpp b/include/poet/ChemistryModule.hpp index 2db3cd17e..fbb932d0f 100644 --- a/include/poet/ChemistryModule.hpp +++ b/include/poet/ChemistryModule.hpp @@ -1,4 +1,4 @@ -// Time-stamp: "Last modified 2023-07-21 12:35:23 mluebke" +// Time-stamp: "Last modified 2023-07-21 17:20:10 mluebke" #ifndef CHEMISTRYMODULE_H_ #define CHEMISTRYMODULE_H_ @@ -162,13 +162,7 @@ public: * is defined by prop_type vector (ChemistryModule::GetPropNames). */ void SetDHTSignifVector(std::vector &signif_vec); - /** - * **Master only** Set the DHT rounding type of each species. See - * DHT_PROP_TYPES enumemartion for explanation. - * - * \param proptype_vec Vector defining DHT prop type for each species. - */ - void SetDHTPropTypeVector(std::vector proptype_vec); + /** * **Master only** Load the state of the DHT from given file. * @@ -272,7 +266,6 @@ protected: CHEM_INIT_SPECIES, CHEM_DHT_ENABLE, CHEM_DHT_SIGNIF_VEC, - CHEM_DHT_PROP_TYPE_VEC, CHEM_DHT_SNAPS, CHEM_DHT_READ_FILE, CHEM_WORK_LOOP, diff --git a/include/poet/DHT_Types.hpp b/include/poet/DHT_Types.hpp index be0ed295b..15eb9913e 100644 --- a/include/poet/DHT_Types.hpp +++ b/include/poet/DHT_Types.hpp @@ -2,7 +2,7 @@ #define DHT_TYPES_H_ namespace poet { -enum DHT_PROP_TYPES { DHT_TYPE_DEFAULT, DHT_TYPE_CHARGE, DHT_TYPE_IGNORE, DHT_TYPE_TOTAL }; +enum DHT_PROP_TYPES { DHT_TYPE_DEFAULT, DHT_TYPE_CHARGE, DHT_TYPE_TOTAL }; } #endif // DHT_TYPES_H_ diff --git a/include/poet/DHT_Wrapper.hpp b/include/poet/DHT_Wrapper.hpp index c1ebffcb1..b7cf01ba6 100644 --- a/include/poet/DHT_Wrapper.hpp +++ b/include/poet/DHT_Wrapper.hpp @@ -198,7 +198,6 @@ public: auto getEvictions() { return this->dht_evictions; }; void SetSignifVector(std::vector signif_vec); - void SetPropTypeVector(std::vector prop_type_vec); void setBaseTotals(const std::array &bt) { this->base_totals = bt; diff --git a/include/poet/SimParams.hpp b/include/poet/SimParams.hpp index 3e7483e31..8d670fe15 100644 --- a/include/poet/SimParams.hpp +++ b/include/poet/SimParams.hpp @@ -193,16 +193,6 @@ public: */ auto getDHTSignifVector() const { return this->dht_signif_vector; }; - /** - * @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 - */ - auto getDHTPropTypeVector() const { return this->dht_prop_type_vector; }; - /** * @brief Return name of DHT snapshot. * @@ -245,7 +235,6 @@ private: t_simparams simparams; std::vector dht_signif_vector; - std::vector dht_prop_type_vector; std::string dht_file; std::string filesim; diff --git a/src/ChemistryModule/ChemistryModule.cpp b/src/ChemistryModule/ChemistryModule.cpp index a42d8151c..d3e6f7e45 100644 --- a/src/ChemistryModule/ChemistryModule.cpp +++ b/src/ChemistryModule/ChemistryModule.cpp @@ -274,23 +274,6 @@ void poet::ChemistryModule::SetDHTSignifVector( this->dht->SetSignifVector(signif_vec); } -void poet::ChemistryModule::SetDHTPropTypeVector( - std::vector proptype_vec) { - if (this->is_master) { - if (proptype_vec.size() != this->prop_count) { - throw std::runtime_error("Prop type vector sizes mismatches prop count."); - } - - int ftype = CHEM_DHT_PROP_TYPE_VEC; - PropagateFunctionType(ftype); - ChemBCast(proptype_vec.data(), proptype_vec.size(), MPI_UINT32_T); - - return; - } - - this->dht->SetPropTypeVector(proptype_vec); -} - void poet::ChemistryModule::ReadDHTFile(const std::string &input_file) { if (this->is_master) { int ftype = CHEM_DHT_READ_FILE; diff --git a/src/ChemistryModule/DHT_Wrapper.cpp b/src/ChemistryModule/DHT_Wrapper.cpp index 129b45340..48ccbbaf5 100644 --- a/src/ChemistryModule/DHT_Wrapper.cpp +++ b/src/ChemistryModule/DHT_Wrapper.cpp @@ -1,3 +1,5 @@ +// Time-stamp: "Last modified 2023-07-21 17:22:00 mluebke" + /* ** Copyright (C) 2018-2021 Alexander Lindemann, Max Luebke (University of ** Potsdam) @@ -61,9 +63,6 @@ DHT_Wrapper::DHT_Wrapper(MPI_Comm dht_comm, uint32_t dht_size, &poet::Murmur2_64A); this->dht_signif_vector.resize(key_size, DHT_KEY_SIGNIF_DEFAULT); - this->dht_signif_vector[0] = DHT_KEY_SIGNIF_TOTALS; - this->dht_signif_vector[1] = DHT_KEY_SIGNIF_TOTALS; - this->dht_signif_vector[2] = DHT_KEY_SIGNIF_CHARGE; this->dht_prop_type_vector.resize(key_count, DHT_TYPE_DEFAULT); this->dht_prop_type_vector[0] = DHT_TYPE_TOTAL; @@ -192,13 +191,11 @@ std::vector DHT_Wrapper::fuzzForDHT(int var_count, void *key, this->dht_prop_type_vector[i] == DHT_TYPE_DEFAULT) { continue; } - if (this->dht_prop_type_vector[i] == DHT_TYPE_IGNORE) { - continue; - } if (this->dht_prop_type_vector[i] == DHT_TYPE_TOTAL) { curr_key -= base_totals[totals_i++]; } - vecFuzz[i].sc_notation = round_key_element(curr_key, dht_signif_vector[i]); + vecFuzz[i].sc_notation = + round_key_element(curr_key, dht_signif_vector[i]); } } // if timestep differs over iterations set current current time step at the @@ -216,11 +213,3 @@ void poet::DHT_Wrapper::SetSignifVector(std::vector signif_vec) { this->dht_signif_vector = signif_vec; } -void poet::DHT_Wrapper::SetPropTypeVector(std::vector prop_type_vec) { - if (prop_type_vec.size() != this->key_count) { - throw std::runtime_error( - "Prop type vector size mismatches count of key elements."); - } - - this->dht_prop_type_vector = prop_type_vec; -} diff --git a/src/ChemistryModule/WorkerFunctions.cpp b/src/ChemistryModule/WorkerFunctions.cpp index 4f5a59fa0..3101a3152 100644 --- a/src/ChemistryModule/WorkerFunctions.cpp +++ b/src/ChemistryModule/WorkerFunctions.cpp @@ -1,4 +1,4 @@ -// Time-stamp: "Last modified 2023-07-12 12:56:17 mluebke" +// Time-stamp: "Last modified 2023-07-21 17:22:19 mluebke" #include "IrmResult.h" #include "poet/ChemistryModule.hpp" @@ -70,13 +70,6 @@ void poet::ChemistryModule::WorkerLoop() { SetDHTSignifVector(input_vec); break; } - case CHEM_DHT_PROP_TYPE_VEC: { - std::vector input_vec(this->prop_count); - ChemBCast(input_vec.data(), this->prop_count, MPI_UINT32_T); - - SetDHTPropTypeVector(input_vec); - break; - } case CHEM_DHT_SNAPS: { int type; ChemBCast(&type, 1, MPI_INT); diff --git a/src/SimParams.cpp b/src/SimParams.cpp index 8d484a54b..c3ff54118 100644 --- a/src/SimParams.cpp +++ b/src/SimParams.cpp @@ -220,55 +220,7 @@ int SimParams::parseFromCmdl(char *argv[], RInside &R) { return poet::PARSER_OK; } -void SimParams::initVectorParams(RInside &R) { - if (simparams.dht_enabled) { - /*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>(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) { - std::vector prop_type_R = - as>(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_CHARGE); - 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) { - // MDL: new output on signif_vector and prop_type - if (signif_vector_exists) { - cout << "CPP: using problem-specific rounding digits: " << endl; - R.parseEval("print(data.frame(prop=prop, type=prop_type, " - "digits=signif_vector))"); - } else { - cout << "CPP: using DHT default rounding digits = " - << simparams.dht_significant_digits << endl; - } - - // MDL: pass to R the DHT stuff. These variables exist - // only if dht_enabled is true - R["dht_final_signif"] = dht_signif_vector; - R["dht_final_proptype"] = dht_prop_type_vector; - } - } -} +void SimParams::initVectorParams(RInside &R) {} std::list SimParams::validateOptions(argh::parser cmdl) { /* store all unknown parameters here */