[Darshan-commits] [Git][darshan/darshan][mmap-dev] apply mmap code changes to other i/o modules

Shane Snyder xgitlab at cels.anl.gov
Tue Jan 19 12:57:51 CST 2016


Shane Snyder pushed to branch mmap-dev at darshan / darshan


Commits:
f78c456f by Shane Snyder at 2016-01-19T12:57:25Z
apply mmap code changes to other i/o modules

- - - - -


5 changed files:

- darshan-runtime/Makefile.in
- 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
@@ -23,8 +23,9 @@ DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
 DARSHAN_VERSION = @DARSHAN_VERSION@
 
 ifndef DISABLE_LDPRELOAD
-all: lib/libdarshan.so lib/darshan-null.po
+all: lib/libdarshan.so
 endif
+#TODO: lib/darshan-null.po
 
 VPATH = $(srcdir)
 
@@ -34,8 +35,8 @@ CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir)
 
 LIBS = -lz @LIBBZ2@
 
-static-mod-objs = lib/darshan-posix.o
-dynamic-mod-objs = lib/darshan-posix.po 
+static-mod-objs = lib/darshan-posix.o lib/darshan-mpiio.o lib/darshan-hdf5.o lib/darshan-pnetcdf.o
+dynamic-mod-objs = lib/darshan-posix.po lib/darshan-mpiio.po lib/darshan-hdf5.po lib/darshan-pnetcdf.po
 
 lib::
 	@mkdir -p $@


=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
--- a/darshan-runtime/lib/darshan-hdf5.c
+++ b/darshan-runtime/lib/darshan-hdf5.c
@@ -55,12 +55,9 @@ struct hdf5_runtime
 {
     struct hdf5_file_runtime* file_runtime_array;
     struct darshan_hdf5_file* file_record_array;
-    int file_array_size;
     int file_array_ndx;
     struct hdf5_file_runtime *file_hash;
     struct hdf5_file_runtime_ref* hid_hash;
-
-    struct darshan_hdf5_file *total_file;
 };
 
 static struct hdf5_runtime *hdf5_runtime = NULL;
@@ -205,9 +202,9 @@ static void hdf5_runtime_initialize()
         .get_output_data = &hdf5_get_output_data,
         .shutdown = &hdf5_shutdown
     };
-    void *mmap_buf;
-    int mmap_buf_size;
-    int mem_limit;
+    void *hdf5_buf;
+    int hdf5_buf_size;
+    int file_array_size;
 
     /* don't do anything if already initialized or instrumenation is disabled */
     if(hdf5_runtime || instrumentation_disabled)
@@ -217,14 +214,13 @@ static void hdf5_runtime_initialize()
     darshan_core_register_module(
         DARSHAN_HDF5_MOD,
         &hdf5_mod_fns,
+        &hdf5_buf_size,
+        &hdf5_buf,
         &my_rank,
-        &mem_limit,
-        &mmap_buf,
-        &mmap_buf_size,
         NULL);
 
-    /* return if no memory assigned by darshan-core */
-    if(mem_limit == 0)
+    /* return if darshan-core does not provide enough module memory */
+    if(hdf5_buf_size < sizeof(struct darshan_hdf5_file))
         return;
 
     hdf5_runtime = malloc(sizeof(*hdf5_runtime));
@@ -232,27 +228,27 @@ static void hdf5_runtime_initialize()
         return;
     memset(hdf5_runtime, 0, sizeof(*hdf5_runtime));
 
-    /* set maximum number of file records according to max memory limit */
-    /* NOTE: maximum number of records is based on the size of a hdf5 file record */
-    /* TODO: should we base memory usage off file record or total runtime structure sizes? */
-    hdf5_runtime->file_array_size = mem_limit / sizeof(struct darshan_hdf5_file);
+    /* set number of trackable files for the HDF5 module according to the
+     * amount of memory returned by darshan-core
+     */
+    file_array_size = hdf5_buf_size / sizeof(struct darshan_hdf5_file);
     hdf5_runtime->file_array_ndx = 0;
 
+    /* store pointer to HDF5 record buffer given by darshan-core */
+    hdf5_runtime->file_record_array = (struct darshan_hdf5_file *)hdf5_buf;
+
     /* allocate array of runtime file records */
-    hdf5_runtime->file_runtime_array = malloc(hdf5_runtime->file_array_size *
+    hdf5_runtime->file_runtime_array = malloc(file_array_size *
                                               sizeof(struct hdf5_file_runtime));
-    /* XXX-MMAP */
-    hdf5_runtime->file_record_array = malloc(hdf5_runtime->file_array_size *
-                                             sizeof(struct darshan_hdf5_file));
-    if(!hdf5_runtime->file_runtime_array || !hdf5_runtime->file_record_array)
+    if(!hdf5_runtime->file_runtime_array)
     {
-        hdf5_runtime->file_array_size = 0;
+        free(hdf5_runtime);
+        hdf5_runtime = NULL;
+        darshan_core_unregister_module(DARSHAN_HDF5_MOD);
         return;
     }
-    memset(hdf5_runtime->file_runtime_array, 0, hdf5_runtime->file_array_size *
+    memset(hdf5_runtime->file_runtime_array, 0, file_array_size *
            sizeof(struct hdf5_file_runtime));
-    memset(hdf5_runtime->file_record_array, 0, hdf5_runtime->file_array_size *
-           sizeof(struct darshan_hdf5_file));
 
     return;
 }
@@ -261,9 +257,10 @@ static void hdf5_runtime_initialize()
 static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
 {
     struct hdf5_file_runtime *file = NULL;
+    struct darshan_hdf5_file *file_rec;
     char *newname = NULL;
     darshan_record_id file_id;
-    int limit_flag;
+    int ret;
 
     if(!hdf5_runtime || instrumentation_disabled)
         return(NULL);
@@ -272,46 +269,36 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
     if(!newname)
         newname = (char*)name;
 
-    limit_flag = (hdf5_runtime->file_array_ndx >= hdf5_runtime->file_array_size);
-
-    /* get a unique id for this file from darshan core */
-    darshan_core_register_record(
+    /* lookup the unique id for this filename */
+    darshan_core_lookup_record(
         (void*)newname,
         strlen(newname),
-        DARSHAN_HDF5_MOD,
-        1,
-        limit_flag,
-        &file_id,
-        NULL);
-
-    /* if record is set to 0, darshan-core is out of space and will not
-     * track this record, so we should avoid tracking it, too
-     */
-    if(file_id == 0)
-    {
-        if(newname != name)
-            free(newname);
-        return(NULL);
-    }
+        &file_id);
 
     /* search the hash table for this file record, and return if found */
     HASH_FIND(hlink, hdf5_runtime->file_hash, &file_id, sizeof(darshan_record_id), file);
-    if(file)
+    if(!file)
     {
-        if(newname != name)
-            free(newname);
-        return(file);
-    }
+        /* register the record with the darshan core component */
+        ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_HDF5_MOD,
+            sizeof(struct darshan_hdf5_file), NULL);
+        if(ret == 1)
+        {
+            /* register was successful */
+            file = &(hdf5_runtime->file_runtime_array[hdf5_runtime->file_array_ndx]);
+            file->file_record =
+                &(hdf5_runtime->file_record_array[hdf5_runtime->file_array_ndx]);
+            file_rec = file->file_record;
 
-    /* no existing record, assign a new file record from the global array */
-    file = &(hdf5_runtime->file_runtime_array[hdf5_runtime->file_array_ndx]);
-    file->file_record = &(hdf5_runtime->file_record_array[hdf5_runtime->file_array_ndx]);
-    file->file_record->f_id = file_id;
-    file->file_record->rank = my_rank;
+            file_rec->base_rec.id = file_id;
+            file_rec->base_rec.rank = my_rank;
 
-    /* add new record to file hash table */
-    HASH_ADD(hlink, hdf5_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
-    hdf5_runtime->file_array_ndx++;
+            /* add new record to file hash table */
+            HASH_ADD(hlink, hdf5_runtime->file_hash, file_record->base_rec.id,
+                sizeof(darshan_record_id), file);
+            hdf5_runtime->file_array_ndx++;
+        }
+    }
 
     if(newname != name)
         free(newname);
@@ -403,9 +390,9 @@ static int hdf5_record_compare(const void* a_p, const void* b_p)
     const struct darshan_hdf5_file* a = a_p;
     const struct darshan_hdf5_file* b = b_p;
 
-    if(a->rank < b->rank)
+    if(a->base_rec.rank < b->base_rec.rank)
         return 1;
-    if(a->rank > b->rank)
+    if(a->base_rec.rank > b->base_rec.rank)
         return -1;
 
     return 0;
@@ -424,8 +411,8 @@ static void hdf5_record_reduction_op(void* infile_v, void* inoutfile_v,
     for(i=0; i<*len; i++)
     {
         memset(&tmp_file, 0, sizeof(struct darshan_hdf5_file));
-        tmp_file.f_id = infile->f_id;
-        tmp_file.rank = -1;
+        tmp_file.base_rec.id = infile->base_rec.id;
+        tmp_file.base_rec.rank = -1;
 
         /* sum */
         for(j=HDF5_OPENS; j<=HDF5_OPENS; j++)
@@ -505,7 +492,7 @@ static void hdf5_get_output_data(
                 sizeof(darshan_record_id), file);
             assert(file);
 
-            file->file_record->rank = -1;
+            file->file_record->base_rec.rank = -1;
         }
 
         /* sort the array of files descending by rank so that we get all of the 


=====================================
darshan-runtime/lib/darshan-mpiio.c
=====================================
--- a/darshan-runtime/lib/darshan-mpiio.c
+++ b/darshan-runtime/lib/darshan-mpiio.c
@@ -99,12 +99,9 @@ struct mpiio_runtime
 {
     struct mpiio_file_runtime* file_runtime_array;
     struct darshan_mpiio_file* file_record_array;
-    int file_array_size;
     int file_array_ndx;
     struct mpiio_file_runtime* file_hash;
     struct mpiio_file_runtime_ref* fh_hash;
-
-    struct darshan_mpiio_file* total_file;
 };
 
 static struct mpiio_runtime *mpiio_runtime = NULL;
@@ -828,26 +825,28 @@ static void mpiio_runtime_initialize()
         .get_output_data = &mpiio_get_output_data,
         .shutdown = &mpiio_shutdown
     };
-    void *mmap_buf;
-    int mmap_buf_size;
-    int mem_limit;
+    void *mpiio_buf;
+    int mpiio_buf_size;
+    int file_array_size;
 
     /* don't do anything if already initialized or instrumenation is disabled */
     if(mpiio_runtime || instrumentation_disabled)
         return;
 
+    /* try and store the default number of records for this module */
+    mpiio_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_mpiio_file);
+
     /* register the mpiio module with darshan core */
     darshan_core_register_module(
         DARSHAN_MPIIO_MOD,
         &mpiio_mod_fns,
+        &mpiio_buf_size,
+        &mpiio_buf,
         &my_rank,
-        &mem_limit,
-        &mmap_buf,
-        &mmap_buf_size,
         NULL);
 
-    /* return if no memory assigned by darshan core */
-    if(mem_limit == 0)
+    /* return if darshan-core does not provide enough module memory */
+    if(mpiio_buf_size < sizeof(struct darshan_mpiio_file))
         return;
 
     mpiio_runtime = malloc(sizeof(*mpiio_runtime));
@@ -855,25 +854,27 @@ static void mpiio_runtime_initialize()
         return;
     memset(mpiio_runtime, 0, sizeof(*mpiio_runtime));
 
-    /* set maximum number of file records according to max memory limit */
-    /* NOTE: maximum number of records is based on the size of a mpiio file record */
-    mpiio_runtime->file_array_size = mem_limit / sizeof(struct darshan_mpiio_file);
+    /* set number of trackable files for the MPIIO module according to the
+     * amount of memory returned by darshan-core
+     */
+    file_array_size = mpiio_buf_size / sizeof(struct darshan_mpiio_file);
     mpiio_runtime->file_array_ndx = 0;
 
+    /* store pointer to MPIIO record buffer given by darshan-core */
+    mpiio_runtime->file_record_array = (struct darshan_mpiio_file *)mpiio_buf;
+
     /* allocate array of runtime file records */
-    mpiio_runtime->file_runtime_array = malloc(mpiio_runtime->file_array_size *
+    mpiio_runtime->file_runtime_array = malloc(file_array_size *
                                                sizeof(struct mpiio_file_runtime));
-    mpiio_runtime->file_record_array = malloc(mpiio_runtime->file_array_size *
-                                              sizeof(struct darshan_mpiio_file));
-    if(!mpiio_runtime->file_runtime_array || !mpiio_runtime->file_record_array)
+    if(!mpiio_runtime->file_runtime_array)
     {
-        mpiio_runtime->file_array_size = 0;
+        free(mpiio_runtime);
+        mpiio_runtime = NULL;
+        darshan_core_unregister_module(DARSHAN_MPIIO_MOD);
         return;
     }
-    memset(mpiio_runtime->file_runtime_array, 0, mpiio_runtime->file_array_size *
+    memset(mpiio_runtime->file_runtime_array, 0, file_array_size *
            sizeof(struct mpiio_file_runtime));
-    memset(mpiio_runtime->file_record_array, 0, mpiio_runtime->file_array_size *
-           sizeof(struct darshan_mpiio_file));
 
     return;
 }
@@ -882,9 +883,10 @@ static void mpiio_runtime_initialize()
 static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
 {
     struct mpiio_file_runtime *file = NULL;
+    struct darshan_mpiio_file *file_rec;
     char *newname = NULL;
     darshan_record_id file_id;
-    int limit_flag;
+    int ret;
 
     if(!mpiio_runtime || instrumentation_disabled)
         return(NULL);
@@ -893,46 +895,36 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
     if(!newname)
         newname = (char*)name;
 
-    limit_flag = (mpiio_runtime->file_array_ndx >= mpiio_runtime->file_array_size);
-
-    /* get a unique id for this file from darshan core */
-    darshan_core_register_record(
+    /* lookup the unique id for this filename */
+    darshan_core_lookup_record(
         (void*)newname,
         strlen(newname),
-        DARSHAN_MPIIO_MOD,
-        1,
-        limit_flag,
-        &file_id,
-        NULL);
-
-    /* the file record id is set to 0 if no memory is available for tracking
-     * new records -- just fall through and ignore this record
-     */
-    if(file_id == 0)
-    {
-        if(newname != name)
-            free(newname);
-        return(NULL);
-    }
+        &file_id);
 
     /* search the hash table for this file record, and return if found */
     HASH_FIND(hlink, mpiio_runtime->file_hash, &file_id, sizeof(darshan_record_id), file);
-    if(file)
+    if(!file)
     {
-        if(newname != name)
-            free(newname);
-        return(file);
-    }
+        /* register the record with the darshan core component */
+        ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_MPIIO_MOD,
+            sizeof(struct darshan_mpiio_file), NULL);
+        if(ret == 1)
+        {
+            /* register was successful */
+            file = &(mpiio_runtime->file_runtime_array[mpiio_runtime->file_array_ndx]);
+            file->file_record =
+                &(mpiio_runtime->file_record_array[mpiio_runtime->file_array_ndx]);
+            file_rec = file->file_record;
 
-    /* no existing record, assign a new file record from the global array */
-    file = &(mpiio_runtime->file_runtime_array[mpiio_runtime->file_array_ndx]);
-    file->file_record = &(mpiio_runtime->file_record_array[mpiio_runtime->file_array_ndx]);
-    file->file_record->f_id = file_id;
-    file->file_record->rank = my_rank;
+            file_rec->base_rec.id = file_id;
+            file_rec->base_rec.rank = my_rank;
 
-    /* add new record to file hash table */
-    HASH_ADD(hlink, mpiio_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
-    mpiio_runtime->file_array_ndx++;
+            /* add new record to file hash table */
+            HASH_ADD(hlink, mpiio_runtime->file_hash, file_record->base_rec.id,
+                sizeof(darshan_record_id), file);
+            mpiio_runtime->file_array_ndx++;
+        }
+    }
 
     if(newname != name)
         free(newname);
@@ -1024,9 +1016,9 @@ static int mpiio_record_compare(const void* a_p, const void* b_p)
     const struct darshan_mpiio_file* a = a_p;
     const struct darshan_mpiio_file* b = b_p;
 
-    if(a->rank < b->rank)
+    if(a->base_rec.rank < b->base_rec.rank)
         return 1;
-    if(a->rank > b->rank)
+    if(a->base_rec.rank > b->base_rec.rank)
         return -1;
 
     return 0;
@@ -1048,9 +1040,8 @@ static void mpiio_record_reduction_op(
     for(i=0; i<*len; i++)
     {
         memset(&tmp_file, 0, sizeof(struct darshan_mpiio_file));
-
-        tmp_file.f_id = infile->f_id;
-        tmp_file.rank = -1;
+        tmp_file.base_rec.id = infile->base_rec.id;
+        tmp_file.base_rec.rank = -1;
 
         /* sum */
         for(j=MPIIO_INDEP_OPENS; j<=MPIIO_VIEWS; j++)
@@ -1358,7 +1349,7 @@ static void mpiio_get_output_data(
 
             /* initialize fastest/slowest info prior to the reduction */
             file->file_record->counters[MPIIO_FASTEST_RANK] =
-                file->file_record->rank;
+                file->file_record->base_rec.rank;
             file->file_record->counters[MPIIO_FASTEST_RANK_BYTES] =
                 file->file_record->counters[MPIIO_BYTES_READ] +
                 file->file_record->counters[MPIIO_BYTES_WRITTEN];
@@ -1376,7 +1367,7 @@ static void mpiio_get_output_data(
             file->file_record->fcounters[MPIIO_F_SLOWEST_RANK_TIME] =
                 file->file_record->fcounters[MPIIO_F_FASTEST_RANK_TIME];
 
-            file->file_record->rank = -1;
+            file->file_record->base_rec.rank = -1;
         }
 
         /* sort the array of files descending by rank so that we get all of the 
@@ -1454,7 +1445,6 @@ static void mpiio_shutdown()
     HASH_CLEAR(hlink, mpiio_runtime->file_hash); /* these entries are freed all at once below */
 
     free(mpiio_runtime->file_runtime_array);
-    free(mpiio_runtime->file_record_array);
     free(mpiio_runtime);
     mpiio_runtime = NULL;
 


=====================================
darshan-runtime/lib/darshan-pnetcdf.c
=====================================
--- a/darshan-runtime/lib/darshan-pnetcdf.c
+++ b/darshan-runtime/lib/darshan-pnetcdf.c
@@ -51,12 +51,9 @@ struct pnetcdf_runtime
 {
     struct pnetcdf_file_runtime* file_runtime_array;
     struct darshan_pnetcdf_file* file_record_array;
-    int file_array_size;
     int file_array_ndx;
     struct pnetcdf_file_runtime *file_hash;
     struct pnetcdf_file_runtime_ref* ncid_hash;
-
-    struct darshan_pnetcdf_file *total_file;
 };
 
 static struct pnetcdf_runtime *pnetcdf_runtime = NULL;
@@ -217,26 +214,28 @@ static void pnetcdf_runtime_initialize()
         .get_output_data = &pnetcdf_get_output_data,
         .shutdown = &pnetcdf_shutdown
     };
-    void *mmap_buf;
-    int mmap_buf_size;
-    int mem_limit;
+    void *pnetcdf_buf;
+    int pnetcdf_buf_size;
+    int file_array_size;
 
     /* don't do anything if already initialized or instrumenation is disabled */
     if(pnetcdf_runtime || instrumentation_disabled)
         return;
 
+    /* try and store the default number of records for this module */
+    pnetcdf_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_pnetcdf_file);
+
     /* register pnetcdf module with darshan-core */
     darshan_core_register_module(
         DARSHAN_PNETCDF_MOD,
         &pnetcdf_mod_fns,
+        &pnetcdf_buf_size,
+        &pnetcdf_buf,
         &my_rank,
-        &mem_limit,
-        &mmap_buf,
-        &mmap_buf_size,
         NULL);
 
-    /* return if no memory assigned by darshan-core */
-    if(mem_limit == 0)
+    /* return if darshan-core does not provide enough module memory */
+    if(pnetcdf_buf_size < sizeof(struct darshan_pnetcdf_file))
         return;
 
     pnetcdf_runtime = malloc(sizeof(*pnetcdf_runtime));
@@ -244,27 +243,27 @@ static void pnetcdf_runtime_initialize()
         return;
     memset(pnetcdf_runtime, 0, sizeof(*pnetcdf_runtime));
 
-    /* set maximum number of file records according to max memory limit */
-    /* NOTE: maximum number of records is based on the size of a pnetcdf file record */
-    /* TODO: should we base memory usage off file record or total runtime structure sizes? */
-    pnetcdf_runtime->file_array_size = mem_limit / sizeof(struct darshan_pnetcdf_file);
+    /* set number of trackable files for the PNETCDF module according to the
+     * amount of memory returned by darshan-core
+     */
+    file_array_size = pnetcdf_buf_size / sizeof(struct darshan_pnetcdf_file);
     pnetcdf_runtime->file_array_ndx = 0;
 
+    /* store pointer to PNETCDF record buffer given by darshan-core */
+    pnetcdf_runtime->file_record_array = (struct darshan_pnetcdf_file *)pnetcdf_buf;
+
     /* allocate array of runtime file records */
-    pnetcdf_runtime->file_runtime_array = malloc(pnetcdf_runtime->file_array_size *
+    pnetcdf_runtime->file_runtime_array = malloc(file_array_size *
                                                  sizeof(struct pnetcdf_file_runtime));
-    /* XXX-MMAP */
-    pnetcdf_runtime->file_record_array = malloc(pnetcdf_runtime->file_array_size *
-                                                sizeof(struct darshan_pnetcdf_file));
-    if(!pnetcdf_runtime->file_runtime_array || !pnetcdf_runtime->file_record_array)
+    if(!pnetcdf_runtime->file_runtime_array)
     {
-        pnetcdf_runtime->file_array_size = 0;
+        free(pnetcdf_runtime);
+        pnetcdf_runtime = NULL;
+        darshan_core_unregister_module(DARSHAN_PNETCDF_MOD);
         return;
     }
-    memset(pnetcdf_runtime->file_runtime_array, 0, pnetcdf_runtime->file_array_size *
+    memset(pnetcdf_runtime->file_runtime_array, 0, file_array_size *
            sizeof(struct pnetcdf_file_runtime));
-    memset(pnetcdf_runtime->file_record_array, 0, pnetcdf_runtime->file_array_size *
-           sizeof(struct darshan_pnetcdf_file));
 
     return;
 }
@@ -273,9 +272,10 @@ static void pnetcdf_runtime_initialize()
 static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
 {
     struct pnetcdf_file_runtime *file = NULL;
+    struct darshan_pnetcdf_file *file_rec;
     char *newname = NULL;
     darshan_record_id file_id;
-    int limit_flag;
+    int ret;
 
     if(!pnetcdf_runtime || instrumentation_disabled)
         return(NULL);
@@ -284,46 +284,36 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
     if(!newname)
         newname = (char*)name;
 
-    limit_flag = (pnetcdf_runtime->file_array_ndx >= pnetcdf_runtime->file_array_size);
-
-    /* get a unique id for this file from darshan core */
-    darshan_core_register_record(
+    /* lookup the unique id for this filename */
+    darshan_core_lookup_record(
         (void*)newname,
         strlen(newname),
-        DARSHAN_PNETCDF_MOD,
-        1,
-        limit_flag,
-        &file_id,
-        NULL);
-
-    /* the file record id is set to 0 if no memory is available for tracking
-     * new records -- just fall through and ignore this record
-     */
-    if(file_id == 0)
-    {
-        if(newname != name)
-            free(newname);
-        return(NULL);
-    }
+        &file_id);
 
     /* search the hash table for this file record, and return if found */
     HASH_FIND(hlink, pnetcdf_runtime->file_hash, &file_id, sizeof(darshan_record_id), file);
-    if(file)
+    if(!file)
     {
-        if(newname != name)
-            free(newname);
-        return(file);
-    }
+        /* register the record with the darshan core component */
+        ret = darshan_core_register_record(file_id, (void *)newname, DARSHAN_PNETCDF_MOD,
+            sizeof(struct darshan_pnetcdf_file), NULL);
+        if(ret == 1)
+        {
+            /* register was successful */
+            file = &(pnetcdf_runtime->file_runtime_array[pnetcdf_runtime->file_array_ndx]);
+            file->file_record =
+                &(pnetcdf_runtime->file_record_array[pnetcdf_runtime->file_array_ndx]);
+            file_rec = file->file_record;
 
-    /* no existing record, assign a new file record from the global array */
-    file = &(pnetcdf_runtime->file_runtime_array[pnetcdf_runtime->file_array_ndx]);
-    file->file_record = &(pnetcdf_runtime->file_record_array[pnetcdf_runtime->file_array_ndx]);
-    file->file_record->f_id = file_id;
-    file->file_record->rank = my_rank;
+            file_rec->base_rec.id = file_id;
+            file_rec->base_rec.rank = my_rank;
 
-    /* add new record to file hash table */
-    HASH_ADD(hlink, pnetcdf_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
-    pnetcdf_runtime->file_array_ndx++;
+            /* add new record to file hash table */
+            HASH_ADD(hlink, pnetcdf_runtime->file_hash, file_record->base_rec.id,
+                sizeof(darshan_record_id), file);
+            pnetcdf_runtime->file_array_ndx++;
+        }
+    }
 
     if(newname != name)
         free(newname);
@@ -415,9 +405,9 @@ static int pnetcdf_record_compare(const void* a_p, const void* b_p)
     const struct darshan_pnetcdf_file* a = a_p;
     const struct darshan_pnetcdf_file* b = b_p;
 
-    if(a->rank < b->rank)
+    if(a->base_rec.rank < b->base_rec.rank)
         return 1;
-    if(a->rank > b->rank)
+    if(a->base_rec.rank > b->base_rec.rank)
         return -1;
 
     return 0;
@@ -436,8 +426,8 @@ static void pnetcdf_record_reduction_op(void* infile_v, void* inoutfile_v,
     for(i=0; i<*len; i++)
     {
         memset(&tmp_file, 0, sizeof(struct darshan_pnetcdf_file));
-        tmp_file.f_id = infile->f_id;
-        tmp_file.rank = -1;
+        tmp_file.base_rec.id = infile->base_rec.id;
+        tmp_file.base_rec.rank = -1;
 
         /* sum */
         for(j=PNETCDF_INDEP_OPENS; j<=PNETCDF_COLL_OPENS; j++)
@@ -517,7 +507,7 @@ static void pnetcdf_get_output_data(
                 sizeof(darshan_record_id), file);
             assert(file);
 
-            file->file_record->rank = -1;
+            file->file_record->base_rec.rank = -1;
         }
 
         /* sort the array of files descending by rank so that we get all of the 


=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -1651,8 +1651,9 @@ static void posix_runtime_initialize()
         return;
     memset(posix_runtime, 0, sizeof(*posix_runtime));
 
-    /* set maximum number of file records according to max memory limit */
-    /* NOTE: maximum number of records is based on the size of a posix file record */
+    /* 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;
 
@@ -1671,8 +1672,6 @@ static void posix_runtime_initialize()
     }
     memset(posix_runtime->file_runtime_array, 0, file_array_size *
            sizeof(struct posix_file_runtime));
-    memset(posix_runtime->file_record_array, 0, file_array_size *
-           sizeof(struct darshan_posix_file));
 
     return;
 }
@@ -1694,7 +1693,7 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
     if(!newname)
         newname = (char*)name;
 
-    /* lookup the unique id for this file */
+    /* lookup the unique id for this filename */
     darshan_core_lookup_record(
         (void*)newname,
         strlen(newname),



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/f78c456f736a007d5efc644293836f9bfc431691
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160119/a8b0755d/attachment-0001.html>


More information about the Darshan-commits mailing list