[Darshan-commits] [Darshan] branch, dev-modular, updated. darshan-2.3.1-75-g6af7ad3

Service Account git at mcs.anl.gov
Tue Mar 31 13:17:09 CDT 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".

The branch, dev-modular has been updated
       via  6af7ad398b4ba7ce8eb1c571cc00aeb20b6a4d1c (commit)
      from  dc00384c4238486f01236ddb7ea69cd86428b096 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6af7ad398b4ba7ce8eb1c571cc00aeb20b6a4d1c
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date:   Tue Mar 31 13:16:28 2015 -0500

    more posix wrappers: sync*, seek*, & stream ops

-----------------------------------------------------------------------

Summary of changes:
 darshan-posix-log-format.h            |   58 +++----
 darshan-runtime/darshan-posix-ld-opts |   10 +
 darshan-runtime/lib/darshan-posix.c   |  307 ++++++++++++++++++++++++++++++++-
 darshan-util/darshan-posix-parser.c   |    8 +
 4 files changed, 352 insertions(+), 31 deletions(-)


Diff of changes:
diff --git a/darshan-posix-log-format.h b/darshan-posix-log-format.h
index 6eaba76..23e8b29 100644
--- a/darshan-posix-log-format.h
+++ b/darshan-posix-log-format.h
@@ -14,40 +14,38 @@ enum darshan_posix_indices
     POSIX_OPENS,              /* count of posix opens */
     POSIX_READS,              /* count of posix reads */
     POSIX_WRITES,             /* count of posix writes */
-#if 0
     POSIX_SEEKS,              /* count of posix seeks */
+#if 0
     POSIX_STATS,              /* count of posix stat/lstat/fstats */
     POSIX_MMAPS,              /* count of posix mmaps */
 #endif
-    POSIX_FOPENS,
-    POSIX_FREADS,
-    POSIX_FWRITES,
-#if 0
-    POSIX_FSEEKS,
-    POSIX_FSYNCS,
-    POSIX_FDSYNCS,
-#endif
-    POSIX_MODE,                /* mode of file */
-    POSIX_BYTES_READ,          /* total bytes read */
-    POSIX_BYTES_WRITTEN,       /* total bytes written */
-    POSIX_MAX_BYTE_READ,       /* highest offset byte read */
-    POSIX_MAX_BYTE_WRITTEN,    /* highest offset byte written */
-    POSIX_CONSEC_READS,        /* count of consecutive reads */
-    POSIX_CONSEC_WRITES,       /* count of consecutive writes */ 
-    POSIX_SEQ_READS,           /* count of sequential reads */
-    POSIX_SEQ_WRITES,          /* count of sequential writes */
-    POSIX_RW_SWITCHES,         /* number of times switched between read and write */
+    POSIX_FOPENS,             /* count of posix fopens */
+    POSIX_FREADS,             /* count of posix freads */
+    POSIX_FWRITES,            /* count of posix fwrites */
+    POSIX_FSEEKS,             /* count of posix fseeks */
+    POSIX_FSYNCS,             /* count of posix fsyncs */
+    POSIX_FDSYNCS,            /* count of posix fdatasyncs */
+    POSIX_MODE,               /* mode of file */
+    POSIX_BYTES_READ,         /* total bytes read */
+    POSIX_BYTES_WRITTEN,      /* total bytes written */
+    POSIX_MAX_BYTE_READ,      /* highest offset byte read */
+    POSIX_MAX_BYTE_WRITTEN,   /* highest offset byte written */
+    POSIX_CONSEC_READS,       /* count of consecutive reads */
+    POSIX_CONSEC_WRITES,      /* count of consecutive writes */ 
+    POSIX_SEQ_READS,          /* count of sequential reads */
+    POSIX_SEQ_WRITES,         /* count of sequential writes */
+    POSIX_RW_SWITCHES,        /* number of times switched between read and write */
 #if 0
