Commit 3b978fa9 authored by Kevin Harms's avatar Kevin Harms

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
parent 1ffc9225
...@@ -12,6 +12,14 @@ ...@@ -12,6 +12,14 @@
#include <mpi.h> #include <mpi.h>
#include "darshan-log-format.h" #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 */ /* maximum number of files per process we will track */
#define CP_MAX_FILES 1024 #define CP_MAX_FILES 1024
......
...@@ -225,6 +225,8 @@ void darshan_shutdown(int timing_flag) ...@@ -225,6 +225,8 @@ void darshan_shutdown(int timing_flag)
int local_ret = 0; int local_ret = 0;
MPI_Offset next_offset = 0; MPI_Offset next_offset = 0;
char* jobid_str; char* jobid_str;
char* envjobid;
char* logpath;
int jobid; int jobid;
int index_count = 0; int index_count = 0;
int lengths[CP_MAX_MEM_SEGMENTS]; int lengths[CP_MAX_MEM_SEGMENTS];
...@@ -369,8 +371,22 @@ void darshan_shutdown(int timing_flag) ...@@ -369,8 +371,22 @@ void darshan_shutdown(int timing_flag)
char cuser[L_cuserid] = {0}; char cuser[L_cuserid] = {0};
struct tm* my_tm; 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 */ /* find a job id */
jobid_str = getenv(CP_JOBID); jobid_str = getenv(envjobid);
if(jobid_str) if(jobid_str)
{ {
/* in cobalt we can find it in env var */ /* in cobalt we can find it in env var */
...@@ -395,7 +411,7 @@ void darshan_shutdown(int timing_flag) ...@@ -395,7 +411,7 @@ void darshan_shutdown(int timing_flag)
ret = snprintf(logfile_name, PATH_MAX, ret = snprintf(logfile_name, PATH_MAX,
"%s/%d/%d/%d/%s_%s_id%d_%d-%d-%d-%llu.darshan_partial", "%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, (my_tm->tm_mon+1), my_tm->tm_mday,
cuser, __progname, jobid, cuser, __progname, jobid,
(my_tm->tm_mon+1), (my_tm->tm_mon+1),
...@@ -407,7 +423,7 @@ void darshan_shutdown(int timing_flag) ...@@ -407,7 +423,7 @@ void darshan_shutdown(int timing_flag)
/* file name was too big; squish it down */ /* file name was too big; squish it down */
snprintf(logfile_name, PATH_MAX, snprintf(logfile_name, PATH_MAX,
"%s/id%d.darshan_partial", "%s/id%d.darshan_partial",
__CP_LOG_PATH, jobid); logpath, jobid);
} }
/* add jobid */ /* add jobid */
......
...@@ -67,6 +67,7 @@ pthread_mutex_t cp_mutex = PTHREAD_MUTEX_INITIALIZER; ...@@ -67,6 +67,7 @@ pthread_mutex_t cp_mutex = PTHREAD_MUTEX_INITIALIZER;
struct darshan_job_runtime* darshan_global_job = NULL; struct darshan_job_runtime* darshan_global_job = NULL;
static int my_rank = -1; static int my_rank = -1;
static struct stat64 cp_stat_buf; static struct stat64 cp_stat_buf;
static int darshan_mem_alignment;
/* these are paths that we will not trace */ /* these are paths that we will not trace */
static char* exclusions[] = { static char* exclusions[] = {
...@@ -709,7 +710,7 @@ ssize_t __wrap_pread64(int fd, void *buf, size_t count, off64_t offset) ...@@ -709,7 +710,7 @@ ssize_t __wrap_pread64(int fd, void *buf, size_t count, off64_t offset)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -727,7 +728,7 @@ ssize_t __wrap_pread(int fd, void *buf, size_t count, off_t offset) ...@@ -727,7 +728,7 @@ ssize_t __wrap_pread(int fd, void *buf, size_t count, off_t offset)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -746,7 +747,7 @@ ssize_t __wrap_pwrite(int fd, const void *buf, size_t count, off_t offset) ...@@ -746,7 +747,7 @@ ssize_t __wrap_pwrite(int fd, const void *buf, size_t count, off_t offset)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -764,7 +765,7 @@ ssize_t __wrap_pwrite64(int fd, const void *buf, size_t count, off64_t offset) ...@@ -764,7 +765,7 @@ ssize_t __wrap_pwrite64(int fd, const void *buf, size_t count, off64_t offset)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -785,7 +786,7 @@ ssize_t __wrap_readv(int fd, const struct iovec *iov, int iovcnt) ...@@ -785,7 +786,7 @@ ssize_t __wrap_readv(int fd, const struct iovec *iov, int iovcnt)
for(i=0; i<iovcnt; i++) for(i=0; i<iovcnt; i++)
{ {
if(((unsigned long)iov[i].iov_base % __CP_MEM_ALIGNMENT) != 0) if(((unsigned long)iov[i].iov_base % darshan_mem_alignment) != 0)
aligned_flag = 0; aligned_flag = 0;
} }
...@@ -807,7 +808,7 @@ ssize_t __wrap_writev(int fd, const struct iovec *iov, int iovcnt) ...@@ -807,7 +808,7 @@ ssize_t __wrap_writev(int fd, const struct iovec *iov, int iovcnt)
for(i=0; i<iovcnt; i++) for(i=0; i<iovcnt; i++)
{ {
if(!((unsigned long)iov[i].iov_base % __CP_MEM_ALIGNMENT == 0)) if(!((unsigned long)iov[i].iov_base % darshan_mem_alignment == 0))
aligned_flag = 0; aligned_flag = 0;
} }
...@@ -826,7 +827,7 @@ size_t __wrap_fread(void *ptr, size_t size, size_t nmemb, FILE *stream) ...@@ -826,7 +827,7 @@ size_t __wrap_fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)ptr % __CP_MEM_ALIGNMENT == 0) if((unsigned long)ptr % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -847,7 +848,7 @@ ssize_t __wrap_read(int fd, void *buf, size_t count) ...@@ -847,7 +848,7 @@ ssize_t __wrap_read(int fd, void *buf, size_t count)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -865,7 +866,7 @@ ssize_t __wrap_write(int fd, const void *buf, size_t count) ...@@ -865,7 +866,7 @@ ssize_t __wrap_write(int fd, const void *buf, size_t count)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)buf % __CP_MEM_ALIGNMENT == 0) if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -883,7 +884,7 @@ size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) ...@@ -883,7 +884,7 @@ size_t __wrap_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
int aligned_flag = 0; int aligned_flag = 0;
double tm1, tm2; double tm1, tm2;
if((unsigned long)ptr % __CP_MEM_ALIGNMENT == 0) if((unsigned long)ptr % darshan_mem_alignment == 0)
aligned_flag = 1; aligned_flag = 1;
tm1 = darshan_wtime(); tm1 = darshan_wtime();
...@@ -985,6 +986,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank) ...@@ -985,6 +986,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
int i; int i;
char* disable; char* disable;
char* disable_timing; char* disable_timing;
char* envstr;
char* truncate_string = "<TRUNCATED>"; char* truncate_string = "<TRUNCATED>";
int truncate_offset; int truncate_offset;
int chars_left = 0; int chars_left = 0;
...@@ -1003,6 +1005,16 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank) ...@@ -1003,6 +1005,16 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
return; return;
} }
envstr = getenv("DARSHAN_MEMALIGN");
if (envstr)
{
sscanf(envstr, "%d", &darshan_mem_alignment);
}
else
{
darshan_mem_alignment = __CP_MEM_ALIGNMENT;
}
/* allocate structure to track darshan_global_job information */ /* allocate structure to track darshan_global_job information */
darshan_global_job = malloc(sizeof(*darshan_global_job)); darshan_global_job = malloc(sizeof(*darshan_global_job));
if(!darshan_global_job) if(!darshan_global_job)
...@@ -1212,7 +1224,7 @@ struct darshan_file_runtime* darshan_file_by_name(const char* name) ...@@ -1212,7 +1224,7 @@ struct darshan_file_runtime* darshan_file_by_name(const char* name)
/* new, unique file */ /* new, unique file */
tmp_file = &darshan_global_job->file_runtime_array[darshan_global_job->file_count]; tmp_file = &darshan_global_job->file_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; tmp_file->log_file->hash = tmp_hash;
/* record last N characters of file name too */ /* record last N characters of file name too */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment