[Darshan-commits] [Git][darshan/darshan][mmap-dev] 2 commits: register/lookup_record now use strings explicitly
Shane Snyder
xgitlab at cels.anl.gov
Tue May 31 15:55:25 CDT 2016
Shane Snyder pushed to branch mmap-dev at darshan / darshan
Commits:
7d35c45a by Shane Snyder at 2016-05-27T16:36:32-05:00
register/lookup_record now use strings explicitly
- - - - -
bfde9eb7 by Shane Snyder at 2016-05-31T15:47:51-05:00
numerous darshan-core api changes
- memory management is now entirely handled by darshan-core for
module records
* when registering new records, darshan-core returns the
corresponding buffer to write it to, rather than allowing
module to determine this
- modules now decide whether darshan-core should track record
names by passing either a valid name or NULL to the register
function
* this allows modules to register records that aren't really
tracked by darshan-core
- only the POSIX module has been ported to new changes for this
commit
- - - - -
8 changed files:
- darshan-runtime/Makefile.in
- darshan-runtime/darshan-core.h
- darshan-runtime/darshan.h
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-hdf5.c
- darshan-runtime/lib/darshan-mpiio.c
- darshan-runtime/lib/darshan-pnetcdf.c
- darshan-runtime/lib/darshan-posix.c
Changes:
=====================================
darshan-runtime/Makefile.in
=====================================
--- a/darshan-runtime/Makefile.in
+++ b/darshan-runtime/Makefile.in
@@ -35,7 +35,8 @@ CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir)
LIBS = -lz @LIBBZ2@
-DARSHAN_STATIC_MOD_OBJS = lib/darshan-posix.o lib/darshan-mpiio.o lib/darshan-hdf5.o lib/darshan-pnetcdf.o
+DARSHAN_STATIC_MOD_OBJS = lib/darshan-posix.o
+# TODO: lib/darshan-mpiio.o lib/darshan-hdf5.o lib/darshan-pnetcdf.o
DARSHAN_DYNAMIC_MOD_OBJS = lib/darshan-posix.po lib/darshan-mpiio.po lib/darshan-hdf5.po lib/darshan-pnetcdf.po
ifdef DARSHAN_USE_BGQ
=====================================
darshan-runtime/darshan-core.h
=====================================
--- a/darshan-runtime/darshan-core.h
+++ b/darshan-runtime/darshan-core.h
@@ -52,8 +52,10 @@
/* structure to track registered modules */
struct darshan_core_module
{
- struct darshan_module_funcs mod_funcs;
- int mem_avail;
+ void *rec_buf_start;
+ void *rec_buf_p;
+ int rec_mem_avail;
+ struct darshan_module_funcs funcs;
};
struct darshan_core_name_record_ref
@@ -78,7 +80,6 @@ struct darshan_core_runtime
struct darshan_core_module* mod_array[DARSHAN_MAX_MODS];
int mod_mem_used;
struct darshan_core_name_record_ref *name_hash;
- int name_hash_cnt;
double wtime_offset;
char *comp_buf;
#ifdef __DARSHAN_ENABLE_MMAP_LOGS
=====================================
darshan-runtime/darshan.h
=====================================
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -101,8 +101,7 @@ struct darshan_module_funcs
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
- int *inout_mod_size,
- void **mod_buf,
+ int *inout_mod_buf_size,
int *rank,
int *sys_mem_alignment);
@@ -114,14 +113,12 @@ void darshan_core_register_module(
void darshan_core_unregister_module(
darshan_module_id mod_id);
-/* darshan_core_lookup_record()
+/* darshan_core_gen_record_id()
*
*
*/
-void darshan_core_lookup_record(
- void *name,
- int name_len,
- darshan_record_id *rec_id);
+darshan_record_id darshan_core_gen_record_id(
+ char *name);
/* darshan_core_register_record()
*
@@ -137,11 +134,11 @@ void darshan_core_lookup_record(
* correspoing Darshan record identifier and 'file_alignment' is an output
* pointer storing the file system alignment value for the given record.
*/
-int darshan_core_register_record(
+void *darshan_core_register_record(
darshan_record_id rec_id,
- void *name,
+ char *name,
darshan_module_id mod_id,
- int rec_size,
+ int rec_len,
int *file_alignment);
/* darshan_core_wtime()
=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -94,8 +94,8 @@ static void darshan_log_record_hints_and_ver(
static void darshan_get_exe_and_mounts(
struct darshan_core_runtime *core, int argc, char **argv);
static void darshan_add_name_record_ref(
- struct darshan_core_runtime *core, char *name,
- darshan_record_id id, struct darshan_core_name_record_ref **ref);
+ struct darshan_core_runtime *core, darshan_record_id rec_id,
+ char *name, darshan_module_id mod_id);
static int darshan_block_size_from_path(
const char *path);
static void darshan_get_user_name(
@@ -436,7 +436,7 @@ void darshan_core_shutdown()
if(final_core->mod_array[i])
{
local_mod_use[i] = 1;
- final_core->mod_array[i]->mod_funcs.begin_shutdown();
+ final_core->mod_array[i]->funcs.begin_shutdown();
}
}
@@ -640,7 +640,9 @@ void darshan_core_shutdown()
*/
if(this_mod)
{
- this_mod->mod_funcs.get_output_data(MPI_COMM_WORLD, mod_shared_recs,
+ 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,
mod_shared_rec_cnt, &mod_buf, &mod_buf_sz);
}
@@ -669,7 +671,7 @@ void darshan_core_shutdown()
/* shutdown module if registered locally */
if(this_mod)
{
- this_mod->mod_funcs.shutdown();
+ this_mod->funcs.shutdown();
}
if(internal_timing_flag)
mod2[i] = DARSHAN_MPI_CALL(PMPI_Wtime)();
@@ -1219,29 +1221,34 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
return;
}
-static void darshan_add_name_record_ref(struct darshan_core_runtime *core, char *name,
- darshan_record_id id, struct darshan_core_name_record_ref **ref)
+static void darshan_add_name_record_ref(struct darshan_core_runtime *core,
+ darshan_record_id rec_id, char *name, darshan_module_id mod_id)
{
+ struct darshan_core_name_record_ref *ref;
int record_size = sizeof(darshan_record_id) + strlen(name) + 1;
if((record_size + core->log_hdr_p->name_map.len) > DARSHAN_NAME_RECORD_BUF_SIZE)
return;
- *ref = malloc(sizeof(**ref));
- if(*ref)
+ ref = malloc(sizeof(*ref));
+ if(ref)
{
- memset(*ref, 0, sizeof(**ref));
+ memset(ref, 0, sizeof(*ref));
- (*ref)->name_record = (struct darshan_name_record *)
+ ref->name_record = (struct darshan_name_record *)
((char *)core->log_name_p + core->log_hdr_p->name_map.len);
- memset((*ref)->name_record, 0, record_size);
- (*ref)->name_record->id = id;
- strcpy((*ref)->name_record->name, name);
+ memset(ref->name_record, 0, record_size);
+ ref->name_record->id = rec_id;
+ strcpy(ref->name_record->name, name);
+
+ if(!DARSHAN_MOD_FLAG_ISSET(ref->mod_flags, mod_id))
+ {
+ DARSHAN_MOD_FLAG_SET(ref->mod_flags, mod_id);
+ }
/* add the record to the hash table */
HASH_ADD(hlink, core->name_hash, name_record->id,
- sizeof(darshan_record_id), (*ref));
- core->name_hash_cnt++;
+ sizeof(darshan_record_id), ref);
core->log_hdr_p->name_map.len += record_size;
}
@@ -1252,7 +1259,7 @@ static void darshan_get_shared_records(struct darshan_core_runtime *core,
darshan_record_id **shared_recs, int *shared_rec_cnt)
{
int i, j;
- int tmp_cnt = core->name_hash_cnt;
+ int tmp_cnt = HASH_CNT(hlink, core->name_hash);
struct darshan_core_name_record_ref *tmp, *ref;
darshan_record_id *id_array;
uint64_t *mod_flags;
@@ -1675,17 +1682,15 @@ 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,
- int *inout_mod_size,
- void **mod_buf,
+ int *inout_mod_buf_size,
int *rank,
int *sys_mem_alignment)
{
struct darshan_core_module* mod;
- int mod_mem_req = *inout_mod_size;
+ int mod_mem_req = *inout_mod_buf_size;
int mod_mem_avail;
- *mod_buf = NULL;
- *inout_mod_size = 0;
+ *inout_mod_buf_size = 0;
if(!darshan_core || (mod_id >= DARSHAN_MAX_MODS))
return;
@@ -1706,26 +1711,27 @@ void darshan_core_register_module(
}
memset(mod, 0, sizeof(*mod));
- /* assign a buffer from Darshan's contiguous module memory range for
- * this module to use for storing record data
- */
+ /* set module's record buffer and max memory usage */
mod_mem_avail = DARSHAN_MOD_MEM_MAX - darshan_core->mod_mem_used;
if(mod_mem_avail >= mod_mem_req)
- *inout_mod_size = mod_mem_req;
+ mod->rec_mem_avail = mod_mem_req;
else
- *inout_mod_size = mod_mem_avail;
- *mod_buf = darshan_core->log_mod_p + darshan_core->mod_mem_used;
+ 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;
/* register module with darshan */
- mod->mod_funcs = *funcs;
- mod->mem_avail = *inout_mod_size;
darshan_core->mod_array[mod_id] = mod;
- darshan_core->mod_mem_used += *inout_mod_size;
+ darshan_core->mod_mem_used += mod->rec_mem_avail;
/* update darshan header */
+ /* TODO: ifdef wrap for mmap ? */
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);
+ ((char *)mod->rec_buf_start - (char *)darshan_core->log_hdr_p);
+
+ *inout_mod_buf_size = mod->rec_mem_avail;
DARSHAN_CORE_UNLOCK();
/* set the memory alignment and calling process's rank, if desired */
@@ -1771,76 +1777,60 @@ void darshan_core_unregister_module(
return;
}
-void darshan_core_lookup_record(
- void *name,
- int name_len,
- darshan_record_id *rec_id)
+darshan_record_id darshan_core_gen_record_id(
+ char *name)
{
- darshan_record_id tmp_rec_id;
-
- /* TODO: how do we handle potentially non-ascii record names? */
-
/* hash the input name to get a unique id for this record */
- tmp_rec_id = darshan_hash(name, name_len, 0);
- *rec_id = tmp_rec_id;
-
- return;
+ return darshan_hash((unsigned char *)name, strlen(name), 0);
}
-int darshan_core_register_record(
+void *darshan_core_register_record(
darshan_record_id rec_id,
- void *name,
+ char *name,
darshan_module_id mod_id,
- int rec_size,
+ int rec_len,
int *file_alignment)
{
struct darshan_core_name_record_ref *ref;
- int mod_oom = 0;
+ void *rec_buf;
if(!darshan_core)
- return 0;
+ return(NULL);
DARSHAN_CORE_LOCK();
/* check to see if this module has enough space to store a new record */
- if(darshan_core->mod_array[mod_id]->mem_avail < rec_size)
- mod_oom = 1;
-
- /* check to see if we've already stored the id->name mapping for this record */
- HASH_FIND(hlink, darshan_core->name_hash, &rec_id, sizeof(darshan_record_id), ref);
- if(!ref && !mod_oom)
- {
- /* no mapping already exists, but this module has memory available for
- * storing the record being registered, so we create a new id->name
- * mapping to correspond to the record
- */
- darshan_add_name_record_ref(darshan_core, name, rec_id, &ref);
- }
-
- if(!ref)
+ if(darshan_core->mod_array[mod_id]->rec_mem_avail < rec_len)
{
- /* if there still is no mapping for this record, either the
- * module is out of memory or there is no more memory available for
- * id->name mappings. just back out and indicate the record was
- * not registered
- */
DARSHAN_MOD_FLAG_SET(darshan_core->log_hdr_p->partial_flag, mod_id);
DARSHAN_CORE_UNLOCK();
- return 0;
+ return(NULL);
}
- if(!DARSHAN_MOD_FLAG_ISSET(ref->mod_flags, mod_id))
+ /* register a name record if a name is given for this record */
+ if(name)
{
- DARSHAN_MOD_FLAG_SET(ref->mod_flags, mod_id);
- darshan_core->mod_array[mod_id]->mem_avail -= rec_size;
- darshan_core->log_hdr_p->mod_map[mod_id].len += rec_size;
+ /* check to see if we've already stored the id->name mapping for
+ * this record, and add a new name record if not
+ */
+ HASH_FIND(hlink, darshan_core->name_hash, &rec_id,
+ sizeof(darshan_record_id), ref);
+ if(!ref)
+ {
+ darshan_add_name_record_ref(darshan_core, rec_id, name, mod_id);
+ }
}
+
+ rec_buf = darshan_core->mod_array[mod_id]->rec_buf_p;
+ darshan_core->mod_array[mod_id]->rec_buf_p += rec_len;
+ darshan_core->mod_array[mod_id]->rec_mem_avail -= rec_len;
+ darshan_core->log_hdr_p->mod_map[mod_id].len += rec_len; /* XXX */
DARSHAN_CORE_UNLOCK();
if(file_alignment)
*file_alignment = darshan_block_size_from_path(name);
- return 1;
+ return(rec_buf);;
}
/* TODO: */
=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
--- a/darshan-runtime/lib/darshan-hdf5.c
+++ b/darshan-runtime/lib/darshan-hdf5.c
@@ -279,8 +279,7 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
/* lookup the unique id for this filename */
darshan_core_lookup_record(
- (void*)newname,
- strlen(newname),
+ newname,
&file_id);
/* search the hash table for this file record, and return if found */
@@ -288,7 +287,7 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
if(!file)
{
/* register the record with the darshan core component */
- ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_HDF5_MOD,
+ ret = darshan_core_register_record(file_id, newname, DARSHAN_HDF5_MOD,
sizeof(struct darshan_hdf5_file), NULL);
if(ret == 1)
{
=====================================
darshan-runtime/lib/darshan-mpiio.c
=====================================
--- a/darshan-runtime/lib/darshan-mpiio.c
+++ b/darshan-runtime/lib/darshan-mpiio.c
@@ -910,8 +910,7 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
/* lookup the unique id for this filename */
darshan_core_lookup_record(
- (void*)newname,
- strlen(newname),
+ newname,
&file_id);
/* search the hash table for this file record, and return if found */
@@ -919,7 +918,7 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
if(!file)
{
/* register the record with the darshan core component */
- ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_MPIIO_MOD,
+ ret = darshan_core_register_record(file_id, newname, DARSHAN_MPIIO_MOD,
sizeof(struct darshan_mpiio_file), NULL);
if(ret == 1)
{
=====================================
darshan-runtime/lib/darshan-pnetcdf.c
=====================================
--- a/darshan-runtime/lib/darshan-pnetcdf.c
+++ b/darshan-runtime/lib/darshan-pnetcdf.c
@@ -291,8 +291,7 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
/* lookup the unique id for this filename */
darshan_core_lookup_record(
- (void*)newname,
- strlen(newname),
+ newname,
&file_id);
/* search the hash table for this file record, and return if found */
@@ -300,7 +299,7 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
if(!file)
{
/* register the record with the darshan core component */
- ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_PNETCDF_MOD,
+ ret = darshan_core_register_record(file_id, newname, DARSHAN_PNETCDF_MOD,
sizeof(struct darshan_pnetcdf_file), NULL);
if(ret == 1)
{
=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -168,9 +168,6 @@ struct posix_file_runtime_ref
*/
struct posix_runtime
{
- struct posix_file_runtime* file_runtime_array;
- struct darshan_posix_file* file_record_array;
- int file_array_ndx;
struct posix_file_runtime* file_hash;
struct posix_file_runtime_ref* fd_hash;
};
@@ -1450,9 +1447,7 @@ static void posix_runtime_initialize()
.get_output_data = &posix_get_output_data,
.shutdown = &posix_shutdown
};
- void *psx_buf;
int psx_buf_size;
- int file_array_size;
/* don't do anything if already initialized or instrumenation is disabled */
if(posix_runtime || instrumentation_disabled)
@@ -1466,7 +1461,6 @@ static void posix_runtime_initialize()
DARSHAN_POSIX_MOD,
&posix_mod_fns,
&psx_buf_size,
- &psx_buf,
&my_rank,
&darshan_mem_alignment);
@@ -1485,40 +1479,17 @@ static void posix_runtime_initialize()
}
memset(posix_runtime, 0, sizeof(*posix_runtime));
- /* set number of trackable files for the POSIX module according to the
- * amount of memory returned by darshan-core
- */
- file_array_size = psx_buf_size / sizeof(struct darshan_posix_file);
- posix_runtime->file_array_ndx = 0;
-
- /* store pointer to POSIX record buffer given by darshan-core */
- posix_runtime->file_record_array = (struct darshan_posix_file *)psx_buf;
-
- /* allocate array of runtime file records */
- posix_runtime->file_runtime_array = malloc(file_array_size *
- sizeof(struct posix_file_runtime));
- if(!posix_runtime->file_runtime_array)
- {
- free(posix_runtime);
- posix_runtime = NULL;
- darshan_core_unregister_module(DARSHAN_POSIX_MOD);
- return;
- }
- memset(posix_runtime->file_runtime_array, 0, file_array_size *
- sizeof(struct posix_file_runtime));
-
return;
}
/* get a POSIX file record for the given file path */
static struct posix_file_runtime* posix_file_by_name(const char *name)
{
- struct posix_file_runtime *file = NULL;
- struct darshan_posix_file *file_rec;
+ struct posix_file_runtime *file_rec_rt;
+ struct darshan_posix_file *file_rec = NULL;
char *newname = NULL;
darshan_record_id file_id;
int file_alignment;
- int ret;
if(!posix_runtime || instrumentation_disabled)
return(NULL);
@@ -1527,42 +1498,44 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
if(!newname)
newname = (char*)name;
- /* lookup the unique id for this filename */
- darshan_core_lookup_record(
- (void*)newname,
- strlen(newname),
- &file_id);
+ /* lookup the id for this filename */
+ file_id = darshan_core_gen_record_id(newname);
/* search the hash table for this file record, and return if found */
- HASH_FIND(hlink, posix_runtime->file_hash, &file_id, sizeof(darshan_record_id), file);
- if(!file)
+ HASH_FIND(hlink, posix_runtime->file_hash, &file_id,
+ sizeof(darshan_record_id), file_rec_rt);
+ if(file_rec_rt == NULL)
{
- /* register the record with the darshan core component */
- ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_POSIX_MOD,
- sizeof(struct darshan_posix_file), &file_alignment);
- if(ret == 1)
+ file_rec_rt = malloc(sizeof(*file_rec_rt));
+ if(file_rec_rt)
{
- /* register was successful */
- file = &(posix_runtime->file_runtime_array[posix_runtime->file_array_ndx]);
- file->file_record =
- &(posix_runtime->file_record_array[posix_runtime->file_array_ndx]);
- file_rec = file->file_record;
+ memset(file_rec_rt, 0, sizeof(*file_rec_rt));
+ /* attempt to register the record with darshan core */
+ file_rec = darshan_core_register_record(file_id, newname, DARSHAN_POSIX_MOD,
+ sizeof(struct darshan_posix_file), &file_alignment);
+ if(!file_rec)
+ free(file_rec_rt);
+ }
+
+ if(file_rec != NULL)
+ {
+ /* register was successful, init structures */
file_rec->base_rec.id = file_id;
file_rec->base_rec.rank = my_rank;
file_rec->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
file_rec->counters[POSIX_FILE_ALIGNMENT] = file_alignment;
+ file_rec_rt->file_record = file_rec;
/* add new record to file hash table */
HASH_ADD(hlink, posix_runtime->file_hash, file_record->base_rec.id,
- sizeof(darshan_record_id), file);
- posix_runtime->file_array_ndx++;
+ sizeof(darshan_record_id), file_rec_rt);
}
}
if(newname != name)
free(newname);
- return(file);
+ return(file_rec_rt);
}
/* get a POSIX file record for the given file path, and also create a
@@ -1578,7 +1551,6 @@ static struct posix_file_runtime* posix_file_by_name_setfd(const char* name, int
/* find file record by name first */
file = posix_file_by_name(name);
-
if(!file)
return(NULL);
@@ -2040,41 +2012,41 @@ static void posix_get_output_data(
void **posix_buf,
int *posix_buf_sz)
{
- struct posix_file_runtime *file;
- struct posix_file_runtime *tmp;
- int i;
+ struct posix_file_runtime *file_rec_rt, *tmp;
+ struct darshan_posix_file *posix_rec_buf = *(struct darshan_posix_file **)posix_buf;
double posix_time;
+ int posix_rec_count;
struct darshan_posix_file *red_send_buf = NULL;
struct darshan_posix_file *red_recv_buf = NULL;
MPI_Datatype red_type;
MPI_Op red_op;
+ int i;
assert(posix_runtime);
+ posix_rec_count = HASH_CNT(hlink, posix_runtime->file_hash);
/* go through file access data for each record and set the 4 most common
* stride/access size counters.
*/
- for(i = 0; i < posix_runtime->file_array_ndx; i++)
+ HASH_ITER(hlink, posix_runtime->file_hash, file_rec_rt, tmp)
{
- tmp = &(posix_runtime->file_runtime_array[i]);
-
#ifndef __DARSHAN_ENABLE_MMAP_LOGS
/* walk common counters to get 4 most common -- only if mmap
* feature is disabled (mmap updates counters on the go)
*/
/* common accesses */
- darshan_walk_common_vals(tmp->access_root,
- &(tmp->file_record->counters[POSIX_ACCESS1_ACCESS]),
- &(tmp->file_record->counters[POSIX_ACCESS1_COUNT]));
+ darshan_walk_common_vals(file_rec_rt->access_root,
+ &(file_rec_rt->file_record->counters[POSIX_ACCESS1_ACCESS]),
+ &(file_rec_rt->file_record->counters[POSIX_ACCESS1_COUNT]));
/* common strides */
- darshan_walk_common_vals(tmp->stride_root,
- &(tmp->file_record->counters[POSIX_STRIDE1_STRIDE]),
- &(tmp->file_record->counters[POSIX_STRIDE1_COUNT]));
+ darshan_walk_common_vals(file_rec_rt->stride_root,
+ &(file_rec_rt->file_record->counters[POSIX_STRIDE1_STRIDE]),
+ &(file_rec_rt->file_record->counters[POSIX_STRIDE1_COUNT]));
#endif
- tdestroy(tmp->access_root, free);
- tdestroy(tmp->stride_root, free);
+ tdestroy(file_rec_rt->access_root, free);
+ tdestroy(file_rec_rt->stride_root, free);
}
/* if there are globally shared files, do a shared file reduction */
@@ -2087,56 +2059,53 @@ static void posix_get_output_data(
for(i = 0; i < shared_rec_count; i++)
{
HASH_FIND(hlink, posix_runtime->file_hash, &shared_recs[i],
- sizeof(darshan_record_id), file);
- assert(file);
+ sizeof(darshan_record_id), file_rec_rt);
+ assert(file_rec_rt);
posix_time =
- file->file_record->fcounters[POSIX_F_READ_TIME] +
- file->file_record->fcounters[POSIX_F_WRITE_TIME] +
- file->file_record->fcounters[POSIX_F_META_TIME];
+ file_rec_rt->file_record->fcounters[POSIX_F_READ_TIME] +
+ file_rec_rt->file_record->fcounters[POSIX_F_WRITE_TIME] +
+ file_rec_rt->file_record->fcounters[POSIX_F_META_TIME];
/* initialize fastest/slowest info prior to the reduction */
- file->file_record->counters[POSIX_FASTEST_RANK] =
- file->file_record->base_rec.rank;
- file->file_record->counters[POSIX_FASTEST_RANK_BYTES] =
- file->file_record->counters[POSIX_BYTES_READ] +
- file->file_record->counters[POSIX_BYTES_WRITTEN];
- file->file_record->fcounters[POSIX_F_FASTEST_RANK_TIME] =
+ file_rec_rt->file_record->counters[POSIX_FASTEST_RANK] =
+ file_rec_rt->file_record->base_rec.rank;
+ file_rec_rt->file_record->counters[POSIX_FASTEST_RANK_BYTES] =
+ file_rec_rt->file_record->counters[POSIX_BYTES_READ] +
+ file_rec_rt->file_record->counters[POSIX_BYTES_WRITTEN];
+ file_rec_rt->file_record->fcounters[POSIX_F_FASTEST_RANK_TIME] =
posix_time;
/* until reduction occurs, we assume that this rank is both
* the fastest and slowest. It is up to the reduction operator
* to find the true min and max.
*/
- file->file_record->counters[POSIX_SLOWEST_RANK] =
- file->file_record->counters[POSIX_FASTEST_RANK];
- file->file_record->counters[POSIX_SLOWEST_RANK_BYTES] =
- file->file_record->counters[POSIX_FASTEST_RANK_BYTES];
- file->file_record->fcounters[POSIX_F_SLOWEST_RANK_TIME] =
- file->file_record->fcounters[POSIX_F_FASTEST_RANK_TIME];
-
- file->file_record->base_rec.rank = -1;
+ file_rec_rt->file_record->counters[POSIX_SLOWEST_RANK] =
+ file_rec_rt->file_record->counters[POSIX_FASTEST_RANK];
+ file_rec_rt->file_record->counters[POSIX_SLOWEST_RANK_BYTES] =
+ file_rec_rt->file_record->counters[POSIX_FASTEST_RANK_BYTES];
+ file_rec_rt->file_record->fcounters[POSIX_F_SLOWEST_RANK_TIME] =
+ file_rec_rt->file_record->fcounters[POSIX_F_FASTEST_RANK_TIME];
+
+ file_rec_rt->file_record->base_rec.rank = -1;
}
/* sort the array of files descending by rank so that we get all of the
* shared files (marked by rank -1) in a contiguous portion at end
* of the array
*/
- qsort(posix_runtime->file_record_array, posix_runtime->file_array_ndx,
- sizeof(struct darshan_posix_file), posix_record_compare);
+ qsort(posix_rec_buf, posix_rec_count, sizeof(struct darshan_posix_file),
+ posix_record_compare);
/* make *send_buf point to the shared files at the end of sorted array */
- red_send_buf =
- &(posix_runtime->file_record_array[posix_runtime->file_array_ndx-shared_rec_count]);
-
+ red_send_buf = &(posix_rec_buf[posix_rec_count-shared_rec_count]);
+
/* allocate memory for the reduction output on rank 0 */
if(my_rank == 0)
{
red_recv_buf = malloc(shared_rec_count * sizeof(struct darshan_posix_file));
if(!red_recv_buf)
- {
return;
- }
}
/* construct a datatype for a POSIX file record. This is serving no purpose
@@ -2160,41 +2129,45 @@ static void posix_get_output_data(
/* clean up reduction state */
if(my_rank == 0)
{
- int tmp_ndx = posix_runtime->file_array_ndx - shared_rec_count;
- memcpy(&(posix_runtime->file_record_array[tmp_ndx]), red_recv_buf,
+ int tmp_ndx = posix_rec_count - shared_rec_count;
+ memcpy(&(posix_rec_buf[tmp_ndx]), red_recv_buf,
shared_rec_count * sizeof(struct darshan_posix_file));
free(red_recv_buf);
}
else
{
- posix_runtime->file_array_ndx -= shared_rec_count;
+ posix_rec_count -= shared_rec_count;
}
DARSHAN_MPI_CALL(PMPI_Type_free)(&red_type);
DARSHAN_MPI_CALL(PMPI_Op_free)(&red_op);
}
- *posix_buf = (void *)(posix_runtime->file_record_array);
- *posix_buf_sz = posix_runtime->file_array_ndx * sizeof(struct darshan_posix_file);
+ /* update output buffer size to account for shared file reduction */
+ *posix_buf_sz = posix_rec_count * sizeof(struct darshan_posix_file);
return;
}
static void posix_shutdown()
{
- struct posix_file_runtime_ref *ref, *tmp;
+ struct posix_file_runtime_ref *fd_ref, *fd_tmp;
+ struct posix_file_runtime *file_ref, *file_tmp;
assert(posix_runtime);
- HASH_ITER(hlink, posix_runtime->fd_hash, ref, tmp)
+ HASH_ITER(hlink, posix_runtime->fd_hash, fd_ref, fd_tmp)
{
- HASH_DELETE(hlink, posix_runtime->fd_hash, ref);
- free(ref);
+ HASH_DELETE(hlink, posix_runtime->fd_hash, fd_ref);
+ free(fd_ref);
}
- HASH_CLEAR(hlink, posix_runtime->file_hash); /* these entries are freed all at once below */
+ HASH_ITER(hlink, posix_runtime->file_hash, file_ref, file_tmp)
+ {
+ HASH_DELETE(hlink, posix_runtime->file_hash, file_ref);
+ free(file_ref);
+ }
- free(posix_runtime->file_runtime_array);
free(posix_runtime);
posix_runtime = NULL;
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/8f463e512cf639f9cbd64bba7c758ca0e02ae8d7...bfde9eb7378a95682389a76d677bbef29af8f530
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160531/b41904c4/attachment-0001.html>
More information about the Darshan-commits
mailing list