Skip to content

Commit 4b327e5

Browse files
authored
Merge pull request #10746 from jjhursey/rm-stream-buffering
Make stream buffing an MCA option again
2 parents 5c24e10 + 3a8edb7 commit 4b327e5

File tree

2 files changed

+30
-20
lines changed

2 files changed

+30
-20
lines changed

ompi/runtime/ompi_mpi_params.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* Copyright (c) 2018-2021 Triad National Security, LLC. All rights
2424
* reserved.
2525
* Copyright (c) 2021 Nanook Consulting. All rights reserved.
26+
* Copyright (c) 2022 IBM Corporation. All rights reserved.
2627
* $COPYRIGHT$
2728
*
2829
* Additional copyrights may follow
@@ -102,6 +103,8 @@ bool ompi_ftmpi_enabled = false;
102103
#include "ompi/communicator/communicator.h"
103104
#endif /* OPAL_ENABLE_FT_MPI */
104105

106+
static int ompi_stream_buffering_mode = -1;
107+
105108
int ompi_mpi_register_params(void)
106109
{
107110
int value;
@@ -404,6 +407,33 @@ int ompi_mpi_register_params(void)
404407
MCA_BASE_VAR_SCOPE_READONLY,
405408
&ompi_enable_timing);
406409

410+
/*
411+
* stdout/stderr buffering
412+
* If the user requested to override the default setting then do
413+
* as they wish.
414+
*/
415+
(void) mca_base_var_register("ompi", "ompi", NULL, "stream_buffering",
416+
"Adjust buffering for stdout/stderr. "
417+
"(0) unbuffered, (1) line buffered, (2) fully buffered.",
418+
MCA_BASE_VAR_TYPE_INT,
419+
NULL, 0, 0,
420+
OPAL_INFO_LVL_3,
421+
MCA_BASE_VAR_SCOPE_READONLY,
422+
&ompi_stream_buffering_mode);
423+
if(0 == ompi_stream_buffering_mode) {
424+
setvbuf(stdout, NULL, _IONBF, 0);
425+
setvbuf(stderr, NULL, _IONBF, 0);
426+
}
427+
else if(1 == ompi_stream_buffering_mode) {
428+
setvbuf(stdout, NULL, _IOLBF, 0);
429+
setvbuf(stderr, NULL, _IOLBF, 0);
430+
}
431+
else if(2 == ompi_stream_buffering_mode) {
432+
setvbuf(stdout, NULL, _IOFBF, 0);
433+
setvbuf(stderr, NULL, _IOFBF, 0);
434+
}
435+
436+
407437
#if OPAL_ENABLE_FT_MPI
408438
/* Before loading any other part of the MPI library, we need to load
409439
* * the ft-mpi tune file to override default component selection when

ompi/runtime/ompi_rte.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -905,26 +905,6 @@ int ompi_rte_init(int *pargc, char ***pargv)
905905
opal_argv_free(peers);
906906
}
907907

908-
/*
909-
* stdout/stderr buffering
910-
* If the user requested to override the default setting then do
911-
* as they wish.
912-
*/
913-
OPAL_MODEX_RECV_VALUE_OPTIONAL(rc, "OMPI_STREAM_BUFFERING",
914-
&opal_process_info.my_name, &u16ptr, PMIX_UINT16);
915-
if (PMIX_SUCCESS == rc) {
916-
if (0 == u16) {
917-
setvbuf(stdout, NULL, _IONBF, 0);
918-
setvbuf(stderr, NULL, _IONBF, 0);
919-
} else if (1 == u16) {
920-
setvbuf(stdout, NULL, _IOLBF, 0);
921-
setvbuf(stderr, NULL, _IOLBF, 0);
922-
} else if (2 == u16 ) {
923-
setvbuf(stdout, NULL, _IOFBF, 0);
924-
setvbuf(stderr, NULL, _IOFBF, 0);
925-
}
926-
}
927-
928908
#ifdef PMIX_NODE_OVERSUBSCRIBED
929909
pname.jobid = opal_process_info.my_name.jobid;
930910
pname.vpid = OPAL_VPID_WILDCARD;

0 commit comments

Comments
 (0)