[Darshan-commits] [Git][darshan/darshan][mmap-dev] 5 commits: cleanup comments in darshan-common

Shane Snyder xgitlab at cels.anl.gov
Fri Jun 17 16:43:50 CDT 2016


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


Commits:
936d1e10 by Shane Snyder at 2016-06-17T13:27:31-05:00
cleanup comments in darshan-common

- - - - -
538812e4 by Shane Snyder at 2016-06-17T14:29:13-05:00
cleanup makefile & autoconf mmap detection

- - - - -
080c680d by Shane Snyder at 2016-06-17T14:32:07-05:00
fix comment in darshan-config

- - - - -
927b8773 by Shane Snyder at 2016-06-17T16:39:58-05:00
ifdef wrap mmap #define

- - - - -
bb9d68c0 by Shane Snyder at 2016-06-17T16:40:27-05:00
honor DARSHAN_MODMEM env variable

- - - - -


8 changed files:

- darshan-runtime/Makefile.in
- darshan-runtime/configure
- darshan-runtime/configure.in
- darshan-runtime/darshan-common.h
- darshan-runtime/darshan-config.in
- darshan-runtime/darshan-core.h
- darshan-runtime/lib/darshan-common.c
- darshan-runtime/lib/darshan-core.c


Changes:

=====================================
darshan-runtime/Makefile.in
=====================================
--- a/darshan-runtime/Makefile.in
+++ b/darshan-runtime/Makefile.in
@@ -18,6 +18,7 @@ CC = @CC@
 LD = @LD@
 
 DISABLE_LDPRELOAD = @DISABLE_LDPRELOAD@
+ENABLE_MMAP_LOGS = @ENABLE_MMAP_LOGS@
 DARSHAN_USE_BGQ = @DARSHAN_USE_BGQ@
 DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
 DARSHAN_VERSION = @DARSHAN_VERSION@
@@ -154,12 +155,14 @@ endif
 	install -m 755 share/mpi-profile/darshan-bg-cc.conf $(datarootdir)/mpi-profile/darshan-bg-cc.conf
 	install -m 755 share/mpi-profile/darshan-bg-cxx.conf $(datarootdir)/mpi-profile/darshan-bg-cxx.conf
 	install -m 755 share/mpi-profile/darshan-bg-f.conf $(datarootdir)/mpi-profile/darshan-bg-f.conf
-	install -m 755 share/darshan-mmap-epilog.sh $(datarootdir)/darshan-mmap-epilog.sh
 	install -d $(datarootdir)/ld-opts
 	install -m 644 share/ld-opts/darshan-base-ld-opts $(datarootdir)/ld-opts/darshan-base-ld-opts
 	install -m 644 $(srcdir)/share/ld-opts/darshan-posix-ld-opts $(datarootdir)/ld-opts/darshan-posix-ld-opts
 	install -m 644 $(srcdir)/share/ld-opts/darshan-hdf5-ld-opts $(datarootdir)/ld-opts/darshan-hdf5-ld-opts
 	install -m 644 $(srcdir)/share/ld-opts/darshan-pnetcdf-ld-opts $(datarootdir)/ld-opts/darshan-pnetcdf-ld-opts
+ifdef ENABLE_MMAP_LOGS
+	install -m 755 share/darshan-mmap-epilog.sh $(datarootdir)/darshan-mmap-epilog.sh
+endif
 	install -d $(libdir)/pkgconfig
 	install -m 644 lib/pkgconfig/darshan-runtime.pc $(libdir)/pkgconfig/darshan-runtime.pc
 
@@ -167,5 +170,5 @@ clean::
 	rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so 
 
 distclean:: clean
