Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/include/communication_plan.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,22 @@ struct CommunicationPlan {

// Destructor to free MPI resources
~CommunicationPlan() {
// Free graph communicator
if (has_comm_graph && mpi_comm_graph != MPI_COMM_NULL) {
int mpi_init = 0;
int mpi_finalized = 0;
MPI_Initialized(&mpi_init);
MPI_Finalized(&mpi_finalized);
if (mpi_init && !mpi_finalized && has_comm_graph && mpi_comm_graph != MPI_COMM_NULL) {
MPI_Comm_free(&mpi_comm_graph);
}
}


void initialize(MPI_Comm comm_world){
int mpi_init = 0;
MPI_Initialized(&mpi_init);
if (!mpi_init) {
return;
}
this->mpi_comm_world = comm_world;
has_comm_world = true;
MPI_Comm_size(comm_world, &world_size);
Expand Down
20 changes: 20 additions & 0 deletions src/include/mpi_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,26 @@ class MPICArrayKokkos {
// MPI_Wait(&req);

void communicate(){
if (!comm_plan_) {
return;
}
if (comm_plan_->comm_type == communication_plan_type::no_communication) {
return;
}

int mpi_initialized = 0;
MPI_Initialized(&mpi_initialized);
if (!mpi_initialized) {
return;
}

if (!comm_plan_->has_comm_world || comm_plan_->world_size <= 1) {
return;
}

if (!comm_plan_->has_comm_graph || comm_plan_->mpi_comm_graph == MPI_COMM_NULL) {
return;
}

fill_send_buffer();

Expand Down
Loading