Skip to content

Commit

Permalink
Merge pull request #10756 from jjhursey/v5-fix-stream-buff
Browse files Browse the repository at this point in the history
Make stream buffing an MCA option again
  • Loading branch information
gpaulsen authored Sep 6, 2022
2 parents 9cf0f0b + 64299ce commit e1fe479
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 20 deletions.
30 changes: 30 additions & 0 deletions ompi/runtime/ompi_mpi_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
20 changes: 0 additions & 20 deletions ompi/runtime/ompi_rte.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e1fe479

Please sign in to comment.