-	rm -f darshan-runtime-config.h darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-gen-cc.pl darshan-mk-log-dirs.pl darshan-config darshan-base-ld-opts aclocal.m4 autom4te.cache/* config.status config.log Makefile 
+	rm -f darshan-runtime-config.h darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-gen-cc.pl darshan-mk-log-dirs.pl darshan-config lib/pkgconfig/darshan-runtime.pc share/craype-1.x/darshan-module share/craype-2.x/darshan-module share/darshan-mmap-epilog.sh share/ld-opts/darshan-base-ld-opts share/mpi-profile/darshan-bg-cc.conf share/mpi-profile/darshan-bg-cxx.conf share/mpi-profile/darshan-bg-f.conf share/mpi-profile/darshan-cc.conf share/mpi-profile/darshan-cxx.conf share/mpi-profile/darshan-f.conf aclocal.m4 autom4te.cache/* config.status config.log Makefile 
 	rm -rf autom4te.cache


=====================================
darshan-runtime/configure
=====================================
--- a/darshan-runtime/configure
+++ b/darshan-runtime/configure
@@ -624,6 +624,7 @@ LIBOBJS
 DARSHAN_USE_BGQ
 MPICH_LIB_OLD
 DARSHAN_VERSION
+ENABLE_MMAP_LOGS
 DISABLE_LDPRELOAD
 __DARSHAN_LOG_PATH
 darshan_share_path
@@ -3580,6 +3581,9 @@ if test "${enable_mmap_logs+set}" = set; then :
 
 $as_echo "#define __DARSHAN_ENABLE_MMAP_LOGS 1" >>confdefs.h
 
+    ENABLE_MMAP_LOGS=1
+    ac_config_files="$ac_config_files share/darshan-mmap-epilog.sh"
+
 fi
 
 fi
@@ -4326,7 +4330,8 @@ DARSHAN_VERSION="3.0.1"
 
 
 
-ac_config_files="$ac_config_files Makefile darshan-mk-log-dirs.pl darshan-gen-cc.pl darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-config share/craype-1.x/darshan-module share/craype-2.x/darshan-module lib/pkgconfig/darshan-runtime.pc share/mpi-profile/darshan-cc.conf share/mpi-profile/darshan-cxx.conf share/mpi-profile/darshan-f.conf share/mpi-profile/darshan-bg-cc.conf share/mpi-profile/darshan-bg-cxx.conf share/mpi-profile/darshan-bg-f.conf share/ld-opts/darshan-base-ld-opts share/darshan-mmap-epilog.sh"
+
+ac_config_files="$ac_config_files Makefile darshan-mk-log-dirs.pl darshan-gen-cc.pl darshan-gen-cxx.pl darshan-gen-fortran.pl darshan-config share/craype-1.x/darshan-module share/craype-2.x/darshan-module lib/pkgconfig/darshan-runtime.pc share/mpi-profile/darshan-cc.conf share/mpi-profile/darshan-cxx.conf share/mpi-profile/darshan-f.conf share/mpi-profile/darshan-bg-cc.conf share/mpi-profile/darshan-bg-cxx.conf share/mpi-profile/darshan-bg-f.conf share/ld-opts/darshan-base-ld-opts"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -5020,6 +5025,7 @@ for ac_config_target in $ac_config_targets
 do
   case $ac_config_target in
     "darshan-runtime-config.h") CONFIG_HEADERS="$CONFIG_HEADERS darshan-runtime-config.h" ;;
+    "share/darshan-mmap-epilog.sh") CONFIG_FILES="$CONFIG_FILES share/darshan-mmap-epilog.sh" ;;
     "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
     "darshan-mk-log-dirs.pl") CONFIG_FILES="$CONFIG_FILES darshan-mk-log-dirs.pl" ;;
     "darshan-gen-cc.pl") CONFIG_FILES="$CONFIG_FILES darshan-gen-cc.pl" ;;
@@ -5036,7 +5042,6 @@ do
     "share/mpi-profile/darshan-bg-cxx.conf") CONFIG_FILES="$CONFIG_FILES share/mpi-profile/darshan-bg-cxx.conf" ;;
     "share/mpi-profile/darshan-bg-f.conf") CONFIG_FILES="$CONFIG_FILES share/mpi-profile/darshan-bg-f.conf" ;;
     "share/ld-opts/darshan-base-ld-opts") CONFIG_FILES="$CONFIG_FILES share/ld-opts/darshan-base-ld-opts" ;;
-    "share/darshan-mmap-epilog.sh") CONFIG_FILES="$CONFIG_FILES share/darshan-mmap-epilog.sh" ;;
 
   *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
   esac


=====================================
darshan-runtime/configure.in
=====================================
--- a/darshan-runtime/configure.in
+++ b/darshan-runtime/configure.in
@@ -57,6 +57,8 @@ AC_ARG_ENABLE(mmap-logs,
 [  --enable-mmmap-logs     Enables ability to mmap I/O data to log file],
 [if test "x$enableval" = "xyes" ; then
     AC_DEFINE(__DARSHAN_ENABLE_MMAP_LOGS, 1, Define if Darshan should mmap data structures to log file)
+    ENABLE_MMAP_LOGS=1
+    AC_CONFIG_FILES(share/darshan-mmap-epilog.sh)
 fi]
 ,)
 
@@ -328,6 +330,7 @@ AC_SUBST(darshan_share_path)
 AC_SUBST(LDFLAGS)
 AC_SUBST(__DARSHAN_LOG_PATH)
 AC_SUBST(DISABLE_LDPRELOAD)
+AC_SUBST(ENABLE_MMAP_LOGS)
 AC_SUBST(DARSHAN_VERSION)
 AC_SUBST(MPICH_LIB_OLD)
 AC_SUBST(DARSHAN_USE_BGQ)
@@ -347,5 +350,4 @@ share/mpi-profile/darshan-bg-cc.conf
 share/mpi-profile/darshan-bg-cxx.conf
 share/mpi-profile/darshan-bg-f.conf
 share/ld-opts/darshan-base-ld-opts
-share/darshan-mmap-epilog.sh
 )


=====================================
darshan-runtime/darshan-common.h
=====================================
--- a/darshan-runtime/darshan-common.h
+++ b/darshan-runtime/darshan-common.h
@@ -76,17 +76,17 @@
  * base of the value counters (i.e., the first of 4 contiguous common value
  * counters) and __cnt_p is a pointer to the base of the count counters (i.e.
  * the first of 4 contiguous common count counters). It is assumed your counters
- * are stored as int64_t types. __online_flag is set if the common val counters are
- * updated during runtime (as opposed to being updated once at darshan shutdown time).
+ * are stored as int64_t types. __add_flag is set if the given count should be
+ * added to the common access counter, rather than just incrementing it.
  */
-#define DARSHAN_COMMON_VAL_COUNTER_INC(__val_p, __cnt_p, __value, __count, __online_flag) do {\
+#define DARSHAN_COMMON_VAL_COUNTER_INC(__val_p, __cnt_p, __value, __count, __add_flag) do {\
     int i; \
     int inc_count, total_count; \
     int64_t tmp_val[4] = {0}; \
     int64_t tmp_cnt[4] = {0}; \
     int tmp_ndx = 0; \
     if(__value == 0) break; \
-    if(__online_flag) \
+    if(__add_flag) \
         inc_count = 1; \
     else \
         inc_count = __count; \
@@ -127,10 +127,7 @@
     memcpy(__cnt_p, tmp_cnt, 4*sizeof(int64_t)); \
 } while(0)
 
-/* maximum number of common values that darshan will track per file at
- * runtime; at shutdown time these will be reduced to the 4 most
- * frequently occuring ones
- */
+/* maximum number of common values that darshan will track per file at runtime */
 #define DARSHAN_COMMON_VAL_MAX_RUNTIME_COUNT 32
 struct darshan_common_val_counter
 {
@@ -157,26 +154,63 @@ struct darshan_variance_dt
 * darshan-common functions for darshan modules *
 ***********************************************/
 
+/* darshan_lookup_record_ref()
+ *
+ * Lookup a record reference pointer using the given 'handle'.
+ * 'handle_sz' is the size of the handle structure, and 'hash_head'
+ * is the pointer to the hash table to search.
+ * If the handle is found, the corresponding record reference pointer
+ * is returned, otherwise NULL is returned.
+ */
 void *darshan_lookup_record_ref(
     void *hash_head,
     void *handle,
     size_t handle_sz);
 
+/* darshan_add_record_ref()
+ *
+ * Add the given record reference pointer, 'rec_ref_p' to the hash
+ * table whose address is stored in the 'hash_head_p' pointer. The
+ * hash is generated from the given 'handle', with size 'handle_sz'.
+ * If the record reference is successfully added, 1 is returned,
+ * otherwise, 0 is returned.
+ */
 int darshan_add_record_ref(
-    void **hash_head,
+    void **hash_head_p,
     void *handle,
     size_t handle_sz,
     void *rec_ref_p);
 
+/* darshan_delete_record_ref()
+ *
+ * Delete the record reference for the given 'handle', with size
+ * 'handle_sz', from the hash table whose address is stored in
+ * the 'hash_head_p' pointer.
+ * On success deletion, the corresponding record reference pointer
+ * is returned, otherwise NULL is returned.
+ */
 void *darshan_delete_record_ref(
-    void **hash_head,
+    void **hash_head_p,
     void *handle,
     size_t handle_sz);
 
+/* darshan_clear_record_refs()
+ *
+ * Clear all record references from the hash table stored in the
+ * 'hash_head_p' pointer. If 'free_flag' is set, the corresponding
+ * record_reference_pointer is also freed.
+ */
 void darshan_clear_record_refs(
-    void **hash_head,    
+    void **hash_head_p,    
     int free_flag);
 
+/* darshan_iter_record_ref()
+ *
+ * Iterate each record reference stored in the hash table pointed
+ * to by 'hash_head' and perform the given action 'iter_action'. 
+ * The action function takes a single pointer which points to the
+ * corresponding record reference pointer.
+ */
 void darshan_iter_record_refs(
     void *hash_head,
     void (*iter_action)(void *));
@@ -191,6 +225,15 @@ void darshan_iter_record_refs(
 char* darshan_clean_file_path(
     const char *path);
 
+/* darshan_record_sort()
+ *
+ * Sort the records in 'rec_buf' by descending rank to get all
+ * shared records in a contiguous region at the end of the buffer.
+ * Records are secondarily sorted by ascending record identifiers.
+ * 'rec_count' is the number of records in the buffer, and 'rec_size'
+ * is the size of the record structure.
+ * NOTE: this function only works on fixed-length records.
+ */
 void darshan_record_sort(
     void *rec_buf,
     int rec_count,
@@ -218,22 +261,6 @@ void darshan_common_val_counter(
     int64_t *val_p,
     int64_t *cnt_p);
 
-/* darshan_walk_common_vals()
- *
- * Walks the tree of common value counters and determines the 4 most
- * frequently occuring values, storing the common values in the
- * appropriate counter fields of the given record. 'common_val_root'
- * is the root of the tree which stores the common value info, 'val_p'
- * is a pointer to the base counter (i.e., the first) of the common
- * values (which are assumed to be 4 total and contiguous in memory),
- * and 'cnt_p' is a pointer to the base counter of the common counts
- * (which are again expected to be contiguous in memory).
- */
-void darshan_walk_common_vals(
-    void *common_val_root,
-    int64_t *val_p,
-    int64_t *cnt_p);
-
 /* darshan_variance_reduce()
  *
  * MPI reduction operation to calculate variances on counters in


=====================================
darshan-runtime/darshan-config.in
=====================================
--- a/darshan-runtime/darshan-config.in
+++ b/darshan-runtime/darshan-config.in
@@ -5,7 +5,7 @@ DARSHAN_SHARE_PATH="@darshan_share_path@"
 DARSHAN_LD_FLAGS="@LDFLAGS@"
 
 # NOTE:
-# - we deliberately list libdarshan-mpi-io twice in the link command.  The
+# - we deliberately list libdarshan twice in the link command.  The
 #   first is necessary to correctly use the MPI profiling interface.  The
 #   final one is necessary to give the linker a change to resolve indirect
 #   dependencies on PnetCDF and HDF5 symbols (if the app used a library which 


=====================================
darshan-runtime/darshan-core.h
=====================================
--- a/darshan-runtime/darshan-core.h
+++ b/darshan-runtime/darshan-core.h
@@ -30,9 +30,14 @@
 /* Environment variable to override memory per module */
 #define DARSHAN_MOD_MEM_OVERRIDE "DARSHAN_MODMEM"
 
+#ifdef __DARSHAN_ENABLE_MMAP_LOGS
 /* Environment variable to override default mmap log path */
 #define DARSHAN_MMAP_LOG_PATH_OVERRIDE "DARSHAN_MMAP_LOGPATH"
 
+/* default path for storing mmap log files is '/tmp' */
+#define DARSHAN_DEF_MMAP_LOG_PATH "/tmp"
+#endif
+
 /* Maximum amount of memory per instrumentation module in MiB */
 #ifdef __DARSHAN_MOD_MEM_MAX
 #define DARSHAN_MOD_MEM_MAX (__DARSHAN_MOD_MEM_MAX * 1024 * 1024)
@@ -40,9 +45,6 @@
 #define DARSHAN_MOD_MEM_MAX (2 * 1024 * 1024) /* 2 MiB default */
 #endif
 
-/* default path for storing mmap log files is '/tmp' */
-#define DARSHAN_DEF_MMAP_LOG_PATH "/tmp"
-
 /* default name record buf can store 2048 records of size 100 bytes */
 #define DARSHAN_NAME_RECORD_BUF_SIZE (2048 * 100)
 


=====================================
darshan-runtime/lib/darshan-common.c
=====================================
--- a/darshan-runtime/lib/darshan-common.c
+++ b/darshan-runtime/lib/darshan-common.c
@@ -19,7 +19,7 @@
 
 #include "darshan.h"
 
-
+/* track opaque record referencre using a hash link */
 struct darshan_record_ref_tracker
 {
     void *rec_ref_p;
@@ -32,6 +32,7 @@ void *darshan_lookup_record_ref(void *hash_head, void *handle, size_t handle_sz)
     struct darshan_record_ref_tracker *ref_tracker_head =
         (struct darshan_record_ref_tracker *)hash_head;
 
+    /* search the hash table for the given handle */
     HASH_FIND(hlink, ref_tracker_head, handle, handle_sz, ref_tracker);
     if(ref_tracker)
         return(ref_tracker->rec_ref_p);
@@ -39,52 +40,57 @@ void *darshan_lookup_record_ref(void *hash_head, void *handle, size_t handle_sz)
         return(NULL);
 }
 
-int darshan_add_record_ref(void **hash_head, void *handle, size_t handle_sz,
+int darshan_add_record_ref(void **hash_head_p, void *handle, size_t handle_sz,
     void *rec_ref_p)
 {
     struct darshan_record_ref_tracker *ref_tracker;
     struct darshan_record_ref_tracker *ref_tracker_head =
-        *(struct darshan_record_ref_tracker **)hash_head;
+        *(struct darshan_record_ref_tracker **)hash_head_p;
     void *handle_p;
 
+    /* allocate a reference tracker, with room to store the handle at the end */
     ref_tracker = malloc(sizeof(*ref_tracker) + handle_sz);
     if(!ref_tracker)
         return(0);
     memset(ref_tracker, 0, sizeof(*ref_tracker) + handle_sz);
 
+    /* initialize the reference tracker and add it to the hash table */
     ref_tracker->rec_ref_p = rec_ref_p;
     handle_p = (char *)ref_tracker + sizeof(*ref_tracker);
     memcpy(handle_p, handle, handle_sz);
     HASH_ADD_KEYPTR(hlink, ref_tracker_head, handle_p, handle_sz, ref_tracker);
-    *hash_head = ref_tracker_head;
+    *hash_head_p = ref_tracker_head;
     return(1);
 }
 
-void *darshan_delete_record_ref(void **hash_head, void *handle, size_t handle_sz)
+void *darshan_delete_record_ref(void **hash_head_p, void *handle, size_t handle_sz)
 {
     struct darshan_record_ref_tracker *ref_tracker;
     struct darshan_record_ref_tracker *ref_tracker_head =
-        *(struct darshan_record_ref_tracker **)hash_head;
+        *(struct darshan_record_ref_tracker **)hash_head_p;
     void *rec_ref_p;
 
+    /* find the reference tracker for this handle */
     HASH_FIND(hlink, ref_tracker_head, handle, handle_sz, ref_tracker);
     if(!ref_tracker)
         return(NULL);
 
+    /* if found, delete from hash table and return the record reference pointer */
     HASH_DELETE(hlink, ref_tracker_head, ref_tracker);
-    *hash_head = ref_tracker_head;
+    *hash_head_p = ref_tracker_head;
     rec_ref_p = ref_tracker->rec_ref_p;
     free(ref_tracker);
 
     return(rec_ref_p);
 }
 
-void darshan_clear_record_refs(void **hash_head, int free_flag)
+void darshan_clear_record_refs(void **hash_head_p, int free_flag)
 {
     struct darshan_record_ref_tracker *ref_tracker, *tmp;
     struct darshan_record_ref_tracker *ref_tracker_head =
-        *(struct darshan_record_ref_tracker **)hash_head;
+        *(struct darshan_record_ref_tracker **)hash_head_p;
 
+    /* iterate the hash table and remove/free all reference trackers */
     HASH_ITER(hlink, ref_tracker_head, ref_tracker, tmp)
     {
         HASH_DELETE(hlink, ref_tracker_head, ref_tracker);
@@ -92,7 +98,7 @@ void darshan_clear_record_refs(void **hash_head, int free_flag)
             free(ref_tracker->rec_ref_p);
         free(ref_tracker);
     }
-    *hash_head = ref_tracker_head;
+    *hash_head_p = ref_tracker_head;
 
     return;
 }
@@ -103,6 +109,9 @@ void darshan_iter_record_refs(void *hash_head, void (*iter_action)(void *))
     struct darshan_record_ref_tracker *ref_tracker_head =
         (struct darshan_record_ref_tracker *)hash_head;
 
+    /* iterate the hash table, performing the given action for each reference
+     * tracker's corresponding record reference pointer
+     */
     HASH_ITER(hlink, ref_tracker_head, ref_tracker, tmp)
     {
         iter_action(ref_tracker->rec_ref_p);
@@ -168,8 +177,11 @@ char* darshan_clean_file_path(const char* path)
     return(newpath);
 }
 
-/* compare function for sorting file records by descending rank first, then
- * by ascending record identifiers (which are just unsigned integers)
+/* compare function for sorting file records according to their 
+ * darshan_base_record structure. Records are sorted first by
+ * descending rank (to get all shared records, with rank set to -1, in
+ * a contiguous region at the end of the record buffer) then
+ * by ascending record identifiers (which are just unsigned integers).
  */
 static int darshan_base_record_compare(const void* a_p, const void* b_p)
 {


=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -195,6 +195,18 @@ void darshan_core_initialize(int argc, char **argv)
             jobid = getpid();
         }
 
+        /* set the memory quota for darshan modules' records */
+        envstr = getenv(DARSHAN_MOD_MEM_OVERRIDE);
+        if(envstr)
+        {
+            ret = sscanf(envstr, "%d", &tmpval);
+            /* silently ignore if the env variable is set poorly */
+            if(ret == 1 && tmpval > 0)
+            {
+                darshan_mod_mem_quota = tmpval * 1024 * 1024; /* convert from MiB */
+            }
+        }
+
         /* allocate structure to track darshan core runtime information */
         init_core = malloc(sizeof(*init_core));
         if(init_core)



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/f6769e56f2f60297a64c3e9fb142b16e15f03f12...bb9d68c0bf4f5146539b12186881f65f62ade8df
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160617/e1bc84a0/attachment-0001.html>


More information about the Darshan-commits mailing list