Commit caff60ad authored by Sonja Happ's avatar Sonja Happ

add time measurements for MPI_Bcast operations in FBS

parent 554760f8
......@@ -104,6 +104,11 @@ public:
Time_measurement* tm_slack;
Time_measurement* tm_df;
/* Time measurements for MPI broadcast operations during FBS */
Time_measurement* tm_bcast_FBS;
Time_measurement* tm_bcast_forward_sweep;
Time_measurement* tm_bcast_backward_sweep;
unsigned int number_of_fbs_sweeps; //!< counting the number of forward-backward sweeps
//!< in each iteration
......
......@@ -1523,7 +1523,10 @@ void Model::forward_backward_sweep() {
this->do_forward_sweep();
}
else {
IO->start_time_measurement(IO->tm_bcast_forward_sweep);
//TODO use MPI_Ibcast instead
MPI_Bcast(&forward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD); // root was 0
IO->stop_time_measurement(IO->tm_bcast_forward_sweep);
}
......@@ -1540,7 +1543,10 @@ void Model::forward_backward_sweep() {
}
}
if(world_size>1) {
IO->start_time_measurement(IO->tm_bcast_FBS);
//TODO use MPI_Ibcast instead
MPI_Bcast(&forward_backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD);
IO->stop_time_measurement(IO->tm_bcast_FBS);
}
IO->increment_number_of_fbs_sweeps();
......@@ -1603,7 +1609,12 @@ void Model::do_backward_sweep() {
}
}
if(world_size > 1){
IO->stop_time_measurement(IO->tm_backward_sweep);
IO->start_time_measurement(IO->tm_bcast_backward_sweep);
//TODO use MPI_Ibcast instead
MPI_Bcast(&backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD);
IO->stop_time_measurement(IO->tm_bcast_backward_sweep);
IO->start_time_measurement(IO->tm_backward_sweep);
}
IO->log_info("Backward sweep finished: " + std::to_string(backward_sweep_finished));
......@@ -1687,8 +1698,12 @@ void Model::do_forward_sweep() {
}
}
IO->stop_time_measurement(IO->tm_forward_sweep);
IO->start_time_measurement(IO->tm_bcast_forward_sweep);
//TODO use MPI_Ibcast instead
MPI_Bcast(&forward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD); // root was 0
IO->stop_time_measurement(IO->tm_bcast_forward_sweep);
IO->start_time_measurement(IO->tm_forward_sweep);
counter++;
// in forward sweep info about next and previous electrical nodes are required
// that is why both sets need to be updated here
......
......@@ -72,6 +72,10 @@ props(_props), rank(_rank), world_size(_world_size), profile_dir(_profile_dir)
tm_substation = new Time_measurement("substation_behavior", rank);
tm_slack = new Time_measurement("slack_behavior", rank);
tm_df = new Time_measurement("df_behavior", rank);
tm_bcast_FBS = new Time_measurement("bcast_fbs", rank);
tm_bcast_forward_sweep = new Time_measurement("bcast_forward_sweep", rank);
tm_bcast_backward_sweep = new Time_measurement("bcast_backward_sweep", rank);
}
/*! \brief Initialize message and result logging on rank level
......@@ -190,6 +194,10 @@ void ModelIO::init_db() {
d_props.result.dbconn->addTimeMeasurementType("slack_behavior","Time for slack behavior in us");
d_props.result.dbconn->addTimeMeasurementType("df_behavior","Time for DF behavior in us");
d_props.result.dbconn->addTimeMeasurementType("bcast_fbs","Time for MPI broadcast for FBS convergence in us");
d_props.result.dbconn->addTimeMeasurementType("bcast_forward_sweep","Time for MPI broadcast for forward sweep completion in us");
d_props.result.dbconn->addTimeMeasurementType("bcast_backward_sweep","Time for MPI broadcast for backward sweep completion in us");
// initialize metadata
addMetaEntry(rank, "simulationmeta", "stop.at", props->getProperty("stop.at"));
addMetaEntry(rank, "simulationmeta", "step.size", props->getProperty("step.size"));
......@@ -292,6 +300,10 @@ void ModelIO::finish_time_measurements(unsigned long &stop_at){
delete tm_slack;
delete tm_df;
delete tm_bcast_FBS;
delete tm_bcast_forward_sweep;
delete tm_bcast_backward_sweep;
}
......@@ -344,7 +356,10 @@ void ModelIO::log_results_for_tick() {
"," + std::to_string(tm_comp->get_duration() / 1000000.0) +
"," + std::to_string(tm_substation->get_duration() / 1000000.0) +
"," + std::to_string(tm_slack->get_duration() / 1000000.0) +
"," + std::to_string(tm_df->get_duration() / 1000000.0)
"," + std::to_string(tm_df->get_duration() / 1000000.0)+
"," + std::to_string(tm_bcast_FBS->get_duration() / 1000000.0)+
"," + std::to_string(tm_bcast_forward_sweep->get_duration() / 1000000.0)+
"," + std::to_string(tm_bcast_backward_sweep->get_duration() / 1000000.0)
);
......@@ -392,6 +407,11 @@ void ModelIO::log_results_for_tick() {
d_props.result.dbconn->addTimeMeasurement(tm_substation->get_time_measurement_type(), tm_substation->getId(), tm_substation->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_slack->get_time_measurement_type(), tm_slack->getId(), tm_slack->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_df->get_time_measurement_type(), tm_df->getId(), tm_df->get_duration(), tick);
// MPI broadcast time measurements
d_props.result.dbconn->addTimeMeasurement(tm_bcast_FBS->get_time_measurement_type(), tm_bcast_FBS->getId(), tm_bcast_FBS->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_bcast_forward_sweep->get_time_measurement_type(), tm_bcast_forward_sweep->getId(), tm_bcast_forward_sweep->get_duration(), tick);
d_props.result.dbconn->addTimeMeasurement(tm_bcast_backward_sweep->get_time_measurement_type(), tm_bcast_backward_sweep->getId(), tm_bcast_backward_sweep->get_duration(), tick);
}
catch (const DBException &ex){
......@@ -444,6 +464,10 @@ void ModelIO::reset_time_measurements() {
tm_slack->reset();
tm_df->reset();
tm_bcast_FBS->reset();
tm_bcast_forward_sweep->reset();
tm_bcast_backward_sweep->reset();
}
void ModelIO::set_result_file_header() {
......@@ -473,6 +497,9 @@ void ModelIO::set_result_file_header() {
"Substation behavior [s]," <<
"Slack behavior [s]," <<
"DF behavior [s]" <<
"MPI bcast FBS [s]" <<
"MPI bcast forward sweep [s]" <<
"MPI bcast backward sweep [s]" <<
std::endl;
......
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