Commit 35a35fe5 authored by Shane Snyder's avatar Shane Snyder
Browse files

Merge branch 'dev-dynamic-dxt-trigger'

parents 07e48c11 d710db8e
......@@ -210,12 +210,16 @@ void darshan_clear_record_refs(
*
* Iterate each record reference stored in the hash table pointed
* to by 'hash_head' and perform the given action 'iter_action'.
* The action function takes a single pointer which points to the
* corresponding record reference pointer.
* The action function takes two pointers as input: the first
* points to the corresponding record reference pointer and the
* second is a user-supplied pointer provided for the action.
* 'user_ptr' is the user-supplied pointer that will be passed
* as the 2nd argument to 'iter_action'.
*/
void darshan_iter_record_refs(
void *hash_head,
void (*iter_action)(void *));
void (*iter_action)(void *, void *),
void *user_ptr);
/* darshan_clean_file_path()
*
......
/*
* Copyright (C) 2019 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/
#ifndef __DARSHAN_DXT_H
#define __DARSHAN_DXT_H
/* dxt_load_trigger_conf()
*
* DXT function exposed to Darshan core to read in any trace triggers
* from the file path in 'trigger_conf_path' before module
* initialization occurs.
*/
void dxt_load_trigger_conf(
char *trigger_conf_path);
/* dxt_posix_runtime_initialize()
*
* DXT function exposed to POSIX module for initializing DXT-POSIX runtime.
*/
void dxt_posix_runtime_initialize(void);
/* dxt_mpiio_runtime_initialize()
*
* DXT function exposed to MPIIO module for initializing DXT-MPIIO runtime.
*/
void dxt_mpiio_runtime_initialize(void);
/* dxt_posix_write(), dxt_posix_read()
*
* DXT function to trace a POSIX write/read call to file record 'rec_id',
* at offset 'offset' and with 'length' size. 'start_time' and 'end_time'
* are starting and ending timestamps for the operation, respectively.
*/
void dxt_posix_write(darshan_record_id rec_id, int64_t offset,
int64_t length, double start_time, double end_time);
void dxt_posix_read(darshan_record_id rec_id, int64_t offset,
int64_t length, double start_time, double end_time);
/* dxt_mpiio_write(), dxt_mpiio_read()
*
* DXT function to trace a MPIIO write/read call to file record 'rec_id',
* with 'length' size. 'start_time' and 'end_time' are starting and ending
* timestamps for the operation, respectively.
*/
void dxt_mpiio_write(darshan_record_id rec_id, int64_t length,
double start_time, double end_time);
void dxt_mpiio_read(darshan_record_id rec_id, int64_t length,
double start_time, double end_time);
void dxt_posix_filter_dynamic_traces(
struct darshan_posix_file *(*rec_id_to_psx_file)(darshan_record_id));
#endif /* __DARSHAN_DXT_H */
......@@ -103,7 +103,8 @@ void darshan_clear_record_refs(void **hash_head_p, int free_flag)
return;
}
void darshan_iter_record_refs(void *hash_head, void (*iter_action)(void *))
void darshan_iter_record_refs(void *hash_head, void (*iter_action)(void *, void *),
void *user_ptr)
{
struct darshan_record_ref_tracker *ref_tracker, *tmp;
struct darshan_record_ref_tracker *ref_tracker_head =
......@@ -114,7 +115,7 @@ void darshan_iter_record_refs(void *hash_head, void (*iter_action)(void *))
*/
HASH_ITER(hlink, ref_tracker_head, ref_tracker, tmp)
{
iter_action(ref_tracker->rec_ref_p);
iter_action(ref_tracker->rec_ref_p, user_ptr);
}
return;
......
......@@ -34,6 +34,7 @@
#include "darshan.h"
#include "darshan-core.h"
#include "darshan-dynamic.h"
#include "darshan-dxt.h"
#ifdef DARSHAN_LUSTRE
#include <lustre/lustre_user.h>
......@@ -308,6 +309,13 @@ void darshan_core_initialize(int argc, char **argv)
/* collect information about command line and mounted file systems */
darshan_get_exe_and_mounts(init_core, argc, argv);
/* determine if/when DXT should be enabled by looking for triggers */
char *trigger_conf = getenv("DARSHAN_DXT_TRIGGER_CONF_PATH");
if(trigger_conf)
{
dxt_load_trigger_conf(trigger_conf);
}
/* if darshan was successfully initialized, set the global pointer
* and bootstrap any modules with static initialization routines
*/
......
This diff is collapsed.
......@@ -27,9 +27,9 @@
static void lustre_runtime_initialize(
void);
static void lustre_subtract_shared_rec_size(
void *rec_ref_p);
void *rec_ref_p, void *user_ptr);
static void lustre_set_rec_ref_pointers(
void *rec_ref_p);
void *rec_ref_p, void *user_ptr);
static int lustre_record_compare(
const void* a_p, const void* b_p);
int sort_lustre_records(
......@@ -266,7 +266,7 @@ static void lustre_shutdown(
if (my_rank != 0)
{
darshan_iter_record_refs(lustre_runtime->record_id_hash,
&lustre_subtract_shared_rec_size);
&lustre_subtract_shared_rec_size, NULL);
}
}
......@@ -282,7 +282,7 @@ static void lustre_shutdown(
return;
}
static void lustre_subtract_shared_rec_size(void *rec_ref_p)
static void lustre_subtract_shared_rec_size(void *rec_ref_p, void *user_ptr)
{
struct lustre_record_ref *l_rec_ref = (struct lustre_record_ref *)rec_ref_p;
......@@ -291,7 +291,7 @@ static void lustre_subtract_shared_rec_size(void *rec_ref_p)
LUSTRE_RECORD_SIZE( l_rec_ref->record->counters[LUSTRE_STRIPE_WIDTH] );
}
static void lustre_set_rec_ref_pointers(void *rec_ref_p)
static void lustre_set_rec_ref_pointers(void *rec_ref_p, void *user_ptr)
{
lustre_runtime->record_ref_array[lustre_runtime->record_ref_array_ndx] = rec_ref_p;
lustre_runtime->record_ref_array_ndx++;
......@@ -356,7 +356,7 @@ int sort_lustre_records()
/* build the array of record reference pointers we want to sort */
darshan_iter_record_refs(lustre_runtime->record_id_hash,
&lustre_set_rec_ref_pointers);
&lustre_set_rec_ref_pointers, NULL);
/* qsort breaks the hash table, so delete it now to free its memory buffers
* and prevent later confusion */
......
......@@ -578,7 +578,7 @@ static void mdhim_shutdown(
if (my_rank != 0)
{
darshan_iter_record_refs(mdhim_runtime->rec_id_hash,
&mdhim_subtract_shared_rec_size);
&mdhim_subtract_shared_rec_size, NULL);
}
}
*mdhim_buf_sz = mdhim_rec_count * mdhim_runtime->record_buffer_size;
......
......@@ -24,6 +24,7 @@
#include "darshan.h"
#include "darshan-dynamic.h"
#include "darshan-dxt.h"
DARSHAN_FORWARD_DECL(PMPI_File_close, int, (MPI_File *fh));
DARSHAN_FORWARD_DECL(PMPI_File_iread_at, int, (MPI_File fh, MPI_Offset offset, void *buf, int count, MPI_Datatype datatype, __D_MPI_REQUEST *request));
......@@ -159,7 +160,7 @@ static void mpiio_runtime_initialize(
static struct mpiio_file_record_ref *mpiio_track_new_file_record(
darshan_record_id rec_id, const char *path);
static void mpiio_finalize_file_records(
void *rec_ref_p);
void *rec_ref_p, void *user_ptr);
static void mpiio_record_reduction_op(
void* infile_v, void* inoutfile_v, int *len, MPI_Datatype *datatype);
static void mpiio_shared_record_variance(
......@@ -172,16 +173,9 @@ static void mpiio_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **mpiio_buf, int *mpiio_buf_sz);
/* extern DXT function defs */
extern void dxt_mpiio_write(darshan_record_id rec_id, int64_t length,
double start_time, double end_time);
extern void dxt_mpiio_read(darshan_record_id rec_id, int64_t length,
double start_time, double end_time);
static struct mpiio_runtime *mpiio_runtime = NULL;
static pthread_mutex_t mpiio_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int my_rank = -1;
static int enable_dxt_io_trace = 0;
#define MPIIO_LOCK() pthread_mutex_lock(&mpiio_runtime_mutex)
#define MPIIO_UNLOCK() pthread_mutex_unlock(&mpiio_runtime_mutex)
......@@ -249,9 +243,7 @@ static int enable_dxt_io_trace = 0;
PMPI_Type_size(__datatype, &size); \
size = size * __count; \
/* DXT to record detailed read tracing information */ \
if(enable_dxt_io_trace) { \
dxt_mpiio_read(rec_ref->file_rec->base_rec.id, size, __tm1, __tm2); \
} \
dxt_mpiio_read(rec_ref->file_rec->base_rec.id, size, __tm1, __tm2); \
DARSHAN_BUCKET_INC(&(rec_ref->file_rec->counters[MPIIO_SIZE_READ_AGG_0_100]), size); \
darshan_common_val_counter(&rec_ref->access_root, &rec_ref->access_count, size, \
&(rec_ref->file_rec->counters[MPIIO_ACCESS1_ACCESS]), \
......@@ -281,10 +273,8 @@ static int enable_dxt_io_trace = 0;
if(!rec_ref) break; \
PMPI_Type_size(__datatype, &size); \
size = size * __count; \
/* DXT to record detailed write tracing information */ \
if(enable_dxt_io_trace) { \
dxt_mpiio_write(rec_ref->file_rec->base_rec.id, size, __tm1, __tm2); \
} \
/* DXT to record detailed write tracing information */ \
dxt_mpiio_write(rec_ref->file_rec->base_rec.id, size, __tm1, __tm2); \
DARSHAN_BUCKET_INC(&(rec_ref->file_rec->counters[MPIIO_SIZE_WRITE_AGG_0_100]), size); \
darshan_common_val_counter(&rec_ref->access_root, &rec_ref->access_count, size, \
&(rec_ref->file_rec->counters[MPIIO_ACCESS1_ACCESS]), \
......@@ -1142,10 +1132,8 @@ static void mpiio_runtime_initialize()
}
memset(mpiio_runtime, 0, sizeof(*mpiio_runtime));
/* check if DXT (Darshan extended tracing) should be enabled */
if (getenv("DXT_ENABLE_IO_TRACE")) {
enable_dxt_io_trace = 1;
}
/* allow DXT module to initialize if needed */
dxt_mpiio_runtime_initialize();
return;
}
......@@ -1198,7 +1186,7 @@ static struct mpiio_file_record_ref *mpiio_track_new_file_record(
return(rec_ref);
}
static void mpiio_finalize_file_records(void *rec_ref_p)
static void mpiio_finalize_file_records(void *rec_ref_p, void *user_ptr)
{
struct mpiio_file_record_ref *rec_ref =
(struct mpiio_file_record_ref *)rec_ref_p;
......@@ -1586,7 +1574,8 @@ static void mpiio_shutdown(
/* perform any final transformations on MPIIO file records before
* writing them out to log file
*/
darshan_iter_record_refs(mpiio_runtime->rec_id_hash, &mpiio_finalize_file_records);
darshan_iter_record_refs(mpiio_runtime->rec_id_hash,
&mpiio_finalize_file_records, NULL);
/* if there are globally shared files, do a shared file reduction */
/* NOTE: the shared file reduction is also skipped if the
......
......@@ -29,6 +29,7 @@
#include "utlist.h"
#include "darshan.h"
#include "darshan-dynamic.h"
#include "darshan-dxt.h"
#ifndef HAVE_OFF64_T
typedef int64_t off64_t;
......@@ -152,7 +153,7 @@ static void posix_aio_tracker_add(
static struct posix_aio_tracker* posix_aio_tracker_del(
int fd, void *aiocbp);
static void posix_finalize_file_records(
void *rec_ref_p);
void *rec_ref_p, void *user_ptr);
static void posix_record_reduction_op(
void* infile_v, void* inoutfile_v, int *len, MPI_Datatype *datatype);
static void posix_shared_record_variance(
......@@ -165,12 +166,6 @@ static void posix_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **posix_buf, int *posix_buf_sz);
/* extern DXT function defs */
extern void dxt_posix_write(darshan_record_id rec_id, int64_t offset,
int64_t length, double start_time, double end_time);
extern void dxt_posix_read(darshan_record_id rec_id, int64_t offset,
int64_t length, double start_time, double end_time);
/* extern function def for querying record name from a STDIO stream */
extern char *darshan_stdio_lookup_record_name(FILE *stream);
......@@ -178,7 +173,6 @@ static struct posix_runtime *posix_runtime = NULL;
static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int my_rank = -1;
static int darshan_mem_alignment = 1;
static int enable_dxt_io_trace = 0;
#define POSIX_LOCK() pthread_mutex_lock(&posix_runtime_mutex)
#define POSIX_UNLOCK() pthread_mutex_unlock(&posix_runtime_mutex)
......@@ -259,9 +253,7 @@ static int enable_dxt_io_trace = 0;
else \
this_offset = rec_ref->offset; \
/* DXT to record detailed read tracing information */ \
if(enable_dxt_io_trace) { \
dxt_posix_read(rec_ref->file_rec->base_rec.id, this_offset, __ret, __tm1, __tm2); \
} \
dxt_posix_read(rec_ref->file_rec->base_rec.id, this_offset, __ret, __tm1, __tm2); \
if(this_offset > rec_ref->last_byte_read) \
rec_ref->file_rec->counters[POSIX_SEQ_READS] += 1; \
if(this_offset == (rec_ref->last_byte_read + 1)) \
......@@ -317,9 +309,7 @@ static int enable_dxt_io_trace = 0;
else \
this_offset = rec_ref->offset; \
/* DXT to record detailed write tracing information */ \
if(enable_dxt_io_trace) { \
dxt_posix_write(rec_ref->file_rec->base_rec.id, this_offset, __ret, __tm1, __tm2); \
} \
dxt_posix_write(rec_ref->file_rec->base_rec.id, this_offset, __ret, __tm1, __tm2); \
if(this_offset > rec_ref->last_byte_written) \
rec_ref->file_rec->counters[POSIX_SEQ_WRITES] += 1; \
if(this_offset == (rec_ref->last_byte_written + 1)) \
......@@ -1506,10 +1496,8 @@ static void posix_runtime_initialize()
}
memset(posix_runtime, 0, sizeof(*posix_runtime));
/* check if DXT (Darshan extended tracing) should be enabled */
if (getenv("DXT_ENABLE_IO_TRACE")) {
enable_dxt_io_trace = 1;
}
/* allow DXT module to initialize if needed */
dxt_posix_runtime_initialize();
return;
}
......@@ -1618,7 +1606,7 @@ static void posix_aio_tracker_add(int fd, void *aiocbp)
return;
}
static void posix_finalize_file_records(void *rec_ref_p)
static void posix_finalize_file_records(void *rec_ref_p, void *user_ptr)
{
struct posix_file_record_ref *rec_ref =
(struct posix_file_record_ref *)rec_ref_p;
......@@ -1971,6 +1959,18 @@ char *darshan_posix_lookup_record_name(int fd)
return(rec_name);
}
static struct darshan_posix_file *darshan_posix_rec_id_to_file(darshan_record_id rec_id)
{
struct posix_file_record_ref *rec_ref;
rec_ref = darshan_lookup_record_ref(posix_runtime->rec_id_hash,
&rec_id, sizeof(darshan_record_id));
if(rec_ref)
return(rec_ref->file_rec);
else
return(NULL);
}
/* posix module shutdown benchmark routine */
void darshan_posix_shutdown_bench_setup(int test_case)
{
......@@ -2067,12 +2067,16 @@ static void posix_shutdown(
POSIX_LOCK();
assert(posix_runtime);
/* allow DXT a chance to filter traces based on dynamic triggers */
dxt_posix_filter_dynamic_traces(darshan_posix_rec_id_to_file);
posix_rec_count = posix_runtime->file_rec_count;
/* perform any final transformations on POSIX file records before
* writing them out to log file
*/
darshan_iter_record_refs(posix_runtime->rec_id_hash, &posix_finalize_file_records);
darshan_iter_record_refs(posix_runtime->rec_id_hash,
&posix_finalize_file_records, NULL);
/* if there are globally shared files, do a shared file reduction */
/* NOTE: the shared file reduction is also skipped if the
......
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