From f9e414d2560beb5e7fa7b696813f7880b41e502a Mon Sep 17 00:00:00 2001 From: Jacob Moore Date: Mon, 27 Apr 2026 09:43:39 -0500 Subject: [PATCH 1/2] ENH: Adding capability to handle 1 rank, or calls without MPI to communicate function --- src/include/mpi_types.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/include/mpi_types.h b/src/include/mpi_types.h index 5f83265b..bc00d852 100644 --- a/src/include/mpi_types.h +++ b/src/include/mpi_types.h @@ -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(); From 21b6383438a912c4de4c6ae36422a60e39229234 Mon Sep 17 00:00:00 2001 From: Jacob Moore Date: Mon, 27 Apr 2026 09:56:05 -0500 Subject: [PATCH 2/2] ENH: Update comm plan to handle the case when called without MPI --- src/include/communication_plan.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/include/communication_plan.h b/src/include/communication_plan.h index f6613c10..0f642b2e 100644 --- a/src/include/communication_plan.h +++ b/src/include/communication_plan.h @@ -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);