From f26baefc40a3506a8bf1cfb5e645d9deddf75db4 Mon Sep 17 00:00:00 2001 From: Shane Snyder Date: Fri, 26 Feb 2016 12:34:02 -0600 Subject: [PATCH] allow job end time to be set by darshan-merge --- .../share/darshan-mmap-epilog.sh.in | 8 +++++-- darshan-util/darshan-merge.c | 23 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/darshan-runtime/share/darshan-mmap-epilog.sh.in b/darshan-runtime/share/darshan-mmap-epilog.sh.in index b17a14d..62c788c 100644 --- a/darshan-runtime/share/darshan-mmap-epilog.sh.in +++ b/darshan-runtime/share/darshan-mmap-epilog.sh.in @@ -11,6 +11,8 @@ DARSHAN_INSTALL_DIR=@prefix@ # use the log dir specified at configure time DARSHAN_LOG_DIR=@__DARSHAN_LOG_PATH@ +JOB_END=$(date +"%s") + # use the default mmap log directory (/tmp), unless the # env variable is set to something if [ -z "$DARSHAN_MMAP_LOGPATH" ]; then @@ -53,7 +55,7 @@ if [ $SLURM_NNODES -gt 1 ]; then mkdir -p $NODE_LOG_DIR # construct the per-node log file and store in the output directory - $DARSHAN_INSTALL_DIR/bin/darshan-merge \ + $DARSHAN_INSTALL_DIR/bin/darshan-merge --job-end-time $JOB_END \ --output ${NODE_LOG_DIR}/${LOG_NAME_PRE}_${NODE_NAME}.darshan \ $DARSHAN_MMAP_LOG_GLOB else @@ -61,7 +63,7 @@ else # single node, just create the final output darshan log LOG_WRITE_START=$(date +%s) - $DARSHAN_INSTALL_DIR/bin/darshan-merge + $DARSHAN_INSTALL_DIR/bin/darshan-merge --job-end-time $JOB_END \ --shared-redux --output ${OUTPUT_LOG_DIR}/${TMP_LOG} \ $DARSHAN_MMAP_LOG_GLOB LOG_WRITE_END=$(date +%s) @@ -72,4 +74,6 @@ else mv ${OUTPUT_LOG_DIR}/${TMP_LOG} ${OUTPUT_LOG_DIR}/${FINAL_LOG} fi +rm -f $DARSHAN_MMAP_LOG_GLOB + exit 0 diff --git a/darshan-util/darshan-merge.c b/darshan-util/darshan-merge.c index c8df4bb..305fd98 100644 --- a/darshan-util/darshan-merge.c +++ b/darshan-util/darshan-merge.c @@ -28,23 +28,27 @@ void usage(char *exename) fprintf(stderr, "Options:\n"); fprintf(stderr, "\t--output\t(REQUIRED) Full path of the output darshan log file.\n"); fprintf(stderr, "\t--shared-redux\tReduce globally shared records into a single record.\n"); + fprintf(stderr, "\t--job-end-time\tSet the output log's job end time (requires argument of seconds since Epoch).\n"); exit(1); } void parse_args(int argc, char **argv, char ***infile_list, int *n_files, - char **outlog_path, int *shared_redux) + char **outlog_path, int *shared_redux, int64_t *job_end_time) { int index; + char *check; static struct option long_opts[] = { - {"shared-redux", no_argument, NULL, 's'}, {"output", required_argument, NULL, 'o'}, + {"shared-redux", no_argument, NULL, 's'}, + {"job-end-time", required_argument, NULL, 'e'}, {0, 0, 0, 0} }; *shared_redux = 0; *outlog_path = NULL; + *job_end_time = 0; while(1) { @@ -60,6 +64,14 @@ void parse_args(int argc, char **argv, char ***infile_list, int *n_files, case 'o': *outlog_path = optarg; break; + case 'e': + *job_end_time = strtol(optarg, &check, 10); + if(optarg == check) + { + fprintf(stderr, "Error: unable to parse job end time value.\n"); + exit(1); + } + break; case '?': default: usage(argv[0]); @@ -173,6 +185,7 @@ int main(int argc, char *argv[]) char **infile_list; int n_infiles; int shared_redux; + int64_t job_end_time = 0; char *outlog_path; darshan_fd in_fd, merge_fd; struct darshan_job in_job, merge_job; @@ -191,7 +204,7 @@ int main(int argc, char *argv[]) int ret; /* grab command line arguments */ - parse_args(argc, argv, &infile_list, &n_infiles, &outlog_path, &shared_redux); + parse_args(argc, argv, &infile_list, &n_infiles, &outlog_path, &shared_redux, &job_end_time); memset(&merge_job, 0, sizeof(struct darshan_job)); @@ -305,6 +318,10 @@ int main(int argc, char *argv[]) darshan_log_close(in_fd); } + /* if a job end time was passed in, apply it to the output job */ + if(job_end_time > 0) + merge_job.end_time = job_end_time; + /* create the output "merged" log */ merge_fd = darshan_log_create(outlog_path, DARSHAN_ZLIB_COMP, 1); if(merge_fd == NULL) -- 2.26.2