Commit 6ce9e074 authored by Sonja Happ's avatar Sonja Happ

the data send via MPI is not used in the code anymore since it is meaningless...

the data send via MPI is not used in the code anymore since it is meaningless anyway, arrays are used for MPI statuses
parent 5a10fd72
......@@ -18,9 +18,10 @@ void Model::forward_backward_sweep() {
bool forward_backward_sweep_finished = false; // set to true if process has finished FBS algorithm,
MPI_Request convergence_req[world_size];
MPI_Status status;
MPI_Status status[world_size];
int flag = 0;
int FBS_COMPLETION_TAG = 123;
int value = 0; // send via MPI, its actual value is meaningless
bool contains_slack = context.contains(repast::AgentId(SLACK_ID,rank,TYPE_SLACK_INT, rank));
......@@ -29,7 +30,7 @@ void Model::forward_backward_sweep() {
// if this rank does not hold the slack
// it issues an asynchronous broadcast
IO->start_time_measurement(IO->tm_bcast_FBS);
MPI_Irecv(&forward_backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1],
MPI_Irecv(&value, 1, MPI_INT, agent_rank_relation[SLACK_ID-1],
FBS_COMPLETION_TAG, filled_ranks, &convergence_req[rank]);
IO->stop_time_measurement(IO->tm_bcast_FBS);
}
......@@ -69,7 +70,8 @@ void Model::forward_backward_sweep() {
// inform all other processes about convergence
for (int i = 0; i <world_size; i++) {
if (i != rank) {
MPI_Isend(&forward_backward_sweep_finished, 1, MPI_C_BOOL, i,
value = 1;
MPI_Isend(&value, 1, MPI_INT, i,
FBS_COMPLETION_TAG, filled_ranks, &convergence_req[i]);
}
}
......@@ -77,7 +79,7 @@ void Model::forward_backward_sweep() {
for (int i = 0; i <world_size; i++) {
if (i != rank) {
IO->log_info("main: wait for irecv of rank " + std::to_string(i));
MPI_Wait(&convergence_req[i], &status);
MPI_Wait(&convergence_req[i], &status[i]);
}
}
......@@ -99,7 +101,7 @@ void Model::forward_backward_sweep() {
if (!contains_slack && world_size > 1) {
// check status of asynchronous MPI Broadcast operation as stop criterion of while loop
IO->start_time_measurement(IO->tm_bcast_FBS);
MPI_Test(&convergence_req[rank], &flag, &status);
MPI_Test(&convergence_req[rank], &flag, &status[rank]);
IO->log_info("MPI-Test has returned: " + std::to_string(flag));
if (flag) {
forward_backward_sweep_finished = true;
......@@ -133,9 +135,10 @@ void Model::do_backward_sweep() {
bool backward_sweep_finished = false; //set to true if process has finished a backward sweep
MPI_Request backward_req[world_size];
MPI_Status status;
MPI_Status status[world_size];
int flag = 0;
int BACKWARD_COMPLETION_TAG = 124;
int value = 0; // send via MPI, its actual value is meaningless
bool contains_slack = context.contains(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank));
......@@ -143,7 +146,7 @@ void Model::do_backward_sweep() {
// if rank does not contain slack it starts an async. broadcast here
IO->start_time_measurement(IO->tm_bcast_backward_sweep);
IO->log_info("Backward sweep: issuing Irecv");
MPI_Irecv(&backward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1],
MPI_Irecv(&value, 1, MPI_INT, agent_rank_relation[SLACK_ID-1],
BACKWARD_COMPLETION_TAG, filled_ranks, &backward_req[rank]);
IO->stop_time_measurement(IO->tm_bcast_backward_sweep);
}
......@@ -182,13 +185,14 @@ void Model::do_backward_sweep() {
// inform all other processes about convergence
for(int i=0; i<=highest_filled_rank; i++){
if (i != rank) {
MPI_Isend(&backward_sweep_finished, 1, MPI_C_BOOL, i,
value = 1;
MPI_Isend(&value, 1, MPI_INT, i,
BACKWARD_COMPLETION_TAG, filled_ranks, &backward_req[i]);
}
}
for(int i=0; i<=highest_filled_rank; i++){
if (i != rank) {
MPI_Wait(&backward_req[i], &status);
MPI_Wait(&backward_req[i], &status[i]);
}
}
}
......@@ -197,7 +201,6 @@ void Model::do_backward_sweep() {
// this barrier is required to make all processes know the
// result of the finished check before entering a new loop iteration
MPI_Barrier(filled_ranks);
IO->log_info("Backward sweep finished: " + std::to_string(backward_sweep_finished));
IO->stop_time_measurement(IO->tm_bcast_backward_sweep);
//synchronize changes
......@@ -210,7 +213,7 @@ void Model::do_backward_sweep() {
// check status of asynchronous MPI Broadcast operation as stop criterion of while loop
IO->stop_time_measurement(IO->tm_backward_sweep);
IO->start_time_measurement(IO->tm_bcast_backward_sweep);
MPI_Test(&backward_req[rank], &flag, &status);
MPI_Test(&backward_req[rank], &flag, &status[rank]);
IO->log_info("BW MPI-Test has returned: " + std::to_string(flag));
if (flag){
backward_sweep_finished = true;
......@@ -237,16 +240,17 @@ void Model::do_forward_sweep() {
bool forward_sweep_finished = false; // set to true if process has finished a forward sweep
MPI_Request forward_req[world_size];
MPI_Status status;
MPI_Status status[world_size];
int flag = 0;
int FORWARD_COMPLETION_TAG = 125;
int value = 0; // send via MPI, its actual value is meaningless
bool contains_slack = context.contains(repast::AgentId(SLACK_ID, rank, TYPE_SLACK_INT, rank));
if (!contains_slack && world_size > 1) {
IO->start_time_measurement(IO->tm_bcast_forward_sweep);
// if rank does not contain slack it starts an async. broadcast here
MPI_Irecv(&forward_sweep_finished, 1, MPI_C_BOOL, agent_rank_relation[SLACK_ID-1],
MPI_Irecv(&value, 1, MPI_INT, agent_rank_relation[SLACK_ID-1],
FORWARD_COMPLETION_TAG, filled_ranks, &forward_req[rank]);
IO->stop_time_measurement(IO->tm_bcast_forward_sweep);
}
......@@ -300,7 +304,8 @@ void Model::do_forward_sweep() {
// inform all other processes about convergence
for(int i=0; i<=highest_filled_rank; i++){
if (i != rank) {
MPI_Isend(&forward_sweep_finished, 1, MPI_C_BOOL, i,
value = 1;
MPI_Isend(&value, 1, MPI_INT, i,
FORWARD_COMPLETION_TAG, filled_ranks, &forward_req[i]);
}
}
......@@ -308,7 +313,7 @@ void Model::do_forward_sweep() {
for(int i=0; i<=highest_filled_rank; i++){
if (i != rank) {
IO->log_info("Waiting for Irecv of rank " + std::to_string(i));
MPI_Wait(&forward_req[i], &status);
MPI_Wait(&forward_req[i], &status[i]);
}
}
}
......@@ -331,7 +336,7 @@ void Model::do_forward_sweep() {
// check status of asynchronous MPI Broadcast operation as stop criterion of while loop
IO->stop_time_measurement(IO->tm_forward_sweep);
IO->start_time_measurement(IO->tm_bcast_forward_sweep);
MPI_Test(&forward_req[rank], &flag, &status);
MPI_Test(&forward_req[rank], &flag, &status[rank]);
IO->log_info("FW MPI-Test has returned: " + std::to_string(flag));
if(flag){
forward_sweep_finished = true;
......
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