Skip to content

Commit

Permalink
whitespace changes and other small things
Browse files Browse the repository at this point in the history
 * move various LDMS code so it's contiguous where possible
 * various indentation/whitespace changes
 * remove unused dC vars
 * fix source copyright
  • Loading branch information
shanedsnyder committed Nov 29, 2023
1 parent 2600470 commit 8732926
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 118 deletions.
4 changes: 2 additions & 2 deletions darshan-runtime/lib/darshan-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void darshan_core_initialize(int argc, char **argv)
/* setup darshan runtime if darshan is enabled and hasn't been initialized already */
if (__darshan_core != NULL || getenv("DARSHAN_DISABLE"))
return;

init_start = darshan_core_wtime_absolute();

/* allocate structure to track darshan core runtime information */
Expand Down Expand Up @@ -356,7 +357,7 @@ void darshan_core_initialize(int argc, char **argv)
/* pass init_core to darshan-ldms connector initialization*/
darshan_ldms_connector_initialize(init_core);
#endif

/* if darshan was successfully initialized, set the global pointer
* and record absolute start time so that we can later generate
* relative times with this as a reference point.
Expand Down Expand Up @@ -776,7 +777,6 @@ void darshan_core_shutdown(int write_log)
free(mod_shared_recs);
}
#endif

free(logfile_name);

return;
Expand Down
91 changes: 45 additions & 46 deletions darshan-runtime/lib/darshan-hdf5.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

#include "darshan.h"
#include "darshan-dynamic.h"
#include "darshan-ldms.h"

#include <hdf5.h>
#include "darshan-ldms.h"

/* H5F prototypes */
DARSHAN_FORWARD_DECL(H5Fcreate, hid_t, (const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist));
Expand Down Expand Up @@ -167,7 +167,6 @@ static int my_rank = -1;
darshan_record_id __rec_id; \
struct hdf5_file_record_ref *__rec_ref; \
char *__newpath; \
extern struct darshanConnector dC; \
__newpath = darshan_clean_file_path(__path); \
if(!__newpath) __newpath = (char *)__path; \
__rec_id = darshan_core_gen_record_id(__newpath); \
Expand All @@ -187,10 +186,11 @@ static int my_rank = -1;
__tm1, __tm2, __rec_ref->last_meta_end); \
darshan_add_record_ref(&(hdf5_file_runtime->hid_hash), &__ret, sizeof(hid_t), __rec_ref); \
if(__newpath != __path) free(__newpath); \
/* LDMS to publish realtime read tracing information to daemon*/ \
/* LDMS to publish realtime open tracing information to daemon*/ \
extern struct darshanConnector dC; \
if(dC.ldms_lib)\
if(dC.hdf5_enable_ldms)\
darshan_ldms_connector_send(__rec_ref->file_rec->base_rec.id, __rec_ref->file_rec->base_rec.rank,__rec_ref->file_rec->counters[H5F_OPENS], "open", -1, -1, -1, -1, __rec_ref->file_rec->counters[H5F_FLUSHES], __tm1, __tm2, __rec_ref->file_rec->fcounters[H5F_F_META_TIME], "H5F", "MET");\
darshan_ldms_connector_send(__rec_ref->file_rec->base_rec.id, __rec_ref->file_rec->base_rec.rank,__rec_ref->file_rec->counters[H5F_OPENS], "open", -1, -1, -1, -1, __rec_ref->file_rec->counters[H5F_FLUSHES], __tm1, __tm2, __rec_ref->file_rec->fcounters[H5F_F_META_TIME], "H5F", "MET");\
} while(0)

hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
Expand Down Expand Up @@ -447,12 +447,12 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
&file_id, sizeof(hid_t));

