Skip to content

Commit c9c9341

Browse files
committed
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 open-mpi#12077 Signed-off-by: Howard Pritchard <[email protected]>
1 parent e2a2583 commit c9c9341

File tree

6 files changed

+42
-12
lines changed

6 files changed

+42
-12
lines changed

docs/man-openmpi/man3/MPI_Comm_split_type.3.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ MPI_COMM_TYPE_SHARED
4646
This type splits the communicator into subcommunicators, each of
4747
which can create a shared memory region.
4848

49+
MPI_COMM_TYPE_HW_GUIDED
50+
This type splits the communicator into subcommunicators according
51+
to the resource type specified by the ``mpi_hw_resource_type``
52+
info key.
53+
54+
MPI_COMM_TYPE_RESOURCE_GUIDED
55+
This type splits the communicator into subcommunicators according
56+
to the resource type specified by the ``mpi_hw_resource_type``
57+
or ``mpi_pset_name`` info key.
58+
4959
OMPI_COMM_TYPE_NODE
5060
Synonym for MPI_COMM_TYPE_SHARED.
5161

ompi/communicator/comm.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
2525
* Copyright (c) 2017-2022 IBM Corporation. All rights reserved.
2626
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
27-
* Copyright (c) 2018-2024 Triad National Security, LLC. All rights
27+
* Copyright (c) 2018-2025 Triad National Security, LLC. All rights
2828
* reserved.
2929
* Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All rights reserved.
3030
* $COPYRIGHT$
@@ -99,6 +99,9 @@ static const char * ompi_comm_split_type_to_str(int split_type) {
9999
else if (MPI_COMM_TYPE_HW_UNGUIDED == split_type) {
100100
return "MPI_COMM_TYPE_HW_UNGUIDED";
101101
}
102+
else if (MPI_COMM_TYPE_RESOURCE_GUIDED == split_type) {
103+
return "MPI_COMM_TYPE_RESOURCE_GUIDED";
104+
}
102105
return "Unknown";
103106
}
104107

