Commit f85ec54f authored by Lukas Weber's avatar Lukas Weber

add_observable -> register_observable

parent 4f73681a
...@@ -18,14 +18,14 @@ int mc::sweep() const { ...@@ -18,14 +18,14 @@ int mc::sweep() const {
void mc::_init() { void mc::_init() {
// simple profiling support: measure the time spent for sweeps/measurements etc // simple profiling support: measure the time spent for sweeps/measurements etc
measure.add_observable("_ll_checkpoint_read_time", 1); measure.register_observable("_ll_checkpoint_read_time", 1);
measure.add_observable("_ll_checkpoint_write_time", 1); measure.register_observable("_ll_checkpoint_write_time", 1);
measure.add_observable("_ll_measurement_time", 1000); measure.register_observable("_ll_measurement_time", 1000);
measure.add_observable("_ll_sweep_time", 1000); measure.register_observable("_ll_sweep_time", 1000);
if(pt_mode_) { if(pt_mode_) {
if(param.get<bool>("pt_statistics", false)) { if(param.get<bool>("pt_statistics", false)) {
measure.add_observable("_ll_pt_rank", 1); measure.register_observable("_ll_pt_rank", 1);
} }
} }
......
...@@ -13,7 +13,7 @@ bool measurements::observable_name_is_legal(const std::string &obs_name) { ...@@ -13,7 +13,7 @@ bool measurements::observable_name_is_legal(const std::string &obs_name) {
return true; return true;
} }
void measurements::add_observable(const std::string &name, size_t bin_size, size_t vector_length) { void measurements::register_observable(const std::string &name, size_t bin_size, size_t vector_length) {
if(!observable_name_is_legal(name)) { if(!observable_name_is_legal(name)) {
throw std::runtime_error( throw std::runtime_error(
fmt::format("Illegal observable name '{}': names must not contain / or .", name)); fmt::format("Illegal observable name '{}': names must not contain / or .", name));
...@@ -30,7 +30,7 @@ void measurements::checkpoint_write(const iodump::group &dump_file) { ...@@ -30,7 +30,7 @@ void measurements::checkpoint_write(const iodump::group &dump_file) {
void measurements::checkpoint_read(const iodump::group &dump_file) { void measurements::checkpoint_read(const iodump::group &dump_file) {
for(const auto &obs_name : dump_file) { for(const auto &obs_name : dump_file) {
add_observable(obs_name); register_observable(obs_name);
observables_.at(obs_name).checkpoint_read(obs_name, dump_file.open_group(obs_name)); observables_.at(obs_name).checkpoint_read(obs_name, dump_file.open_group(obs_name));
} }
} }
......
...@@ -14,7 +14,7 @@ class measurements { ...@@ -14,7 +14,7 @@ class measurements {
public: public:
static bool observable_name_is_legal(const std::string &name); static bool observable_name_is_legal(const std::string &name);
void add_observable(const std::string &name, size_t bin_size = 1, size_t vector_length = 1); void register_observable(const std::string &name, size_t bin_size = 1, size_t vector_length = 1);
// use this to add a measurement sample to an observable. // use this to add a measurement sample to an observable.
template<class T> template<class T>
......
...@@ -302,7 +302,6 @@ void runner_pt_master::checkpoint_read() { ...@@ -302,7 +302,6 @@ void runner_pt_master::checkpoint_read() {
pt_chains_.at(id).checkpoint_read(pt_chains.open_group(name)); pt_chains_.at(id).checkpoint_read(pt_chains.open_group(name));
} }
g.read("current_chain_id", current_chain_id_);
} }
} }
...@@ -340,8 +339,6 @@ void runner_pt_master::checkpoint_write() { ...@@ -340,8 +339,6 @@ void runner_pt_master::checkpoint_write() {
c.checkpoint_write(pt_chains.open_group(fmt::format("{:04d}", c.id))); c.checkpoint_write(pt_chains.open_group(fmt::format("{:04d}", c.id)));
} }
g.write("current_chain_id", current_chain_id_);
if(use_param_optimization_) { if(use_param_optimization_) {
write_params_yaml(); write_params_yaml();
} }
...@@ -389,8 +386,8 @@ int runner_pt_master::schedule_chain_run() { ...@@ -389,8 +386,8 @@ int runner_pt_master::schedule_chain_run() {
int nchains = pt_chains_.size(); int nchains = pt_chains_.size();
for(int i = 1; i <= nchains; i++) { for(int i = 1; i <= nchains; i++) {
if(!pt_chains_[(old_id + i) % nchains].is_done()) { if(!pt_chains_[(old_id + i) % nchains].is_done()) {
int new_chain_id = (old_id + i) % nchains; current_chain_id_ = (old_id + i) % nchains;
auto &chain = pt_chains_[new_chain_id]; auto &chain = pt_chains_[current_chain_id_];
chain.scheduled_runs++; chain.scheduled_runs++;
int idx = 0; int idx = 0;
...@@ -774,7 +771,9 @@ int runner_pt_slave::what_is_next(int status) { ...@@ -774,7 +771,9 @@ int runner_pt_slave::what_is_next(int status) {
void runner_pt_slave::checkpoint_write() { void runner_pt_slave::checkpoint_write() {
time_last_checkpoint_ = MPI_Wtime(); time_last_checkpoint_ = MPI_Wtime();
sys_->_write(job_.rundir(task_id_, run_id_)); sys_->_write(job_.rundir(task_id_, run_id_));
job_.log(fmt::format("* rank {}: checkpoint {}", rank_, job_.rundir(task_id_, run_id_))); if(chain_rank_ == 0) {
job_.log(fmt::format("* rank {}: chain checkpoint {}", rank_, job_.rundir(task_id_, run_id_)));
}
} }
void runner_pt_master::send_action(int action, int destination) { void runner_pt_master::send_action(int action, int destination) {
......
...@@ -37,16 +37,15 @@ public: ...@@ -37,16 +37,15 @@ public:
int id{}; int id{};
int run_id{}; int run_id{};
bool swap_odd{}; bool swap_odd{};
pt_chain_run(const pt_chain &chain, int run_id);
static pt_chain_run checkpoint_read(const iodump::group &g);
void checkpoint_write(const iodump::group &g);
std::vector<int> rank_to_pos; std::vector<int> rank_to_pos;
std::vector<int> last_visited;
std::vector<int> switch_partners; std::vector<int> switch_partners;
std::vector<double> weight_ratios; std::vector<double> weight_ratios;
std::vector<int> last_visited; pt_chain_run(const pt_chain &chain, int run_id);
static pt_chain_run checkpoint_read(const iodump::group &g);
void checkpoint_write(const iodump::group &g);
}; };
int runner_pt_start(jobinfo job, const mc_factory &mccreator, int argc, char **argv); int runner_pt_start(jobinfo job, const mc_factory &mccreator, int argc, char **argv);
...@@ -67,6 +66,8 @@ private: ...@@ -67,6 +66,8 @@ private:
std::map<int, int> rank_to_chain_run_; std::map<int, int> rank_to_chain_run_;
int current_chain_id_{-1}; int current_chain_id_{-1};
measurements pt_meas_;
void construct_pt_chains(); void construct_pt_chains();
void checkpoint_write(); void checkpoint_write();
void checkpoint_read(); void checkpoint_read();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment