Commit fed37946 authored by Shane Snyder's avatar Shane Snyder

convert to a single module shutdown function

rather than using 'begin_shutdown', 'get_output_data', and
'shutdown', we combine all three into one shutdown routine.
parent 54baa7dd
......@@ -55,7 +55,7 @@ struct darshan_core_module
void *rec_buf_start;
void *rec_buf_p;
int rec_mem_avail;
struct darshan_module_funcs funcs;
darshan_module_shutdown mod_shutdown_func;
};
/* strucutre for keeping a reference to registered name records */
......
......@@ -56,32 +56,22 @@
/* default number of records to attempt to store for each module */
#define DARSHAN_DEF_MOD_REC_COUNT 1024
/* module developers provide the following functions to darshan-core */
struct darshan_module_funcs
{
/* perform any necessary pre-shutdown steps
*
* NOTE: this typically includes disabling wrapper functions so
* darshan-core can shutdown in a consistent state.
*/
void (*begin_shutdown)(void);
/* retrieve module data to write to log file
*
* NOTE: module developers can use this function to run collective
* MPI operations at shutdown time. Typically this functionality
* has been used to reduce records shared globablly (given in the
* 'shared_recs' array) into a single data record.
*/
void (*get_output_data)(
MPI_Comm mod_comm, /* MPI communicator to run collectives with */
darshan_record_id *shared_recs, /* list of shared data record ids */
int shared_rec_count, /* count of shared data records */
void** mod_buf, /* output parameter to save module buffer address */
int* mod_buf_sz /* output parameter to save module buffer size */
);
/* shutdown module data structures */
void (*shutdown)(void);
};
/* module developers must define a 'darshan_module_shutdown' function
* for allowing darshan-core to call into a module and retrieve final
* output data to be saved in the log.
*
* NOTE: module developers can use this function to run collective
* MPI operations at shutdown time. Typically this functionality
* has been used to reduce records shared globablly (given in the
* 'shared_recs' array) into a single data record.
*/
typedef void (*darshan_module_shutdown)(
MPI_Comm mod_comm, /* MPI communicator to run collectives with */
darshan_record_id *shared_recs, /* list of shared data record ids */
int shared_rec_count, /* count of shared data records */
void **mod_buf, /* output parameter to save module buffer address */
int *mod_buf_sz /* output parameter to save module buffer size */
);
/*****************************************************
* darshan-core functions exported to darshan modules *
......@@ -103,7 +93,7 @@ struct darshan_module_funcs
*/
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
darshan_module_shutdown mod_shutdown_func,
int *inout_mod_buf_size,
int *rank,
int *sys_mem_alignment);
......
......@@ -406,10 +406,7 @@ void darshan_core_shutdown()
for(i = 0; i < DARSHAN_MAX_MODS; i++)
{
if(final_core->mod_array[i])
{
local_mod_use[i] = 1;
final_core->mod_array[i]->funcs.begin_shutdown();
}
}
/* reduce the number of times a module was opened globally and bcast to everyone */
......@@ -566,7 +563,7 @@ void darshan_core_shutdown()
{
mod_buf = final_core->mod_array[i]->rec_buf_start;
mod_buf_sz = final_core->mod_array[i]->rec_buf_p - mod_buf;
this_mod->funcs.get_output_data(MPI_COMM_WORLD, mod_shared_recs,
this_mod->mod_shutdown_func(MPI_COMM_WORLD, mod_shared_recs,
mod_shared_rec_cnt, &mod_buf, &mod_buf_sz);
}
......@@ -593,11 +590,6 @@ void darshan_core_shutdown()
return;
}
/* shutdown module if registered locally */
if(this_mod)
{
this_mod->funcs.shutdown();
}
if(internal_timing_flag)
mod2[i] = DARSHAN_MPI_CALL(PMPI_Wtime)();
}
......@@ -1692,7 +1684,7 @@ static void darshan_core_cleanup(struct darshan_core_runtime* core)
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
darshan_module_shutdown mod_shutdown_func,
int *inout_mod_buf_size,
int *rank,
int *sys_mem_alignment)
......@@ -1730,7 +1722,7 @@ void darshan_core_register_module(
mod->rec_mem_avail = mod_mem_avail;
mod->rec_buf_start = darshan_core->log_mod_p + darshan_core->mod_mem_used;
mod->rec_buf_p = mod->rec_buf_start;
mod->funcs = *funcs;
mod->mod_shutdown_func = mod_shutdown_func;
/* register module with darshan */
darshan_core->mod_array[mod_id] = mod;
......
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