From 8bb77292499a3718c257d960cb393af725266f6d Mon Sep 17 00:00:00 2001 From: jayeshkrishna Date: Fri, 15 May 2026 12:26:09 -0500 Subject: [PATCH 1/3] Skip MPI_Comm_split_type() for mpi serial Since MPI_Comm_split_type() is not supported by the MPI serial library switch to MPI_Comm_dup() when using the MPI serial library --- src/clib/core/pioc.cpp | 15 +++++++++++++++ src/clib/core/util/spio_decomp_logger.hpp | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/clib/core/pioc.cpp b/src/clib/core/pioc.cpp index 195567931a..5213b12644 100644 --- a/src/clib/core/pioc.cpp +++ b/src/clib/core/pioc.cpp @@ -1547,8 +1547,13 @@ int PIOc_Init_Intracomm_impl(MPI_Comm comp_comm, int num_iotasks, int stride, in /* Create the node local comm - all procs in comp_comm that are local to * this compute node (share memory) */ +#ifndef MPI_SERIAL mpierr = MPI_Comm_split_type(ios->comp_comm, MPI_COMM_TYPE_SHARED, 0, ios->info, &(ios->node_comm)); +#else + /* MPI serial library does not support MPI_Comm_split_type() */ + mpierr = MPI_Comm_dup(ios->comp_comm, &(ios->node_comm)); +#endif if(mpierr != MPI_SUCCESS){ return check_mpi(ios, NULL, mpierr, __FILE__, __LINE__); } @@ -2472,8 +2477,13 @@ int PIOc_init_async_impl(MPI_Comm world, int num_io_procs, const int *io_proc_li /* Create the node local comm - all procs in comp_comm that are local to * this compute node (share memory) */ +#ifndef MPI_SERIAL mpierr = MPI_Comm_split_type(my_iosys->comp_comm, MPI_COMM_TYPE_SHARED, 0, my_iosys->info, &(my_iosys->node_comm)); +#else + /* MPI serial lib does not support MPI_Comm_split_type() */ + mpierr = MPI_Comm_dup(my_iosys->comp_comm, &(my_iosys->node_comm)); +#endif if(mpierr != MPI_SUCCESS){ return check_mpi(NULL, NULL, mpierr, __FILE__, __LINE__); } @@ -3072,8 +3082,13 @@ int PIOc_init_intercomm_impl(int component_count, const MPI_Comm peer_comm, /* Create the node local comm - all procs in comp_comm that are local to * this compute node (share memory) */ +#ifndef MPI_SERIAL ret = MPI_Comm_split_type(iosys[i]->comp_comm, MPI_COMM_TYPE_SHARED, 0, iosys[i]->info, &(iosys[i]->node_comm)); +#else + /* MPI Serial lib does not support MPI_Comm_split_type() */ + ret = MPI_Comm_dup(iosys[i]->comp_comm, &(iosys[i]->node_comm)); +#endif if(ret != MPI_SUCCESS){ return check_mpi(NULL, NULL, ret, __FILE__, __LINE__); } diff --git a/src/clib/core/util/spio_decomp_logger.hpp b/src/clib/core/util/spio_decomp_logger.hpp index ffb0198e92..23662998bd 100644 --- a/src/clib/core/util/spio_decomp_logger.hpp +++ b/src/clib/core/util/spio_decomp_logger.hpp @@ -190,7 +190,12 @@ namespace SPIO_Util{ int ret = MPI_SUCCESS; ret = MPI_Comm_dup(ucomm, &comm); assert(ret == MPI_SUCCESS); +#ifndef MPI_SERIAL ret = MPI_Comm_split_type(comm, MPI_COMM_TYPE_SHARED, 0, MPI_INFO_NULL, &agg_comm); assert(ret == MPI_SUCCESS); +#else + /* MPI serial library does not have support for MPI_Comm_split_type() */ + ret = MPI_Comm_dup(comm, &agg_comm); assert(ret == MPI_SUCCESS); +#endif ret = MPI_Comm_rank(agg_comm, &agg_comm_rank); assert(ret == MPI_SUCCESS); int color = (agg_comm_rank == 0) ? 0 : MPI_UNDEFINED; From ca95501a50361d192ab9404bdae0afe83942c0bb Mon Sep 17 00:00:00 2001 From: jayeshkrishna Date: Fri, 15 May 2026 13:09:59 -0500 Subject: [PATCH 2/3] Avoid MPI_Type_dup() for mpi serial Since MPI serial lib does not support MPI_Type_dup() avoid duping the type in test --- tests/cunit/test_spio_rearr_utils_gather.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/cunit/test_spio_rearr_utils_gather.cpp b/tests/cunit/test_spio_rearr_utils_gather.cpp index 13e5d20403..0f1c0b8aea 100644 --- a/tests/cunit/test_spio_rearr_utils_gather.cpp +++ b/tests/cunit/test_spio_rearr_utils_gather.cpp @@ -221,12 +221,17 @@ int test_gatherw_contig_block_decomp(MPI_Comm comm, int wrank, int wsz) recvcounts[i] = 1; rdispls[i] = i * LOCAL_SZ * sizeof(double); +#ifndef MPI_SERIAL ret = MPI_Type_dup(sendtype, &(recvtypes[i])); +#else + /* MPI serial does not support MPI_Type_dup() */ + ret = MPI_Type_contiguous(LOCAL_SZ, MPI_DOUBLE, &(recvtypes[i])); +#endif if(ret == MPI_SUCCESS){ ret = MPI_Type_commit(&(recvtypes[i])); } if(ret != MPI_SUCCESS){ - LOG_RANK0(wrank, "ERROR: Unable to create MPI dup of send type to recv doubles\n"); + LOG_RANK0(wrank, "ERROR: Unable to create recv type (same as send type) to recv doubles\n"); return PIO_EINTERNAL; } } From 6edbb07fcad7369cbfa1921f3215fbd21e820dab Mon Sep 17 00:00:00 2001 From: jayeshkrishna Date: Fri, 15 May 2026 13:11:26 -0500 Subject: [PATCH 3/3] Include MPI header compatible with MPI serial lib Including MPI header from the MPI serial library from a C++ source requires decorating the include with "extern C" blocks. So either add these decorations explicitly or use the includes in pio.h/argparser.h --- src/clib/core/progress_engine/spio_async_tcomm.hpp | 11 ++++++++++- tests/cunit/test_req_block_wait.cpp | 1 - util/argparser.cxx | 1 - 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/clib/core/progress_engine/spio_async_tcomm.hpp b/src/clib/core/progress_engine/spio_async_tcomm.hpp index 36dd8711d4..d3b26943c4 100644 --- a/src/clib/core/progress_engine/spio_async_tcomm.hpp +++ b/src/clib/core/progress_engine/spio_async_tcomm.hpp @@ -5,8 +5,17 @@ #include #include #include -#include "mpi.h" +#include #include "pio_config.h" +#ifdef MPI_SERIAL +extern "C" { +#endif + +#include "mpi.h" + +#ifdef MPI_SERIAL +} +#endif #include "spio_async_tpool.hpp" namespace SPIO_Util{ diff --git a/tests/cunit/test_req_block_wait.cpp b/tests/cunit/test_req_block_wait.cpp index c68e7592c4..9b53b5a758 100644 --- a/tests/cunit/test_req_block_wait.cpp +++ b/tests/cunit/test_req_block_wait.cpp @@ -1,4 +1,3 @@ -#include "mpi.h" #include "pio.h" #include "pio_internal.h" #include "pio_minmax.h" diff --git a/util/argparser.cxx b/util/argparser.cxx index 06a947dcc9..37e859aad5 100644 --- a/util/argparser.cxx +++ b/util/argparser.cxx @@ -1,4 +1,3 @@ -#include "mpi.h" #include #include #include