@@ -830,9 +833,10 @@ static int ompi_comm_split_type_get_part (ompi_group_t *group, const int split_t
830833
break;
831834
case MPI_COMM_TYPE_HW_GUIDED:
832835
case MPI_COMM_TYPE_HW_UNGUIDED:
836+
case MPI_COMM_TYPE_RESOURCE_GUIDED:
833837
/*
834-
* MPI_COMM_TYPE_HW_(UN)GUIDED handled in calling function.
835-
* We should not get here as the split type will be changed
838+
* MPI_COMM_TYPE_HW_(UN)GUIDED and MPI_COMM_TYPE_RESOURCE_GUIDED handled
839+
* in calling function. We should not get here as the split type will be changed
836840
* at a higher level.
837841
*/
838842
opal_show_help("help-comm.txt",
@@ -1186,7 +1190,8 @@ int ompi_comm_split_type (ompi_communicator_t *comm, int split_type, int key,
11861190
inter = OMPI_COMM_IS_INTER(comm);
11871191

11881192
/* Step 0: Convert MPI_COMM_TYPE_HW_GUIDED to the internal type */
1189-
if (MPI_COMM_TYPE_HW_GUIDED == split_type) {
1193+
if ((MPI_COMM_TYPE_HW_GUIDED == split_type) ||
1194+
(MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) {
11901195
opal_info_get(info, "mpi_hw_resource_type", &value, &flag);
11911196
/* If key is not in the 'info', then return MPI_COMM_NULL.
11921197
* This is caught at the MPI interface level, but it doesn't hurt to

ompi/include/mpi.h.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ enum {
862862
OMPI_COMM_TYPE_CU,
863863
OMPI_COMM_TYPE_CLUSTER,
864864
MPI_COMM_TYPE_HW_UNGUIDED,
865-
MPI_COMM_TYPE_HW_GUIDED
865+
MPI_COMM_TYPE_HW_GUIDED,
866+
MPI_COMM_TYPE_RESOURCE_GUIDED
866867
};
867868
#define OMPI_COMM_TYPE_NODE MPI_COMM_TYPE_SHARED
868869

ompi/include/mpif-values.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@
338338
'OMPI_COMM_TYPE_CLUSTER': 11,
339339
'MPI_COMM_TYPE_HW_UNGUIDED': 12,
340340
'MPI_COMM_TYPE_HW_GUIDED': 13,
341+
'MPI_COMM_TYPE_RESOURCE_GUIDED': 14,
341342
}
342343

343344
# IO Constants

ompi/mpi/bindings/ompi_bindings/consts.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2024 Triad National Security, LLC. All rights
1+
# Copyright (c) 2024-2025 Triad National Security, LLC. All rights
22
# reserved.
33
#
44
# $COPYRIGHT$
@@ -157,6 +157,7 @@
157157
'MPI_COMM_TYPE_SHARED',
158158
'MPI_COMM_TYPE_HW_UNGUIDED',
159159
'MPI_COMM_TYPE_HW_GUIDED',
160+
'MPI_COMM_TYPE_RESOURCE_GUIDED',
160161
]
161162

162163
RESERVED_WINDOWS = [

ompi/mpi/c/comm_split_type.c.in

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
1717
* Copyright (c) 2017-2022 IBM Corporation. All rights reserved.
18-
* Copyright (c) 2024 Triad National Security, LLC. All rights
18+
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
1919
* reserved.
2020
* $COPYRIGHT$
2121
*
@@ -59,6 +59,7 @@ PROTOTYPE ERROR_CLASS comm_split_type(COMM comm, INT split_type, INT key,
5959
if ( MPI_COMM_TYPE_SHARED != split_type && // Same as OMPI_COMM_TYPE_NODE
6060
MPI_COMM_TYPE_HW_UNGUIDED != split_type &&
6161
MPI_COMM_TYPE_HW_GUIDED != split_type &&
62+
MPI_COMM_TYPE_RESOURCE_GUIDED != split_type &&
6263
OMPI_COMM_TYPE_CLUSTER != split_type &&
6364
OMPI_COMM_TYPE_CU != split_type &&
6465
OMPI_COMM_TYPE_HOST != split_type &&
@@ -93,8 +94,9 @@ PROTOTYPE ERROR_CLASS comm_split_type(COMM comm, INT split_type, INT key,
9394
}
9495
#endif
9596

96-
if ( MPI_COMM_TYPE_HW_GUIDED == split_type ) {
97-
int flag;
97+
if (( MPI_COMM_TYPE_HW_GUIDED == split_type ) ||
98+
( MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) {
99+
int flag_hw, flag_res;
98100
opal_cstring_t *value = NULL;
99101

100102
/* 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,
106108
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
107109
}
108110

109-
/* MPI_Info with key "mpi_hw_resource_type" is required for this split_type.
111+
/* MPI_Info with key "mpi_hw_resource_type" or "mpi_pset_name",
112+
* in the case of MPI_COMM_TYPE_RESOURCED_GUIDED, is required for
113+
* these split_types.
110114
* Not an error condition, per MPI 4.0.
111115
*/
112-
ompi_info_get(info, "mpi_hw_resource_type", &value, &flag);
113-
if ( !flag ) {
116+
ompi_info_get(info, "mpi_hw_resource_type", &value, &flag_hw);
117+
if ( !flag_hw && (MPI_COMM_TYPE_HW_GUIDED == split_type)) {
114118
*newcomm = MPI_COMM_NULL;
115119
rc = MPI_SUCCESS;
116120
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
117121
}
122+
if( !flag_hw && (MPI_COMM_TYPE_RESOURCE_GUIDED == split_type)) {
123+
ompi_info_get(info, "mpi_pset_name", &value, &flag_res);
124+
if ( !flag_res ) {
125+
*newcomm = MPI_COMM_NULL;
126+
rc = MPI_SUCCESS;
127+
OMPI_ERRHANDLER_RETURN ( rc, comm, rc, FUNC_NAME);
128+
}
129+
}
118130
}
119131

120132
if( (MPI_COMM_SELF == comm) && (MPI_UNDEFINED == split_type) ) {

0 commit comments

Comments
 (0)