[Darshan-commits] [Git][darshan/darshan][mmap-dev] modify register_record routine used by modules

Shane Snyder xgitlab at cels.anl.gov
Fri Dec 4 10:21:02 CST 2015


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


Commits:
376eefa8 by Shane Snyder at 2015-12-04T10:20:47Z
modify register_record routine used by modules

Now, register_record() accepts an argument for the size of
the record being registered, and this is used to track how much
data each module has stored in their allocated memory region.

- - - - -


4 changed files:

- darshan-runtime/darshan.h
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-posix.c
- darshan-util/darshan-parser.c


Changes:

=====================================
darshan-runtime/darshan.h
=====================================
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -127,10 +127,10 @@ void darshan_core_unregister_module(
  */
 void darshan_core_register_record(
     void *name,
-    int len,
+    int name_len,
+    int rec_size,
     darshan_module_id mod_id,
     int printable_flag,
-    int mod_limit_flag,
     darshan_record_id *rec_id,
     int *file_alignment);
 


=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -1265,9 +1265,11 @@ void darshan_core_register_module(
         return;
     }
 
-    /* XXX how do we assign size and address */
+    /* XXX MMAP: how do we assign size and address */
     *mod_buf = darshan_core->log_mod_p;
-    *mod_buf_size = 2*1024*1024;
+    *mod_buf_size = DARSHAN_MOD_MEM_MAX;
+    darshan_core->log_hdr_p->mod_map[mod_id].off =
+        ((char *)darshan_core->log_mod_p - (char *)darshan_core->log_hdr_p);
 
     /* this module has not been registered yet, allocate and initialize it */
     mod = malloc(sizeof(*mod));
@@ -1315,12 +1317,13 @@ void darshan_core_unregister_module(
     return;
 }
 
+/* TODO: maybe a return code to distinguish between id 0 and a failure */
 void darshan_core_register_record(
     void *name,
-    int len,
+    int name_len,
+    int rec_size,
     darshan_module_id mod_id,
     int printable_flag,
-    int mod_limit_flag,
     darshan_record_id *rec_id,
     int *file_alignment)
 {
@@ -1328,14 +1331,16 @@ void darshan_core_register_record(
     struct darshan_core_record_ref *ref;
 
     *rec_id = 0;
+    *file_alignment = 0;
 
     if(!darshan_core)
         return;
 
     /* TODO: what do you do with printable flag? */
+    /* TODO: what about partial flag? */
 
     /* hash the input name to get a unique id for this record */
-    tmp_rec_id = darshan_hash(name, len, 0);
+    tmp_rec_id = darshan_hash(name, name_len, 0);
 
     /* check to see if we've already stored the id->name mapping for this record */
     DARSHAN_CORE_LOCK();
@@ -1345,28 +1350,26 @@ void darshan_core_register_record(
         /* record not found -- add it to the hash if this module has not already used
          * all of its memory
          */
-
-#if 0
-        if(mod_limit_flag)
+        darshan_add_record_hashref(darshan_core, name, tmp_rec_id, &ref);
+        if(!ref)
         {
-            /* if this module is OOM, set a flag in the header to indicate this */
-            DARSHAN_MOD_FLAG_SET(darshan_core->log_header.partial_flag, mod_id);
+            /* just give up and return if adding this record failed */
             DARSHAN_CORE_UNLOCK();
             return;
         }
-#endif
-
-        darshan_add_record_hashref(darshan_core, name, tmp_rec_id, &ref);
     }
-    
-    if(ref)
+
+    if(!DARSHAN_MOD_FLAG_ISSET(ref->mod_flags, mod_id))
+    {
         DARSHAN_MOD_FLAG_SET(ref->mod_flags, mod_id);
+        darshan_core->log_hdr_p->mod_map[mod_id].len += rec_size;
+    }
     DARSHAN_CORE_UNLOCK();
 
     if(file_alignment)
         darshan_block_size_from_path(name, file_alignment);
 
-    *rec_id = 0; /* XXX */
+    *rec_id = tmp_rec_id;
     return;
 }
 


=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -1677,7 +1677,6 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
     char *newname = NULL;
     darshan_record_id file_id;
     int file_alignment;
-    int limit_flag;
 
     if(!posix_runtime || instrumentation_disabled)
         return(NULL);
@@ -1686,15 +1685,13 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
     if(!newname)
         newname = (char*)name;
 
-    limit_flag = (posix_runtime->file_array_ndx >= posix_runtime->file_array_size);
-
     /* get a unique id for this file from darshan core */
     darshan_core_register_record(
         (void*)newname,
         strlen(newname),
+        sizeof(struct darshan_posix_file),
         DARSHAN_POSIX_MOD,
         1,
-        limit_flag,
         &file_id,
         &file_alignment);
 
@@ -2364,7 +2361,7 @@ static void posix_shutdown()
     HASH_CLEAR(hlink, posix_runtime->file_hash); /* these entries are freed all at once below */
 
     free(posix_runtime->file_runtime_array);
-    free(posix_runtime->file_record_array);
+    /* XXX: MMAP free(posix_runtime->file_record_array); */
     free(posix_runtime);
     posix_runtime = NULL;
 


=====================================
darshan-util/darshan-parser.c
=====================================
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -310,9 +310,9 @@ int main(int argc, char **argv)
     }
 
     /* print breakdown of each log file region's contribution to file size */
-    printf("\n# log file region sizes (compressed)\n");
+    printf("\n# log file region sizes\n");
     printf("# -------------------------------------------------------\n");
-    printf("# header: %zu bytes (uncompressed)\n", sizeof(struct darshan_header));
+    printf("# header: %zu bytes\n", sizeof(struct darshan_header));
     printf("# job data: %zu bytes\n", fd->job_map.len);
     printf("# record table: %zu bytes\n", fd->rec_map.len);
     for(i=0; i<DARSHAN_MAX_MODS; i++)



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


More information about the Darshan-commits mailing list