-    MEM_NOT_ALIGNED,           /* count of accesses not mem aligned */
-    MEM_ALIGNMENT,             /* mem alignment in bytes */
-    FILE_NOT_ALIGNED,          /* count of accesses not file aligned */
-    FILE_ALIGNMENT,            /* file alignment in bytes */
+    MEM_NOT_ALIGNED,          /* count of accesses not mem aligned */
+    MEM_ALIGNMENT,            /* mem alignment in bytes */
+    FILE_NOT_ALIGNED,         /* count of accesses not file aligned */
+    FILE_ALIGNMENT,           /* file alignment in bytes */
 #endif
     POSIX_MAX_READ_TIME_SIZE,
     POSIX_MAX_WRITE_TIME_SIZE,
 #if 0
     /* buckets */
-    SIZE_READ_0_100,           /* count of posix read size ranges */
+    SIZE_READ_0_100,          /* count of posix read size ranges */
     SIZE_READ_100_1K,
     SIZE_READ_1K_10K,
     SIZE_READ_10K_100K,
@@ -58,7 +56,7 @@ enum darshan_posix_indices
     SIZE_READ_100M_1G,
     SIZE_READ_1G_PLUS,
     /* buckets */
-    SIZE_WRITE_0_100,          /* count of posix write size ranges */
+    SIZE_WRITE_0_100,         /* count of posix write size ranges */
     SIZE_WRITE_100_1K,
     SIZE_WRITE_1K_10K,
     SIZE_WRITE_10K_100K,
@@ -69,23 +67,23 @@ enum darshan_posix_indices
     SIZE_WRITE_100M_1G,
     SIZE_WRITE_1G_PLUS,
     /* counters */
-    STRIDE1_STRIDE,             /* the four most frequently appearing strides */
+    STRIDE1_STRIDE,           /* the four most frequently appearing strides */
     STRIDE2_STRIDE,
     STRIDE3_STRIDE,
     STRIDE4_STRIDE,
-    STRIDE1_COUNT,              /* count of each of the most frequent strides */
+    STRIDE1_COUNT,            /* count of each of the most frequent strides */
     STRIDE2_COUNT,
     STRIDE3_COUNT,
     STRIDE4_COUNT,
-    ACCESS1_ACCESS,             /* the four most frequently appearing access sizes */
+    ACCESS1_ACCESS,           /* the four most frequently appearing access sizes */
     ACCESS2_ACCESS,
     ACCESS3_ACCESS,
     ACCESS4_ACCESS,
-    ACCESS1_COUNT,              /* count of each of the most frequent access sizes */
+    ACCESS1_COUNT,            /* count of each of the most frequent access sizes */
     ACCESS2_COUNT,
     ACCESS3_COUNT,
     ACCESS4_COUNT,
-    DEVICE,                     /* device id reported by stat */
+    DEVICE,                   /* device id reported by stat */
     SIZE_AT_OPEN,
     FASTEST_RANK,
     FASTEST_RANK_BYTES,
diff --git a/darshan-runtime/darshan-posix-ld-opts b/darshan-runtime/darshan-posix-ld-opts
index be3b1df..581d6b9 100644
--- a/darshan-runtime/darshan-posix-ld-opts
+++ b/darshan-runtime/darshan-posix-ld-opts
@@ -2,6 +2,8 @@
 --wrap=open64
 --wrap=creat
 --wrap=creat64
+--wrap=fopen
+--wrap=fopen64
 --wrap=read
 --wrap=write
 --wrap=pread
@@ -10,4 +12,12 @@
 --wrap=pwrite64
 --wrap=readv
 --wrap=writev
+--wrap=fread
+--wrap=fwrite
+--wrap=lseek
+--wrap=lseek64
+--wrap=fseek
+--wrap=fsync
+--wrap=fdatasync
 --wrap=close
+--wrap=fclose
diff --git a/darshan-runtime/lib/darshan-posix.c b/darshan-runtime/lib/darshan-posix.c
index 24b68b4..94a800b 100644
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -41,6 +41,8 @@ DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
 DARSHAN_FORWARD_DECL(open64, int, (const char *path, int flags, ...));
 DARSHAN_FORWARD_DECL(creat, int, (const char* path, mode_t mode));
 DARSHAN_FORWARD_DECL(creat64, int, (const char* path, mode_t mode));
+DARSHAN_FORWARD_DECL(fopen, FILE*, (const char *path, const char *mode));
+DARSHAN_FORWARD_DECL(fopen64, FILE*, (const char *path, const char *mode));
 DARSHAN_FORWARD_DECL(read, ssize_t, (int fd, void *buf, size_t count));
 DARSHAN_FORWARD_DECL(write, ssize_t, (int fd, const void *buf, size_t count));
 DARSHAN_FORWARD_DECL(pread, ssize_t, (int fd, void *buf, size_t count, off_t offset));
@@ -49,7 +51,17 @@ DARSHAN_FORWARD_DECL(pread64, ssize_t, (int fd, void *buf, size_t count, off64_t
 DARSHAN_FORWARD_DECL(pwrite64, ssize_t, (int fd, const void *buf, size_t count, off64_t offset));
 DARSHAN_FORWARD_DECL(readv, ssize_t, (int fd, const struct iovec *iov, int iovcnt));
 DARSHAN_FORWARD_DECL(writev, ssize_t, (int fd, const struct iovec *iov, int iovcnt));
+DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
+DARSHAN_FORWARD_DECL(fwrite, size_t, (const void *ptr, size_t size, size_t nmemb, FILE *stream));
+DARSHAN_FORWARD_DECL(lseek, off_t, (int fd, off_t offset, int whence));
+DARSHAN_FORWARD_DECL(lseek64, off64_t, (int fd, off64_t offset, int whence));
+DARSHAN_FORWARD_DECL(fseek, int, (FILE *stream, long offset, int whence));
+/* stats */
+/* mmaps */
+DARSHAN_FORWARD_DECL(fsync, int, (int fd));
+DARSHAN_FORWARD_DECL(fdatasync, int, (int fd));
 DARSHAN_FORWARD_DECL(close, int, (int fd));
+DARSHAN_FORWARD_DECL(fclose, int, (FILE *fp));
 
 static void posix_runtime_initialize(void);
 static struct posix_file_runtime* posix_file_by_name(const char *name);
@@ -373,6 +385,56 @@ int DARSHAN_DECL(creat64)(const char* path, mode_t mode)
     return(ret);
 }
 
+FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
+{
+    FILE* ret;
+    int fd;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fopen);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fopen(path, mode);
+    tm2 = darshan_core_wtime();
+
+    if(ret == NULL)
+        fd = -1;
+    else
+        fd = fileno(ret);
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    POSIX_RECORD_OPEN(fd, path, 0, 1, tm1, tm2);
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
+FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
+{
+    FILE* ret;
+    int fd;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fopen64);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fopen64(path, mode);
+    tm2 = darshan_core_wtime();
+
+    if(ret == NULL)
+        fd = -1;
+    else
+        fd = fileno(ret);
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    POSIX_RECORD_OPEN(fd, path, 0, 1, tm1, tm2);
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
 ssize_t DARSHAN_DECL(read)(int fd, void *buf, size_t count)
 {
     ssize_t ret;
@@ -526,6 +588,7 @@ ssize_t DARSHAN_DECL(readv)(int fd, const struct iovec *iov, int iovcnt)
     tm2 = darshan_core_wtime();
 
     POSIX_LOCK();
+    posix_runtime_initialize();
     POSIX_RECORD_READ(ret, fd, 0, 0, aligned_flag, 0, tm1, tm2);
     POSIX_UNLOCK();
 
@@ -553,12 +616,223 @@ ssize_t DARSHAN_DECL(writev)(int fd, const struct iovec *iov, int iovcnt)
     tm2 = darshan_core_wtime();
 
     POSIX_LOCK();
+    posix_runtime_initialize();
     POSIX_RECORD_WRITE(ret, fd, 0, 0, aligned_flag, 0, tm1, tm2);
     POSIX_UNLOCK();
 
     return(ret);
 }
 
+size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+    size_t ret;
+    int aligned_flag = 0;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fread);
+
+    /* if((unsigned long)ptr % darshan_mem_alignment == 0) aligned_flag = 1; */
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fread(ptr, size, nmemb, stream);
+    tm2 = darshan_core_wtime();
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    if(ret > 0)
+    {
+        POSIX_RECORD_READ(size*ret, fileno(stream), 0, 0,
+            aligned_flag, 1, tm1, tm2);
+    }
+    else
+    {
+        POSIX_RECORD_READ(ret, fileno(stream), 0, 0,
+            aligned_flag, 1, tm1, tm2);
+    }
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
+size_t DARSHAN_DECL(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *stream)
+{
+    size_t ret;
+    int aligned_flag = 0;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fwrite);
+
+    /* if((unsigned long)ptr % darshan_mem_alignment == 0) aligned_flag = 1; */
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fwrite(ptr, size, nmemb, stream);
+    tm2 = darshan_core_wtime();
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    if(ret > 0)
+    {
+        POSIX_RECORD_WRITE(size*ret, fileno(stream), 0, 0,
+            aligned_flag, 1, tm1, tm2);
+    }
+    else
+    {
+        POSIX_RECORD_WRITE(ret, fileno(stream), 0, 0,
+            aligned_flag, 1, tm1, tm2);
+    }
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
+off_t DARSHAN_DECL(lseek)(int fd, off_t offset, int whence)
+{
+    off_t ret;
+    struct posix_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(lseek);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_lseek(fd, offset, whence);
+    tm2 = darshan_core_wtime();
+
+    if(ret >= 0)
+    {
+        POSIX_LOCK();
+        posix_runtime_initialize();
+        file = posix_file_by_fd(fd);
+        if(file)
+        {
+            file->offset = ret;
+            DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+                tm1, tm2, file->last_meta_end, POSIX_F_META_TIME);
+            DARSHAN_COUNTER_INC(file->file_record, POSIX_SEEKS, 1);
+        }
+        POSIX_UNLOCK();
+    }
+
+    return(ret);
+}
+
+off_t DARSHAN_DECL(lseek64)(int fd, off_t offset, int whence)
+{
+    off_t ret;
+    struct posix_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(lseek64);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_lseek64(fd, offset, whence);
+    tm2 = darshan_core_wtime();
+
+    if(ret >= 0)
+    {
+        POSIX_LOCK();
+        posix_runtime_initialize();
+        file = posix_file_by_fd(fd);
+        if(file)
+        {
+            file->offset = ret;
+            DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+                tm1, tm2, file->last_meta_end, POSIX_F_META_TIME);
+            DARSHAN_COUNTER_INC(file->file_record, POSIX_SEEKS, 1);
+        }
+        POSIX_UNLOCK();
+    }
+
+    return(ret);
+}
+
+int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
+{
+    int ret;
+    struct posix_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fseek);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fseek(stream, offset, whence);
+    tm2 = darshan_core_wtime();
+
+    if(ret >= 0)
+    {
+        POSIX_LOCK();
+        posix_runtime_initialize();
+        file = posix_file_by_fd(fileno(stream));
+        if(file)
+        {
+            file->offset = ftell(stream); /* TODO: this seems wrong. ftell? */
+            DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+                tm1, tm2, file->last_meta_end, POSIX_F_META_TIME);
+            DARSHAN_COUNTER_INC(file->file_record, POSIX_FSEEKS, 1);
+        }
+        POSIX_UNLOCK();
+    }
+
+    return(ret);
+}
+
+int DARSHAN_DECL(fsync)(int fd)
+{
+    int ret;
+    struct posix_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fsync);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fsync(fd);
+    tm2 = darshan_core_wtime();
+
+    if(ret < 0)
+        return(ret);
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    file = posix_file_by_fd(fd);
+    if(file)
+    {
+        DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+            tm1, tm2, file->last_write_end, POSIX_F_WRITE_TIME);
+        DARSHAN_COUNTER_INC(file->file_record, POSIX_FSYNCS, 1);
+    }
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
+int DARSHAN_DECL(fdatasync)(int fd)
+{
+    int ret;
+    struct posix_file_runtime* file;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(fdatasync);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fdatasync(fd);
+    tm2 = darshan_core_wtime();
+
+    if(ret < 0)
+        return(ret);
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    file = posix_file_by_fd(fd);
+    if(file)
+    {
+        DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+            tm1, tm2, file->last_write_end, POSIX_F_WRITE_TIME); 
+        DARSHAN_COUNTER_INC(file->file_record, POSIX_FDSYNCS, 1);
+    }
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
 int DARSHAN_DECL(close)(int fd)
 {
     struct posix_file_runtime* file;
@@ -589,6 +863,37 @@ int DARSHAN_DECL(close)(int fd)
     return(ret);
 }
 
