darshan-logutils.h 2.48 KB
Newer Older
1 2 3 4 5
/*
 *  (C) 2009 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

6 7 8 9
#ifndef __DARSHAN_LOG_UTILS_H
#define __DARSHAN_LOG_UTILS_H
#include <darshan-log-format.h>
#include <zlib.h>
10 11 12 13 14

struct darshan_fd_s
{
    gzFile gzf;
    int swap_flag;
15
    char version[10];
16
    int job_struct_size;
17 18
};
typedef struct darshan_fd_s* darshan_fd;
19 20 21 22

extern char *darshan_names[];
extern char *darshan_f_names[];

23
darshan_fd darshan_log_open(const char *name);
24
int darshan_log_getjob(darshan_fd file, struct darshan_job *job);
25 26 27
int darshan_log_getfile(darshan_fd fd, 
    struct darshan_job* job, 
    struct darshan_file *file);
28
int darshan_log_getexe(darshan_fd fd, char *buf, int *flag);
29
int darshan_log_getmounts(darshan_fd fd, int64_t** devs, char*** mnt_pts, char***
30
    fs_types, int* count, int *flag);
31
void darshan_log_close(darshan_fd file);
32
void darshan_log_print_version_warnings(struct darshan_job *job);
33

34
/* convenience macros for printing out counters */
35 36
#define CP_PRINT_HEADER() printf("#<rank>\t<file>\t<counter>\t<value>\t<name suffix>\t<mount pt>\t<fs type>\n")
#define CP_PRINT(__job, __file, __counter, __mnt_pt, __fs_type) do {\
37 38
        printf("%lld\t%llu\t%s\t%lld\t...%s\t%s\t%s\n", \
            lld((__file)->rank), llu((__file)->hash), darshan_names[__counter], \
39 40
            lld((__file)->counters[__counter]), (__file)->name_suffix, \
            __mnt_pt, __fs_type); \
41
} while(0)
42
#define CP_F_PRINT(__job, __file, __counter, __mnt_pt, __fs_type) do {\
43 44
        printf("%lld\t%llu\t%s\t%f\t...%s\t%s\t%s\n", \
            lld((__file)->rank), llu((__file)->hash), darshan_f_names[__counter], \
45 46
            (__file)->fcounters[__counter], (__file)->name_suffix, \
            __mnt_pt, __fs_type); \
47 48
} while(0)

49 50 51 52 53 54 55 56 57 58 59 60 61 62
/* naive byte swap implementation */
#define DARSHAN_BSWAP64(__ptr) do {\
    char __dst_char[8]; \
    char* __src_char = (char*)__ptr; \
    __dst_char[0] = __src_char[7]; \
    __dst_char[1] = __src_char[6]; \
    __dst_char[2] = __src_char[5]; \
    __dst_char[3] = __src_char[4]; \
    __dst_char[4] = __src_char[3]; \
    __dst_char[5] = __src_char[2]; \
    __dst_char[6] = __src_char[1]; \
    __dst_char[7] = __src_char[0]; \
    memcpy(__ptr, __dst_char, 8); \
} while(0)
63 64 65 66 67 68 69 70 71 72
#define DARSHAN_BSWAP32(__ptr) do {\
    char __dst_char[4]; \
    char* __src_char = (char*)__ptr; \
    __dst_char[0] = __src_char[3]; \
    __dst_char[1] = __src_char[2]; \
    __dst_char[2] = __src_char[1]; \
    __dst_char[3] = __src_char[0]; \
    memcpy(__ptr, __dst_char, 4); \
} while(0)

73

74
#endif