darshan.h 3.69 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 16
#include "darshan-log-format.h"

17 18 19 20 21 22 23 24 25 26 27 28
/* Environment variable to override CP_JOBID */
#define CP_JOBID_OVERRIDE "DARSHAN_JOBID"

/* Environment variable to override __CP_LOG_PATH */
#define CP_LOG_PATH_OVERRIDE "DARSHAN_LOGPATH"

/* Environment variable to override __CP_LOG_PATH */
#define CP_LOG_HINTS_OVERRIDE "DARSHAN_LOGHINTS"

/* Environment variable to override __CP_MEM_ALIGNMENT */
#define CP_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN"

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/* macros for declaring wrapper functions and calling MPI routines
 * consistently regardless of whether static or dynamic linking is used
 */
#ifdef DARSHAN_PRELOAD
#define __USE_GNU
#include <dlfcn.h>
#include <stdlib.h>

#define DARSHAN_FORWARD_DECL(name,ret,args) \
  ret (*__real_ ## name)args = NULL;

#define DARSHAN_DECL(__name) __name

#define DARSHAN_MPI_CALL(func) __real_ ## func

#define MAP_OR_FAIL(func) \
    if (!(__real_ ## func)) \
    { \
        __real_ ## func = dlsym(RTLD_NEXT, #func); \
        if(!(__real_ ## func)) { \
           fprintf(stderr, "Darshan failed to map symbol: %s\n", #func); \
           exit(1); \
       } \
    }

#else

#define DARSHAN_FORWARD_DECL(name,ret,args) \
  extern ret __real_ ## name args;

#define DARSHAN_DECL(__name) __wrap_ ## __name

#define DARSHAN_MPI_CALL(func) func

#define MAP_OR_FAIL(func)

#endif

/* macros for manipulating module's counter variables */
/* NOTE: */

Shane Snyder's avatar
Shane Snyder committed
70
/* module developers provide the following functions to darshan-core */
71
struct darshan_module_funcs
72
{
73
    /* disable futher instrumentation within a module */
Shane Snyder's avatar
Shane Snyder committed
74
    void (*disable_instrumentation)(void);
Shane Snyder's avatar
Shane Snyder committed
75
    /* perform any necessary steps prior to reducing */
76
    void (*prepare_for_reduction)(
Shane Snyder's avatar
Shane Snyder committed
77
        darshan_record_id *shared_recs, /* input list of shared records */
78
        int *shared_rec_count, /* in/out shared record count */
Shane Snyder's avatar
Shane Snyder committed
79 80 81
        void **send_buf, /* send buffer for shared file reduction */
        void **recv_buf, /* recv buffer for shared file reduction (root only) */
        int *rec_size /* size of records being stored for this module */
82
    );
Shane Snyder's avatar
Shane Snyder committed
83
    /* reduce records which are shared globally across this module */
84
    void (*record_reduction_op)(
85 86 87 88 89 90
        void* infile_v,
        void* inoutfile_v,
        int *len,
        MPI_Datatype *datatype
    );
    /* retrieve module data to write to log file */
91 92 93 94
    void (*get_output_data)(
        void** buf, /* output parameter to save module buffer address */
        int* size /* output parameter to save module buffer size */
    );
95
    /* shutdown module data structures */
96
    void (*shutdown)(void);
97 98
};

99 100 101
/* paths that darshan will not trace */
extern char* darshan_path_exclusions[]; /* defined in lib/darshan-core.c */

102 103 104
/*****************************************************
* darshan-core functions exported to darshan modules *
*****************************************************/
105

106
void darshan_core_register_module(
107
    darshan_module_id mod_id,
108 109
    struct darshan_module_funcs *funcs,
    int *runtime_mem_limit);
110

111 112 113
void darshan_core_unregister_module(
    darshan_module_id mod_id);

Shane Snyder's avatar
Shane Snyder committed
114
void darshan_core_register_record(
115 116 117
    void *name,
    int len,
    int printable_flag,
118
    darshan_module_id mod_id,
119
    darshan_record_id *rec_id);
120

Shane Snyder's avatar
Shane Snyder committed
121 122 123 124
void darshan_core_unregister_record(
    darshan_record_id rec_id,
    darshan_module_id mod_id);

125
double darshan_core_wtime(void);
126

127 128 129 130 131 132
/***********************************************
* darshan-common functions for darshan modules *
***********************************************/

char* darshan_clean_file_path(const char* path);

133
#endif /* __DARSHAN_H */