From 3b978fa9f7c71f7e55f8a147c13b0cda1a1fdf56 Mon Sep 17 00:00:00 2001 From: harms Date: Thu, 9 Dec 2010 21:56:17 +0000 Subject: [PATCH] Add new environment variables to override the configure based values. DARSHAN_JOBID: name of environment variable that holds the job's Id DARSHAN_LOGPATH: og path to write darshan logs to (still needs year/month/day subdirs) DARSHAN_MEMALIGN: value for determining if accesses are aligned in memory git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@367 3b7491f3-a168-0410-bf4b-c445ed680a29 --- darshan.h | 8 ++++++++ lib/darshan-mpi-io.c | 22 +++++++++++++++++++--- lib/darshan-posix.c | 34 +++++++++++++++++++++++----------- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/darshan.h b/darshan.h index 726f668..d6b370f 100644 --- a/darshan.h +++ b/darshan.h @@ -12,6 +12,14 @@ #include #include "darshan-log-format.h" +/* Environment variable to override CP_JOBID */ +#define CP_JOBID_OVERRIDE "DARSHAN_JOBID" + +/* Environment variable to override __CP_LOG_PATH */ +#define CP_LOG_PATH_OVERRIDE "DARSHAN_LOGPATH" + +/* Environment variable to override __CP_MEM_ALIGNMENT */ +#define CP_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN" /* maximum number of files per process we will track */ #define CP_MAX_FILES 1024 diff --git a/lib/darshan-mpi-io.c b/lib/darshan-mpi-io.c index ad34faa..ca140fa 100644 --- a/lib/darshan-mpi-io.c +++ b/lib/darshan-mpi-io.c @@ -225,6 +225,8 @@ void darshan_shutdown(int timing_flag) int local_ret = 0; MPI_Offset next_offset = 0; char* jobid_str; + char* envjobid; + char* logpath; int jobid; int index_count = 0; int lengths[CP_MAX_MEM_SEGMENTS]; @@ -369,8 +371,22 @@ void darshan_shutdown(int timing_flag) char cuser[L_cuserid] = {0}; struct tm* my_tm; + /* Use CP_JOBID_OVERRIDE for the env var or CP_JOBID */ + envjobid = getenv(CP_JOBID_OVERRIDE); + if (!envjobid) + { + envjobid = CP_JOBID; + } + + /* Use CP_LOG_PATH_OVERRIDE for the value or __CP_LOG_PATH */ + logpath = getenv(CP_LOG_PATH_OVERRIDE); + if (!logpath) + { + logpath = __CP_LOG_PATH; + } + /* find a job id */ - jobid_str = getenv(CP_JOBID); + jobid_str = getenv(envjobid); if(jobid_str) { /* in cobalt we can find it in env var */ @@ -395,7 +411,7 @@ void darshan_shutdown(int timing_flag) ret = snprintf(logfile_name, PATH_MAX, "%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%llu.darshan_partial", - __CP_LOG_PATH, (my_tm->tm_year+1900), + logpath, (my_tm->tm_year+1900), (my_tm->tm_mon+1), my_tm->tm_mday, cuser, __progname, jobid, (my_tm->tm_mon+1), @@ -407,7 +423,7 @@ void darshan_shutdown(int timing_flag) /* file name was too big; squish it down */ snprintf(logfile_name, PATH_MAX, "%s/id%d.darshan_partial", - __CP_LOG_PATH, jobid); + logpath, jobid); } /* add jobid */ diff --git a/lib/darshan-posix.c b/lib/darshan-posix.c index 0fad028..656f2c4 100644 --- a/lib/darshan-posix.c +++ b/lib/darshan-posix.c @@ -67,6 +67,7 @@ pthread_mutex_t cp_mutex = PTHREAD_MUTEX_INITIALIZER; struct darshan_job_runtime* darshan_global_job = NULL; static int my_rank = -1; static struct stat64 cp_stat_buf; +static int darshan_mem_alignment; /* these are paths that we will not trace */ static char* exclusions[] = { @@ -709,7 +710,7 @@ ssize_t __wrap_pread64(int fd, void *buf, size_t count, off64_t offset) int aligned_flag = 0; double tm1, tm2; - if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) + if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; tm1 = darshan_wtime(); @@ -727,7 +728,7 @@ ssize_t __wrap_pread(int fd, void *buf, size_t count, off_t offset) int aligned_flag = 0; double tm1, tm2; - if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) + if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; tm1 = darshan_wtime(); @@ -746,7 +747,7 @@ ssize_t __wrap_pwrite(int fd, const void *buf, size_t count, off_t offset) int aligned_flag = 0; double tm1, tm2; - if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) + if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; tm1 = darshan_wtime(); @@ -764,7 +765,7 @@ ssize_t __wrap_pwrite64(int fd, const void *buf, size_t count, off64_t offset) int aligned_flag = 0; double tm1, tm2; - if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) + if((unsigned long)buf % darshan_mem_alignment == 0) aligned_flag = 1; tm1 = darshan_wtime(); @@ -785,7 +786,7 @@ ssize_t __wrap_readv(int fd, const struct iovec *iov, int iovcnt) for(i=0; ifile_runtime_array[darshan_global_job->file_count]; - CP_SET(tmp_file, CP_MEM_ALIGNMENT, __CP_MEM_ALIGNMENT); + CP_SET(tmp_file, CP_MEM_ALIGNMENT, darshan_mem_alignment); tmp_file->log_file->hash = tmp_hash; /* record last N characters of file name too */ -- 2.26.2