#ifdef HAVE_LDMS
rec_ref->close_counts++;
/* publish close information for h5f */
extern struct darshanConnector dC;
if(dC.ldms_lib)
if(dC.hdf5_enable_ldms)
darshan_ldms_connector_send(rec_ref->file_rec->base_rec.id, rec_ref->file_rec->base_rec.rank, rec_ref->close_counts, "close", -1, -1, -1, -1, rec_ref->file_rec->counters[H5F_FLUSHES], tm1, tm2, rec_ref->file_rec->fcounters[H5F_F_META_TIME], "H5F", "MOD");
rec_ref->close_counts++;
/* publish close information for h5f */
extern struct darshanConnector dC;
if(dC.ldms_lib)
if(dC.hdf5_enable_ldms)
darshan_ldms_connector_send(rec_ref->file_rec->base_rec.id, rec_ref->file_rec->base_rec.rank, rec_ref->close_counts, "close", -1, -1, -1, -1, rec_ref->file_rec->counters[H5F_FLUSHES], tm1, tm2, rec_ref->file_rec->fcounters[H5F_F_META_TIME], "H5F", "MOD");
#endif
}
H5F_POST_RECORD();
Expand Down Expand Up @@ -495,7 +495,6 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
ssize_t __req_name_len = DARSHAN_HDF5_MAX_NAME_LEN-1, __ret_name_len; \
darshan_record_id __rec_id, __file_rec_id = 0; \
struct hdf5_dataset_record_ref *__rec_ref; \
extern struct darshanConnector dC; \
hsize_t __chunk_dims[H5D_MAX_NDIMS] = {0}; \
int __i, __n_chunk_dims = 0; \
/* get corresponding file name */\
Expand Down Expand Up @@ -539,16 +538,17 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
if(__dcpl_id != H5P_DEFAULT && H5Pget_layout(__dcpl_id) == H5D_CHUNKED) { \
__n_chunk_dims = H5Pget_chunk(__dcpl_id, H5D_MAX_NDIMS, __chunk_dims); \
__n_chunk_dims = (__n_chunk_dims < H5D_MAX_NDIMS) ? __n_chunk_dims : H5D_MAX_NDIMS; \
for(__i = 0; __i < __n_chunk_dims; __i++){ \
__rec_ref->dataset_rec->counters[H5D_CHUNK_SIZE_D1 + __i] = __chunk_dims[__n_chunk_dims - __i - 1];} \
}\
for(__i = 0; __i < __n_chunk_dims; __i++) \
__rec_ref->dataset_rec->counters[H5D_CHUNK_SIZE_D1 + __i] = __chunk_dims[__n_chunk_dims - __i - 1]; \
} \
__rec_ref->dataset_rec->counters[H5D_DATATYPE_SIZE] = H5Tget_size(__type_id); \
__rec_ref->dataset_rec->file_rec_id = __file_rec_id; \
darshan_add_record_ref(&(hdf5_dataset_runtime->hid_hash), &__ret, sizeof(hid_t), __rec_ref); \
/* LDMS to publish runtime h5d tracing information to daemon*/ \
extern struct darshanConnector dC; \
if(dC.ldms_lib)\
if(dC.hdf5_enable_ldms)\
darshan_ldms_connector_send(__rec_ref->dataset_rec->base_rec.id, __rec_ref->dataset_rec->base_rec.rank,__rec_ref->dataset_rec->counters[H5D_OPENS], "open", -1, -1, -1, -1, __rec_ref->dataset_rec->counters[H5D_FLUSHES], __tm1, __tm2, __rec_ref->dataset_rec->fcounters[H5D_F_META_TIME], "H5D", "MET");\
darshan_ldms_connector_send(__rec_ref->dataset_rec->base_rec.id, __rec_ref->dataset_rec->base_rec.rank,__rec_ref->dataset_rec->counters[H5D_OPENS], "open", -1, -1, -1, -1, __rec_ref->dataset_rec->counters[H5D_FLUSHES], __tm1, __tm2, __rec_ref->dataset_rec->fcounters[H5D_F_META_TIME], "H5D", "MET");\
} while(0)

hid_t DARSHAN_DECL(H5Dcreate1)(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id)
Expand Down Expand Up @@ -797,19 +797,19 @@ herr_t DARSHAN_DECL(H5Dread)(hid_t dataset_id, hid_t mem_type_id, hid_t mem_spac
tm1, tm2, rec_ref->last_read_end);

