[Darshan-commits] [Git][darshan/darshan][master] 2 commits: Darshan logutil helpers for Python bindings

Shane Snyder xgitlab at cels.anl.gov
Thu Apr 30 15:22:06 CDT 2020



Shane Snyder pushed to branch master at darshan / darshan


Commits:
39452379 by Jakob Luettgau at 2020-04-30T15:22:03-05:00
Darshan logutil helpers for Python bindings

- - - - -
49eb46cc by Shane Snyder at 2020-04-30T15:22:03-05:00
Merge branch 'python-bindings' into 'master'

Python Bindings via CFFI

See merge request darshan/darshan!31
- - - - -


3 changed files:

- darshan-util/darshan-logutils.c
- darshan-util/darshan-logutils.h
- darshan-util/darshan-stdio-logutils.c


Changes:

=====================================
darshan-util/darshan-logutils.c
=====================================
@@ -1837,6 +1837,98 @@ int darshan_log_get_namerecs_3_00(void *name_rec_buf, int buf_len,
     return(buf_processed);
 }
 
+/*
+ * Support functions for use with other languages
+ */
+
+/*
+ * darshan_log_get_modules
+ *
+ * Gets list of modules present in logs and returns the info
+ */
+void darshan_log_get_modules (darshan_fd fd,
+                              struct darshan_mod_info **mods,
+                              int* count)
+{
+    int i;
+    int j;
+
+    *mods = malloc(sizeof(**mods) * DARSHAN_MAX_MODS);
+    assert(*mods);
+
+    for (i = 0, j = 0; i < DARSHAN_MAX_MODS; i++)
+    {
+        if (fd->mod_map[i].len)
+        {
+            (*mods)[j].name = darshan_module_names[i];
+            (*mods)[j].len  = fd->mod_map[i].len;
+            (*mods)[j].ver  = fd->mod_ver[i];
+            (*mods)[j].idx  = i;
+            j += 1;
+        }
+    }
+
+    *count = j;
+}
+
+
+/*
+ * darshan_log_get_name_records
+ *
+ * Gets list of hashed name_records present in logs and returns the info
+ */
+void darshan_log_get_name_records(darshan_fd fd,
+                              struct darshan_name_record_info **name_records,
+                              int* count)
+{
+
+    int ret;
+    struct darshan_name_record_ref *name_hash = NULL;
+    struct darshan_name_record_ref *ref = NULL;
+    struct darshan_name_record_ref *tmp = NULL;
+    struct darshan_name_record_ref *curr = NULL;
+
+    /* read hash of darshan records */
+    ret = darshan_log_get_namehash(fd, &name_hash);
+    if(ret < 0)
+    {
+        darshan_log_close(fd);
+        return(-1);
+    }
+
+    int num = HASH_CNT(hlink, name_hash);
+    *name_records = malloc(sizeof(**name_records) * num);
+    assert(*name_records);
+
+    int i = 0;
+    HASH_ITER(hlink, name_hash, curr, tmp)
+    {
+        (*name_records)[i].id = curr->name_record->id;
+        (*name_records)[i].name = curr->name_record->name;
+        i++;
+    }
+ 
+    *count = num;
+    return;
+}
+
+
+/*
+ * darshan_log_get_record 
+ *
+ *   Wrapper to hide the mod_logutils callback functions.
+ */
+int  darshan_log_get_record (darshan_fd fd,
+                             int mod_idx,
+                             void **buf)
+{
+    int r;
+
+    r = mod_logutils[mod_idx]->log_get_record(fd, buf);
+
+    return r;
+}
+
 /*
  * Local variables:
  *  c-indent-level: 4


=====================================
darshan-util/darshan-logutils.h
=====================================
@@ -68,6 +68,22 @@ struct darshan_mnt_info
     char mnt_path[DARSHAN_EXE_LEN];
 };
 
+struct darshan_mod_info
+{
+    char *name;
+    int  len;
+    int  ver;
+    int  idx;
+};
+
+struct darshan_name_record_info
+{
+    darshan_record_id id;
+    char *name;
+};
+
+
+
 /* functions to be implemented by each module for integration with
  * darshan log file utilities (e.g., parser & convert tools)
  */
@@ -158,6 +174,11 @@ int darshan_log_put_mod(darshan_fd fd, darshan_module_id mod_id,
     void *mod_buf, int mod_buf_sz, int ver);
 void darshan_log_close(darshan_fd file);
 void darshan_log_print_version_warnings(const char *version_string);
+void darshan_log_get_modules (darshan_fd fd, struct darshan_mod_info **mods, int* count);
+void darshan_log_get_name_records(darshan_fd fd,
+                              struct darshan_name_record_info **mods,
+                              int* count);
+int darshan_log_get_record (darshan_fd fd, int mod_idx, void **buf);
 
 /* convenience macros for printing Darshan counters */
 #define DARSHAN_PRINT_HEADER() \


=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
@@ -109,7 +109,7 @@ static int darshan_log_get_stdio_record(darshan_fd fd, void** stdio_buf_p)
             *((int64_t *)src_p) = -1;
         }
 
-        memcpy(file, scratch, sizeof(struct darshan_posix_file));
+        memcpy(file, scratch, sizeof(struct darshan_stdio_file));
     }
 
 exit:



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/559219497a455fec5d58446c6e093905c118acb0...49eb46cc77b8de07a8e81ec21a8c2b9d0f473192

-- 
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/559219497a455fec5d58446c6e093905c118acb0...49eb46cc77b8de07a8e81ec21a8c2b9d0f473192
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/20200430/c986323a/attachment-0001.html>


More information about the Darshan-commits mailing list