[Darshan-commits] [Git][darshan/darshan][mmap-dev] 3 commits: bug fix to byte swap module version array

Shane Snyder xgitlab at cels.anl.gov
Mon Jun 20 20:52:49 CDT 2016


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


Commits:
ddd83318 by Shane Snyder at 2016-06-20T15:47:44-05:00
bug fix to byte swap module version array

- - - - -
f3afdb75 by Shane Snyder at 2016-06-20T16:03:11-05:00
move back-compat code out of dedicated directory

- - - - -
6ccaea46 by Shane Snyder at 2016-06-20T20:50:29-05:00
bgq backwards compatibility code

- - - - -


6 changed files:

- darshan-bgq-log-format.h
- darshan-util/Makefile.in
- − darshan-util/compat/darshan-logutils-compat.c
- − darshan-util/compat/darshan-logutils-compat.h
- darshan-util/darshan-bgq-logutils.c
- darshan-util/darshan-logutils.c


Changes:

=====================================
darshan-bgq-log-format.h
=====================================
--- a/darshan-bgq-log-format.h
+++ b/darshan-bgq-log-format.h
@@ -11,7 +11,7 @@
 #define DARSHAN_BGQ_VER 1
 
 #define BGQ_COUNTERS \
-    /* control system jobid*/\
+    /* control system jobid */\
     X(BGQ_CSJOBID) \
     /* number of BGQ compute nodes */\
     X(BGQ_NNODES) \


=====================================
darshan-util/Makefile.in
=====================================
--- a/darshan-util/Makefile.in
+++ b/darshan-util/Makefile.in
@@ -17,8 +17,6 @@ DARSHAN_MOD_LOG_FORMATS = $(srcdir)/../darshan-posix-log-format.h $(srcdir)/../d
 DARSHAN_MOD_LOGUTIL_HEADERS = darshan-posix-logutils.h darshan-mpiio-logutils.h darshan-hdf5-logutils.h darshan-pnetcdf-logutils.h
 DARSHAN_STATIC_MOD_OBJS = darshan-posix-logutils.o darshan-mpiio-logutils.o darshan-hdf5-logutils.o darshan-pnetcdf-logutils.o darshan-bgq-logutils.o
 DARSHAN_DYNAMIC_MOD_OBJS = darshan-posix-logutils.po darshan-mpiio-logutils.po darshan-hdf5-logutils.po darshan-pnetcdf-logutils.po darshan-bgq-logutils.po
-DARSHAN_STATIC_COMPAT_OBJS = compat/darshan-logutils-compat.o
-DARSHAN_DYNAMIC_COMPAT_OBJS = compat/darshan-logutils-compat.po
 
 DARSHAN_ENABLE_SHARED=@DARSHAN_ENABLE_SHARED@
 
@@ -83,12 +81,7 @@ darshan-bgq-logutils.o: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-lo
 darshan-bgq-logutils.po: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-logutils.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-bgq-log-format.h | uthash-1.9.2
 	$(CC) $(CFLAGS_SHARED) -c  $< -o $@
 
-compat/darshan-logutils-compat.o: compat/darshan-logutils-compat.c compat/darshan-logutils-compat.h darshan-logutils.h $(DARSHAN_LOG_FORMAT) | uthash-1.9.2
-	$(CC) $(CFLAGS) -c  $< -o $@
-#compat/darshan-logutils-compat.po: compat/darshan-logutils-compat.c compat/darshan-logutils-compat.h darshan-logutils.h $(DARSHAN_LOG_FORMAT) | uthash-1.9.2
-#	$(CC) $(CFLAGS_SHARED) -c  $< -o $@
-
-libdarshan-util.a: darshan-logutils.o $(DARSHAN_STATIC_MOD_OBJS) $(DARSHAN_STATIC_COMPAT_OBJS)
+libdarshan-util.a: darshan-logutils.o $(DARSHAN_STATIC_MOD_OBJS)
 	ar rcs libdarshan-util.a $^
 
 libdarshan-util.so: darshan-logutils.po $(DARSHAN_DYNAMIC_MOD_OBJS) 
@@ -165,7 +158,7 @@ endif
 
 
 clean::
