[Darshan-commits] [Git][darshan/darshan][master] 2 commits: Add H5D module counter to indicate corresponding H5F record ID

Shane Snyder xgitlab at cels.anl.gov
Thu Mar 25 21:48:44 CDT 2021



Shane Snyder pushed to branch master at darshan / darshan


Commits:
cfda2264 by Shane Snyder at 2021-03-25T21:48:40-05:00
Add H5D module counter to indicate corresponding H5F record ID

- - - - -
63130594 by Shane Snyder at 2021-03-25T21:48:40-05:00
Merge branch 'dev-h5d-file-rec-counter' into 'master'

Add H5D module counter to indicate corresponding H5F record  ID

See merge request darshan/darshan!91
- - - - -


4 changed files:

- darshan-hdf5-log-format.h
- darshan-runtime/lib/darshan-hdf5.c
- darshan-util/darshan-hdf5-logutils.c
- darshan-util/pydarshan/darshan/backend/api_def_c.py


Changes:

=====================================
darshan-hdf5-log-format.h
=====================================
@@ -9,7 +9,7 @@
 
 /* current HDF5 log format versions */
 #define DARSHAN_H5F_VER 3
-#define DARSHAN_H5D_VER 1
+#define DARSHAN_H5D_VER 2
 
 #define H5D_MAX_NDIMS 5
 
@@ -245,6 +245,7 @@ struct darshan_hdf5_file
 struct darshan_hdf5_dataset
 {
     struct darshan_base_record base_rec;
+    uint64_t file_rec_id;
     int64_t counters[H5D_NUM_INDICES];
     double fcounters[H5D_F_NUM_INDICES];
 };


=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
@@ -410,7 +410,7 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
     char *__file_path, *__tmp_ptr; \
     char __rec_name[DARSHAN_HDF5_MAX_NAME_LEN] = {0}; \
     ssize_t __req_name_len = DARSHAN_HDF5_MAX_NAME_LEN-1, __ret_name_len; \
-    darshan_record_id __rec_id; \
+    darshan_record_id __rec_id, __file_rec_id = 0; \
     struct hdf5_dataset_record_ref *__rec_ref; \
     hsize_t __chunk_dims[H5D_MAX_NDIMS] = {0}; \
     int __i, __n_chunk_dims = 0; \
@@ -424,6 +424,7 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
             free(__file_path); \
             break; \
         } \
+        __file_rec_id = darshan_core_gen_record_id(__file_path); \
         strncpy(__rec_name, __file_path, __req_name_len); \
         free(__file_path); \
         if(strlen(__rec_name) + 2 <= __req_name_len) { \
@@ -462,6 +463,7 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
             __rec_ref->dataset_rec->counters[H5D_CHUNK_SIZE_D1 + __i] = __chunk_dims[__n_chunk_dims - __i - 1]; \
     } \
     __rec_ref->dataset_rec->counters[H5D_DATATYPE_SIZE] = H5Tget_size(__type_id); \
+    __rec_ref->dataset_rec->file_rec_id = __file_rec_id; \
     darshan_add_record_ref(&(hdf5_dataset_runtime->hid_hash), &__ret, sizeof(hid_t), __rec_ref); \
 } while(0)
 