#ifdef HAVE_LDMS
/* LDMS to publish runtime h5d tracing information to daemon*/
extern struct darshanConnector dC;
if(dC.ldms_lib){
if(dC.hdf5_enable_ldms){
dC.hdf5_data[0] = rec_ref->dataset_rec->counters[H5D_POINT_SELECTS];
dC.hdf5_data[1] = rec_ref->dataset_rec->counters[H5D_IRREGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[2] = rec_ref->dataset_rec->counters[H5D_REGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[3] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NDIMS];
dC.hdf5_data[4] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NPOINTS];

darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->dataset_rec->counters[H5D_READS], "read", -1, rec_ref->dataset_rec->counters[H5D_MAX_READ_TIME_SIZE], -1, rec_ref->dataset_rec->counters[H5D_RW_SWITCHES], rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_READ_TIME], "H5D", "MOD");
/* LDMS to publish runtime h5d tracing information to daemon*/
extern struct darshanConnector dC;
if(dC.ldms_lib){
if(dC.hdf5_enable_ldms){
dC.hdf5_data[0] = rec_ref->dataset_rec->counters[H5D_POINT_SELECTS];
dC.hdf5_data[1] = rec_ref->dataset_rec->counters[H5D_IRREGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[2] = rec_ref->dataset_rec->counters[H5D_REGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[3] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NDIMS];
dC.hdf5_data[4] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NPOINTS];

darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->dataset_rec->counters[H5D_READS], "read", -1, rec_ref->dataset_rec->counters[H5D_MAX_READ_TIME_SIZE], -1, rec_ref->dataset_rec->counters[H5D_RW_SWITCHES], rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_READ_TIME], "H5D", "MOD");
}
}
}
#endif
}
H5D_POST_RECORD();
Expand Down Expand Up @@ -929,20 +929,19 @@ herr_t DARSHAN_DECL(H5Dwrite)(hid_t dataset_id, hid_t mem_type_id, hid_t mem_spa
tm1, tm2, rec_ref->last_write_end);

#ifdef HAVE_LDMS
/* LDMS to publish runtime h5d tracing information to daemon*/
extern struct darshanConnector dC;
if(dC.ldms_lib){
if(dC.hdf5_enable_ldms){
dC.hdf5_data[0] = rec_ref->dataset_rec->counters[H5D_POINT_SELECTS];
dC.hdf5_data[1] = rec_ref->dataset_rec->counters[H5D_IRREGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[2] = rec_ref->dataset_rec->counters[H5D_REGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[3] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NDIMS];
dC.hdf5_data[4] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NPOINTS];

darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->dataset_rec->counters[H5D_WRITES], "write", -1, rec_ref->dataset_rec->counters[H5D_MAX_WRITE_TIME_SIZE], -1, rec_ref->dataset_rec->counters[H5D_RW_SWITCHES], rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_WRITE_TIME], "H5D", "MOD");

/* LDMS to publish runtime h5d tracing information to daemon*/
extern struct darshanConnector dC;
if(dC.ldms_lib){
if(dC.hdf5_enable_ldms){
dC.hdf5_data[0] = rec_ref->dataset_rec->counters[H5D_POINT_SELECTS];
dC.hdf5_data[1] = rec_ref->dataset_rec->counters[H5D_IRREGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[2] = rec_ref->dataset_rec->counters[H5D_REGULAR_HYPERSLAB_SELECTS];
dC.hdf5_data[3] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NDIMS];
dC.hdf5_data[4] = rec_ref->dataset_rec->counters[H5D_DATASPACE_NPOINTS];

darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->dataset_rec->counters[H5D_WRITES], "write", -1, rec_ref->dataset_rec->counters[H5D_MAX_WRITE_TIME_SIZE], -1, rec_ref->dataset_rec->counters[H5D_RW_SWITCHES], rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_WRITE_TIME], "H5D", "MOD");
}
}
}
#endif
}
H5D_POST_RECORD();
Expand Down Expand Up @@ -1011,12 +1010,12 @@ herr_t DARSHAN_DECL(H5Dclose)(hid_t dataset_id)
darshan_delete_record_ref(&(hdf5_dataset_runtime->hid_hash), &dataset_id, sizeof(hid_t));