-	rm -f *.o *.po compat/*.o compat/*.po *.a *.so darshan-analyzer darshan-convert darshan-diff darshan-parser darshan-merge jenkins-hash-gen
+	rm -f *.o *.po *.a *.so darshan-analyzer darshan-convert darshan-diff darshan-parser darshan-merge jenkins-hash-gen
 
 distclean:: clean
 	rm -f darshan-runtime-config.h aclocal.m4 autom4te.cache/* config.status config.log Makefile util/bin/darshan-job-summary.pl


=====================================
darshan-util/compat/darshan-logutils-compat.c deleted
=====================================
--- a/darshan-util/compat/darshan-logutils-compat.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2015 University of Chicago.
- * See COPYRIGHT notice in top-level directory.
- *
- */
-
-#define _GNU_SOURCE
-#include "darshan-util-config.h"
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <sys/types.h>
-
-#include "darshan-logutils-compat.h"
-
-int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
-    int swap_flag, struct darshan_name_record_ref **hash)
-{
-    struct darshan_name_record_ref *ref;
-    char *buf_ptr;
-    darshan_record_id *rec_id_ptr;
-    uint32_t *path_len_ptr;
-    char *path_ptr;
-    int rec_len;
-    int buf_processed = 0;
-
-    /* work through the name record buffer -- deserialize the mapping data and
-     * add to the output hash table
-     * NOTE: these mapping pairs are variable in length, so we have to be able
-     * to handle incomplete mappings temporarily here
-     */
-    buf_ptr = name_rec_buf;
-    while(buf_len > (sizeof(darshan_record_id) + sizeof(uint32_t)))
-    {
-        /* see if we have enough buf space to read in the next full record */
-        path_len_ptr = (uint32_t *)(buf_ptr + sizeof(darshan_record_id));
-        if(swap_flag)
-            DARSHAN_BSWAP32(path_len_ptr);
-        rec_len = sizeof(darshan_record_id) + sizeof(uint32_t) + *path_len_ptr;
-
-        /* we need to read more before we continue deserializing */
-        if(buf_len < rec_len)
-            break;
-
-        /* get pointers for each field of this darshan record */
-        /* NOTE: darshan record hash serialization method: 
-         *          ... darshan_record_id | (uint32_t) path_len | path ...
-         */
-        rec_id_ptr = (darshan_record_id *)buf_ptr;
-        path_ptr = (char *)(buf_ptr + sizeof(darshan_record_id) + sizeof(uint32_t));
-
-        if(swap_flag)
-            /* we need to sort out endianness issues before deserializing */
-            DARSHAN_BSWAP64(rec_id_ptr);
-
-        HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
-        if(!ref)
-        {
-            ref = malloc(sizeof(*ref));
-            if(!ref)
-                return(-1);
-
-            ref->name_record = malloc(rec_len - sizeof(uint32_t) + 1);
-            if(!ref->name_record)
-            {
-                free(ref);
-                return(-1);
-            }
-
-            /* transform the serialized name record into the zero-length
-             * array structure darshan uses to track name records
-             */
-            ref->name_record->id = *rec_id_ptr;
-            memcpy(ref->name_record->name, path_ptr, *path_len_ptr);
-            ref->name_record->name[*path_len_ptr] = '\0';
-
-            /* add this record to the hash */
-            HASH_ADD(hlink, *hash, name_record->id, sizeof(darshan_record_id), ref);
-        }
-
-        buf_ptr += rec_len;
-        buf_len -= rec_len;
-        buf_processed += rec_len;
-    }
-
-    return(buf_processed);
-}
-
-/*
- * Local variables:
- *  c-indent-level: 4
- *  c-basic-offset: 4
- * End:
- *
- * vim: ts=8 sts=4 sw=4 expandtab
- */


=====================================
darshan-util/compat/darshan-logutils-compat.h deleted
=====================================
--- a/darshan-util/compat/darshan-logutils-compat.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (C) 2015 University of Chicago.
- * See COPYRIGHT notice in top-level directory.
- *
- */
-
-#ifndef __DARSHAN_LOG_UTILS_COMPAT_H
-#define __DARSHAN_LOG_UTILS_COMPAT_H
-
-#include "darshan-logutils.h"
-
-int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
-    int swap_flag, struct darshan_name_record_ref **hash);
-
-#endif


=====================================
darshan-util/darshan-bgq-logutils.c
=====================================
--- a/darshan-util/darshan-bgq-logutils.c
+++ b/darshan-util/darshan-bgq-logutils.c
@@ -30,6 +30,15 @@ char *bgq_f_counter_names[] = {
 };
 #undef X
 
+/* old definitions for enforcing backwards compatibility */
+struct darshan_bgq_record_1
+{
+    struct darshan_base_record base_rec;
+    int alignment;
+    int64_t counters[BGQ_NUM_INDICES];
+    double fcounters[BGQ_F_NUM_INDICES];
+};
+
 static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf);
 static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf, int ver);
 static void darshan_log_print_bgq_rec(void *file_rec,
@@ -51,19 +60,46 @@ struct darshan_mod_logutil_funcs bgq_logutils =
 
 static int darshan_log_get_bgq_rec(darshan_fd fd, void* bgq_buf)
 {
-    struct darshan_bgq_record *rec;
+    int log_rec_len;
+    struct darshan_bgq_record *rec =
+        (struct darshan_bgq_record *)bgq_buf;
     int i;
-    int ret;
+    int ret = -1;
+
+    /* read the BGQ record from file, checking the version first so we
+     * can read it correctly
+     */
+    if(fd->mod_ver[DARSHAN_BGQ_MOD] == 1)
+    {
+        struct darshan_bgq_record_1 bgq_rec_1;
+        log_rec_len = sizeof(struct darshan_bgq_record_1);
+
+        ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, &bgq_rec_1,
+            log_rec_len);
+        if(ret == log_rec_len)
+        {
+            /* up-convert old BGQ format to new format */
+            rec->base_rec = bgq_rec_1.base_rec;
+            memcpy(rec->counters, bgq_rec_1.counters,
+                BGQ_NUM_INDICES * sizeof(int64_t));
+            memcpy(rec->fcounters, bgq_rec_1.fcounters,
+                BGQ_F_NUM_INDICES * sizeof(double));
+        }
+    }
+    else if(fd->mod_ver[DARSHAN_BGQ_MOD] == 2)
+    {
+        log_rec_len = sizeof(struct darshan_bgq_record);
+
+        ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, rec,
+            log_rec_len);
+    }
 
-    ret = darshan_log_get_mod(fd, DARSHAN_BGQ_MOD, bgq_buf,
-        sizeof(struct darshan_bgq_record));
     if(ret < 0)
         return(-1);
-    else if(ret < sizeof(struct darshan_bgq_record))
+    else if(ret < log_rec_len)
         return(0);
     else
     {
-        rec = (struct darshan_bgq_record *)bgq_buf;
         if(fd->swap_flag)
         {
             /* swap bytes if necessary */


=====================================
darshan-util/darshan-logutils.c
=====================================
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -18,7 +18,6 @@
 #include <errno.h>
 
 #include "darshan-logutils.h"
-#include "compat/darshan-logutils-compat.h"
 
 /* default input buffer size for decompression algorithm */
 #define DARSHAN_DEF_COMP_BUF_SZ (1024*1024) /* 1 MiB */
@@ -71,6 +70,15 @@ struct darshan_fd_int_state
     struct darshan_dz_state dz;
 };
 
+/* each module's implementation of the darshan logutil functions */
+#define X(a, b, c, d) d,
+struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
+{
+    DARSHAN_MODULE_IDS
+};
+#undef X
+
+/* internal helper functions */
 static int darshan_mnt_info_cmp(const void *a, const void *b);
 static int darshan_log_get_namerecs(void *name_rec_buf, int buf_len,
     int swap_flag, struct darshan_name_record_ref **hash);
@@ -100,13 +108,14 @@ static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p);
 static int darshan_log_noz_read(darshan_fd fd, struct darshan_log_map map,
     void *buf, int len, int reset_strm_flag);
 
-/* each module's implementation of the darshan logutil functions */
-#define X(a, b, c, d) d,
-struct darshan_mod_logutil_funcs *mod_logutils[DARSHAN_MAX_MODS] =
-{
-    DARSHAN_MODULE_IDS
-};
-#undef X
+/* backwards compatibility functions */
+int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
+    int swap_flag, struct darshan_name_record_ref **hash);
+
+
+/********************************************************
+ *        publically exposed logutil functions          *
+ ********************************************************/
 
 /* darshan_log_open()
  *
@@ -754,7 +763,9 @@ void darshan_log_close(darshan_fd fd)
     return;
 }
 
-/* **************************************************** */
+/********************************************************
+ *             internal helper functions                *
+ ********************************************************/
 
 static int darshan_mnt_info_cmp(const void *a, const void *b)
 {
@@ -911,6 +922,7 @@ static int darshan_log_get_header(darshan_fd fd)
             {
                 DARSHAN_BSWAP64(&(header.mod_map[i].off));
                 DARSHAN_BSWAP64(&(header.mod_map[i].len));
+                DARSHAN_BSWAP32(&(header.mod_ver[i]));
             }
         }
         else
@@ -1727,6 +1739,83 @@ static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p)
     return (0);
 }
 
+/********************************************************
+ *          backwards compatibility functions           *
+ ********************************************************/
+
+int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
+    int swap_flag, struct darshan_name_record_ref **hash)
+{
+    struct darshan_name_record_ref *ref;
+    char *buf_ptr;
+    darshan_record_id *rec_id_ptr;
+    uint32_t *path_len_ptr;
+    char *path_ptr;
+    int rec_len;
+    int buf_processed = 0;
+
+    /* work through the name record buffer -- deserialize the mapping data and
+     * add to the output hash table
+     * NOTE: these mapping pairs are variable in length, so we have to be able
+     * to handle incomplete mappings temporarily here
+     */
+    buf_ptr = name_rec_buf;
+    while(buf_len > (sizeof(darshan_record_id) + sizeof(uint32_t)))
+    {
+        /* see if we have enough buf space to read in the next full record */
+        path_len_ptr = (uint32_t *)(buf_ptr + sizeof(darshan_record_id));
+        if(swap_flag)
+            DARSHAN_BSWAP32(path_len_ptr);
+        rec_len = sizeof(darshan_record_id) + sizeof(uint32_t) + *path_len_ptr;
+
+        /* we need to read more before we continue deserializing */
+        if(buf_len < rec_len)
+            break;
+
+        /* get pointers for each field of this darshan record */
+        /* NOTE: darshan record hash serialization method: 
+         *          ... darshan_record_id | (uint32_t) path_len | path ...
+         */
+        rec_id_ptr = (darshan_record_id *)buf_ptr;
+        path_ptr = (char *)(buf_ptr + sizeof(darshan_record_id) + sizeof(uint32_t));
+
+        if(swap_flag)
+            /* we need to sort out endianness issues before deserializing */
+            DARSHAN_BSWAP64(rec_id_ptr);
+
+        HASH_FIND(hlink, *hash, rec_id_ptr, sizeof(darshan_record_id), ref);
+        if(!ref)
+        {
+            ref = malloc(sizeof(*ref));
+            if(!ref)
+                return(-1);
+
+            ref->name_record = malloc(rec_len - sizeof(uint32_t) + 1);
+            if(!ref->name_record)
+            {
+                free(ref);
+                return(-1);
+            }
+
+            /* transform the serialized name record into the zero-length
+             * array structure darshan uses to track name records
+             */
+            ref->name_record->id = *rec_id_ptr;
+            memcpy(ref->name_record->name, path_ptr, *path_len_ptr);
+            ref->name_record->name[*path_len_ptr] = '\0';
+
+            /* add this record to the hash */
+            HASH_ADD(hlink, *hash, name_record->id, sizeof(darshan_record_id), ref);
+        }
+
+        buf_ptr += rec_len;
+        buf_len -= rec_len;
+        buf_processed += rec_len;
+    }
+
+    return(buf_processed);
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/0d2cb76b400993ff0a0cb860f9614d3c4e093609...6ccaea467e12501f5fbe40024fb792fc073ba2d9
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160620/6c91e874/attachment-0001.html>


More information about the Darshan-commits mailing list