darshan.h 5.29 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 13
#ifndef __DARSHAN_H
#define __DARSHAN_H

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

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

18 19 20 21
/* macros for declaring wrapper functions and calling MPI routines
 * consistently regardless of whether static or dynamic linking is used
 */
#ifdef DARSHAN_PRELOAD
22

23 24 25
#include <dlfcn.h>
#include <stdlib.h>

26 27
#define DARSHAN_FORWARD_DECL(__func,__ret,__args) \
  __ret (*__real_ ## __func)__args = NULL
28

29
#define DARSHAN_DECL(__func) __func
30

31
#define DARSHAN_MPI_CALL(__func) __real_ ## __func
32

33 34
#define MAP_OR_FAIL(__func) \
    if (!(__real_ ## __func)) \
35
    { \
36 37 38
        __real_ ## __func = dlsym(RTLD_NEXT, #__func); \
        if(!(__real_ ## __func)) { \
           fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
39 40 41 42 43 44
           exit(1); \
       } \
    }

#else

45 46
#define DARSHAN_FORWARD_DECL(__name,__ret,__args) \
  extern __ret __real_ ## __name __args;
47 48 49

#define DARSHAN_DECL(__name) __wrap_ ## __name

50
#define DARSHAN_MPI_CALL(__func) __func
51

52
#define MAP_OR_FAIL(__func)
53 54 55

#endif

Shane Snyder's avatar
Shane Snyder committed
56
/* module developers provide the following functions to darshan-core */
57
struct darshan_module_funcs
58
{
59 60 61 62 63
    /* perform any necessary pre-shutdown steps
     *
     * NOTE: this typically includes disabling wrapper functions so
     * darshan-core can shutdown in a consistent state.
     */
64
    void (*begin_shutdown)(void);
65 66 67 68 69 70 71
    /* retrieve module data to write to log file
     *
     * NOTE: module developers can use this function to run collective
     * MPI operations at shutdown time. Typically this functionality
     * has been used to reduce records shared globablly (given in the
     * 'shared_recs' array) into a single data record.
     */
72
    void (*get_output_data)(
73 74 75 76 77
        MPI_Comm mod_comm,  /* MPI communicator to run collectives with */
        darshan_record_id *shared_recs, /* list of shared data record ids */
        int shared_rec_count, /* count of shared data records */
        void** mod_buf, /* output parameter to save module buffer address */
        int* mod_buf_sz /* output parameter to save module buffer size */
78 79 80
    );
    /* shutdown module data structures */
    void (*shutdown)(void);
81 82
};

83 84 85 86 87
/* stores FS info from statfs calls for a given mount point */
struct darshan_fs_info
{
    int fs_type;
    int block_size;
88 89
    int ost_count;
    int mdt_count;
90 91
};

92 93 94
/* paths that darshan will not trace */
extern char* darshan_path_exclusions[]; /* defined in lib/darshan-core.c */

95 96 97
/*****************************************************
* darshan-core functions exported to darshan modules *
*****************************************************/
98

99 100 101 102 103 104
/* darshan_core_register_module()
 *
 * Register module identifier 'mod_id' with the darshan-core runtime
 * environment, allowing the module to store I/O characterization data.
 * 'funcs' is a pointer to a structure containing each of the function
 * pointers required by darshan-core to shut down the module. The function
105
 * returns the following integers passed in as pointers: 'rank' is the
106 107 108 109
 * MPI rank of the calling process, 'mod_mem_limit' is the maximum amount
 * of memory the module may use, and 'sys_mem_alignment' is the configured
 * memory alignment value Darshan was configured with.
 */
110
void darshan_core_register_module(
111
    darshan_module_id mod_id,
112
    struct darshan_module_funcs *funcs,
113
    int *rank,
114 115
    int *mod_mem_limit,
    int *sys_mem_alignment);
116

117 118 119 120 121
/* darshan_core_unregister_module()
 * 
 * Unregisters module identifier 'mod_id' with the darshan-core runtime,
 * removing the given module from the resulting I/O characterization log.
 */
122 123 124
void darshan_core_unregister_module(
    darshan_module_id mod_id);

125 126
/* darshan_core_register_record()
 *
127 128 129 130 131 132 133 134 135 136 137
 * Register a record with the darshan-core runtime, allowing it to be
 * properly tracked and (potentially) correlated with records from other
 * modules. 'name' is the the name of the Darshan record (e.g., the full
 * file path) and 'len' is the size of the name pointer (string length
 * for string names). 'mod_id' is the identifier of the calling module,
 * 'printable_flag' indicates whether the name is a string, and 
 * 'mod_limit_flag' is set if the calling module is out of memory (to
 * prevent darshan-core from creating new records and to just search
 * through existing records). 'rec_id' is an output pointer storing the
 * correspoing Darshan record identifier and 'file_alignment' is an output
 * pointer storing the file system alignment value for the given record.
138
 */
Shane Snyder's avatar
Shane Snyder committed
139
void darshan_core_register_record(
140 141
    void *name,
    int len,
142
    darshan_module_id mod_id,
143 144
    int printable_flag,
    int mod_limit_flag,
145
    darshan_record_id *rec_id,
146
    struct darshan_fs_info *fs_info);
147

148 149 150 151 152 153 154
/* darshan_core_unregister_record()
 *
 * Unregister record identifier 'rec_id' in the darshan-core runtime.
 * This unregister is only in the context of module identifier 'mod_id',
 * meaning that if the file record has other module's associated with
 * it, then the record won't be completely removed.
 */
Shane Snyder's avatar
Shane Snyder committed
155 156 157 158
void darshan_core_unregister_record(
    darshan_record_id rec_id,
    darshan_module_id mod_id);

159 160 161 162 163
/* darshan_core_wtime()
 *
 * Returns the elapsed time relative to (roughly) the start of
 * the application.
 */
164
double darshan_core_wtime(void);
165 166

#endif /* __DARSHAN_H */