Commit f57f753c authored by Shane Snyder's avatar Shane Snyder

bug fixes from merge of mmap-dev to dev-modular

parent 96801d4a
......@@ -144,17 +144,6 @@ int darshan_core_register_record(
int rec_size,
int *file_alignment);
/* darshan_core_unregister_record()
*
* Unregister record identifier 'rec_id' in the darshan-core runtime.
* This unregister is only in the context of module identifier 'mod_id',
* meaning that if the file record has other module's associated with
* it, then the record won't be completely removed.
*/
void darshan_core_unregister_record(
darshan_record_id rec_id,
darshan_module_id mod_id);
/* darshan_core_wtime()
*
* Returns the elapsed time relative to (roughly) the start of
......
......@@ -1551,7 +1551,6 @@ static void darshan_core_cleanup(struct darshan_core_runtime* core)
HASH_ITER(hlink, core->rec_hash, ref, tmp)
{
HASH_DELETE(hlink, core->rec_hash, ref);
/* XXX MMAP: free(ref->rec.name); */
free(ref);
}
......@@ -1599,6 +1598,14 @@ void darshan_core_register_module(
return;
}
mod = malloc(sizeof(*mod));
if(!mod)
{
DARSHAN_CORE_UNLOCK();
return;
}
memset(mod, 0, sizeof(*mod));
/* assign a buffer from Darshan's contiguous module memory range for
* this module to use for storing record data
*/
......@@ -1607,25 +1614,18 @@ void darshan_core_register_module(
*inout_mod_size = mod_mem_req;
else
*inout_mod_size = mod_mem_avail;
*mod_buf = darshan_core->log_mod_p + darshan_core->mod_mem_used;
darshan_core->mod_mem_used += *inout_mod_size;
darshan_core->log_hdr_p->mod_map[mod_id].off =
((char *)*mod_buf - (char *)darshan_core->log_hdr_p);
mod = malloc(sizeof(*mod));
if(!mod)
{
DARSHAN_CORE_UNLOCK();
return;
}
memset(mod, 0, sizeof(*mod));
/* register module with darshan */
mod->mod_funcs = *funcs;
mod->mem_avail = *inout_mod_size;
/* register module with darshan */
darshan_core->mod_array[mod_id] = mod;
/* update darshan header and internal structures */
darshan_core->log_hdr_p->mod_ver[mod_id] = darshan_module_versions[mod_id];
darshan_core->log_hdr_p->mod_map[mod_id].off =
((char *)*mod_buf - (char *)darshan_core->log_hdr_p);
darshan_core->mod_mem_used += *inout_mod_size;
DARSHAN_CORE_UNLOCK();
/* set the memory alignment and calling process's rank, if desired */
......@@ -1637,7 +1637,6 @@ void darshan_core_register_module(
return;
}
/* TODO: test */
void darshan_core_unregister_module(
darshan_module_id mod_id)
{
......@@ -1651,11 +1650,20 @@ void darshan_core_unregister_module(
/* iterate all records and disassociate this module from them */
HASH_ITER(hlink, darshan_core->rec_hash, ref, tmp)
{
darshan_core_unregister_record(ref->id, mod_id);
/* disassociate this module from the given record id */
DARSHAN_MOD_FLAG_UNSET(ref->mod_flags, mod_id);
if(!(ref->mod_flags))
{
/* if no other modules are associated with this rec, delete it */
HASH_DELETE(hlink, darshan_core->rec_hash, ref);
}
}
/* update darshan internal structures and header */
free(darshan_core->mod_array[mod_id]);
darshan_core->mod_array[mod_id] = NULL;
darshan_core->log_hdr_p->mod_map[mod_id].off =
darshan_core->log_hdr_p->mod_map[mod_id].len = 0;
DARSHAN_CORE_UNLOCK();
......@@ -1741,25 +1749,6 @@ void darshan_core_unregister_record(
darshan_record_id rec_id,
darshan_module_id mod_id)
{
struct darshan_core_record_ref *ref;
if(!darshan_core)
return;
DARSHAN_CORE_LOCK();
HASH_FIND(hlink, darshan_core->rec_hash, &rec_id, sizeof(darshan_record_id), ref);
assert(ref);
/* disassociate this module from the given record id */
DARSHAN_MOD_FLAG_UNSET(ref->mod_flags, mod_id);
if(!(ref->mod_flags))
{
/* if no other modules are associated with this rec, delete it */
HASH_DELETE(hlink, darshan_core->rec_hash, ref);
}
DARSHAN_CORE_UNLOCK();
return;
}
double darshan_core_wtime()
......
......@@ -209,6 +209,9 @@ static void hdf5_runtime_initialize()
if(hdf5_runtime || instrumentation_disabled)
return;
/* try and store the default number of records for this module */
hdf5_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_hdf5_file);
/* register hdf5 module with darshan-core */
darshan_core_register_module(
DARSHAN_HDF5_MOD,
......@@ -220,11 +223,17 @@ static void hdf5_runtime_initialize()
/* return if darshan-core does not provide enough module memory */
if(hdf5_buf_size < sizeof(struct darshan_hdf5_file))
{
darshan_core_unregister_module(DARSHAN_HDF5_MOD);
return;
}
hdf5_runtime = malloc(sizeof(*hdf5_runtime));
if(!hdf5_runtime)
{
darshan_core_unregister_module(DARSHAN_HDF5_MOD);
return;
}
memset(hdf5_runtime, 0, sizeof(*hdf5_runtime));
/* set number of trackable files for the HDF5 module according to the
......@@ -567,7 +576,6 @@ static void hdf5_shutdown()
HASH_CLEAR(hlink, hdf5_runtime->file_hash); /* these entries are freed all at once below */
free(hdf5_runtime->file_runtime_array);
free(hdf5_runtime->file_record_array);
free(hdf5_runtime);
hdf5_runtime = NULL;
......
......@@ -846,11 +846,17 @@ static void mpiio_runtime_initialize()
/* return if darshan-core does not provide enough module memory */
if(mpiio_buf_size < sizeof(struct darshan_mpiio_file))
{
darshan_core_unregister_module(DARSHAN_MPIIO_MOD);
return;
}
mpiio_runtime = malloc(sizeof(*mpiio_runtime));
if(!mpiio_runtime)
{
darshan_core_unregister_module(DARSHAN_MPIIO_MOD);
return;
}
memset(mpiio_runtime, 0, sizeof(*mpiio_runtime));
/* set number of trackable files for the MPIIO module according to the
......
......@@ -388,7 +388,6 @@ static void null_shutdown()
HASH_CLEAR(hlink, null_runtime->record_hash); /* these hash entries are freed all at once below */
free(null_runtime->runtime_record_array);
free(null_runtime->record_array);
free(null_runtime);
null_runtime = NULL;
......
......@@ -235,11 +235,17 @@ static void pnetcdf_runtime_initialize()
/* return if darshan-core does not provide enough module memory */
if(pnetcdf_buf_size < sizeof(struct darshan_pnetcdf_file))
{
darshan_core_unregister_module(DARSHAN_PNETCDF_MOD);
return;
}
pnetcdf_runtime = malloc(sizeof(*pnetcdf_runtime));
if(!pnetcdf_runtime)
{
darshan_core_unregister_module(DARSHAN_PNETCDF_MOD);
return;
}
memset(pnetcdf_runtime, 0, sizeof(*pnetcdf_runtime));
/* set number of trackable files for the PNETCDF module according to the
......@@ -582,7 +588,6 @@ static void pnetcdf_shutdown()
HASH_CLEAR(hlink, pnetcdf_runtime->file_hash); /* these entries are freed all at once below */
free(pnetcdf_runtime->file_runtime_array);
free(pnetcdf_runtime->file_record_array);
free(pnetcdf_runtime);
pnetcdf_runtime = NULL;
......
......@@ -1641,11 +1641,17 @@ static void posix_runtime_initialize()
/* return if darshan-core does not provide enough module memory */
if(psx_buf_size < sizeof(struct darshan_posix_file))
{
darshan_core_unregister_module(DARSHAN_POSIX_MOD);
return;
}
posix_runtime = malloc(sizeof(*posix_runtime));
if(!posix_runtime)
{
darshan_core_unregister_module(DARSHAN_POSIX_MOD);
return;
}
memset(posix_runtime, 0, sizeof(*posix_runtime));
/* set number of trackable files for the POSIX module according to 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