Commit 9d7f638b authored by Shane Snyder's avatar Shane Snyder

change util record ref structure def

parent cb1c7ace
...@@ -148,13 +148,13 @@ void obfuscate_filenames(int key, struct darshan_record_ref *rec_hash) ...@@ -148,13 +148,13 @@ void obfuscate_filenames(int key, struct darshan_record_ref *rec_hash)
HASH_ITER(hlink, rec_hash, ref, tmp) HASH_ITER(hlink, rec_hash, ref, tmp)
{ {
hashed = darshan_hashlittle(ref->rec.name, strlen(ref->rec.name), key); hashed = darshan_hashlittle(ref->name, strlen(ref->name), key);
sprintf(tmp_string, "%u", hashed); sprintf(tmp_string, "%u", hashed);
free(ref->rec.name); free(ref->name);
ref->rec.name = malloc(strlen(tmp_string) + 1); ref->name = malloc(strlen(tmp_string) + 1);
assert(ref->rec.name); assert(ref->name);
memcpy(ref->rec.name, tmp_string, strlen(tmp_string)); memcpy(ref->name, tmp_string, strlen(tmp_string));
ref->rec.name[strlen(tmp_string)] = '\0'; ref->name[strlen(tmp_string)] = '\0';
} }
return; return;
...@@ -208,10 +208,10 @@ static void remove_hash_recs(struct darshan_record_ref **rec_hash, darshan_recor ...@@ -208,10 +208,10 @@ static void remove_hash_recs(struct darshan_record_ref **rec_hash, darshan_recor
HASH_ITER(hlink, *rec_hash, ref, tmp) HASH_ITER(hlink, *rec_hash, ref, tmp)
{ {
if(ref->rec.id != hash) if(ref->id != hash)
{ {
HASH_DELETE(hlink, *rec_hash, ref); HASH_DELETE(hlink, *rec_hash, ref);
free(ref->rec.name); free(ref->name);
free(ref); free(ref);
} }
} }
...@@ -403,7 +403,7 @@ int main(int argc, char **argv) ...@@ -403,7 +403,7 @@ int main(int argc, char **argv)
HASH_ITER(hlink, rec_hash, ref, tmp) HASH_ITER(hlink, rec_hash, ref, tmp)
{ {
HASH_DELETE(hlink, rec_hash, ref); HASH_DELETE(hlink, rec_hash, ref);
free(ref->rec.name); free(ref->name);
free(ref); free(ref);
} }
......
...@@ -589,8 +589,8 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash) ...@@ -589,8 +589,8 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
free(hash_buf); free(hash_buf);
return(-1); return(-1);
} }
ref->rec.name = malloc(strlen(path_ptr) + 1); ref->name = malloc(strlen(path_ptr) + 1);
if(!ref->rec.name) if(!ref->name)
{ {
free(ref); free(ref);
free(hash_buf); free(hash_buf);
...@@ -598,11 +598,11 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash) ...@@ -598,11 +598,11 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
} }
/* set the fields for this record */ /* set the fields for this record */
ref->rec.id = *rec_id_ptr; ref->id = *rec_id_ptr;
strcpy(ref->rec.name, path_ptr); strcpy(ref->name, path_ptr);
/* add this record to the hash */ /* add this record to the hash */
HASH_ADD(hlink, *hash, rec.id, sizeof(darshan_record_id), ref); HASH_ADD(hlink, *hash, id, sizeof(darshan_record_id), ref);
} }
buf_ptr += strlen(path_ptr) + 1; buf_ptr += strlen(path_ptr) + 1;
...@@ -658,10 +658,10 @@ int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash) ...@@ -658,10 +658,10 @@ int darshan_log_puthash(darshan_fd fd, struct darshan_record_ref *hash)
* NOTE: darshan record hash serialization method: * NOTE: darshan record hash serialization method:
* ... darshan_record_id | path '\0' ... * ... darshan_record_id | path '\0' ...
*/ */
*((darshan_record_id *)buf_ptr) = ref->rec.id; *((darshan_record_id *)buf_ptr) = ref->id;
buf_ptr += sizeof(darshan_record_id); buf_ptr += sizeof(darshan_record_id);
strcpy(buf_ptr, ref->rec.name); strcpy(buf_ptr, ref->name);
buf_ptr += strlen(ref->rec.name) + 1; buf_ptr += strlen(ref->name) + 1;
/* write this hash entry to log file */ /* write this hash entry to log file */
wrote = darshan_log_dzwrite(fd, DARSHAN_REC_MAP_REGION_ID, wrote = darshan_log_dzwrite(fd, DARSHAN_REC_MAP_REGION_ID,
...@@ -1146,10 +1146,8 @@ static void darshan_log_dzdestroy(darshan_fd fd) ...@@ -1146,10 +1146,8 @@ static void darshan_log_dzdestroy(darshan_fd fd)
break; break;
#endif #endif
case DARSHAN_NO_COMP: case DARSHAN_NO_COMP:
{
/* do nothing */ /* do nothing */
break; break;
}
default: default:
fprintf(stderr, "Error: invalid compression type.\n"); fprintf(stderr, "Error: invalid compression type.\n");
} }
...@@ -1192,10 +1190,8 @@ static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len) ...@@ -1192,10 +1190,8 @@ static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len)
break; break;
#endif #endif
case DARSHAN_NO_COMP: case DARSHAN_NO_COMP:
{
ret = darshan_log_noz_read(fd, map, buf, len, reset_strm_flag); ret = darshan_log_noz_read(fd, map, buf, len, reset_strm_flag);
break; break;
}
default: default:
fprintf(stderr, "Error: invalid compression type.\n"); fprintf(stderr, "Error: invalid compression type.\n");
return(-1); return(-1);
......
...@@ -43,7 +43,8 @@ typedef struct darshan_fd_s* darshan_fd; ...@@ -43,7 +43,8 @@ typedef struct darshan_fd_s* darshan_fd;
struct darshan_record_ref struct darshan_record_ref
{ {
struct darshan_record rec; char *name;
darshan_record_id id;
UT_hash_handle hlink; UT_hash_handle hlink;
}; };
......
...@@ -412,7 +412,7 @@ int main(int argc, char **argv) ...@@ -412,7 +412,7 @@ int main(int argc, char **argv)
/* get mount point and fs type associated with this record */ /* get mount point and fs type associated with this record */
for(j=0; j<mount_count; j++) for(j=0; j<mount_count; j++)
{ {
if(strncmp(mnt_pts[j], ref->rec.name, strlen(mnt_pts[j])) == 0) if(strncmp(mnt_pts[j], ref->name, strlen(mnt_pts[j])) == 0)
{ {
mnt_pt = mnt_pts[j]; mnt_pt = mnt_pts[j];
fs_type = fs_types[j]; fs_type = fs_types[j];
...@@ -427,7 +427,7 @@ int main(int argc, char **argv) ...@@ -427,7 +427,7 @@ int main(int argc, char **argv)
if(mask & OPTION_BASE) if(mask & OPTION_BASE)
{ {
/* print the corresponding module data for this record */ /* print the corresponding module data for this record */
mod_logutils[i]->log_print_record(mod_buf, ref->rec.name, mod_logutils[i]->log_print_record(mod_buf, ref->name,
mnt_pt, fs_type); mnt_pt, fs_type);
} }
...@@ -623,7 +623,7 @@ cleanup: ...@@ -623,7 +623,7 @@ cleanup:
HASH_ITER(hlink, rec_hash, ref, tmp_ref) HASH_ITER(hlink, rec_hash, ref, tmp_ref)
{ {
HASH_DELETE(hlink, rec_hash, ref); HASH_DELETE(hlink, rec_hash, ref);
free(ref->rec.name); free(ref->name);
free(ref); free(ref);
} }
...@@ -1461,7 +1461,7 @@ void posix_file_list(hash_entry_t *file_hash, ...@@ -1461,7 +1461,7 @@ void posix_file_list(hash_entry_t *file_hash,
printf("%" PRIu64 "\t%s\t%" PRId64 "\t%f\t%f", printf("%" PRIu64 "\t%s\t%" PRId64 "\t%f\t%f",
curr->rec_id, curr->rec_id,
ref->rec.name, ref->name,
curr->procs, curr->procs,
curr->slowest_time, curr->slowest_time,
curr->cumul_time/(double)curr->procs); curr->cumul_time/(double)curr->procs);
...@@ -1555,7 +1555,7 @@ void mpiio_file_list(hash_entry_t *file_hash, ...@@ -1555,7 +1555,7 @@ void mpiio_file_list(hash_entry_t *file_hash,
printf("%" PRIu64 "\t%s\t%" PRId64 "\t%f\t%f", printf("%" PRIu64 "\t%s\t%" PRId64 "\t%f\t%f",
curr->rec_id, curr->rec_id,
ref->rec.name, ref->name,
curr->procs, curr->procs,
curr->slowest_time, curr->slowest_time,
curr->cumul_time/(double)curr->procs); curr->cumul_time/(double)curr->procs);
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#include <glob.h>
#include <string.h> #include <string.h>
#include <getopt.h>
#include <glob.h>
#include "darshan-logutils.h" #include "darshan-logutils.h"
#define DEF_MOD_BUF_SIZE 1024 /* 1 KiB is enough for all current mod records ... */ #define DEF_MOD_BUF_SIZE 1024 /* 1 KiB is enough for all current mod records ... */
/* TODO: are there any checks we should do to ensure tmp logs belong to the same job */
/* we can't specifically check the job id, since the pid is used if no job scheduler */
/* TODO: how do we set the output logfile name to be unique, and have necessary semantic info contained */
void usage(char *exename)
{
fprintf(stderr, "Usage: %s [options] <tmp_dir> <job_id>\n", exename);
fprintf(stderr, " TODO: description.\n");
fprintf(stderr, " --shared-redux Reduce globally shared records into a single record.\n");
exit(1);
}
void parse_args(int argc, char **argv, char **tmplog_dir, int *tmplog_jobid,
int *shared_redux)
{
int index;
static struct option long_opts[] =
{
{"shared-redux", no_argument, NULL, 's'},
{0, 0, 0, 0}
};
*shared_redux = 0;
while(1)
{
int c = getopt_long(argc, argv, "", long_opts, &index);
if(c == -1) break;
switch(c)
{
case 's':
*shared_redux = 1;
break;
case '?':
default:
usage(argv[0]);
break;
}
}
if(optind + 2 == argc)
{
*tmplog_dir = argv[optind];
*tmplog_jobid = atoi(argv[optind+1]);
}
else
{
usage(argv[0]);
}
return;
}
int logfile_path_comp(const void *a, const void *b) int logfile_path_comp(const void *a, const void *b)
{ {
char *pathA = *(char **)a; char *pathA = *(char **)a;
...@@ -31,6 +89,7 @@ int logfile_path_comp(const void *a, const void *b) ...@@ -31,6 +89,7 @@ int logfile_path_comp(const void *a, const void *b)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int shared_redux;
char *tmplog_dir; char *tmplog_dir;
int job_id; int job_id;
glob_t globbuf; glob_t globbuf;
...@@ -50,22 +109,8 @@ int main(int argc, char *argv[]) ...@@ -50,22 +109,8 @@ int main(int argc, char *argv[])
int i, j; int i, j;
int ret; int ret;
/* TODO: are there any checks we should do to ensure tmp logs belong to the same job */
/* we can't specifically check the job id, since the pid is used if no job scheduler */
/* TODO: how do we set the output logfile name to be unique, and have necessary semantic info contained */
if(argc != 3)
{
fprintf(stderr, "Usage: ./darshan-stitch-tmplogs <tmp_dir> <job_id>\n"
"\t<tmp_dir> is the directory containing the temporary Darshan logs\n"
"\t<job_id> is the job id of the logs we are trying to stitch\n");
return(0);
}
/* grab command line arguments */ /* grab command line arguments */
tmplog_dir = argv[1]; parse_args(argc, argv, &tmplog_dir, &job_id, &shared_redux);
job_id = atoi(argv[2]);
/* construct the list of input log files to stitch together */ /* construct the list of input log files to stitch together */
snprintf(glob_pstr, 512, "%s/darshan_job%d*", tmplog_dir, job_id); snprintf(glob_pstr, 512, "%s/darshan_job%d*", tmplog_dir, job_id);
...@@ -169,14 +214,12 @@ int main(int argc, char *argv[]) ...@@ -169,14 +214,12 @@ int main(int argc, char *argv[])
*/ */
HASH_ITER(hlink, in_hash, ref, tmp) HASH_ITER(hlink, in_hash, ref, tmp)
{ {
HASH_FIND(hlink, stitch_hash, &(ref->rec.id), HASH_FIND(hlink, stitch_hash, &(ref->id), sizeof(darshan_record_id), found);
sizeof(darshan_record_id), found);
if(!found) if(!found)
{ {
HASH_ADD(hlink, stitch_hash, rec.id, HASH_ADD(hlink, stitch_hash, id, sizeof(darshan_record_id), ref);
sizeof(darshan_record_id), ref);
} }
else if(strcmp(ref->rec.name, found->rec.name)) else if(strcmp(ref->name, found->name))
{ {
fprintf(stderr, fprintf(stderr,
"Error: invalid Darshan record table entry.\n"); "Error: invalid Darshan record table entry.\n");
...@@ -250,25 +293,30 @@ int main(int argc, char *argv[]) ...@@ -250,25 +293,30 @@ int main(int argc, char *argv[])
} }
memset(mod_buf, 0, DEF_MOD_BUF_SIZE); memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
/* iterate over active darshan modules and gather module data to write
* to the stitched together output log
*/
for(i = 0; i < DARSHAN_MPIIO_MOD; i++) for(i = 0; i < DARSHAN_MPIIO_MOD; i++)
{ {
if(!mod_logutils[i]) continue; if(!mod_logutils[i]) continue;
#if 0 if(shared_redux)
/* XXX first build shared record list? */
for(j = 0; j < globbuf.gl_pathc; j++)
{ {
/* copy all root's file records into an array */
} /* compare and updated shared records? */
for(j = 1; j < globbuf.gl_pathc; j++)
{
}
/* XXX second aggregate shared records ? */ /* XXX aggregate shared records? */
for(j = 0; j < globbuf.gl_pathc; j++) for(j = 0; j < globbuf.gl_pathc; j++)
{ {
}
} }
#endif
/* XXX third write each rank's blobs, with rank 0 writing the shared ones ? */ /* XXX third write each rank's blobs, with rank 0 writing the shared ones? */
for(j = 0; j < globbuf.gl_pathc; j++) for(j = 0; j < globbuf.gl_pathc; j++)
{ {
in_fd = darshan_log_open(globbuf.gl_pathv[j]); in_fd = darshan_log_open(globbuf.gl_pathv[j]);
......
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