Commit 5ecf4013 authored by Shane Snyder's avatar Shane Snyder

more docs + "NULL" example module implementation

parent 233f1607
/* /*
* (C) 2009 by Argonne National Laboratory. * Copyright (C) 2015 University of Chicago.
* See COPYRIGHT in top-level directory. * See COPYRIGHT notice in top-level directory.
*
*/ */
#ifndef __DARSHAN_LOG_FORMAT_H #ifndef __DARSHAN_LOG_FORMAT_H
...@@ -39,7 +40,8 @@ typedef uint64_t darshan_record_id; ...@@ -39,7 +40,8 @@ typedef uint64_t darshan_record_id;
#define DARSHAN_MAX_MODS 16 #define DARSHAN_MAX_MODS 16
typedef enum typedef enum
{ {
DARSHAN_POSIX_MOD = 0, DARSHAN_NULL_MOD = 0,
DARSHAN_POSIX_MOD,
DARSHAN_MPIIO_MOD, DARSHAN_MPIIO_MOD,
DARSHAN_HDF5_MOD, DARSHAN_HDF5_MOD,
DARSHAN_PNETCDF_MOD, DARSHAN_PNETCDF_MOD,
...@@ -47,6 +49,7 @@ typedef enum ...@@ -47,6 +49,7 @@ typedef enum
static char * const darshan_module_names[] = static char * const darshan_module_names[] =
{ {
"NULL",
"POSIX", "POSIX",
"MPI-IO", "MPI-IO",
"HDF5", "HDF5",
......
/* /*
* (C) 2015 by Argonne National Laboratory. * Copyright (C) 2015 University of Chicago.
* See COPYRIGHT in top-level directory. * See COPYRIGHT notice in top-level directory.
*
*/ */
#ifndef __DARSHAN_MPIIO_LOG_FORMAT_H #ifndef __DARSHAN_MPIIO_LOG_FORMAT_H
......
/*
* Copyright (C) 2015 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef __DARSHAN_NULL_LOG_FORMAT_H
#define __DARSHAN_NULL_LOG_FORMAT_H
#include "darshan-log-format.h"
/* integer counters for the "NULL" example module */
enum darshan_null_indices
{
NULL_BARS, /* count of number of 'bar' function calls */
NULL_BAR_DAT, /* arbitrary data value set by last call to 'bar' */
NULL_NUM_INDICES,
};
/* floating point counters for the "NULL" example module */
enum darshan_null_f_indices
{
NULL_F_BAR_TIMESTAMP, /* timestamp of the first call to function 'bar' */
NULL_F_BAR_DURATION, /* timer indicating duration of last call to 'bar' */
NULL_F_NUM_INDICES,
};
/* the darshan_null_record structure encompasses the high-level data/counters
* which would actually be logged to file by Darshan for the "NULL" example
* module. This example implementation logs the following data for each
* record:
* - a corresponding Darshan record identifier
* - the rank of the process responsible for the record
* - integer I/O counters (operation counts, I/O sizes, etc.)
* - floating point I/O counters (timestamps, cumulative timers, etc.)
*/
struct darshan_null_record
{
darshan_record_id f_id;
int64_t rank;
int64_t counters[NULL_NUM_INDICES];
double fcounters[NULL_F_NUM_INDICES];
};
#endif /* __DARSHAN_NULL_LOG_FORMAT_H */
all: lib/libdarshan.a all: lib/libdarshan.a lib/darshan-null.o
DESTDIR = DESTDIR =
srcdir = @srcdir@ srcdir = @srcdir@
...@@ -19,7 +19,7 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h ...@@ -19,7 +19,7 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_VERSION = @DARSHAN_VERSION@ DARSHAN_VERSION = @DARSHAN_VERSION@
ifndef DISABLE_LDPRELOAD ifndef DISABLE_LDPRELOAD
all: lib/libdarshan.so all: lib/libdarshan.so lib/darshan-null.po
endif endif
VPATH = $(srcdir) VPATH = $(srcdir)
...@@ -51,16 +51,22 @@ lib/darshan-common.o: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib ...@@ -51,16 +51,22 @@ lib/darshan-common.o: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
lib/darshan-common.po: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-common.po: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-posix.o: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-null.o: lib/darshan-null.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-null-log-format.h | lib
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-null.po: lib/darshan-null.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-null-log-format.h | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-mpiio.o: lib/darshan-mpiio.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-posix.o: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-posix-log-format.h | lib
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
lib/darshan-mpiio.po: lib/darshan-mpiio.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-posix-log-format.h | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-mpiio.o: lib/darshan-mpiio.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-mpiio-log-format.h | lib
$(CC) $(CFLAGS) -c $< -o $@
lib/darshan-mpiio.po: lib/darshan-mpiio.c darshan.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-mpiio-log-format.h | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup3.o: lib/lookup3.c lib/lookup3.o: lib/lookup3.c
......
...@@ -34,38 +34,43 @@ ...@@ -34,38 +34,43 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <stdlib.h> #include <stdlib.h>
#define DARSHAN_FORWARD_DECL(name,ret,args) \ #define DARSHAN_FORWARD_DECL(__func,__ret,__args) \
ret (*__real_ ## name)args = NULL __ret (*__real_ ## __func)__args = NULL
#define DARSHAN_DECL(__name) __name #define DARSHAN_DECL(__func) __func
#define DARSHAN_MPI_CALL(func) __real_ ## func #define DARSHAN_MPI_CALL(__func) __real_ ## __func
#define MAP_OR_FAIL(func) \ #define MAP_OR_FAIL(__func) \
if (!(__real_ ## func)) \ if (!(__real_ ## __func)) \
{ \ { \
__real_ ## func = dlsym(RTLD_NEXT, #func); \ __real_ ## __func = dlsym(RTLD_NEXT, #__func); \
if(!(__real_ ## func)) { \ if(!(__real_ ## __func)) { \
fprintf(stderr, "Darshan failed to map symbol: %s\n", #func); \ fprintf(stderr, "Darshan failed to map symbol: %s\n", #__func); \
exit(1); \ exit(1); \
} \ } \
} }
#else #else
#define DARSHAN_FORWARD_DECL(name,ret,args) \ #define DARSHAN_FORWARD_DECL(__name,__ret,__args) \
extern ret __real_ ## name args; extern __ret __real_ ## __name __args;
#define DARSHAN_DECL(__name) __wrap_ ## __name #define DARSHAN_DECL(__name) __wrap_ ## __name
#define DARSHAN_MPI_CALL(func) func #define DARSHAN_MPI_CALL(__func) __func
#define MAP_OR_FAIL(func) #define MAP_OR_FAIL(__func)
#endif #endif
/* macros for manipulating module's counter variables */ /* macros for manipulating a module's counter variables */
/* NOTE: */ /* NOTE: These macros assume a module's record stores integer
* and floating point counters in arrays, named counters and
* fcounters, respectively. __rec_p is the a pointer to the
* data record, __counter is the counter in question, and
* __value is the corresponding data value.
*/
#define DARSHAN_COUNTER_SET(__rec_p, __counter, __value) do{ \ #define DARSHAN_COUNTER_SET(__rec_p, __counter, __value) do{ \
(__rec_p)->counters[__counter] = __value; \ (__rec_p)->counters[__counter] = __value; \
} while(0) } while(0)
...@@ -102,6 +107,11 @@ ...@@ -102,6 +107,11 @@
(__rec_p)->counters[__counter] = __value; \ (__rec_p)->counters[__counter] = __value; \
} while(0) } while(0)
/* NOTE: This macro is for storing histogram counters with 10
* distinct buckets. For an example of how it is used, consult
* the POSIX module implementation, which stores histograms of
* access sizes for POSIX I/O functions.
*/
#define DARSHAN_BUCKET_INC(__rec_p, __counter_base, __value) do {\ #define DARSHAN_BUCKET_INC(__rec_p, __counter_base, __value) do {\
if(__value < 101) \ if(__value < 101) \
(__rec_p)->counters[__counter_base] += 1; \ (__rec_p)->counters[__counter_base] += 1; \
...@@ -128,10 +138,10 @@ ...@@ -128,10 +138,10 @@
/* module developers provide the following functions to darshan-core */ /* module developers provide the following functions to darshan-core */
struct darshan_module_funcs struct darshan_module_funcs
{ {
/* disable futher instrumentation within a module */ /* perform any necessary pre-shutdown steps */
void (*disable_instrumentation)(void); void (*begin_shutdown)(void);
/* perform any necessary steps prior to reducing */ /* perform any necessary steps prior to reducing */
void (*prepare_for_reduction)( void (*setup_reduction)(
darshan_record_id *shared_recs, /* input list of shared records */ darshan_record_id *shared_recs, /* input list of shared records */
int *shared_rec_count, /* in/out shared record count */ int *shared_rec_count, /* in/out shared record count */
void **send_buf, /* send buffer for shared file reduction */ void **send_buf, /* send buffer for shared file reduction */
......
...@@ -258,14 +258,15 @@ void darshan_core_shutdown() ...@@ -258,14 +258,15 @@ void darshan_core_shutdown()
darshan_core = NULL; darshan_core = NULL;
/* we also need to set which modules were registered on this process and /* we also need to set which modules were registered on this process and
* disable tracing within those modules while we shutdown * call into those modules and give them a chance to perform any necessary
* pre-shutdown steps.
*/ */
for(i = 0; i < DARSHAN_MAX_MODS; i++) for(i = 0; i < DARSHAN_MAX_MODS; i++)
{ {
if(final_core->mod_array[i]) if(final_core->mod_array[i])
{ {
local_mod_use[i] = 1; local_mod_use[i] = 1;
final_core->mod_array[i]->mod_funcs.disable_instrumentation(); final_core->mod_array[i]->mod_funcs.begin_shutdown();
} }
} }
DARSHAN_CORE_UNLOCK(); DARSHAN_CORE_UNLOCK();
...@@ -492,10 +493,10 @@ void darshan_core_shutdown() ...@@ -492,10 +493,10 @@ void darshan_core_shutdown()
} }
/* if there are globally shared files, do a shared file reduction */ /* if there are globally shared files, do a shared file reduction */
if(shared_rec_count && this_mod->mod_funcs.prepare_for_reduction && if(shared_rec_count && this_mod->mod_funcs.setup_reduction &&
this_mod->mod_funcs.record_reduction_op) this_mod->mod_funcs.record_reduction_op)
{ {
this_mod->mod_funcs.prepare_for_reduction(mod_shared_recs, &shared_rec_count, this_mod->mod_funcs.setup_reduction(mod_shared_recs, &shared_rec_count,
&red_send_buf, &red_recv_buf, &rec_sz); &red_send_buf, &red_recv_buf, &rec_sz);
if(shared_rec_count) if(shared_rec_count)
......
...@@ -114,7 +114,7 @@ static int my_rank = -1; ...@@ -114,7 +114,7 @@ static int my_rank = -1;
#define MPIIO_UNLOCK() pthread_mutex_unlock(&mpiio_runtime_mutex) #define MPIIO_UNLOCK() pthread_mutex_unlock(&mpiio_runtime_mutex)
static void mpiio_runtime_initialize(void); static void mpiio_runtime_initialize(void);
static void mpiio_disable_instrumentation(void); static void mpiio_begin_shutdown(void);
static void mpiio_shutdown(void); static void mpiio_shutdown(void);
static void mpiio_get_output_data( static void mpiio_get_output_data(
void **buffer, void **buffer,
...@@ -123,7 +123,7 @@ static struct mpiio_file_runtime* mpiio_file_by_name_setfh(const char* name, MPI ...@@ -123,7 +123,7 @@ static struct mpiio_file_runtime* mpiio_file_by_name_setfh(const char* name, MPI
static struct mpiio_file_runtime* mpiio_file_by_name(const char *name); static struct mpiio_file_runtime* mpiio_file_by_name(const char *name);
static void mpiio_record_reduction_op(void* infile_v, void* inoutfile_v, static void mpiio_record_reduction_op(void* infile_v, void* inoutfile_v,
int *len, MPI_Datatype *datatype); int *len, MPI_Datatype *datatype);
static void mpiio_prepare_for_reduction(darshan_record_id *shared_recs, static void mpiio_setup_reduction(darshan_record_id *shared_recs,
int *shared_rec_count, void **send_buf, void **recv_buf, int *rec_size); int *shared_rec_count, void **send_buf, void **recv_buf, int *rec_size);
static int mpiio_file_compare(const void* a, const void* b); static int mpiio_file_compare(const void* a, const void* b);
...@@ -192,8 +192,8 @@ static void mpiio_runtime_initialize() ...@@ -192,8 +192,8 @@ static void mpiio_runtime_initialize()
int mem_limit; int mem_limit;
struct darshan_module_funcs mpiio_mod_fns = struct darshan_module_funcs mpiio_mod_fns =
{ {
.disable_instrumentation = &mpiio_disable_instrumentation, .begin_shutdown = &mpiio_begin_shutdown,
.prepare_for_reduction = &mpiio_prepare_for_reduction, .setup_reduction = &mpiio_setup_reduction,
.record_reduction_op = &mpiio_record_reduction_op, .record_reduction_op = &mpiio_record_reduction_op,
.get_output_data = &mpiio_get_output_data, .get_output_data = &mpiio_get_output_data,
.shutdown = &mpiio_shutdown .shutdown = &mpiio_shutdown
...@@ -245,7 +245,7 @@ static void mpiio_runtime_initialize() ...@@ -245,7 +245,7 @@ static void mpiio_runtime_initialize()
return; return;
} }
static void mpiio_disable_instrumentation() static void mpiio_begin_shutdown()
{ {
assert(mpiio_runtime); assert(mpiio_runtime);
...@@ -444,7 +444,7 @@ static void mpiio_record_reduction_op( ...@@ -444,7 +444,7 @@ static void mpiio_record_reduction_op(
return; return;
} }
static void mpiio_prepare_for_reduction( static void mpiio_setup_reduction(
darshan_record_id *shared_recs, darshan_record_id *shared_recs,
int *shared_rec_count, int *shared_rec_count,
void **send_buf, void **send_buf,
......
This diff is collapsed.
...@@ -215,9 +215,9 @@ static void posix_walk_file_accesses(void); ...@@ -215,9 +215,9 @@ static void posix_walk_file_accesses(void);
static int posix_access_compare(const void* a_p, const void* b_p); static int posix_access_compare(const void* a_p, const void* b_p);
static int posix_file_compare(const void* a, const void* b); static int posix_file_compare(const void* a, const void* b);
static void posix_disable_instrumentation(void); static void posix_begin_shutdown(void);
static void posix_prepare_for_reduction(darshan_record_id *shared_recs, static void posix_setup_reduction(darshan_record_id *shared_recs, int *shared_rec_count,
int *shared_rec_count, void **send_buf, void **recv_buf, int *rec_size); void **send_buf, void **recv_buf, int *rec_size);
static void posix_record_reduction_op(void* infile_v, void* inoutfile_v, static void posix_record_reduction_op(void* infile_v, void* inoutfile_v,
int *len, MPI_Datatype *datatype); int *len, MPI_Datatype *datatype);
static void posix_get_output_data(void **buffer, int *size); static void posix_get_output_data(void **buffer, int *size);
...@@ -1295,8 +1295,8 @@ static void posix_runtime_initialize() ...@@ -1295,8 +1295,8 @@ static void posix_runtime_initialize()
int mem_limit; int mem_limit;
struct darshan_module_funcs posix_mod_fns = struct darshan_module_funcs posix_mod_fns =
{ {
.disable_instrumentation = &posix_disable_instrumentation, .begin_shutdown = &posix_begin_shutdown,
.prepare_for_reduction = &posix_prepare_for_reduction, .setup_reduction = &posix_setup_reduction,
.record_reduction_op = &posix_record_reduction_op, .record_reduction_op = &posix_record_reduction_op,
.get_output_data = &posix_get_output_data, .get_output_data = &posix_get_output_data,
.shutdown = &posix_shutdown .shutdown = &posix_shutdown
...@@ -1627,21 +1627,25 @@ static int posix_file_compare(const void* a_p, const void* b_p) ...@@ -1627,21 +1627,25 @@ static int posix_file_compare(const void* a_p, const void* b_p)
* Functions exported by this module for coordinating with darshan-core * * Functions exported by this module for coordinating with darshan-core *
************************************************************************/ ************************************************************************/
static void posix_disable_instrumentation() static void posix_begin_shutdown()
{ {
assert(posix_runtime); assert(posix_runtime);
POSIX_LOCK(); POSIX_LOCK();
/* go through file access data for each record and set the 4 most common
* stride/access size counters.
*/
posix_walk_file_accesses(); posix_walk_file_accesses();
/* disable further instrumentation while Darshan shuts down */
instrumentation_disabled = 1; instrumentation_disabled = 1;
POSIX_UNLOCK(); POSIX_UNLOCK();
return; return;
} }
static void posix_prepare_for_reduction( static void posix_setup_reduction(
darshan_record_id *shared_recs, darshan_record_id *shared_recs,
int *shared_rec_count, int *shared_rec_count,
void **send_buf, void **send_buf,
...@@ -1980,6 +1984,8 @@ static void posix_shutdown() ...@@ -1980,6 +1984,8 @@ static void posix_shutdown()
{ {
struct posix_file_runtime_ref *ref, *tmp; struct posix_file_runtime_ref *ref, *tmp;
assert(posix_runtime);
HASH_ITER(hlink, posix_runtime->fd_hash, ref, tmp) HASH_ITER(hlink, posix_runtime->fd_hash, ref, tmp)
{ {
HASH_DELETE(hlink, posix_runtime->fd_hash, ref); HASH_DELETE(hlink, posix_runtime->fd_hash, ref);
......
This diff is collapsed.
...@@ -6,11 +6,6 @@ Darshan modularization branch development notes ...@@ -6,11 +6,6 @@ Darshan modularization branch development notes
Darshan is a lightweight toolkit for characterizing the I/O performance of instrumented Darshan is a lightweight toolkit for characterizing the I/O performance of instrumented
HPC applications. HPC applications.
Darshan was originally designed to gather I/O data from a static set of sources.
Adding instrumentation for additional sources of I/O data was only possible through
manual modification of the Darshan log file format, which consequentially breaks
any other utilities reliant on that format.
Starting with version 3.0.0, the Darshan runtime environment and log file format have Starting with version 3.0.0, the Darshan runtime environment and log file format have
been redesigned such that new "instrumentation modules" can be added without breaking been redesigned such that new "instrumentation modules" can be added without breaking
existing tools. Developers are given a framework to implement arbitrary instrumentation existing tools. Developers are given a framework to implement arbitrary instrumentation
...@@ -52,6 +47,8 @@ applications and generating I/O characterization logs. ...@@ -52,6 +47,8 @@ applications and generating I/O characterization logs.
* *darshan-util*: Darshan utilities for analyzing the contents of a given Darshan * *darshan-util*: Darshan utilities for analyzing the contents of a given Darshan
I/O characterization log. I/O characterization log.
The following subsections provide an overview of each of these components with specific The following subsections provide an overview of each of these components with specific
attention to how new instrumentation modules may be integrated into Darshan. attention to how new instrumentation modules may be integrated into Darshan.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment