Skip to content

Commit 66ab9da

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]> (cherry picked from commit dcd9801) Signed-off-by: Joshua Hursey <[email protected]>
1 parent f5ad91b commit 66ab9da

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
@@ -10,6 +10,7 @@
1010
* Copyright (c) 2004-2005 The Regents of the University of California.
1111
* All rights reserved.
1212
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
13+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1314
* $COPYRIGHT$
1415
*
1516
* Additional copyrights may follow
@@ -181,7 +182,7 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
181182
close(opts->p_stderr[1]);
182183
}
183184

184-
if (!orte_map_stddiag_to_stderr) {
185+
if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) {
185186
/* Set an environment variable that the new child process can use
186187
to get the fd of the pipe connected to the INTERNAL IOF tag. */
187188
asprintf(&str, "%d", opts->p_internal[1]);
@@ -190,6 +191,9 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
190191
free(str);
191192
}
192193
}
194+
else if( orte_map_stddiag_to_stdout ) {
195+
opal_setenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT", "1", true, env);
196+
}
193197

194198
return ORTE_SUCCESS;
195199
}

orte/mca/plm/base/plm_base_launch_support.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,11 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
12541254
opal_argv_append(argc, argv, "orte_map_stddiag_to_stderr");
12551255
opal_argv_append(argc, argv, "1");
12561256
}
1257+
else if (orte_map_stddiag_to_stdout) {
1258+
opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID);
1259+
opal_argv_append(argc, argv, "orte_map_stddiag_to_stdout");
1260+
opal_argv_append(argc, argv, "1");
1261+
}
12571262

12581263
/* the following is not an mca param */
12591264
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-2015 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
@@ -188,6 +189,7 @@ bool orte_staged_execution = false;
188189

189190
/* map stddiag output to stderr so it isn't forwarded to mpirun */
190191
bool orte_map_stddiag_to_stderr = false;
192+
bool orte_map_stddiag_to_stdout = false;
191193

192194
/* maximum size of virtual machine - used to subdivide allocation */
193195
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-2015 Intel, Inc. All rights reserved
17+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -572,6 +573,7 @@ ORTE_DECLSPEC extern bool orte_staged_execution;
572573

573574
/* map stddiag output to stderr so it isn't forwarded to mpirun */
574575
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stderr;
576+
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stdout;
575577

576578
/* maximum size of virtual machine - used to subdivide allocation */
577579
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-2015 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
@@ -523,6 +524,18 @@ int orte_register_params(void)
523524
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
524525
&orte_map_stddiag_to_stderr);
525526

527+
/* whether or not to map stddiag to stderr */
528+
orte_map_stddiag_to_stdout = false;
529+
(void) mca_base_var_register ("orte", "orte", NULL, "map_stddiag_to_stdout",
530+
"Map output from opal_output to stdout of the local process [default: no]",
531+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
532+
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
533+
&orte_map_stddiag_to_stdout);
534+
if( orte_map_stddiag_to_stderr && orte_map_stddiag_to_stdout ) {
535+
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.");
536+
return ORTE_ERROR;
537+
}
538+
526539
/* generate new terminal windows to display output from specified ranks */
527540
orte_xterm = NULL;
528541
(void) mca_base_var_register ("orte", "orte", NULL, "xterm",

0 commit comments

Comments
 (0)