From 964e1cc38d3766939bd9a1cb199d544abff485d0 Mon Sep 17 00:00:00 2001 From: Howard Pritchard Date: Mon, 13 Jan 2025 13:01:08 -0700 Subject: [PATCH] dpm: set default rankby order if not specified by caller The MPI standard defines a specific mappings of ranks in the MCW of a set of processes started by MPI_Comm_spawn_multiple to the supplied commands. See for example section 11.8.3 of the MPI 4.1 standard. Something changed between orte in OMPI 4.1.x and prtte in OMPI 5 and main that caused this to not be the default ordering of ranks to commands in the MPI_Comm_spawn_multiple. This resulted in the ompi-tests/ibm/dynamic/spawn_multiple to fail with wrong mapping of arguments to ranks. So, add a check in the ompi_dpm_spawn to set the PMIX_RANKBY attribute to "slot" if the app has not specified some other ranking option. Signed-off-by: Howard Pritchard --- ompi/dpm/dpm.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ompi/dpm/dpm.c b/ompi/dpm/dpm.c index 4b5dbf623e1..bd3e589a4d9 100644 --- a/ompi/dpm/dpm.c +++ b/ompi/dpm/dpm.c @@ -21,7 +21,7 @@ * and Technology (RIST). All rights reserved. * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved. * Copyright (c) 2021-2024 Nanook Consulting All rights reserved. - * Copyright (c) 2018-2022 Triad National Security, LLC. All rights + * Copyright (c) 2018-2025 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2022 IBM Corporation. All rights reserved. * Copyright (c) 2023 Jeffrey M. Squyres. All rights reserved. @@ -852,6 +852,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], #if PMIX_NUMERIC_VERSION >= 0x00040000 const char *checkkey; #endif + bool found_pmix_rankby_item = false; /* parse the info object */ /* check potentially for @@ -1358,6 +1359,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], /* check for 'rank_by' - job-level key */ ompi_info_get(array_of_info[i], "rank_by", &info_str, &flag); if ( flag ) { + found_pmix_rankby_item = true; rc = dpm_convert(&job_info, "rank_by", PMIX_RANKBY, info_str->string, NULL, false); OBJ_RELEASE(info_str); if (OMPI_SUCCESS != rc) { @@ -1369,6 +1371,7 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], } ompi_info_get(array_of_info[i], "PMIX_RANKBY", &info_str, &flag); if ( flag ) { + found_pmix_rankby_item = true; info = OBJ_NEW(opal_info_item_t); PMIX_INFO_LOAD(&info->info, PMIX_RANKBY, info_str->string, PMIX_STRING); opal_list_append(&job_info, &info->super); @@ -1378,13 +1381,13 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], checkkey = PMIx_Get_attribute_string("PMIX_RANKBY"); ompi_info_get(array_of_info[i], checkkey, &info_str, &flag); if ( flag ) { + found_pmix_rankby_item = true; info = OBJ_NEW(opal_info_item_t); PMIX_INFO_LOAD(&info->info, PMIX_RANKBY, info_str->string, PMIX_STRING); opal_list_append(&job_info, &info->super); OBJ_RELEASE(info_str); } #endif - /* check for 'bind_to' - job-level key */ ompi_info_get(array_of_info[i], "bind_to", &info_str, &flag); if ( flag ) { @@ -1541,6 +1544,18 @@ int ompi_dpm_spawn(int count, const char *array_of_commands[], #endif } + /* + * If the application has not specified otherwise, we want to get + * the behavior of MPI_Comm_spawn_multiple ranking as specified in the + * Process Creation and Management chapter of the MPI standard. + * See section 11.8.3 of the MPI 4.1 standard. + */ + if (false == found_pmix_rankby_item) { + info = OBJ_NEW(opal_info_item_t); + PMIX_INFO_LOAD(&info->info, PMIX_RANKBY, "slot", PMIX_STRING); + opal_list_append(&job_info, &info->super); + } + /* default value: If the user did not tell us where to look for the * executable, we assume the current working directory */