Skip to content

Commit dcd9801

Browse files
committed
orte/iof: Add orte_map_stddiag_to_stdout option
* Similar to `orte_map_stddiag_to_stderr` except it redirects `stddiag` to `stdout` instead of `stderr`. * Add protection so that the user canot supply both: - `orte_map_stddiag_to_stderr` - `orte_map_stddiag_to_stdout` Signed-off-by: Joshua Hursey <[email protected]>
1 parent c6595c2 commit dcd9801

File tree

7 files changed

+43
-3
lines changed

7 files changed

+43
-3
lines changed

opal/mca/base/mca_base_open.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
1414
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
16+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1617
* $COPYRIGHT$
1718
*
1819
* Additional copyrights may follow
@@ -121,7 +122,13 @@ int mca_base_open(void)
121122
MCA_BASE_VAR_SYN_FLAG_DEPRECATED);
122123

123124
/* What verbosity level do we want for the default 0 stream? */
124-
mca_base_verbose = "stderr";
125+
char *str = getenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT");
126+
if (NULL != str && str[0] == '1') {
127+
mca_base_verbose = "stdout";
128+
}
129+
else {
130+
mca_base_verbose = "stderr";
131+
}
125132
var_id = mca_base_var_register("opal", "mca", "base", "verbose",
126133
"Specifies where the default error output stream goes (this is separate from distinct help messages). Accepts a comma-delimited list of: stderr, stdout, syslog, syslogpri:<notice|info|debug>, syslogid:<str> (where str is the prefix string for all syslog notices), file[:filename] (if filename is not specified, a default filename is used), fileappend (if not specified, the file is opened for truncation), level[:N] (if specified, integer verbose level; otherwise, 0 is implied)",
127134
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,

opal/util/output.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* reserved.
1616
* Copyright (c) 2015 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
18+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1819
* $COPYRIGHT$
1920
*
2021
* Additional copyrights may follow
@@ -174,7 +175,13 @@ bool opal_output_init(void)
174175
verbose.lds_want_stderr = false;
175176
verbose.lds_want_stdout = false;
176177
} else {
177-
verbose.lds_want_stderr = true;
178+
str = getenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT");
179+
if (NULL != str && str[0] == '1') {
180+
verbose.lds_want_stdout = true;
181+
}
182+
else {
183+
verbose.lds_want_stderr = true;
184+
}
178185
}
179186
gethostname(hostname, sizeof(hostname));
180187
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());

orte/mca/iof/base/iof_base_setup.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* All rights reserved.
1212
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
1313
* Copyright (c) 2016-2017 Intel, Inc. All rights reserved.
14+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1415
* $COPYRIGHT$
1516
*
1617
* Additional copyrights may follow
@@ -183,7 +184,7 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
183184
close(opts->p_stderr[1]);
184185
}
185186

186-
if (!orte_map_stddiag_to_stderr) {
187+
if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) {
187188
/* Set an environment variable that the new child process can use
188189
to get the fd of the pipe connected to the INTERNAL IOF tag. */
189190
asprintf(&str, "%d", opts->p_internal[1]);
@@ -192,6 +193,9 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
192193
free(str);
193194
}
194195
}
196+
else if( orte_map_stddiag_to_stdout ) {
197+
opal_setenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT", "1", true, env);
198+
}
195199

196200
return ORTE_SUCCESS;
197201
}

orte/mca/plm/base/plm_base_launch_support.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,11 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
13641364
opal_argv_append(argc, argv, "orte_map_stddiag_to_stderr");
13651365
opal_argv_append(argc, argv, "1");
13661366
}
1367+
else if (orte_map_stddiag_to_stdout) {
1368+
opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID);
1369+
opal_argv_append(argc, argv, "orte_map_stddiag_to_stdout");
1370+
opal_argv_append(argc, argv, "1");
1371+
}
13671372

13681373
/* the following is not an mca param */
13691374
if (NULL != getenv("ORTE_TEST_ORTED_SUICIDE")) {

orte/runtime/orte_globals.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2014-2015 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -184,6 +185,7 @@ char **orte_forwarded_envars = NULL;
184185

185186
/* map stddiag output to stderr so it isn't forwarded to mpirun */
186187
bool orte_map_stddiag_to_stderr = false;
188+
bool orte_map_stddiag_to_stdout = false;
187189

188190
/* maximum size of virtual machine - used to subdivide allocation */
189191
int orte_max_vm_size = -1;

orte/runtime/orte_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
1515
* All rights reserved.
1616
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
17+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -564,6 +565,7 @@ ORTE_DECLSPEC extern char **orte_forwarded_envars;
564565

565566
/* map stddiag output to stderr so it isn't forwarded to mpirun */
566567
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stderr;
568+
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stdout;
567569

568570
/* maximum size of virtual machine - used to subdivide allocation */
569571
ORTE_DECLSPEC extern int orte_max_vm_size;

orte/runtime/orte_mca_params.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* Copyright (c) 2013-2017 Intel, Inc. All rights reserved.
1717
* Copyright (c) 2014 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
19+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1920
* $COPYRIGHT$
2021
*
2122
* Additional copyrights may follow
@@ -545,6 +546,18 @@ int orte_register_params(void)
545546
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
546547
&orte_map_stddiag_to_stderr);
547548

549+
/* whether or not to map stddiag to stderr */
550+
orte_map_stddiag_to_stdout = false;
551+
(void) mca_base_var_register ("orte", "orte", NULL, "map_stddiag_to_stdout",
552+
"Map output from opal_output to stdout of the local process [default: no]",
553+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
554+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
555+
&orte_map_stddiag_to_stdout);
556+
if( orte_map_stddiag_to_stderr && orte_map_stddiag_to_stdout ) {
557+
opal_output(0, "The options \"orte_map_stddiag_to_stderr\" and \"orte_map_stddiag_to_stdout\" are mutually exclusive. They cannot both be set to true.");
558+
return ORTE_ERROR;
559+
}
560+
548561
/* generate new terminal windows to display output from specified ranks */
549562
orte_xterm = NULL;
550563
(void) mca_base_var_register ("orte", "orte", NULL, "xterm",

0 commit comments

Comments
 (0)