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

6 7 8
#ifndef __DARSHAN_LOG_UTILS_H
#define __DARSHAN_LOG_UTILS_H
#include <darshan-log-format.h>
9 10

typedef struct darshan_fd_s* darshan_fd;
11

12
darshan_fd darshan_log_open(const char *name, const char* mode);
13
int darshan_log_getheader(darshan_fd file, struct darshan_header *header);
14
int darshan_log_getjob(darshan_fd file, struct darshan_job *job);
15 16 17 18
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);
#if 0
19
int darshan_log_putjob(darshan_fd file, struct darshan_job *job);
20 21 22
int darshan_log_getfile(darshan_fd fd, 
    struct darshan_job* job, 
    struct darshan_file *file);
23 24 25
int darshan_log_putfile(darshan_fd fd, 
    struct darshan_job* job, 
    struct darshan_file *file);
26
int darshan_log_getexe(darshan_fd fd, char *buf);
27 28 29 30 31
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,
32
    int* count);
33 34 35 36 37
int darshan_log_putmounts(darshan_fd fd,
    int64_t* devs,
    char** mnt_pts,
    char** fs_types,
    int count);
38
#endif
39
void darshan_log_close(darshan_fd file);
40
//void darshan_log_print_version_warnings(struct darshan_job *job);
41

42
/* convenience macros for printing out counters */
43 44
#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 {\
Philip Carns's avatar
Philip Carns committed
45
        printf("%" PRId64 "\t%" PRIu64 "\t%s\t%" PRId64 "\t...%s\t%s\t%s\n", \
46 47
            (__file)->rank, (__file)->hash, darshan_names[__counter], \
            (__file)->counters[__counter], (__file)->name_suffix, \
48
            __mnt_pt, __fs_type); \
49
} while(0)
50
#define CP_F_PRINT(__job, __file, __counter, __mnt_pt, __fs_type) do {\
Philip Carns's avatar
Philip Carns committed
51
        printf("%" PRId64 "\t%" PRIu64 "\t%s\t%f\t...%s\t%s\t%s\n", \
52
            (__file)->rank, (__file)->hash, darshan_f_names[__counter], \
53 54
            (__file)->fcounters[__counter], (__file)->name_suffix, \
            __mnt_pt, __fs_type); \
55 56
} while(0)

57 58 59 60 61 62 63 64 65 66 67 68 69 70
/* 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)
71 72 73 74 75 76 77 78 79 80
#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)

81
#endif