Skip to content

Commit 771fed4

Browse files
committed
mpirun: add cli option to turn off gpu support
idea is that maybe one might want to build open mpi with gpu support, but there may be performance benefit of disabling all gpu related paths when using this library on systems without accelerators. Signed-off-by: Howard Pritchard <[email protected]>
1 parent 30cadc6 commit 771fed4

File tree

6 files changed

+48
-3
lines changed

6 files changed

+48
-3
lines changed

src/mca/schizo/ompi/schizo-ompi-cli.rstxt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ MPI Options
163163
attached to predefined communicators during the first MPI call.
164164
* ``--memory-alloc-kinds``: Value is a comma separated list of
165165
memory allocation kinds.
166+
* ``--disable-gpu-support``: Specify to disable any accelerator support
167+
built in to the Open MPI installation at run time.
166168
* ``--display-comm``: Display table of communication methods between
167169
MPI_COMM_WORLD ranks during MPI_Init
168170
* ``--display-comm-finalize``: Display table of communication methods

src/mca/schizo/ompi/schizo_ompi.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
* and Technology (RIST). All rights reserved.
2020
* Copyright (c) 2018-2022 IBM Corporation. All rights reserved.
2121
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
22-
* Copyright (c) 2022-2024 Triad National Security, LLC. All rights
22+
* Copyright (c) 2022-2025 Triad National Security, LLC. All rights
2323
* reserved.
2424
* $COPYRIGHT$
2525
*
@@ -194,6 +194,7 @@ static struct option ompioptions[] = {
194194
PMIX_OPTION_DEFINE(PRTE_CLI_DISABLE_RECOVERY, PMIX_ARG_NONE),
195195
PMIX_OPTION_DEFINE(PRTE_CLI_CONTINUOUS, PMIX_ARG_NONE),
196196
PMIX_OPTION_DEFINE("with-ft", PMIX_ARG_REQD),
197+
PMIX_OPTION_DEFINE(PRTE_CLI_DISABLE_GPU_SUPPORT, PMIX_ARG_NONE),
197198

198199
/* mpiexec mandated form launch key parameters - MPI 4.0 */
199200
PMIX_OPTION_DEFINE("initial-errhandler", PMIX_ARG_REQD),
@@ -1612,6 +1613,15 @@ static int parse_env(char **srcenv, char ***dstenv,
16121613
}
16131614
}
16141615

