Commit 7fdf26f0 authored by Shane Snyder's avatar Shane Snyder

First cut at logutils and posix parser

parent 3d963df9
This diff is collapsed.
......@@ -5,39 +5,34 @@
#ifndef __DARSHAN_LOG_UTILS_H
#define __DARSHAN_LOG_UTILS_H
#include <darshan-log-format.h>
#include "uthash-1.9.2/src/uthash.h"
typedef struct darshan_fd_s* darshan_fd;
struct darshan_record_ref
{
struct darshan_record rec;
UT_hash_handle hlink;
};
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_getmap(darshan_fd file, unsigned char **map_buf);
int darshan_log_build_map(unsigned char *map_buf);
int darshan_log_destroy_map(void);
int darshan_log_getmap(darshan_fd file, struct darshan_record_ref **map);
#if 0
int darshan_log_putjob(darshan_fd file, struct darshan_job *job);
int darshan_log_getfile(darshan_fd fd,
struct darshan_job* job,
struct darshan_file *file);
int darshan_log_putfile(darshan_fd fd,
struct darshan_job* job,
struct darshan_file *file);
int darshan_log_getexe(darshan_fd fd, char *buf);
int darshan_log_putexe(darshan_fd fd, char *buf);
int darshan_log_getmounts(darshan_fd fd,
int64_t** devs,
char*** mnt_pts,
char*** fs_types,
int* count);
int darshan_log_putmounts(darshan_fd fd,
int64_t* devs,
char** mnt_pts,
char** fs_types,
int count);
#endif
void darshan_log_close(darshan_fd file);
//void darshan_log_print_version_warnings(struct darshan_job *job);
/* convenience macros for printing out counters */
#define CP_PRINT_HEADER() printf("#<rank>\t<file>\t<counter>\t<value>\t<name suffix>\t<mount pt>\t<fs type>\n")
......
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <zlib.h>
#include <time.h>
#include <stdlib.h>
#include <getopt.h>
#include <assert.h>
#include "darshan-logutils.h"
#include "uthash-1.9.2/src/uthash.h"
int main(int argc, char **argv)
{
int ret;
char *filename;
darshan_fd file;
struct darshan_header header;
struct darshan_job job;
struct darshan_record_ref *rec_map = NULL;
struct darshan_record_ref *ref, *tmp;
struct darshan_posix_file next_rec;
assert(argc == 2);
filename = argv[1];
struct stat sbuf;
stat(filename, &sbuf);
printf("\nDarshan log file size: %"PRId64"\n", sbuf.st_size);
printf("size of header: %"PRId64"\n", sizeof(struct darshan_header));
printf("size of index map: %"PRId64"\n", 2*sizeof(int64_t));
printf("size of job data: %"PRId64"\n", sizeof(struct darshan_job));
file = darshan_log_open(filename, "r");
if(!file)
{
fprintf(stderr, "darshan_log_open() failed to open %s\n.", filename);
return(-1);
}
/* read the log header */
ret = darshan_log_getheader(file, &header);
if(ret < 0)
{
fprintf(stderr, "darshan_log_getheader() failed to read log header.\n");
darshan_log_close(file);
return(-1);
}
printf("\n*** HEADER DATA ***\n");
printf("\tver=%s\n\tmagic_nr=%"PRId64"\n\tcomp_type=%d\n\tmod_count=%d\n",
header.version_string, header.magic_nr, header.comp_type, header.mod_count);
/* read job info */
ret = darshan_log_getjob(file, &job);
if(ret < 0)
{
fprintf(stderr, "darshan_log_getjob() failed to read job data.\n");
darshan_log_close(file);
return(-1);
}
printf("\n*** JOB DATA ***\n");
printf(
"\tuid=%"PRId64"\n\tstart_time=%"PRId64"\n\tend_time=%"PRId64"\n\tnprocs=%"PRId64"\n\tjobid=%"PRId64"\n",
job.uid, job.start_time, job.end_time, job.nprocs, job.jobid);
/* read record map */
ret = darshan_log_getmap(file, &rec_map);
if(ret < 0)
{
fprintf(stderr, "darshan_log_getmap() failed to read record map.\n");
darshan_log_close(file);
return(-1);
}
/* try to retrieve first record (may not exist) */
ret = darshan_log_getfile(file, &next_rec);
if(ret < 0)
{
fprintf(stderr, "Error: failed to parse log file.\n");
fflush(stderr);
return(-1);
}
if(ret == 0)
{
/* it looks like the app didn't open any files */
printf("# no files opened.\n");
darshan_log_close(file);
return(0);
}
/* iterate the posix file records stored in the darshan log */
printf("\n*** FILE RECORD DATA ***\n");
int i = 0;
do{
struct darshan_record_ref *ref;
/* get the pathname for this record */
HASH_FIND(hlink, rec_map, &next_rec.f_id, sizeof(darshan_record_id), ref);
assert(ref);
printf("\tRecord %d: id=%"PRIu64" (path=%s, rank=%"PRId64")\n",
i, next_rec.f_id, ref->rec.name, next_rec.rank);
i++;
} while((ret = darshan_log_getfile(file, &next_rec)) == 1);
darshan_log_close(file);
return(0);
}
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