Commit c2e58260 authored by Philip Carns's avatar Philip Carns

added collection of device id for each open file, bumped log version,

updated logutils to support new version and be backwards compatible


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@133 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 48baa063
......@@ -12,7 +12,7 @@
#include "darshan-config.h"
/* update this on file format changes */
#define CP_VERSION "1.22"
#define CP_VERSION "1.23"
/* size (in bytes) of job record */
#define CP_JOB_RECORD_SIZE 1024
......@@ -177,6 +177,7 @@ enum darshan_indices
CP_ACCESS2_COUNT,
CP_ACCESS3_COUNT,
CP_ACCESS4_COUNT,
CP_DEVICE, /* device id reported by stat */
CP_NUM_INDICES,
};
......
......@@ -6,6 +6,7 @@
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <stdlib.h>
#include "darshan-logutils.h"
/* isn't there a clever c way to avoid this? */
......@@ -148,6 +149,7 @@ char *darshan_names[] = {
"CP_ACCESS2_COUNT",
"CP_ACCESS3_COUNT",
"CP_ACCESS4_COUNT",
"CP_DEVICE",
"CP_NUM_INDICES"
};
......@@ -172,20 +174,43 @@ char *darshan_f_names[] = {
};
/*******************************
* version 1.21 to 1.22 differences
* version 1.22 to 1.23 differences
*
* - added:
* - CP_DEVICE
* - changed params:
* - CP_FILE_RECORD_SIZE: 1240 to 1244
* - CP_NUM_INDICES: 138 to 139
*/
#define CP_NUM_INDICES_1_22 138
struct darshan_file_1_22
{
uint64_t hash;
int rank;
int64_t counters[CP_NUM_INDICES_1_22];
double fcounters[CP_F_NUM_INDICES];
char name_suffix[CP_NAME_SUFFIX_LEN+1];
};
static void shift_missing_1_22(struct darshan_file* file);
/*******************************
* version 1.21 to 1.23 differences
* - added:
* - CP_INDEP_NC_OPENS
* - CP_COLL_NC_OPENS
* - CP_HDF5_OPENS
* - CP_MAX_READ_TIME_SIZE
* - CP_MAX_WRITE_TIME_SIZE
* - CP_DEVICE
* - CP_F_MAX_READ_TIME
* - CP_F_MAX_WRITE_TIME
* - changed params:
* - CP_FILE_RECORD_SIZE: 1184 to 1240
* - CP_NUM_INDICES: 133 to 138
* - CP_FILE_RECORD_SIZE: 1184 to 1244
* - CP_NUM_INDICES: 133 to 139
* - CP_F_NUM_INDICES: 12 to 14
* - so 56 bytes worth of new indices are the only difference
* - so 60 bytes worth of new indices are the only difference
*/
#define CP_NUM_INDICES_1_21 133
#define CP_F_NUM_INDICES_1_21 12
......@@ -246,6 +271,7 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_job *job, struct darshan_f
int ret;
const char* err_string;
struct darshan_file_1_21 file_1_21;
struct darshan_file_1_22 file_1_22;
if(gztell(file) < CP_JOB_RECORD_SIZE)
gzseek(file, CP_JOB_RECORD_SIZE, SEEK_SET);
......@@ -277,9 +303,28 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_job *job, struct darshan_f
}
}
else if(strcmp(job->version_string, "1.22") == 0)
{
ret = gzread(fd, &file_1_22, sizeof(file_1_22));
if(ret == sizeof(file_1_22))
{
/* convert to new file record structure */
file->hash = file_1_22.hash;
file->rank = file_1_22.rank;
strcpy(file->name_suffix, file_1_22.name_suffix);
memcpy(file->counters, file_1_22.counters,
(CP_NUM_INDICES_1_22*sizeof(int64_t)));
memcpy(file->fcounters, file_1_22.fcounters,
(CP_F_NUM_INDICES*sizeof(double)));
shift_missing_1_22(file);
/* got exactly one, correct size record */
return(1);
}
}
else if(strcmp(job->version_string, "1.23") == 0)
{
/* make sure this is the current version */
assert(strcmp("1.22", CP_VERSION) == 0);
assert(strcmp("1.23", CP_VERSION) == 0);
ret = gzread(fd, file, sizeof(*file));
if(ret == sizeof(*file))
......@@ -313,6 +358,83 @@ int darshan_log_getfile(darshan_fd fd, struct darshan_job *job, struct darshan_f
return(-1);
}
/* 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, int** devs, char*** mnt_pts, char***
fs_types, int* count, int *flag)
{
int ret;
char* pos;
int array_index = 0;
char buf[CP_EXE_LEN+1];
gzseek(fd, sizeof(struct darshan_job), SEEK_SET);
ret = gzread(fd, buf, (CP_EXE_LEN + 1));
if (ret < (CP_EXE_LEN + 1))
{
perror("gzread");
return(-1);
}
if (gzeof(fd))
*flag = 1;
else
*flag = 0;
/* count entries */
*count = 0;
pos = buf;
while((pos = strchr(pos, '\n')) != NULL)
{
pos++;
(*count)++;
}
if(*count == 0)
{
/* no mount entries present */
return(0);
}
/* allocate output arrays */
*devs = malloc((*count)*sizeof(int));
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(buf, '\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, "%d\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);
}
int darshan_log_getexe(darshan_fd fd, char *buf, int *flag)
{
int ret;
......@@ -392,6 +514,7 @@ static void shift_missing_1_21(struct darshan_file* file)
CP_HDF5_OPENS,
CP_MAX_READ_TIME_SIZE,
CP_MAX_WRITE_TIME_SIZE,
CP_DEVICE,
-1};
int missing_f_counters[] = {
CP_F_MAX_READ_TIME,
......@@ -432,3 +555,34 @@ static void shift_missing_1_21(struct darshan_file* file)
return;
}
/* shift_missing_1_22()
*
* translates indices to account for counters that weren't present in log
* format 1.22
*/
static void shift_missing_1_22(struct darshan_file* file)
{
int c_index = 0;
int missing_counters[] = {
CP_DEVICE,
-1};
c_index = 0;
while(missing_counters[c_index] != -1)
{
int missing_counter = missing_counters[c_index];
c_index++;
if(missing_counter < (CP_NUM_INDICES - 1))
{
/* shift down */
memmove(&file->counters[missing_counter+1],
&file->counters[missing_counter],
(CP_NUM_INDICES-missing_counter-1)*sizeof(int64_t));
}
/* zero out missing counter */
file->counters[missing_counter] = 0;
}
return;
}
......@@ -18,6 +18,8 @@ int darshan_log_getfile(darshan_fd fd,
struct darshan_job* job,
struct darshan_file *file);
int darshan_log_getexe(darshan_fd fd, char *buf, int *flag);
int darshan_log_getmounts(darshan_fd fd, int** devs, char*** mnt_pts, char***
fs_types, int* count, int *flag);
void darshan_log_close(darshan_fd file);
void darshan_log_print_version_warnings(struct darshan_job *job);
......
......@@ -11,6 +11,7 @@
#include <string.h>
#include <zlib.h>
#include <time.h>
#include <stdlib.h>
#include "darshan-logutils.h"
......@@ -24,6 +25,10 @@ int main(int argc, char **argv)
time_t tmp_time = 0;
darshan_fd file;
int i;
int mount_count;
int* devs;
char** mnt_pts;
char** fs_types;
if(argc != 2)
{
......@@ -58,6 +63,7 @@ int main(int argc, char **argv)
return(-1);
}
/* print job summary */
printf("# darshan log version: %s\n", job.version_string);
printf("# size of file statistics: %d bytes\n", sizeof(cp_file));
printf("# size of job statistics: %d bytes\n", sizeof(job));
......@@ -71,7 +77,22 @@ int main(int argc, char **argv)
printf("# end_time_asci: %s", ctime(&tmp_time));
printf("# nprocs: %d\n", job.nprocs);
printf("# run time: %ld\n", (long)(job.end_time - job.start_time + 1));
/* print table of mounted file systems */
ret = darshan_log_getmounts(file, &devs, &mnt_pts, &fs_types, &mount_count,
&no_files_flag);
printf("\n# mounted file systems (device, fs type, and mount point)\n");
printf("# -------------------------------------------------------\n");
for(i=0; i<mount_count; i++)
{
printf("# mount entry: %d\t%s\t%s\n", devs[i], mnt_pts[i], fs_types[i]);
free(mnt_pts[i]);
free(fs_types[i]);
}
free(devs);
free(mnt_pts);
free(fs_types);
if(no_files_flag)
{
/* it looks like the app didn't open any files */
......
......@@ -192,8 +192,10 @@ static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size,
if(file->fd != -1) break; /* TODO: handle multiple concurrent opens */ \
file->fd = __ret; \
if(!CP_VALUE(file, CP_FILE_ALIGNMENT)){ \
if(fstat(file->fd, &cp_stat_buf) == 0) \
if(fstat(file->fd, &cp_stat_buf) == 0) {\
CP_SET(file, CP_DEVICE, cp_stat_buf.st_dev); \
CP_SET(file, CP_FILE_ALIGNMENT, cp_stat_buf.st_blksize); \
}\
}\
file->log_file->rank = my_rank; \
if(__mode) \
......
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