1616+
if (NULL != (opt = pmix_cmd_line_get_param(results, "disable-gpu-support"))) {
1617+
rc = check_cache(&cache, &cachevals, "disable_gpu_support", "true");
1618+
if (PRTE_SUCCESS != rc) {
1619+
PMIX_ARGV_FREE_COMPAT(cache);
1620+
PMIX_ARGV_FREE_COMPAT(cachevals);
1621+
return rc;
1622+
}
1623+
}
1624+
16151625
if (pmix_cmd_line_is_taken(results, "display-comm") &&
16161626
pmix_cmd_line_is_taken(results, "display-comm-finalize")) {
16171627
PMIX_SETENV_COMPAT("OMPI_MCA_ompi_display_comm", "mpi_init,mpi_finalize", true, dstenv);

src/mca/schizo/prte/schizo_prte.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* and Technology (RIST). All rights reserved.
2020
* Copyright (c) 2018-2022 IBM Corporation. All rights reserved.
2121
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
22+
* Copyright (c) 2025 Triad National Security, LLC. All rights
23+
* reserved.
2224
* $COPYRIGHT$
2325
*
2426
* Additional copyrights may follow
@@ -197,6 +199,7 @@ static struct option prterunoptions[] = {
197199
PMIX_OPTION_DEFINE(PRTE_CLI_DO_NOT_AGG_HELP, PMIX_ARG_NONE),
198200
PMIX_OPTION_DEFINE(PRTE_CLI_FWD_ENVIRON, PMIX_ARG_OPTIONAL),
199201
PMIX_OPTION_DEFINE(PRTE_CLI_MEM_ALLOC_KIND, PMIX_ARG_REQD),
202+
PMIX_OPTION_DEFINE(PRTE_CLI_DISABLE_GPU_SUPPORT, PMIX_ARG_NONE),
200203

201204
// output options
202205
PMIX_OPTION_DEFINE(PRTE_CLI_OUTPUT, PMIX_ARG_REQD),
@@ -312,6 +315,7 @@ static struct option prunoptions[] = {
312315
PMIX_OPTION_DEFINE(PRTE_CLI_DO_NOT_AGG_HELP, PMIX_ARG_NONE),
313316
PMIX_OPTION_DEFINE(PRTE_CLI_FWD_ENVIRON, PMIX_ARG_OPTIONAL),
314317
PMIX_OPTION_DEFINE(PRTE_CLI_MEM_ALLOC_KIND, PMIX_ARG_REQD),
318+
PMIX_OPTION_DEFINE(PRTE_CLI_DISABLE_GPU_SUPPORT, PMIX_ARG_NONE),
315319

316320
// output options
317321
PMIX_OPTION_DEFINE(PRTE_CLI_OUTPUT, PMIX_ARG_REQD),

src/prted/pmix/pmix_server_queries.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* and Technology (RIST). All rights reserved.
2121
* Copyright (c) 2020 IBM Corporation. All rights reserved.
2222
* Copyright (c) 2021-2024 Nanook Consulting All rights reserved.
23-
* Copyright (c) 2024 Triad National Security, LLC. All rights
23+
* Copyright (c) 2024-2025 Triad National Security, LLC. All rights
2424
* reserved.
2525
* $COPYRIGHT$
2626
*
@@ -31,6 +31,7 @@
3131
*/
3232

3333
#include "prte_config.h"
34+
#include "pmix.h"
3435

3536
#ifdef HAVE_UNISTD_H
3637
# include <unistd.h>
@@ -825,6 +826,27 @@ static void _query(int sd, short args, void *cbdata)
825826
PMIX_ERROR_LOG(rc);
826827
goto done;
827828
}
829+
#endif
830+
#ifdef PMIX_DISABLE_GPU_SUPPORT
831+
} else if (0 == strcmp(q->keys[n], PMIX_DISABLE_GPU_SUPPORT)) {
832+
pmix_value_t *value;
833+
jdata = prte_get_job_data_object(jobid);
834+
if (NULL == jdata) {
835+
ret = PMIX_ERR_NOT_FOUND;
836+
goto done;
837+
}
838+
PMIX_LOAD_PROCID(&pproc, jobid, PMIX_RANK_WILDCARD);
839+
PMIX_INFO_LOAD(&info, PMIX_IMMEDIATE, NULL, PMIX_BOOL);
840+
ret = PMIx_Get(&pproc, PMIX_DISABLE_GPU_SUPPORT, &info, 1, &value);
841+
if (PMIX_SUCCESS != ret) {
842+
goto done;
843+
}
844+
PMIX_INFO_LIST_ADD(rc, results, PMIX_DISABLE_GPU, value->data.string, PMIX_STRING);
845+
PMIX_VALUE_RELEASE(value);
846+
if (PMIX_SUCCESS != rc) {
847+
PMIX_ERROR_LOG(rc);
848+
goto done;
849+
}
828850
#endif
829851
} else {
830852
fprintf(stderr, "Query for unrecognized attribute: %s\n", q->keys[n]);

src/prted/prun_common.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,12 @@ int prun_common(pmix_cli_result_t *results,
667667
PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_MEM_ALLOC_KIND, opt->values[0], PMIX_STRING);
668668
}
669669
#endif
670+
#ifdef PMIX_DISABLE_GPU_SUPPORT
671+
/* mark if gpu support is disabled on the cmd line */
672+
if (pmix_cmd_line_is_taken(results, PRTE_CLI_DISABLE_GPU_SUPPORT)) {
673+
PMIX_INFO_LIST_ADD(ret, jinfo, PMIX_DISABLE_GPU_SUPPORT, &flag, PMIX_BOOL);
674+
}
675+
#endif
670676

671677
/* give the schizo components a chance to add to the job info */
672678
schizo->job_info(results, jinfo);

src/util/prte_cmd_line.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ BEGIN_C_DECLS
108108
#define PRTE_CLI_SET_CWD_SESSION "set-cwd-to-session-dir" // none
109109
#define PRTE_CLI_ENABLE_RECOVERY "enable-recovery" // none
110110
#define PRTE_CLI_DISABLE_RECOVERY "disable-recovery" // none
111-
#define PRTE_CLI_MEM_ALLOC_KIND "memory-alloc-kinds" // required
111+
#define PRTE_CLI_MEM_ALLOC_KIND "memory-alloc-kinds" // required
112+
#define PRTE_CLI_DISABLE_GPU_SUPPORT "disable-gpu-support" // none
112113

113114
// Placement options
114115
#define PRTE_CLI_MAPBY "map-by" // required

0 commit comments

Comments
 (0)