Skip to content

Commit 3555e02

Browse files
authored
Merge pull request #2906 from jjhursey/topic/ibm/v2.x/stdiag-to-stdout
Extend options for stddiag routing
2 parents 09b0e86 + 637d32e commit 3555e02

File tree

9 files changed

+64
-5
lines changed

9 files changed

+64
-5
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: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,13 @@ bool opal_output_init(void)
175175
verbose.lds_want_stderr = false;
176176
verbose.lds_want_stdout = false;
177177
} else {
178-
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+
}
179185
}
180186
gethostname(hostname, sizeof(hostname));
181187
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());

orte/mca/iof/base/base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct orte_iof_base_t {
131131
char *input_files;
132132
orte_iof_sink_t *iof_write_stdout;
133133
orte_iof_sink_t *iof_write_stderr;
134+
bool redirect_app_stderr_to_stdout;
134135
};
135136
typedef struct orte_iof_base_t orte_iof_base_t;
136137

orte/mca/iof/base/iof_base_frame.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* Copyright (c) 2015 Intel, Inc. All rights reserved.
1515
* Copyright (c) 2015 Research Organization for Information Science
1616
* and Technology (RIST). All rights reserved.
17+
* Copyright (c) 2017 IBM Corporation. All rights reserved.
1718
* $COPYRIGHT$
1819
*
1920
* Additional copyrights may follow
@@ -204,6 +205,15 @@ static int orte_iof_base_register(mca_base_register_flag_t flags)
204205
MCA_BASE_VAR_SCOPE_READONLY,
205206
&orte_iof_base.input_files);
206207

208+
/* Redirect application stderr to stdout (at source) */
209+
orte_iof_base.redirect_app_stderr_to_stdout = false;
210+
(void) mca_base_var_register("orte", "iof","base", "redirect_app_stderr_to_stdout",
211+
"Redirect application stderr to stdout at source (default: false)",
212+
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
213+
OPAL_INFO_LVL_9,
214+
MCA_BASE_VAR_SCOPE_READONLY,
215+
&orte_iof_base.redirect_app_stderr_to_stdout);
216+
207217
return ORTE_SUCCESS;
208218
}
209219

orte/mca/iof/base/iof_base_setup.c

Lines changed: 19 additions & 3 deletions
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
@@ -65,6 +66,7 @@
6566
#include "orte/runtime/orte_globals.h"
6667

6768
#include "orte/mca/iof/iof.h"
69+
#include "orte/mca/iof/base/base.h"
6870
#include "orte/mca/iof/base/iof_base_setup.h"
6971

7072
int
@@ -150,11 +152,19 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
150152
}
151153
ret = dup2(opts->p_stdout[1], fileno(stdout));
152154
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
155+
if( orte_iof_base.redirect_app_stderr_to_stdout ) {
156+
ret = dup2(opts->p_stdout[1], fileno(stderr));
157+
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
158+
}
153159
close(opts->p_stdout[1]);
154160
} else {
155161
if(opts->p_stdout[1] != fileno(stdout)) {
156162
ret = dup2(opts->p_stdout[1], fileno(stdout));
157163
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
164+
if( orte_iof_base.redirect_app_stderr_to_stdout ) {
165+
ret = dup2(opts->p_stdout[1], fileno(stderr));
166+
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
167+
}
158168
close(opts->p_stdout[1]);
159169
}
160170
}
@@ -175,13 +185,16 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
175185
close(fd);
176186
}
177187
}
188+
178189
if(opts->p_stderr[1] != fileno(stderr)) {
179-
ret = dup2(opts->p_stderr[1], fileno(stderr));
180-
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
190+
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
191+
ret = dup2(opts->p_stderr[1], fileno(stderr));
192+
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
193+
}
181194
close(opts->p_stderr[1]);
182195
}
183196

184-
if (!orte_map_stddiag_to_stderr) {
197+
if (!orte_map_stddiag_to_stderr && !orte_map_stddiag_to_stdout ) {
185198
/* Set an environment variable that the new child process can use
186199
to get the fd of the pipe connected to the INTERNAL IOF tag. */
187200
asprintf(&str, "%d", opts->p_internal[1]);
@@ -190,6 +203,9 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
190203
free(str);
191204
}
192205
}
206+
else if( orte_map_stddiag_to_stdout ) {
207+
opal_setenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT", "1", true, env);
208+
}
193209

194210
return ORTE_SUCCESS;
195211
}

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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ bool orte_staged_execution = false;
191191

192192
/* map stddiag output to stderr so it isn't forwarded to mpirun */
193193
bool orte_map_stddiag_to_stderr = false;
194+
bool orte_map_stddiag_to_stdout = false;
194195

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

orte/runtime/orte_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ ORTE_DECLSPEC extern bool orte_staged_execution;
573573

574574
/* map stddiag output to stderr so it isn't forwarded to mpirun */
575575
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stderr;
576+
ORTE_DECLSPEC extern bool orte_map_stddiag_to_stdout;
576577

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

orte/runtime/orte_mca_params.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,18 @@ int orte_register_params(void)
524524
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
525525
&orte_map_stddiag_to_stderr);
526526

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+
527539
/* generate new terminal windows to display output from specified ranks */
528540
orte_xterm = NULL;
529541
(void) mca_base_var_register ("orte", "orte", NULL, "xterm",

0 commit comments

Comments
 (0)