Commit 756b640d authored by Shane Snyder's avatar Shane Snyder

updated runtime/util to use exe/mount info

parent 01812211
......@@ -36,7 +36,6 @@ typedef uint64_t darshan_record_id;
/* NOTES: - valid ids range from [0...DARSHAN_MAX_MODS-1]
* - order of ids control module shutdown order (and consequently, order in log file)
*/
/* TODO: enforce maximum? */
#define DARSHAN_MAX_MODS 16
typedef enum
{
......@@ -84,7 +83,7 @@ struct darshan_job
int64_t end_time;
int64_t nprocs;
int64_t jobid;
char metadata[DARSHAN_JOB_METADATA_LEN]; /* TODO: what is this? */
char metadata[DARSHAN_JOB_METADATA_LEN];
};
struct darshan_record
......
......@@ -22,14 +22,14 @@ struct darshan_core_module
};
/* in memory structure to keep up with job level data */
/* TODO: trailing data ? */
struct darshan_core_runtime
{
struct darshan_job log_job;
char exe[CP_EXE_LEN+1];
double wtime_offset;
struct darshan_core_record_ref *rec_hash;
struct darshan_core_module* mod_array[DARSHAN_MAX_MODS];
double wtime_offset;
char *trailing_data;
};
struct darshan_core_record_ref
......
......@@ -407,7 +407,6 @@ behavior at runtime:
* DARSHAN_DISABLE: disables Darshan instrumentation
* DARSHAN_INTERNAL_TIMING: enables internal instrumentation that will print the time required to startup and shutdown Darshan to stderr at run time.
* DARSHAN_LOGHINTS: specifies the MPI-IO hints to use when storing the Darshan output file. The format is a semicolon-delimited list of key=value pairs, for example: hint1=value1;hint2=value2
* DARSHAN_DISABLE_TIMING: disables the subset of Darshan instrumentation that gathers timing information
* DARSHAN_MEMALIGN: specifies a value for memory alignment (CP_MEM_ALIGNMENT)
* DARSHAN_JOBID: specifies the name of the environment variable to use for the job identifier, such as PBS_JOBID
* DARSHAN_DISABLE_SHARED_REDUCTION: disables the step in Darshan aggregation
......
This diff is collapsed.
......@@ -27,10 +27,9 @@ struct darshan_fd_s
{
int pf;
int64_t pos;
char mode[2];
int swap_flag;
char version[8];
char* name;
int swap_flag;
char *exe_mnt_data;
struct darshan_log_map job_map;
struct darshan_log_map rec_map;
struct darshan_log_map mod_map[DARSHAN_MAX_MODS];
......@@ -64,21 +63,9 @@ darshan_fd darshan_log_open(const char *name, const char *mode)
return(NULL);
memset(tmp_fd, 0, sizeof(*tmp_fd));
/* TODO: why is mode needed??? */
/* TODO: why is name needed??? */
tmp_fd->mode[0] = mode[0];
tmp_fd->mode[1] = mode[1];
tmp_fd->name = strdup(name);
if(!tmp_fd->name)
{
free(tmp_fd);
return(NULL);
}
tmp_fd->pf = open(name, o_flags);
if(tmp_fd->pf < 0)
{
free(tmp_fd->name);
free(tmp_fd);
return(NULL);
}
......@@ -163,6 +150,7 @@ int darshan_log_getheader(darshan_fd fd, struct darshan_header *header)
*/
int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
{
char job_buf[CP_JOB_RECORD_SIZE] = {0};
int ret;
ret = darshan_log_seek(fd, fd->job_map.off);
......@@ -173,13 +161,15 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
}
/* read the job data from the log file */
ret = darshan_log_read(fd, job, fd->job_map.len);
ret = darshan_log_read(fd, job_buf, fd->job_map.len);
if(ret < fd->job_map.len)
{
fprintf(stderr, "Error: invalid darshan log file (failed to read job data).\n");
return(-1);
}
memcpy(job, job_buf, sizeof(*job));
if(fd->swap_flag)
{
/* swap bytes if necessary */
......@@ -190,6 +180,131 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
DARSHAN_BSWAP64(&job->jobid);
}
/* save trailing job data, so exe and mount information can be retrieved later */
fd->exe_mnt_data = malloc(CP_EXE_LEN+1);
if(!fd->exe_mnt_data)
return(-1);
memcpy(fd->exe_mnt_data, &job_buf[sizeof(*job)], CP_EXE_LEN+1);
return(0);
}
#if 0
#ifdef HAVE_STRNDUP
metadata = strndup(job->metadata, sizeof(job->metadata));
#else
metadata = strdup(job->metadata);
#endif
char *kv;
char *key;
char *value;
char *save;
for(kv=strtok_r(metadata, "\n", &save);
kv != NULL;
kv=strtok_r(NULL, "\n", &save))
{
/* NOTE: we intentionally only split on the first = character.
* There may be additional = characters in the value portion
* (for example, when storing mpi-io hints).
*/
strcpy(buffer, kv);
key = buffer;
value = index(buffer, '=');
if(!value)
continue;
/* convert = to a null terminator to split key and value */
value[0] = '\0';
value++;
if (strcmp(key, "prev_ver") == 0)
{
strncpy(job->version_string, value, sizeof(job->version_string));
}
}
free(metadata);
#endif
int darshan_log_getexe(darshan_fd fd, char *buf)
{
char *newline;
/* TODO: try reading log job one more time to set this buffer up */
if(!fd->exe_mnt_data)
return(-1);
newline = strchr(fd->exe_mnt_data, '\n');
/* copy over the exe string */
if(newline)
memcpy(buf, fd->exe_mnt_data, (newline - fd->exe_mnt_data));
return (0);
}
/* darshan_log_getmounts()
*
* retrieves mount table information from the log. Note that devs, mnt_pts,
* and fs_types are arrays that will be allocated by the function and must
* be freed by the caller. count will indicate the size of the arrays
*/
int darshan_log_getmounts(darshan_fd fd, int64_t** devs, char*** mnt_pts,
char*** fs_types, int* count)
{
int ret;
char *pos;
int array_index = 0;
/* TODO: try reading log job one more time to set this buffer up */
if(!fd->exe_mnt_data)
return(-1);
/* count entries */
*count = 0;
pos = fd->exe_mnt_data;
while((pos = strchr(pos, '\n')) != NULL)
{
pos++;
(*count)++;
}
if(*count == 0)
{
/* no mount entries present */
return(0);
}
/* allocate output arrays */
*devs = malloc((*count)*sizeof(int64_t));
assert(*devs);
*mnt_pts = malloc((*count)*sizeof(char*));
assert(*mnt_pts);
*fs_types = malloc((*count)*sizeof(char*));
assert(*fs_types);
/* work backwards through the table and parse each line (except for
* first, which holds command line information)
*/
while((pos = strrchr(fd->exe_mnt_data, '\n')) != NULL)
{
/* overestimate string lengths */
(*mnt_pts)[array_index] = malloc(CP_EXE_LEN);
assert((*mnt_pts)[array_index]);
(*fs_types)[array_index] = malloc(CP_EXE_LEN);
assert((*fs_types)[array_index]);
ret = sscanf(++pos, "%" PRId64 "\t%s\t%s", &(*devs)[array_index],
(*fs_types)[array_index], (*mnt_pts)[array_index]);
if(ret != 3)
{
fprintf(stderr, "Error: poorly formatted mount table in log file.\n");
return(-1);
}
pos--;
*pos = '\0';
array_index++;
}
return(0);
}
......@@ -340,35 +455,6 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_posix_file *file)
return(-1);
}
#if 0
int darshan_log_getexe(darshan_fd fd, char *buf)
{
int ret;
char* newline;
ret = darshan_log_seek(fd, fd->job_struct_size);
if(ret < 0)
return(ret);
ret = darshan_log_read(fd, buf, (fd->COMPAT_CP_EXE_LEN + 1));
if (ret < (fd->COMPAT_CP_EXE_LEN + 1))
{
perror("darshan_log_read");
return(-1);
}
/* this call is only supposed to return the exe string, but starting in
* log format 1.23 there could be a table of mount entry information
* after the exe. Look for newline character and truncate there.
*/
newline = strchr(buf, '\n');
if(newline)
*newline = '\0';
return (0);
}
#endif
/* darshan_log_close()
*
* close an open darshan file descriptor
......@@ -380,7 +466,9 @@ void darshan_log_close(darshan_fd fd)
if(fd->pf)
close(fd->pf);
free(fd->name);
if(fd->exe_mnt_data)
free(fd->exe_mnt_data);
free(fd);
}
......
......@@ -22,17 +22,10 @@ darshan_fd darshan_log_open(const char *name, const char* mode);
int darshan_log_getheader(darshan_fd file, struct darshan_header *header);
int darshan_log_getjob(darshan_fd file, struct darshan_job *job);
int darshan_log_gethash(darshan_fd file, struct darshan_record_ref **hash);
#if 0
int darshan_log_getfile(darshan_fd fd,
struct darshan_job* job,
struct darshan_file *file);
int darshan_log_getfile(darshan_fd fd, struct darshan_posix_file *file);
int darshan_log_getexe(darshan_fd fd, char *buf);
int darshan_log_getmounts(darshan_fd fd,
int64_t** devs,
char*** mnt_pts,
char*** fs_types,
int* count);
#endif
int darshan_log_getmounts(darshan_fd fd, int64_t** devs, char*** mnt_pts,
char*** fs_types, int* count);
void darshan_log_close(darshan_fd file);
/* convenience macros for printing out counters */
......
......@@ -21,6 +21,7 @@
int main(int argc, char **argv)
{
int ret;
int i;
char *filename;
char tmp_string[4096];
darshan_fd file;
......@@ -28,8 +29,15 @@ int main(int argc, char **argv)
struct darshan_job job;
struct darshan_record_ref *rec_hash = NULL;
struct darshan_record_ref *ref, *tmp;
int mount_count;
int64_t* devs;
char** mnt_pts;
char** fs_types;
struct darshan_posix_file next_rec;
time_t tmp_time = 0;
char *token;
char *save;
char buffer[DARSHAN_JOB_METADATA_LEN];
assert(argc == 2);
filename = argv[1];
......@@ -62,6 +70,15 @@ int main(int argc, char **argv)
return(-1);
}
/* get the original command line for this job */
ret = darshan_log_getexe(file, tmp_string);
if(ret < 0)
{
fprintf(stderr, "Error: unable to read trailing job information.\n");
darshan_log_close(file);
return(-1);
}
/* print job summary */
printf("# darshan log version: %s\n", header.version_string);
printf("# size of POSIX file statistics: %zu bytes\n", sizeof(next_rec));
......@@ -78,6 +95,43 @@ int main(int argc, char **argv)
printf("# end_time_asci: %s", ctime(&tmp_time));
printf("# nprocs: %" PRId64 "\n", job.nprocs);
printf("# run time: %" PRId64 "\n", job.end_time - job.start_time + 1);
for(token=strtok_r(job.metadata, "\n", &save);
token != NULL;
token=strtok_r(NULL, "\n", &save))
{
char *key;
char *value;
/* NOTE: we intentionally only split on the first = character.
* There may be additional = characters in the value portion
* (for example, when storing mpi-io hints).
*/
strcpy(buffer, token);
key = buffer;
value = index(buffer, '=');
if(!value)
continue;
/* convert = to a null terminator to split key and value */
value[0] = '\0';
value++;
printf("# metadata: %s = %s\n", key, value);
}
/* get the mount information for this log */
ret = darshan_log_getmounts(file, &devs, &mnt_pts, &fs_types, &mount_count);
if(ret < 0)
{
fprintf(stderr, "darshan_log_getmounts() failed to read mount information.\n");
darshan_log_close(file);
return(-1);
}
/* print table of mounted file systems */
printf("\n# mounted file systems (device, mount point, and fs type)\n");
printf("# -------------------------------------------------------\n");
for(i=0; i<mount_count; i++)
{
printf("# mount entry: %" PRId64 "\t%s\t%s\n", devs[i], mnt_pts[i], fs_types[i]);
}
/* read hash of darshan records */
ret = darshan_log_gethash(file, &rec_hash);
......@@ -106,7 +160,7 @@ int main(int argc, char **argv)
/* iterate the posix file records stored in the darshan log */
printf("\n*** FILE RECORD DATA ***\n");
int i = 0;
i = 0;
do{
struct darshan_record_ref *ref;
......
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