darshan-core.h 2.75 KB
Newer Older
1
/*
Shane Snyder's avatar
Shane Snyder committed
2 3 4
 * Copyright (C) 2015 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
5 6 7 8 9 10 11 12
 */

#ifndef __DARSHAN_CORE_H
#define __DARSHAN_CORE_H

#include <unistd.h>
#include <sys/types.h>
#include <stdint.h>
13
#include <limits.h>
14

15 16
#include "uthash.h"
#include "darshan-log-format.h"
17

18 19
/* Environment variable to override __DARSHAN_JOBID */
#define DARSHAN_JOBID_OVERRIDE "DARSHAN_JOBID"
20

21 22
/* Environment variable to override __DARSHAN_LOG_PATH */
#define DARSHAN_LOG_PATH_OVERRIDE "DARSHAN_LOGPATH"
23

24 25
/* Environment variable to override __DARSHAN_LOG_HINTS */
#define DARSHAN_LOG_HINTS_OVERRIDE "DARSHAN_LOGHINTS"
26

27 28
/* Environment variable to override __DARSHAN_MEM_ALIGNMENT */
#define DARSHAN_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN"
29

30 31
/* Environment variable to override memory per module */
#define DARSHAN_MOD_MEM_OVERRIDE "DARSHAN_MODMEM"
32

Shane Snyder's avatar
Shane Snyder committed
33
#ifdef __DARSHAN_ENABLE_MMAP_LOGS
34 35 36
/* Environment variable to override default mmap log path */
#define DARSHAN_MMAP_LOG_PATH_OVERRIDE "DARSHAN_MMAP_LOGPATH"

Shane Snyder's avatar
Shane Snyder committed
37 38 39 40
/* default path for storing mmap log files is '/tmp' */
#define DARSHAN_DEF_MMAP_LOG_PATH "/tmp"
#endif

41 42 43
/* Maximum amount of memory per instrumentation module in MiB */
#ifdef __DARSHAN_MOD_MEM_MAX
#define DARSHAN_MOD_MEM_MAX (__DARSHAN_MOD_MEM_MAX * 1024 * 1024)
44
#else
45
#define DARSHAN_MOD_MEM_MAX (2 * 1024 * 1024) /* 2 MiB default */
46
#endif
47

48 49
/* default name record buf can store 2048 records of size 100 bytes */
#define DARSHAN_NAME_RECORD_BUF_SIZE (2048 * 100)
50

51 52 53
/* structure to track registered modules */
struct darshan_core_module
{
54 55 56
    void *rec_buf_start;
    void *rec_buf_p;
    int rec_mem_avail;
57
    darshan_module_shutdown mod_shutdown_func;
58 59
};

60
/* strucutre for keeping a reference to registered name records */
61 62 63 64 65 66 67 68
struct darshan_core_name_record_ref
{
    struct darshan_name_record *name_record;
    uint64_t mod_flags;
    uint64_t global_mod_flags;
    UT_hash_handle hlink;
};

69
/* in memory structure to keep up with job level data */
70
struct darshan_core_runtime
71
{
72
    /* pointers to each log file component */
73 74 75
    struct darshan_header *log_hdr_p;
    struct darshan_job *log_job_p;
    char *log_exemnt_p;
76
    void *log_name_p;
77
    void *log_mod_p;
78

79
    /* darshan-core internal data structures */
80
    struct darshan_core_module* mod_array[DARSHAN_MAX_MODS];
81
    int mod_mem_used;
82
    struct darshan_core_name_record_ref *name_hash;
83
    int name_mem_used; 
84
    double wtime_offset;
85
    char *comp_buf;
86 87 88
#ifdef __DARSHAN_ENABLE_MMAP_LOGS
    char mmap_log_name[PATH_MAX];
#endif
89 90
};

91 92 93
void darshan_core_initialize(int argc, char **argv);
void darshan_core_shutdown(void);

94 95 96
uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
uint64_t darshan_hash(const register unsigned char *k, register uint64_t length, register uint64_t level);

97
#endif /* __DARSHAN_CORE_H */