+int DARSHAN_DECL(fclose)(FILE *fp)
+{
+    struct posix_file_runtime* file;
+    int fd = fileno(fp);
+    double tm1, tm2;
+    int ret;
+
+    MAP_OR_FAIL(fclose);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_fclose(fp);
+    tm2 = darshan_core_wtime();
+
+    POSIX_LOCK();
+    posix_runtime_initialize();
+    file = posix_file_by_fd(fd);
+    if(file)
+    {
+        file->last_byte_written = 0;
+        file->last_byte_read = 0;
+        DARSHAN_COUNTER_F_SET(file->file_record,
+            POSIX_F_CLOSE_TIMESTAMP, darshan_core_wtime());
+        DARSHAN_COUNTER_F_INC_NO_OVERLAP(file->file_record,
+            tm1, tm2, file->last_meta_end, POSIX_F_META_TIME);
+        posix_file_close_fd(fd);
+    }
+    POSIX_UNLOCK();
+
+    return(ret);
+}
+
 /**********************************************************
  * Internal functions for manipulating POSIX module state *
  **********************************************************/
@@ -883,7 +1188,7 @@ static void posix_record_reduction_op(
         tmp_file.rank = -1;
 
         /* sum */
-        for(j=POSIX_OPENS; j<=POSIX_FWRITES; j++)
+        for(j=POSIX_OPENS; j<=POSIX_FDSYNCS; j++)
         {
             tmp_file.counters[j] = infile->counters[j] + inoutfile->counters[j];
         }
diff --git a/darshan-util/darshan-posix-parser.c b/darshan-util/darshan-posix-parser.c
index c645d38..bc7e324 100644
--- a/darshan-util/darshan-posix-parser.c
+++ b/darshan-util/darshan-posix-parser.c
@@ -173,9 +173,13 @@ int main(int argc, char **argv)
             "\t\tPOSIX_OPENS:\t%"PRIu64"\n"
             "\t\tPOSIX_READS:\t%"PRIu64"\n"
             "\t\tPOSIX_WRITES:\t%"PRIu64"\n"
+            "\t\tPOSIX_SEEKS:\t%"PRIu64"\n"
             "\t\tPOSIX_FOPENS:\t%"PRIu64"\n"
             "\t\tPOSIX_FREADS:\t%"PRIu64"\n"
             "\t\tPOSIX_FWRITES:\t%"PRIu64"\n"
+            "\t\tPOSIX_FSEEKS:\t%"PRIu64"\n"
+            "\t\tPOSIX_FSYNCS:\t%"PRIu64"\n"
+            "\t\tPOSIX_FDSYNCS:\t%"PRIu64"\n"
             "\t\tPOSIX_MODE:\t%"PRIu64"\n"
             "\t\tPOSIX_BYTES_READ:\t%"PRIu64"\n"
             "\t\tPOSIX_BYTES_WRITTEN:\t%"PRIu64"\n"
@@ -201,9 +205,13 @@ int main(int argc, char **argv)
             next_file.counters[POSIX_OPENS],
             next_file.counters[POSIX_READS],
             next_file.counters[POSIX_WRITES],
+            next_file.counters[POSIX_SEEKS],
             next_file.counters[POSIX_FOPENS],
             next_file.counters[POSIX_FREADS],
             next_file.counters[POSIX_FWRITES],
+            next_file.counters[POSIX_FSEEKS],
+            next_file.counters[POSIX_FSYNCS],
+            next_file.counters[POSIX_FDSYNCS],
             next_file.counters[POSIX_MODE],
             next_file.counters[POSIX_BYTES_READ],
             next_file.counters[POSIX_BYTES_WRITTEN],


hooks/post-receive
--



More information about the Darshan-commits mailing list