From c9c93417015db12762f66131d413b982c0a59d8a Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Wed, 10 Sep 2025 16:44:58 -0600 Subject: [PATCH] TYPE_RESOURCE_GUIDED: add minimal support Add minimal support for MPI_COMM_TYPE_RESOURCE_GUIDED. It can support all of the mpi_hw_resource_type values supported by MPI_COMM_TYPE_HW_GUIDED. No support is provided in this PR for mpi_pset_name info key. Related to #12077 Signed-off-by: Howard Pritchard --- .../man3/MPI_Comm_split_type.3.rst | 10 ++++++++ ompi/communicator/comm.c | 13 ++++++---- ompi/include/mpi.h.in | 3 ++- ompi/include/mpif-values.py | 1 + ompi/mpi/bindings/ompi_bindings/consts.py | 3 ++- ompi/mpi/c/comm_split_type.c.in | 24 ++++++++++++++----- 6 files changed, 42 insertions(+), 12 deletions(-) diff --git a/docs/man-openmpi/man3/MPI_Comm_split_type.3.rst b/docs/man-openmpi/man3/MPI_Comm_split_type.3.rst index bf0e97a452e..74651ea0b47 100644 --- a/docs/man-openmpi/man3/MPI_Comm_split_type.3.rst +++ b/docs/man-openmpi/man3/MPI_Comm_split_type.3.rst @@ -46,6 +46,16 @@ MPI_COMM_TYPE_SHARED This type splits the communicator into subcommunicators, each of which can create a shared memory region. +MPI_COMM_TYPE_HW_GUIDED + This type splits the communicator into subcommunicators according + to the resource type specified by the ``mpi_hw_resource_type`` + info key. + +MPI_COMM_TYPE_RESOURCE_GUIDED + This type splits the communicator into subcommunicators according + to the resource type specified by the ``mpi_hw_resource_type`` + or ``mpi_pset_name`` info key. + OMPI_COMM_TYPE_NODE Synonym for MPI_COMM_TYPE_SHARED. diff --git a/ompi/communicator/comm.c b/ompi/communicator/comm.c index af82a3e9d8c..ffa990854f2 100644 --- a/ompi/communicator/comm.c +++ b/ompi/communicator/comm.c @@ -24,7 +24,7 @@ * Copyright (c) 2015 Mellanox Technologies. All rights reserved. * Copyright (c) 2017-2022 IBM Corporation. All rights reserved. * Copyright (c) 2021 Nanook Consulting. All rights reserved. - * Copyright (c) 2018-2024 Triad National Security, LLC. All rights + * Copyright (c) 2018-2025 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved. * $COPYRIGHT$ @@ -99,6 +99,9 @@ static const char * ompi_comm_split_type_to_str(int split_type) { else if (MPI_COMM_TYPE_HW_UNGUIDED == split_type) { return "MPI_COMM_TYPE_HW_UNGUIDED"; } + else if (MPI_COMM_TYPE_RESOURCE_GUIDED == split_type) { + return "MPI_COMM_TYPE_RESOURCE_GUIDED"; + } return "Unknown"; } @@ -830,9 +833,10 @@ static int ompi_comm_split_type_get_part (ompi_group_t *group, const int split_t break; case MPI_COMM_TYPE_HW_GUIDED: case MPI_COMM_TYPE_HW_UNGUIDED: + case MPI_COMM_TYPE_RESOURCE_GUIDED: /* - * MPI_COMM_TYPE_HW_(UN)GUIDED handled in calling function. - * We should not get here as the split type will be changed + * MPI_COMM_TYPE_HW_(UN)GUIDED and MPI_COMM_TYPE_RESOURCE_GUIDED handled + * in calling function. We should not get here as the split type will be changed * at a higher level. */ opal_show_help("help-comm.txt", @@ -1186,7 +1190,8 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key, inter = OMPI_COMM_IS_INTER(comm); /* Step 0: Convert MPI_COMM_TYPE_HW_GUIDED to the internal type */ - if (MPI_COMM_TYPE_HW_GUIDED == split_type) { + if ((MPI_COMM_TYPE_HW_GUIDED == split_type) || + (MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) { opal_info_get(info, "mpi_hw_resource_type", &value, &flag); /* If key is not in the 'info', then return MPI_COMM_NULL. * This is caught at the MPI interface level, but it doesn't hurt to diff --git a/ompi/include/mpi.h.in b/ompi/include/mpi.h.in index ea05aba0eff..358d7782cf0 100644 --- a/ompi/include/mpi.h.in +++ b/ompi/include/mpi.h.in @@ -862,7 +862,8 @@ enum { OMPI_COMM_TYPE_CU, OMPI_COMM_TYPE_CLUSTER, MPI_COMM_TYPE_HW_UNGUIDED, - MPI_COMM_TYPE_HW_GUIDED + MPI_COMM_TYPE_HW_GUIDED, + MPI_COMM_TYPE_RESOURCE_GUIDED }; #define OMPI_COMM_TYPE_NODE MPI_COMM_TYPE_SHARED diff --git a/ompi/include/mpif-values.py b/ompi/include/mpif-values.py index 6045fbf5a1c..61affac1046 100755 --- a/ompi/include/mpif-values.py +++ b/ompi/include/mpif-values.py @@ -338,6 +338,7 @@ 'OMPI_COMM_TYPE_CLUSTER': 11, 'MPI_COMM_TYPE_HW_UNGUIDED': 12, 'MPI_COMM_TYPE_HW_GUIDED': 13, + 'MPI_COMM_TYPE_RESOURCE_GUIDED': 14, } # IO Constants diff --git a/ompi/mpi/bindings/ompi_bindings/consts.py b/ompi/mpi/bindings/ompi_bindings/consts.py index 48ef249223f..43bca486b57 100644 --- a/ompi/mpi/bindings/ompi_bindings/consts.py +++ b/ompi/mpi/bindings/ompi_bindings/consts.py @@ -1,4 +1,4 @@ -# Copyright (c) 2024 Triad National Security, LLC. All rights +# Copyright (c) 2024-2025 Triad National Security, LLC. All rights # reserved. # # $COPYRIGHT$ @@ -157,6 +157,7 @@ 'MPI_COMM_TYPE_SHARED', 'MPI_COMM_TYPE_HW_UNGUIDED', 'MPI_COMM_TYPE_HW_GUIDED', + 'MPI_COMM_TYPE_RESOURCE_GUIDED', ] RESERVED_WINDOWS = [ diff --git a/ompi/mpi/c/comm_split_type.c.in b/ompi/mpi/c/comm_split_type.c.in index 26f2b39cea9..0bac2380019 100644 --- a/ompi/mpi/c/comm_split_type.c.in +++ b/ompi/mpi/c/comm_split_type.c.in @@ -15,7 +15,7 @@ * Copyright (c) 2015 Research Organization for Information Science * and Technology (RIST). All rights reserved. * Copyright (c) 2017-2022 IBM Corporation. All rights reserved. - * Copyright (c) 2024 Triad National Security, LLC. All rights + * Copyright (c) 2024-2025 Triad National Security, LLC. All rights * reserved. * $COPYRIGHT$ * @@ -59,6 +59,7 @@ PROTOTYPE ERROR_CLASS comm_split_type(COMM comm, INT split_type, INT key, if ( MPI_COMM_TYPE_SHARED != split_type && // Same as OMPI_COMM_TYPE_NODE MPI_COMM_TYPE_HW_UNGUIDED != split_type && MPI_COMM_TYPE_HW_GUIDED != split_type && + MPI_COMM_TYPE_RESOURCE_GUIDED != split_type && OMPI_COMM_TYPE_CLUSTER != split_type && OMPI_COMM_TYPE_CU != split_type && OMPI_COMM_TYPE_HOST != split_type && @@ -93,8 +94,9 @@ PROTOTYPE ERROR_CLASS comm_split_type(COMM comm, INT split_type, INT key, } #endif - if ( MPI_COMM_TYPE_HW_GUIDED == split_type ) { - int flag; + if (( MPI_COMM_TYPE_HW_GUIDED == split_type ) || + ( MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) { + int flag_hw, flag_res; opal_cstring_t *value = NULL; /* MPI_Info is required for this split_type. @@ -106,15 +108,25 @@ PROTOTYPE ERROR_CLASS comm_split_type(COMM comm, INT split_type, INT key, OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME); } - /* MPI_Info with key "mpi_hw_resource_type" is required for this split_type. + /* MPI_Info with key "mpi_hw_resource_type" or "mpi_pset_name", + * in the case of MPI_COMM_TYPE_RESOURCED_GUIDED, is required for + * these split_types. * Not an error condition, per MPI 4.0. */ - ompi_info_get(info, "mpi_hw_resource_type", &value, &flag); - if ( !flag ) { + ompi_info_get(info, "mpi_hw_resource_type", &value, &flag_hw); + if ( !flag_hw && (MPI_COMM_TYPE_HW_GUIDED == split_type)) { *newcomm = MPI_COMM_NULL; rc = MPI_SUCCESS; OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME); } + if( !flag_hw && (MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) { + ompi_info_get(info, "mpi_pset_name", &value, &flag_res); + if ( !flag_res ) { + *newcomm = MPI_COMM_NULL; + rc = MPI_SUCCESS; + OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME); + } + } } if( (MPI_COMM_SELF == comm) && (MPI_UNDEFINED == split_type) ) {