@@ -1177,6 +1179,7 @@ static void hdf5_dataset_record_reduction_op(void* inrec_v, void* inoutrec_v,
         memset(&tmp_dataset, 0, sizeof(struct darshan_hdf5_dataset));
         tmp_dataset.base_rec.id = inrec->base_rec.id;
         tmp_dataset.base_rec.rank = -1;
+        tmp_dataset.file_rec_id = inrec->file_rec_id;
 
         /* sum */
         for(j=H5D_OPENS; j<=H5D_POINT_SELECTS; j++)


=====================================
darshan-util/darshan-hdf5-logutils.c
=====================================
@@ -39,6 +39,8 @@ char *h5d_f_counter_names[] = {
 #define DARSHAN_H5F_FILE_SIZE_1 40
 #define DARSHAN_H5F_FILE_SIZE_2 56
 
+#define DARSHAN_H5D_DATASET_SIZE_1 904
+
 static int darshan_log_get_hdf5_file(darshan_fd fd, void** hdf5_buf_p);
 static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf);
 static void darshan_log_print_hdf5_file(void *ds_rec,
@@ -246,6 +248,30 @@ static int darshan_log_get_hdf5_dataset(darshan_fd fd, void** hdf5_buf_p)
         rec_len = sizeof(struct darshan_hdf5_dataset);
         ret = darshan_log_get_mod(fd, DARSHAN_H5D_MOD, ds, rec_len);
     }
+    else
+    {
+        char scratch[1024] = {0};
+        char *src_p, *dest_p;
+        int len;
+
+        if(fd->mod_ver[DARSHAN_H5D_MOD] == 1)
+        {
+            rec_len = DARSHAN_H5D_DATASET_SIZE_1;
+            ret = darshan_log_get_mod(fd, DARSHAN_H5D_MOD, scratch, rec_len);
+            if(ret != rec_len)
+                goto exit;
+
+            /* upconvert version 1 to version 2 in-place */
+            dest_p = scratch + sizeof(struct darshan_base_record) + sizeof(uint64_t);
+            src_p = dest_p - sizeof(uint64_t);
+            len = DARSHAN_H5D_DATASET_SIZE_1 - sizeof(struct darshan_base_record);
+            memmove(dest_p, src_p, len);
+            /* set FILE_REC_ID to 0 */
+            *((uint64_t *)src_p) = 0;
+        }
+
+        memcpy(ds, scratch, sizeof(struct darshan_hdf5_dataset));
+    }
 
 exit:
     if(*hdf5_buf_p == NULL)
@@ -267,6 +293,11 @@ exit:
         {
             DARSHAN_BSWAP64(&(ds->base_rec.id));
             DARSHAN_BSWAP64(&(ds->base_rec.rank));
+            /* skip counters we explicitly set to 0 since they don't
+             * need to be byte swapped
+             */
+            if(fd->mod_ver[DARSHAN_H5F_MOD] >= 2)
+                DARSHAN_BSWAP64(&ds->file_rec_id);
             for(i=0; i<H5D_NUM_INDICES; i++)
                 DARSHAN_BSWAP64(&ds->counters[i]);
             for(i=0; i<H5D_F_NUM_INDICES; i++)
@@ -352,6 +383,11 @@ static void darshan_log_print_hdf5_dataset(void *ds_rec, char *ds_name,
             ds_name, mnt_pt, fs_type);
     }
 
+    DARSHAN_U_COUNTER_PRINT(darshan_module_names[DARSHAN_H5D_MOD],
+        hdf5_ds_rec->base_rec.rank, hdf5_ds_rec->base_rec.id,
+        "H5D_FILE_REC_ID", hdf5_ds_rec->file_rec_id,
+        ds_name, mnt_pt, fs_type);
+
     return;
 }
 
@@ -410,6 +446,13 @@ static void darshan_log_print_hdf5_dataset_description(int ver)
     printf("#   H5D_F_MAX_*_TIME: duration of the slowest H5D read and write operations.\n");
     printf("#   H5D_F_*_RANK_TIME: fastest and slowest I/O time for a single rank (for shared datasets).\n");
     printf("#   H5D_F_VARIANCE_RANK_*: variance of total I/O time and bytes moved for all ranks (for shared datasets).\n");
+    printf("#   H5D_FILE_REC_ID: Darshan record ID corresponding to the dataset.\n");
+
+    if(ver == 1)
+    {
+        printf("\n# WARNING: H5D module log format version 1 does not support the following counters:\n");
+        printf("# - H5D_FILE_REC_ID\n");
+    }
 
     return;
 }
@@ -646,6 +689,7 @@ static void darshan_log_agg_hdf5_datasets(void *rec, void *agg_rec, int init_fla
     struct var_t *var_bytes_p = (struct var_t *)
         ((char *)var_time_p + sizeof(struct var_t));
 
+    agg_hdf5_rec->file_rec_id = hdf5_rec->file_rec_id;
     for(i = 0; i < H5D_NUM_INDICES; i++)
     {
         switch(i)


=====================================
darshan-util/pydarshan/darshan/backend/api_def_c.py
=====================================
@@ -78,6 +78,7 @@ struct darshan_hdf5_file
 struct darshan_hdf5_dataset
 {
     struct darshan_base_record base_rec;
+    uint64_t file_rec_id;
     int64_t counters[94];
     double fcounters[17];
 };



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/-/compare/054de6708ac8ff0ea3b6f994dae6b6c0fe89a5ce...631305946cbda0d1a1c6dd0178fb01b7f94095be

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/-/compare/054de6708ac8ff0ea3b6f994dae6b6c0fe89a5ce...631305946cbda0d1a1c6dd0178fb01b7f94095be
You're receiving this email because of your account on xgitlab.cels.anl.gov.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20210325/98026edc/attachment-0001.html>


More information about the Darshan-commits mailing list