Commit c55b7d45 authored by Sonja Happ's avatar Sonja Happ

change time measurements for MPI bcast, remove loop breaks

parent 7e96b61d
...@@ -1599,7 +1599,11 @@ void Model::do_backward_sweep() { ...@@ -1599,7 +1599,11 @@ void Model::do_backward_sweep() {
IO->log_info("Skipping ..."); IO->log_info("Skipping ...");
} }
counter++;
//check if finished //check if finished
IO->stop_time_measurement(IO->tm_backward_sweep);
IO->start_time_measurement(IO->tm_bcast_backward_sweep);
if (context.contains(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank))) { if (context.contains(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank))) {
Agent *slack = context.getAgent(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank)); Agent *slack = context.getAgent(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank));
...@@ -1609,17 +1613,11 @@ void Model::do_backward_sweep() { ...@@ -1609,17 +1613,11 @@ void Model::do_backward_sweep() {
} }
} }
if(world_size > 1){ 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 //TODO use MPI_Ibcast instead
MPI_Bcast(&backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1], MPI_COMM_WORLD); 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)); IO->log_info("Backward sweep finished: " + std::to_string(backward_sweep_finished));
IO->stop_time_measurement(IO->tm_bcast_backward_sweep);
counter++;
IO->stop_time_measurement(IO->tm_backward_sweep);
//synchronize changes //synchronize changes
synchronize_el_connections(); synchronize_el_connections();
...@@ -1656,10 +1654,6 @@ void Model::do_forward_sweep() { ...@@ -1656,10 +1654,6 @@ void Model::do_forward_sweep() {
} else{ } else{
started_convergence_check = false; started_convergence_check = false;
} }
if (state[i-1] == DONE_NOTHING){
break; // stop iteration if one agent could not complete forward sweep because previous agents have not completed yet
}
} else { } else {
IO->log_info("Skipping AgentID " + std::to_string(agents_scheduling[i-1]->getId().id())); IO->log_info("Skipping AgentID " + std::to_string(agents_scheduling[i-1]->getId().id()));
} }
...@@ -1675,9 +1669,6 @@ void Model::do_forward_sweep() { ...@@ -1675,9 +1669,6 @@ void Model::do_forward_sweep() {
if(state[index] == DONE_CONVERGENCE_CHECK){ if(state[index] == DONE_CONVERGENCE_CHECK){
checked_convergence++; checked_convergence++;
} }
if (state[index] == DONE_NOTHING){
break; // stop iteration if one agent could to nothing because it is likely that the following agents cannot to anything either
}
} else { } else {
IO->log_info("Skipping AgentID " + std::to_string(i->getId().id())); IO->log_info("Skipping AgentID " + std::to_string(i->getId().id()));
} }
...@@ -1688,7 +1679,11 @@ void Model::do_forward_sweep() { ...@@ -1688,7 +1679,11 @@ void Model::do_forward_sweep() {
IO->log_info("Skipping ..."); IO->log_info("Skipping ...");
} }
//check if finished counter++;
//check if finished
IO->stop_time_measurement(IO->tm_forward_sweep);
IO->start_time_measurement(IO->tm_bcast_forward_sweep);
if(context.contains(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank))){ if(context.contains(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank))){
Agent * slack = context.getAgent(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank)); Agent * slack = context.getAgent(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank));
...@@ -1698,16 +1693,12 @@ void Model::do_forward_sweep() { ...@@ -1698,16 +1693,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 //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 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->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
// in forward sweep info about next and previous electrical nodes are required
// that is why both sets need to be updated here // that is why both sets need to be updated here
IO->stop_time_measurement(IO->tm_forward_sweep);
synchronize_el_connections(); synchronize_el_connections();
IO->start_time_measurement(IO->tm_forward_sweep); IO->start_time_measurement(IO->tm_forward_sweep);
......
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