Commit ab32cf66 authored by Shane Snyder's avatar Shane Snyder
Browse files

port utilities to new log get record interface

parent f21728f3
...@@ -38,12 +38,13 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p ...@@ -38,12 +38,13 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
struct darshan_job job; struct darshan_job job;
struct darshan_mod_logutil_funcs *psx_mod = mod_logutils[DARSHAN_POSIX_MOD]; struct darshan_mod_logutil_funcs *psx_mod = mod_logutils[DARSHAN_POSIX_MOD];
struct darshan_posix_file psx_rec; struct darshan_posix_file psx_rec;
void *psx_rec_p = &psx_rec;
int f_count; int f_count;
double total_io_time; double total_io_time;
double total_job_time; double total_job_time;
assert(psx_mod); assert(psx_mod);
memset(&psx_rec, 0, sizeof(struct darshan_posix_file)); memset(psx_rec_p, 0, sizeof(struct darshan_posix_file));
file = darshan_log_open(fname); file = darshan_log_open(fname);
if (file == NULL) if (file == NULL)
...@@ -63,7 +64,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p ...@@ -63,7 +64,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
f_count = 0; f_count = 0;
total_io_time = 0.0; total_io_time = 0.0;
while((ret = psx_mod->log_get_record(file, &psx_rec)) == 1) while((ret = psx_mod->log_get_record(file, &psx_rec_p)) == 1)
{ {
f_count += 1; f_count += 1;
...@@ -76,7 +77,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p ...@@ -76,7 +77,7 @@ int process_log(const char *fname, double *io_ratio, int *used_mpio, int *used_p
psx_rec.fcounters[POSIX_F_WRITE_TIME] + psx_rec.fcounters[POSIX_F_WRITE_TIME] +
psx_rec.fcounters[POSIX_F_META_TIME]); psx_rec.fcounters[POSIX_F_META_TIME]);
memset(&psx_rec, 0, sizeof(struct darshan_posix_file)); memset(psx_rec_p, 0, sizeof(struct darshan_posix_file));
} }
if (ret < 0) if (ret < 0)
{ {
......
...@@ -258,7 +258,7 @@ int main(int argc, char **argv) ...@@ -258,7 +258,7 @@ int main(int argc, char **argv)
struct darshan_mnt_info *mnt_data_array; struct darshan_mnt_info *mnt_data_array;
struct darshan_name_record_ref *name_hash = NULL; struct darshan_name_record_ref *name_hash = NULL;
struct darshan_name_record_ref *ref, *tmp; struct darshan_name_record_ref *ref, *tmp;
char mod_buf[DEF_MOD_BUF_SIZE]; char *mod_buf;
enum darshan_comp_type comp_type; enum darshan_comp_type comp_type;
int bzip2; int bzip2;
int obfuscate; int obfuscate;
...@@ -363,6 +363,14 @@ int main(int argc, char **argv) ...@@ -363,6 +363,14 @@ int main(int argc, char **argv)
return(-1); return(-1);
} }
mod_buf = malloc(DEF_MOD_BUF_SIZE);
if(!mod_buf)
{
darshan_log_close(infile);
darshan_log_close(outfile);
return(-1);
}
/* loop over each module and convert it's data to the new format */ /* loop over each module and convert it's data to the new format */
for(i=0; i<DARSHAN_MAX_MODS; i++) for(i=0; i<DARSHAN_MAX_MODS; i++)
{ {
...@@ -381,7 +389,7 @@ int main(int argc, char **argv) ...@@ -381,7 +389,7 @@ int main(int argc, char **argv)
/* we have module data to convert */ /* we have module data to convert */
memset(mod_buf, 0, DEF_MOD_BUF_SIZE); memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
ret = mod_logutils[i]->log_get_record(infile, mod_buf); ret = mod_logutils[i]->log_get_record(infile, (void **)&mod_buf);
if(ret != 1) if(ret != 1)
{ {
fprintf(stderr, "Error: failed to parse the first %s module record.\n", fprintf(stderr, "Error: failed to parse the first %s module record.\n",
...@@ -409,7 +417,7 @@ int main(int argc, char **argv) ...@@ -409,7 +417,7 @@ int main(int argc, char **argv)
memset(mod_buf, 0, DEF_MOD_BUF_SIZE); memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
} }
} while((ret = mod_logutils[i]->log_get_record(infile, mod_buf)) == 1); } while((ret = mod_logutils[i]->log_get_record(infile, (void **)&mod_buf)) == 1);
} }
darshan_log_close(infile); darshan_log_close(infile);
...@@ -425,6 +433,8 @@ int main(int argc, char **argv) ...@@ -425,6 +433,8 @@ int main(int argc, char **argv)
free(ref); free(ref);
} }
free(mod_buf);
return(ret); return(ret);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
struct darshan_mod_record_ref struct darshan_mod_record_ref
{ {
int rank; int rank;
char mod_dat[DEF_MOD_BUF_SIZE]; char *mod_dat;
struct darshan_mod_record_ref *prev; struct darshan_mod_record_ref *prev;
struct darshan_mod_record_ref *next; struct darshan_mod_record_ref *next;
}; };
...@@ -269,6 +269,7 @@ int main(int argc, char *argv[]) ...@@ -269,6 +269,7 @@ int main(int argc, char *argv[])
mod_rec1->next->prev = mod_rec1->prev; mod_rec1->next->prev = mod_rec1->prev;
rec_ref1->mod_recs[i] = mod_rec1->next; rec_ref1->mod_recs[i] = mod_rec1->next;
} }
free(mod_rec1->mod_dat);
free(mod_rec1); free(mod_rec1);
} }
if(mod_buf2) if(mod_buf2)
...@@ -283,6 +284,7 @@ int main(int argc, char *argv[]) ...@@ -283,6 +284,7 @@ int main(int argc, char *argv[])
mod_rec2->next->prev = mod_rec2->prev; mod_rec2->next->prev = mod_rec2->prev;
rec_ref2->mod_recs[i] = mod_rec2->next; rec_ref2->mod_recs[i] = mod_rec2->next;
} }
free(mod_rec2->mod_dat);
free(mod_rec2); free(mod_rec2);
} }
} }
...@@ -327,6 +329,7 @@ int main(int argc, char *argv[]) ...@@ -327,6 +329,7 @@ int main(int argc, char *argv[])
mod_rec2->next->prev = mod_rec2->prev; mod_rec2->next->prev = mod_rec2->prev;
rec_ref2->mod_recs[i] = mod_rec2->next; rec_ref2->mod_recs[i] = mod_rec2->next;
} }
free(mod_rec2->mod_dat);
free(mod_rec2); free(mod_rec2);
} }
} }
...@@ -377,16 +380,18 @@ static int darshan_build_global_record_hash( ...@@ -377,16 +380,18 @@ static int darshan_build_global_record_hash(
assert(mod_rec); assert(mod_rec);
memset(mod_rec, 0, sizeof(struct darshan_mod_record_ref)); memset(mod_rec, 0, sizeof(struct darshan_mod_record_ref));
ret = mod_logutils[i]->log_get_record(fd, mod_rec->mod_dat); ret = mod_logutils[i]->log_get_record(fd, (void **)&(mod_rec->mod_dat));
if(ret < 0) if(ret < 0)
{ {
fprintf(stderr, "Error: unable to read module %s data from log file.\n", fprintf(stderr, "Error: unable to read module %s data from log file.\n",
darshan_module_names[i]); darshan_module_names[i]);
free(mod_rec->mod_dat);
free(mod_rec); free(mod_rec);
return(-1); return(-1);
} }
else if(ret == 0) else if(ret == 0)
{ {
free(mod_rec->mod_dat);
free(mod_rec); free(mod_rec);
break; break;
} }
......
...@@ -109,7 +109,7 @@ int build_mod_shared_rec_hash(char **infile_list, int n_infiles, ...@@ -109,7 +109,7 @@ int build_mod_shared_rec_hash(char **infile_list, int n_infiles,
return(-1); return(-1);
} }
while((ret = mod_logutils[mod_id]->log_get_record(in_fd, mod_buf)) == 1) while((ret = mod_logutils[mod_id]->log_get_record(in_fd, (void **)&mod_buf)) == 1)
{ {
base_rec = (struct darshan_base_record *)mod_buf; base_rec = (struct darshan_base_record *)mod_buf;
if(init_rank == -1) if(init_rank == -1)
...@@ -422,7 +422,7 @@ int main(int argc, char *argv[]) ...@@ -422,7 +422,7 @@ int main(int argc, char *argv[])
} }
/* loop over module records and write them to output file */ /* loop over module records and write them to output file */
while((ret = mod_logutils[i]->log_get_record(in_fd, mod_buf)) == 1) while((ret = mod_logutils[i]->log_get_record(in_fd, (void **)&mod_buf)) == 1)
{ {
base_rec = (struct darshan_base_record *)mod_buf; base_rec = (struct darshan_base_record *)mod_buf;
......
...@@ -422,7 +422,7 @@ int main(int argc, char **argv) ...@@ -422,7 +422,7 @@ int main(int argc, char **argv)
mod_logutils[i]->log_print_description(); mod_logutils[i]->log_print_description();
} }
ret = mod_logutils[i]->log_get_record(fd, mod_buf); ret = mod_logutils[i]->log_get_record(fd, (void **)&mod_buf);
if(ret != 1) if(ret != 1)
{ {
fprintf(stderr, "Error: failed to parse the first %s module record.\n", fprintf(stderr, "Error: failed to parse the first %s module record.\n",
...@@ -526,7 +526,7 @@ int main(int argc, char **argv) ...@@ -526,7 +526,7 @@ int main(int argc, char **argv)
memset(mod_buf, 0, DEF_MOD_BUF_SIZE); memset(mod_buf, 0, DEF_MOD_BUF_SIZE);
} while((ret = mod_logutils[i]->log_get_record(fd, mod_buf)) == 1); } while((ret = mod_logutils[i]->log_get_record(fd, (void **)&mod_buf)) == 1);
if (ret < 0) if (ret < 0)
{ {
ret = -1; ret = -1;
......
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