mirror of
https://git.gfz-potsdam.de/naaice/poet.git
synced 2025-12-16 04:48:23 +01:00
Merge branch '9-toggle-progressbar-with-commandline-option' into 'main'
Resolve "Toggle progressbar with commandline option" Closes #9 See merge request naaice/poet!14
This commit is contained in:
commit
25abe63e83
@ -131,6 +131,10 @@ inline double RunMasterLoop(SimParams ¶ms, RInside &R,
|
|||||||
poet::ChemistryModule::SingleCMap init_df = DFToHashMap(d_params.initial_t);
|
poet::ChemistryModule::SingleCMap init_df = DFToHashMap(d_params.initial_t);
|
||||||
chem.initializeField(diffusion.getField());
|
chem.initializeField(diffusion.getField());
|
||||||
|
|
||||||
|
if (params.getNumParams().print_progressbar) {
|
||||||
|
chem.setProgressBarPrintout(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (params.getNumParams().dht_enabled) {
|
if (params.getNumParams().dht_enabled) {
|
||||||
chem.SetDHTEnabled(true, params.getNumParams().dht_size_per_process,
|
chem.SetDHTEnabled(true, params.getNumParams().dht_size_per_process,
|
||||||
chem_params.dht_species);
|
chem_params.dht_species);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Time-stamp: "Last modified 2023-04-24 14:30:06 mluebke"
|
// Time-stamp: "Last modified 2023-07-12 12:50:53 mluebke"
|
||||||
|
|
||||||
#ifndef CHEMISTRYMODULE_H_
|
#ifndef CHEMISTRYMODULE_H_
|
||||||
#define CHEMISTRYMODULE_H_
|
#define CHEMISTRYMODULE_H_
|
||||||
@ -274,6 +274,13 @@ public:
|
|||||||
* \return Reference to the chemical field.
|
* \return Reference to the chemical field.
|
||||||
*/
|
*/
|
||||||
Field &getField() { return this->chem_field; }
|
Field &getField() { return this->chem_field; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* **Master only** Enable/disable progress bar.
|
||||||
|
*
|
||||||
|
* \param enabled True if print progressbar, false if not.
|
||||||
|
*/
|
||||||
|
void setProgressBarPrintout(bool enabled);
|
||||||
#endif
|
#endif
|
||||||
protected:
|
protected:
|
||||||
#ifdef POET_USE_PRM
|
#ifdef POET_USE_PRM
|
||||||
@ -290,6 +297,7 @@ protected:
|
|||||||
CHEM_DHT_READ_FILE,
|
CHEM_DHT_READ_FILE,
|
||||||
CHEM_WORK_LOOP,
|
CHEM_WORK_LOOP,
|
||||||
CHEM_PERF,
|
CHEM_PERF,
|
||||||
|
CHEM_PROGRESSBAR,
|
||||||
CHEM_BREAK_MAIN_LOOP
|
CHEM_BREAK_MAIN_LOOP
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -391,6 +399,8 @@ protected:
|
|||||||
|
|
||||||
std::array<double, 2> base_totals{0};
|
std::array<double, 2> base_totals{0};
|
||||||
|
|
||||||
|
bool print_progessbar{false};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
double chem_t = 0.;
|
double chem_t = 0.;
|
||||||
|
|||||||
@ -67,6 +67,9 @@ typedef struct {
|
|||||||
unsigned int wp_size;
|
unsigned int wp_size;
|
||||||
/** indicates if resulting grid should be stored after every iteration */
|
/** indicates if resulting grid should be stored after every iteration */
|
||||||
bool store_result;
|
bool store_result;
|
||||||
|
/** indicating whether the progress bar during chemistry simulation should be
|
||||||
|
* printed or not */
|
||||||
|
bool print_progressbar;
|
||||||
} t_simparams;
|
} t_simparams;
|
||||||
|
|
||||||
using GridParams = struct s_GridParams {
|
using GridParams = struct s_GridParams {
|
||||||
@ -233,7 +236,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
std::list<std::string> validateOptions(argh::parser cmdl);
|
std::list<std::string> validateOptions(argh::parser cmdl);
|
||||||
|
|
||||||
const std::set<std::string> flaglist{"ignore-result", "dht", "dht-nolog"};
|
const std::set<std::string> flaglist{"ignore-result", "dht", "dht-nolog", "P",
|
||||||
|
"progress"};
|
||||||
const std::set<std::string> paramlist{"work-package-size", "dht-signif",
|
const std::set<std::string> paramlist{"work-package-size", "dht-signif",
|
||||||
"dht-strategy", "dht-size",
|
"dht-strategy", "dht-size",
|
||||||
"dht-snaps", "dht-file"};
|
"dht-snaps", "dht-file"};
|
||||||
|
|||||||
@ -240,7 +240,7 @@ void poet::ChemistryModule::MasterRunParallel() {
|
|||||||
// grid.shuffleAndExport(mpi_buffer);
|
// grid.shuffleAndExport(mpi_buffer);
|
||||||
std::vector<double> mpi_buffer =
|
std::vector<double> mpi_buffer =
|
||||||
shuffleField(chem_field.AsVector(), this->n_cells, this->prop_count,
|
shuffleField(chem_field.AsVector(), this->n_cells, this->prop_count,
|
||||||
wp_sizes_vector.size());
|
wp_sizes_vector.size());
|
||||||
|
|
||||||
/* setup local variables */
|
/* setup local variables */
|
||||||
pkg_to_send = wp_sizes_vector.size();
|
pkg_to_send = wp_sizes_vector.size();
|
||||||
@ -263,7 +263,9 @@ void poet::ChemistryModule::MasterRunParallel() {
|
|||||||
// while there are still packages to recv
|
// while there are still packages to recv
|
||||||
while (pkg_to_recv > 0) {
|
while (pkg_to_recv > 0) {
|
||||||
// print a progressbar to stdout
|
// print a progressbar to stdout
|
||||||
printProgressbar((int)i_pkgs, (int)wp_sizes_vector.size());
|
if (print_progessbar) {
|
||||||
|
printProgressbar((int)i_pkgs, (int)wp_sizes_vector.size());
|
||||||
|
}
|
||||||
// while there are still packages to send
|
// while there are still packages to send
|
||||||
if (pkg_to_send > 0) {
|
if (pkg_to_send > 0) {
|
||||||
// send packages to all free workers ...
|
// send packages to all free workers ...
|
||||||
@ -288,7 +290,7 @@ void poet::ChemistryModule::MasterRunParallel() {
|
|||||||
// grid.importAndUnshuffle(mpi_buffer);
|
// grid.importAndUnshuffle(mpi_buffer);
|
||||||
std::vector<double> out_vec{mpi_buffer};
|
std::vector<double> out_vec{mpi_buffer};
|
||||||
unshuffleField(mpi_buffer, this->n_cells, this->prop_count,
|
unshuffleField(mpi_buffer, this->n_cells, this->prop_count,
|
||||||
wp_sizes_vector.size(), out_vec);
|
wp_sizes_vector.size(), out_vec);
|
||||||
chem_field.SetFromVector(out_vec);
|
chem_field.SetFromVector(out_vec);
|
||||||
|
|
||||||
/* do master stuff */
|
/* do master stuff */
|
||||||
@ -332,3 +334,12 @@ poet::ChemistryModule::CalculateWPSizesVector(uint32_t n_cells,
|
|||||||
|
|
||||||
return wp_sizes_vector;
|
return wp_sizes_vector;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void poet::ChemistryModule::setProgressBarPrintout(bool enabled) {
|
||||||
|
if (is_master) {
|
||||||
|
int type = CHEM_PROGRESSBAR;
|
||||||
|
ChemBCast(&type, 1, MPI_INT);
|
||||||
|
ChemBCast(&enabled, 1, MPI_CXX_BOOL);
|
||||||
|
}
|
||||||
|
this->print_progessbar = enabled;
|
||||||
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
// Time-stamp: "Last modified 2023-04-24 16:55:34 mluebke"
|
// Time-stamp: "Last modified 2023-07-12 12:56:17 mluebke"
|
||||||
|
|
||||||
#include "IrmResult.h"
|
#include "IrmResult.h"
|
||||||
#include "poet/ChemistryModule.hpp"
|
#include "poet/ChemistryModule.hpp"
|
||||||
@ -103,6 +103,12 @@ void poet::ChemistryModule::WorkerLoop() {
|
|||||||
WorkerMetricsToMaster(type);
|
WorkerMetricsToMaster(type);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case CHEM_PROGRESSBAR: {
|
||||||
|
bool enable;
|
||||||
|
ChemBCast(&enable, 1, MPI_CXX_BOOL);
|
||||||
|
setProgressBarPrintout(enable);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case CHEM_BREAK_MAIN_LOOP: {
|
case CHEM_BREAK_MAIN_LOOP: {
|
||||||
WorkerPostSim(iteration);
|
WorkerPostSim(iteration);
|
||||||
loop = false;
|
loop = false;
|
||||||
|
|||||||
@ -141,6 +141,8 @@ int SimParams::parseFromCmdl(char *argv[], RInside &R) {
|
|||||||
return poet::PARSER_ERROR;
|
return poet::PARSER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
simparams.print_progressbar = cmdl[{"P", "progress"}];
|
||||||
|
|
||||||
/*Parse DHT arguments*/
|
/*Parse DHT arguments*/
|
||||||
simparams.dht_enabled = cmdl["dht"];
|
simparams.dht_enabled = cmdl["dht"];
|
||||||
// cout << "CPP: DHT is " << ( dht_enabled ? "ON" : "OFF" ) << '\n';
|
// cout << "CPP: DHT is " << ( dht_enabled ? "ON" : "OFF" ) << '\n';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user