Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion opal/mca/base/mca_base_open.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* Copyright (c) 2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -121,7 +122,13 @@ int mca_base_open(void)
MCA_BASE_VAR_SYN_FLAG_DEPRECATED);

/* What verbosity level do we want for the default 0 stream? */
mca_base_verbose = "stderr";
char *str = getenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT");
if (NULL != str && str[0] == '1') {
mca_base_verbose = "stdout";
}
else {
mca_base_verbose = "stderr";
}
var_id = mca_base_var_register("opal", "mca", "base", "verbose",
"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)",
MCA_BASE_VAR_TYPE_STRING, NULL, 0, 0,
Expand Down
9 changes: 8 additions & 1 deletion opal/util/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -174,7 +175,13 @@ bool opal_output_init(void)
verbose.lds_want_stderr = false;
verbose.lds_want_stdout = false;
} else {
verbose.lds_want_stderr = true;
str = getenv("OPAL_OUTPUT_INTERNAL_TO_STDOUT");
if (NULL != str && str[0] == '1') {
verbose.lds_want_stdout = true;
}
else {
verbose.lds_want_stderr = true;
}
}
gethostname(hostname, sizeof(hostname));
asprintf(&verbose.lds_prefix, "[%s:%05d] ", hostname, getpid());
Expand Down
1 change: 1 addition & 0 deletions orte/mca/iof/base/base.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ struct orte_iof_base_t {
char *input_files;
orte_iof_sink_t *iof_write_stdout;
orte_iof_sink_t *iof_write_stderr;
bool redirect_app_stderr_to_stdout;
};
typedef struct orte_iof_base_t orte_iof_base_t;

Expand Down
10 changes: 10 additions & 0 deletions orte/mca/iof/base/iof_base_frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Copyright (c) 2015 Intel, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -204,6 +205,15 @@ static int orte_iof_base_register(mca_base_register_flag_t flags)
MCA_BASE_VAR_SCOPE_READONLY,
&orte_iof_base.input_files);

/* Redirect application stderr to stdout (at source) */
orte_iof_base.redirect_app_stderr_to_stdout = false;
(void) mca_base_var_register("orte", "iof","base", "redirect_app_stderr_to_stdout",
"Redirect application stderr to stdout at source (default: false)",
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&orte_iof_base.redirect_app_stderr_to_stdout);

return ORTE_SUCCESS;
}

Expand Down
22 changes: 19 additions & 3 deletions orte/mca/iof/base/iof_base_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -65,6 +66,7 @@
#include "orte/runtime/orte_globals.h"

#include "orte/mca/iof/iof.h"
#include "orte/mca/iof/base/base.h"
#include "orte/mca/iof/base/iof_base_setup.h"

int
Expand Down Expand Up @@ -150,11 +152,19 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
}
ret = dup2(opts->p_stdout[1], fileno(stdout));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
if( orte_iof_base.redirect_app_stderr_to_stdout ) {
ret = dup2(opts->p_stdout[1], fileno(stderr));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
}
close(opts->p_stdout[1]);
} else {
if(opts->p_stdout[1] != fileno(stdout)) {
ret = dup2(opts->p_stdout[1], fileno(stdout));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
if( orte_iof_base.redirect_app_stderr_to_stdout ) {
ret = dup2(opts->p_stdout[1], fileno(stderr));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
}
close(opts->p_stdout[1]);
}
}
Expand All @@ -175,13 +185,16 @@ orte_iof_base_setup_child(orte_iof_base_io_conf_t *opts, char ***env)
close(fd);
}
}

if(opts->p_stderr[1] != fileno(stderr)) {
ret = dup2(opts->p_stderr[1], fileno(stderr));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
if( !orte_iof_base.redirect_app_stderr_to_stdout ) {
ret = dup2(opts->p_stderr[1], fileno(stderr));
if (ret < 0) return ORTE_ERR_PIPE_SETUP_FAILURE;
}
close(opts->p_stderr[1]);
}

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

return ORTE_SUCCESS;
}
Expand Down
5 changes: 5 additions & 0 deletions orte/mca/plm/base/plm_base_launch_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,11 @@ int orte_plm_base_orted_append_basic_args(int *argc, char ***argv,
opal_argv_append(argc, argv, "orte_map_stddiag_to_stderr");
opal_argv_append(argc, argv, "1");
}
else if (orte_map_stddiag_to_stdout) {
opal_argv_append(argc, argv, "-"OPAL_MCA_CMD_LINE_ID);
opal_argv_append(argc, argv, "orte_map_stddiag_to_stdout");
opal_argv_append(argc, argv, "1");
}

/* the following is not an mca param */
if (NULL != getenv("ORTE_TEST_ORTED_SUICIDE")) {
Expand Down
2 changes: 2 additions & 0 deletions orte/runtime/orte_globals.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2014-2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -188,6 +189,7 @@ bool orte_staged_execution = false;

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

/* maximum size of virtual machine - used to subdivide allocation */
int orte_max_vm_size = -1;
Expand Down
2 changes: 2 additions & 0 deletions orte/runtime/orte_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* Copyright (c) 2011-2013 Los Alamos National Security, LLC.
* All rights reserved.
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -572,6 +573,7 @@ ORTE_DECLSPEC extern bool orte_staged_execution;

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

/* maximum size of virtual machine - used to subdivide allocation */
ORTE_DECLSPEC extern int orte_max_vm_size;
Expand Down
13 changes: 13 additions & 0 deletions orte/runtime/orte_mca_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2014 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2017 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
Expand Down Expand Up @@ -523,6 +524,18 @@ int orte_register_params(void)
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
&orte_map_stddiag_to_stderr);

/* whether or not to map stddiag to stderr */
orte_map_stddiag_to_stdout = false;
(void) mca_base_var_register ("orte", "orte", NULL, "map_stddiag_to_stdout",
"Map output from opal_output to stdout of the local process [default: no]",
MCA_BASE_VAR_TYPE_BOOL, NULL, 0, 0,
OPAL_INFO_LVL_9, MCA_BASE_VAR_SCOPE_READONLY,
&orte_map_stddiag_to_stdout);
if( orte_map_stddiag_to_stderr && orte_map_stddiag_to_stdout ) {
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.");
return ORTE_ERROR;
}

/* generate new terminal windows to display output from specified ranks */
orte_xterm = NULL;
(void) mca_base_var_register ("orte", "orte", NULL, "xterm",
Expand Down