#ifdef HAVE_LDMS
rec_ref->close_counts++;
/* publish close information for h5f */
extern struct darshanConnector dC;
if(dC.ldms_lib)
if(dC.hdf5_enable_ldms)
darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->close_counts, "close", -1, -1, -1, -1, rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_META_TIME], "H5D", "MOD");
rec_ref->close_counts++;
/* publish close information for h5d */
extern struct darshanConnector dC;
if(dC.ldms_lib)
if(dC.hdf5_enable_ldms)
darshan_ldms_connector_send(rec_ref->dataset_rec->base_rec.id, rec_ref->dataset_rec->base_rec.rank, rec_ref->close_counts, "close", -1, -1, -1, -1, rec_ref->dataset_rec->counters[H5D_FLUSHES], tm1, tm2, rec_ref->dataset_rec->fcounters[H5D_F_META_TIME], "H5D", "MOD");
#endif

}
Expand Down
29 changes: 14 additions & 15 deletions darshan-runtime/lib/darshan-ldms.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 Intel Corporation.
* See COPYRIGHT notice in top-level directory.
* Copyright (C) 2019 University of Chicago.
* See COPYRIGHT notice in top-level directory.
*
*/

Expand Down Expand Up @@ -57,7 +57,6 @@ static void event_cb(ldms_t x, ldms_xprt_event_t e, void *cb_arg)
ldms_t setup_connection(const char *xprt, const char *host,
const char *port, const char *auth)
{
char hostname[PATH_MAX];
const char *timeout = "5";
int rc;
struct timespec ts;
Expand Down Expand Up @@ -114,8 +113,8 @@ void darshan_ldms_connector_initialize(struct darshan_core_runtime *init_core)
else if (getenv("LOAD_STEP_ID"))
dC.jobid = atoi(getenv("LOAD_STEP_ID"));
else
/* grab jobid from darshan_core_runtime if slurm, lsf, sge or loadleveler do not exist*/
dC.jobid = init_core->log_job_p->jobid;
/* grab jobid from darshan_core_runtime if slurm, lsf, sge or loadleveler do not exist*/
dC.jobid = init_core->log_job_p->jobid;

/* grab exe path from darshan_core_runtime. Save with a tmp that will be used later*/
dC.exepath = strtok(init_core->log_exemnt_p, " ");
Expand Down Expand Up @@ -169,16 +168,16 @@ void darshan_ldms_connector_initialize(struct darshan_core_runtime *init_core)

pthread_mutex_lock(&dC.ln_lock);
dC.ldms_darsh = setup_connection(env_ldms_xprt, env_ldms_host, env_ldms_port, env_ldms_auth);
if (dC.conn_status != 0) {
darshan_core_fprintf(stderr, "LDMS library: darshanConnector error %i setting up connection to LDMS streams daemon -- exiting.\n", dC.conn_status);
pthread_mutex_unlock(&dC.ln_lock);
return;
}
else if (dC.ldms_darsh->disconnected){
darshan_core_fprintf(stderr, "LDMS library: darshanConnector disconnected from LDMS streams daemon -- exiting.\n");
pthread_mutex_unlock(&dC.ln_lock);
return;
}
if (dC.conn_status != 0) {
darshan_core_fprintf(stderr, "LDMS library: darshanConnector error %i setting up connection to LDMS streams daemon -- exiting.\n", dC.conn_status);
pthread_mutex_unlock(&dC.ln_lock);
return;
}
else if (dC.ldms_darsh->disconnected){
darshan_core_fprintf(stderr, "LDMS library: darshanConnector disconnected from LDMS streams daemon -- exiting.\n");
pthread_mutex_unlock(&dC.ln_lock);
return;
}
pthread_mutex_unlock(&dC.ln_lock);
return;
}
Expand Down
6 changes: 0 additions & 6 deletions darshan-runtime/lib/darshan-ldms.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ typedef struct darshanConnector {
int64_t write_count;
int conn_status;
struct timespec ts;
uint64_t *record_id;
int64_t *record_count;
pthread_mutex_t ln_lock;
ldms_t ldms_darsh;
ldms_t ldms_g;
Expand Down Expand Up @@ -68,10 +66,6 @@ typedef struct darshanConnector {
* specified module from the set environment variables (i.e. *MODULENAME*_ENABLE_LDMS)
* to LDMSD streams plugin.
*
* LDMS related function to retrieve and set the meta data of each Darshan
* run (i.e. record id, rank, etc.). These values will not be updated unless a different module
* is detected or a new run is executed.
*
*/
void darshan_ldms_connector_initialize(struct darshan_core_runtime *);

Expand Down
Loading

0 comments on commit 8732926

Please sign in to comment.