diff --git a/ompi/runtime/ompi_mpi_params.c b/ompi/runtime/ompi_mpi_params.c index 10f0bf00ab6..b7409b63e3f 100644 --- a/ompi/runtime/ompi_mpi_params.c +++ b/ompi/runtime/ompi_mpi_params.c @@ -23,6 +23,7 @@ * Copyright (c) 2018-2021 Triad National Security, LLC. All rights * reserved. * Copyright (c) 2021 Nanook Consulting. All rights reserved. + * Copyright (c) 2022 IBM Corporation. All rights reserved. * $COPYRIGHT$ * * Additional copyrights may follow @@ -102,6 +103,8 @@ bool ompi_ftmpi_enabled = false; #include "ompi/communicator/communicator.h" #endif /* OPAL_ENABLE_FT_MPI */ +static int ompi_stream_buffering_mode = -1; + int ompi_mpi_register_params(void) { int value; @@ -404,6 +407,33 @@ int ompi_mpi_register_params(void) MCA_BASE_VAR_SCOPE_READONLY, &ompi_enable_timing); + /* + * stdout/stderr buffering + * If the user requested to override the default setting then do + * as they wish. + */ + (void) mca_base_var_register("ompi", "ompi", NULL, "stream_buffering", + "Adjust buffering for stdout/stderr. " + "(0) unbuffered, (1) line buffered, (2) fully buffered.", + MCA_BASE_VAR_TYPE_INT, + NULL, 0, 0, + OPAL_INFO_LVL_3, + MCA_BASE_VAR_SCOPE_READONLY, + &ompi_stream_buffering_mode); + if(0 == ompi_stream_buffering_mode) { + setvbuf(stdout, NULL, _IONBF, 0); + setvbuf(stderr, NULL, _IONBF, 0); + } + else if(1 == ompi_stream_buffering_mode) { + setvbuf(stdout, NULL, _IOLBF, 0); + setvbuf(stderr, NULL, _IOLBF, 0); + } + else if(2 == ompi_stream_buffering_mode) { + setvbuf(stdout, NULL, _IOFBF, 0); + setvbuf(stderr, NULL, _IOFBF, 0); + } + + #if OPAL_ENABLE_FT_MPI /* Before loading any other part of the MPI library, we need to load * * the ft-mpi tune file to override default component selection when diff --git a/ompi/runtime/ompi_rte.c b/ompi/runtime/ompi_rte.c index 6071b9bf65f..667dafb15a3 100644 --- a/ompi/runtime/ompi_rte.c +++ b/ompi/runtime/ompi_rte.c @@ -900,26 +900,6 @@ int ompi_rte_init(int *pargc, char ***pargv) opal_argv_free(peers); } - /* - * stdout/stderr buffering - * If the user requested to override the default setting then do - * as they wish. - */ - OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, "OMPI_STREAM_BUFFERING", - &opal_process_info.my_name, &u16ptr, PMIX_UINT16); - if (PMIX_SUCCESS == rc) { - if (0 == u16) { - setvbuf(stdout, NULL, _IONBF, 0); - setvbuf(stderr, NULL, _IONBF, 0); - } else if (1 == u16) { - setvbuf(stdout, NULL, _IOLBF, 0); - setvbuf(stderr, NULL, _IOLBF, 0); - } else if (2 == u16 ) { - setvbuf(stdout, NULL, _IOFBF, 0); - setvbuf(stderr, NULL, _IOFBF, 0); - } - } - #ifdef PMIX_NODE_OVERSUBSCRIBED pname.jobid = opal_process_info.my_name.jobid; pname.vpid = OPAL_VPID_WILDCARD;