[Darshan-commits] [Git][darshan/darshan][dev-stdio] start filling in fopen counters

Philip Carns xgitlab at cels.anl.gov
Fri Apr 29 16:22:39 CDT 2016


Philip Carns pushed to branch dev-stdio at darshan / darshan


Commits:
28131252 by Phil Carns at 2016-04-29T17:22:27-04:00
start filling in fopen counters

- - - - -


2 changed files:

- darshan-runtime/lib/darshan-stdio.c
- darshan-stdio-log-format.h


Changes:

=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -135,15 +135,52 @@ static void stdio_shutdown(void);
 #define STDIO_LOCK() pthread_mutex_lock(&stdio_runtime_mutex)
 #define STDIO_UNLOCK() pthread_mutex_unlock(&stdio_runtime_mutex)
 
+/* TODO: remember to clean up stream_flag in posix module */
+/* TODO: remember to update start_timestamp logic in other modules */
+
+#define STDIO_RECORD_OPEN(__ret, __path, __tm1, __tm2) do { \
+    struct stdio_file_runtime* file; \
+    char* exclude; \
+    int tmp_index = 0; \
+    if(__ret == NULL) break; \
+    while((exclude = darshan_path_exclusions[tmp_index])) { \
+        if(!(strncmp(exclude, __path, strlen(exclude)))) \
+            break; \
+        tmp_index++; \
+    } \
+    if(exclude) break; \
+    file = stdio_file_by_name_setstream(__path, __ret); \
+    if(!file) break; \
+    file->offset = 0; \
+    file->last_byte_written = 0; \
+    file->last_byte_read = 0; \
+    file->file_record->counters[STDIO_FOPENS] += 1; \
+    if(file->file_record->fcounters[STDIO_F_OPEN_START_TIMESTAMP] == 0 || \
+     file->file_record->fcounters[STDIO_F_OPEN_START_TIMESTAMP] > __tm1) \
+        file->file_record->fcounters[STDIO_F_OPEN_START_TIMESTAMP] = __tm1; \
+    file->file_record->fcounters[STDIO_F_OPEN_END_TIMESTAMP] = __tm2; \
+    DARSHAN_TIMER_INC_NO_OVERLAP(file->file_record->fcounters[STDIO_F_META_TIME], __tm1, __tm2, file->last_meta_end); \
+} while(0)
+
+
+
 FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
 {
     FILE* ret;
+    double tm1, tm2;
 
     fprintf(stderr, "FOO: HELLO WORLD (FOPEN)\n");
 
     MAP_OR_FAIL(fopen);
 
+    tm1 = darshan_core_wtime();
     ret = __real_fopen(path, mode);
+    tm2 = darshan_core_wtime();
+
+    STDIO_LOCK();
+    stdio_runtime_initialize();
+    STDIO_RECORD_OPEN(ret, path, tm1, tm2);
+    STDIO_UNLOCK();
 
     return(ret);
 }


=====================================
darshan-stdio-log-format.h
=====================================
--- a/darshan-stdio-log-format.h
+++ b/darshan-stdio-log-format.h
@@ -56,18 +56,18 @@
  */
 
 #define STDIO_COUNTERS \
-    /* count of number of 'bar' function calls */\
-    X(STDIO_BARS) \
-    /* arbitrary data value set by last call to 'bar' */\
-    X(STDIO_BAR_DAT) \
+    /* count of fopens */\
+    X(STDIO_FOPENS) \
     /* end of counters */\
     X(STDIO_NUM_INDICES)
 
 #define STDIO_F_COUNTERS \
-    /* timestamp of the first call to function 'bar' */\
-    X(STDIO_F_BAR_TIMESTAMP) \
-    /* timer indicating duration of last call to 'bar' */\
-    X(STDIO_F_BAR_DURATION) \
+    /* timestamp of first open */\
+    X(STDIO_F_OPEN_START_TIMESTAMP) \
+    /* timestamp of last open completion */\
+    X(STDIO_F_OPEN_END_TIMESTAMP) \
+    /* cumulative meta time */\
+    X(STDIO_F_META_TIME) \
     /* end of counters */\
     X(STDIO_F_NUM_INDICES)
 



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/2813125263dd0df65050808b627d6c6a3350f4fa
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160429/0c954527/attachment.html>


More information about the Darshan-commits mailing list