Commit d172df2e authored by Shane Snyder's avatar Shane Snyder
Browse files

add user pointer to record_ref iterators

parent 9007db12
......@@ -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()
*
......
......@@ -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;
......
......@@ -752,7 +752,7 @@ static struct dxt_file_record_ref *dxt_mpiio_track_new_file_record(
return(rec_ref);
}
static void dxt_free_record_data(void *rec_ref_p)
static void dxt_free_record_data(void *rec_ref_p, void *user_ptr)
{
struct dxt_file_record_ref *dxt_rec_ref = (struct dxt_file_record_ref *)rec_ref_p;
......@@ -763,7 +763,8 @@ static void dxt_free_record_data(void *rec_ref_p)
static void dxt_posix_cleanup_runtime()
{
darshan_iter_record_refs(dxt_posix_runtime->rec_id_hash, dxt_free_record_data);
darshan_iter_record_refs(dxt_posix_runtime->rec_id_hash,
dxt_free_record_data, NULL);
darshan_clear_record_refs(&(dxt_posix_runtime->rec_id_hash), 1);
free(dxt_posix_runtime);
......@@ -774,7 +775,8 @@ static void dxt_posix_cleanup_runtime()
static void dxt_mpiio_cleanup_runtime()
{
darshan_iter_record_refs(dxt_mpiio_runtime->rec_id_hash, dxt_free_record_data);
darshan_iter_record_refs(dxt_mpiio_runtime->rec_id_hash,
dxt_free_record_data, NULL);
darshan_clear_record_refs(&(dxt_mpiio_runtime->rec_id_hash), 1);
free(dxt_mpiio_runtime);
......@@ -787,7 +789,7 @@ static void dxt_mpiio_cleanup_runtime()
* shutdown function exported by this module for coordinating with darshan-core *
********************************************************************************/
static void dxt_serialize_posix_records(void *rec_ref_p)
static void dxt_serialize_posix_records(void *rec_ref_p, void *user_ptr)
{
struct dxt_file_record_ref *rec_ref = (struct dxt_file_record_ref *)rec_ref_p;
struct dxt_file_record *file_rec;
......@@ -888,7 +890,8 @@ static void dxt_posix_shutdown(
dxt_posix_runtime->record_buf_size = 0;
/* iterate all dxt posix records and serialize them to the output buffer */
darshan_iter_record_refs(dxt_posix_runtime->rec_id_hash, dxt_serialize_posix_records);
darshan_iter_record_refs(dxt_posix_runtime->rec_id_hash,
dxt_serialize_posix_records, NULL);
/* set output */
*dxt_posix_buf = dxt_posix_runtime->record_buf;
......@@ -900,7 +903,7 @@ static void dxt_posix_shutdown(
return;
}
static void dxt_serialize_mpiio_records(void *rec_ref_p)
static void dxt_serialize_mpiio_records(void *rec_ref_p, void *user_ptr)
{
struct dxt_file_record_ref *rec_ref = (struct dxt_file_record_ref *)rec_ref_p;
struct dxt_file_record *file_rec;
......@@ -998,7 +1001,8 @@ static void dxt_mpiio_shutdown(
dxt_mpiio_runtime->record_buf_size = 0;
/* iterate all dxt posix records and serialize them to the output buffer */
darshan_iter_record_refs(dxt_mpiio_runtime->rec_id_hash, dxt_serialize_mpiio_records);
darshan_iter_record_refs(dxt_mpiio_runtime->rec_id_hash,
dxt_serialize_mpiio_records, NULL);
/* set output */
*dxt_mpiio_buf = dxt_mpiio_runtime->record_buf;
......
......@@ -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;
......
......@@ -160,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(
......@@ -1186,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;
......@@ -1574,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
......
......@@ -153,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(
......@@ -1606,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;
......@@ -2060,7 +2060,8 @@ static void posix_shutdown(
/* 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