Skip to content

Commit cb50b26

Browse files
committed
Continue updates to support MPICH integration
Extend IOF outputting format to cover Hydra options. Signed-off-by: Ralph Castain <[email protected]>
1 parent 7294e3d commit cb50b26

File tree

3 files changed

+79
-18
lines changed

3 files changed

+79
-18
lines changed

include/pmix_common.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,8 @@ typedef uint32_t pmix_rank_t;
876876
#define PMIX_IOF_XML_OUTPUT "pmix.iof.xml" // (bool) Format output in XML
877877
#define PMIX_IOF_OUTPUT_TO_FILE "pmix.iof.file" // (char*) direct application output into files of form
878878
// "<filename>.rank" with both stdout and stderr redirected into it
879+
#define PMIX_IOF_FILE_PATTERN "pmix.iof.fpt" // (bool) Specified output file is to be treated as a pattern and not
880+
// automatically annotated by nspace, rank, or other parameters
879881
#define PMIX_IOF_OUTPUT_TO_DIRECTORY "pmix.iof.dir" // (char*) direct application output into files of form
880882
// "<directory>/<jobid>/rank.<rank>/stdout[err]"
881883
#define PMIX_IOF_FILE_ONLY "pmix.iof.fonly" // (bool) output only into designated files - do not also output

src/common/pmix_iof.c

Lines changed: 76 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,15 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
781781
}
782782
/* define a sink to that file descriptor */
783783
snk = PMIX_NEW(pmix_iof_sink_t);
784-
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
785-
PMIX_FWD_STDOUT_CHANNEL, pmix_iof_write_handler);
784+
if (nptr->iof_flags.merge) {
785+
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
786+
PMIX_FWD_ALL_CHANNELS, pmix_iof_write_handler);
787+
} else {
788+
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
789+
PMIX_FWD_STDOUT_CHANNEL, pmix_iof_write_handler);
790+
}
786791
pmix_list_append(&nptr->sinks, &snk->super);
792+
return &snk->wev;
787793
} else {
788794
/* setup the stderr sink */
789795
pmix_asprintf(&outfile, "%s/stderr", outdir);
@@ -799,8 +805,8 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
799805
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
800806
PMIX_FWD_STDERR_CHANNEL, pmix_iof_write_handler);
801807
pmix_list_append(&nptr->sinks, &snk->super);
808+
return &snk->wev;
802809
}
803-
return &snk->wev;
804810
}
805811

806812
/* see if we are to output to a file */
@@ -814,22 +820,71 @@ static pmix_iof_write_event_t* pmix_iof_setup(pmix_namespace_t *nptr,
814820
free(outdir);
815821
return NULL;
816822
}
817-
/* setup the file */
818-
pmix_asprintf(&outfile, "%s.%s.%0*u", nptr->iof_flags.file,
819-
nptr->nspace, numdigs, rank);
820-
fdout = open(outfile, O_CREAT | O_RDWR | O_TRUNC, 0644);
821-
free(outfile);
822-
if (fdout < 0) {
823-
/* couldn't be opened */
824-
PMIX_ERROR_LOG(PMIX_ERR_FILE_OPEN_FAILURE);
825-
return NULL;
823+
if (PMIX_FWD_STDOUT_CHANNEL & stream ||
824+
nptr->iof_flags.merge) {
825+
/* setup the stdout sink */
826+
if (nptr->iof_flags.pattern) {
827+
/* if there are no '%' signs in the pattern, then it is just a literal string */
828+
if (NULL == strchr(nptr->iof_flags.file, '%')) {
829+
/* setup the file */
830+
pmix_asprintf(&outfile, "%s.out", nptr->iof_flags.file);
831+
} else {
832+
/* must process the pattern - for now, just take it literally */
833+
pmix_asprintf(&outfile, "%s.out", nptr->iof_flags.file);
834+
}
835+
} else {
836+
/* setup the file */
837+
pmix_asprintf(&outfile, "%s.%s.%0*u.out", nptr->iof_flags.file,
838+
nptr->nspace, numdigs, rank);
839+
}
840+
fdout = open(outfile, O_CREAT | O_RDWR | O_TRUNC, 0644);
841+
free(outfile);
842+
if (fdout < 0) {
843+
/* couldn't be opened */
844+
PMIX_ERROR_LOG(PMIX_ERR_FILE_OPEN_FAILURE);
845+
return NULL;
846+
}
847+
/* define a sink to that file descriptor */
848+
snk = PMIX_NEW(pmix_iof_sink_t);
849+
if (nptr->iof_flags.merge) {
850+
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
851+
PMIX_FWD_ALL_CHANNELS, pmix_iof_write_handler);
852+
} else {
853+
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
854+
PMIX_FWD_STDOUT_CHANNEL, pmix_iof_write_handler);
855+
}
856+
pmix_list_append(&nptr->sinks, &snk->super);
857+
return &snk->wev;
858+
} else {
859+
/* setup the stderr sink */
860+
if (nptr->iof_flags.pattern) {
861+
/* if there are no '%' signs in the pattern, then it is just a literal string */
862+
if (NULL == strchr(nptr->iof_flags.file, '%')) {
863+
/* setup the file */
864+
pmix_asprintf(&outfile, "%s.err", nptr->iof_flags.file);
865+
} else {
866+
/* must process the pattern - for now, just take it literally */
867+
pmix_asprintf(&outfile, "%s.err", nptr->iof_flags.file);
868+
}
869+
} else {
870+
/* setup the file */
871+
pmix_asprintf(&outfile, "%s.%s.%0*u.err", nptr->iof_flags.file,
872+
nptr->nspace, numdigs, rank);
873+
}
874+
fdout = open(outfile, O_CREAT | O_RDWR | O_TRUNC, 0644);
875+
free(outfile);
876+
if (fdout < 0) {
877+
/* couldn't be opened */
878+
PMIX_ERROR_LOG(PMIX_ERR_FILE_OPEN_FAILURE);
879+
return NULL;
880+
}
881+
/* define a sink to that file descriptor */
882+
snk = PMIX_NEW(pmix_iof_sink_t);
883+
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
884+
PMIX_FWD_STDERR_CHANNEL, pmix_iof_write_handler);
885+
pmix_list_append(&nptr->sinks, &snk->super);
886+
return &snk->wev;
826887
}
827-
/* define a sink to that file descriptor */
828-
snk = PMIX_NEW(pmix_iof_sink_t);
829-
PMIX_IOF_SINK_DEFINE(snk, &pmix_globals.myid, fdout,
830-
PMIX_FWD_ALL_CHANNELS, pmix_iof_write_handler);
831-
pmix_list_append(&nptr->sinks, &snk->super);
832-
return &snk->wev;
833888
}
834889

835890
return NULL;
@@ -870,6 +925,9 @@ void pmix_iof_check_flags(pmix_info_t *info, pmix_iof_flags_t *flags)
870925
} else if (PMIX_CHECK_KEY(info, PMIX_IOF_LOCAL_OUTPUT)) {
871926
flags->local_output = PMIX_INFO_TRUE(info);
872927
flags->set = true;
928+
} else if (PMIX_CHECK_KEY(info, PMIX_IOF_FILE_PATTERN)) {
929+
flags->pattern = PMIX_INFO_TRUE(info);
930+
/* don't mark as set here as this is just a qualifier */
873931
}
874932
}
875933

src/include/pmix_globals.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ typedef struct {
203203
bool nocopy;
204204
bool merge;
205205
bool local_output;
206+
bool pattern;
206207
} pmix_iof_flags_t;
207208

208209
/* objects used by servers for tracking active nspaces */

0 commit comments

Comments
 (0)