[Darshan-commits] [Git][darshan/darshan][dev-stdio-utils] 8 commits: add instrument_fs call to darshan-core

Philip Carns xgitlab at cels.anl.gov
Sat Aug 20 08:35:01 CDT 2016


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


Commits:
beac22fc by Shane Snyder at 2016-07-07T20:44:46-07:00
add instrument_fs call to darshan-core

This function can be called by modules to allow FS-specific
modules to gather data for a given file path/file descriptor.
Currently integrated into POSIX and STDIO modules.

- - - - -
90b7a90e by Shane Snyder at 2016-08-09T08:34:42-07:00
fix to get output ordering right in shutdown_bench

- - - - -
81c31e82 by Shane Snyder at 2016-08-09T13:24:48-05:00
fix memory leak in mpiio shutdown benchmark

- - - - -
def2fe28 by Shane Snyder at 2016-08-09T14:30:52-07:00
bug fixes in disabling instr. in modules

- - - - -
d4dc84f4 by Shane Snyder at 2016-08-17T21:30:12-05:00
bug fix in writing of name records

- - - - -
49ebb1b4 by Shane Snyder at 2016-08-17T21:30:47-05:00
make sure to write records in current version

- - - - -
173d3d49 by Phil Carns at 2016-08-20T09:11:40-04:00
tracking stdout stderr and stdin

- - - - -
76d33b22 by Phil Carns at 2016-08-20T09:33:40-04:00
Merge branch 'master' into dev-stdio-utils

- - - - -


20 changed files:

- darshan-runtime/darshan.h
- darshan-runtime/lib/darshan-common.c
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-hdf5.c
- darshan-runtime/lib/darshan-lustre.c
- darshan-runtime/lib/darshan-mpiio.c
- darshan-runtime/lib/darshan-null.c
- darshan-runtime/lib/darshan-pnetcdf.c
- darshan-runtime/lib/darshan-posix.c
- darshan-runtime/lib/darshan-stdio.c
- darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
- darshan-util/darshan-bgq-logutils.c
- darshan-util/darshan-hdf5-logutils.c
- darshan-util/darshan-logutils.c
- darshan-util/darshan-lustre-logutils.c
- darshan-util/darshan-mpiio-logutils.c
- darshan-util/darshan-null-logutils.c
- darshan-util/darshan-pnetcdf-logutils.c
- darshan-util/darshan-posix-logutils.c
- darshan-util/darshan-stdio-logutils.c


Changes:

=====================================
darshan-runtime/darshan.h
=====================================
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -144,6 +144,12 @@ void *darshan_core_register_record(
     int rec_len,
     struct darshan_fs_info *fs_info);
 
+/* TODO */
+void darshan_instrument_fs_data(
+    int fs_type,
+    const char *path,
+    int fd);
+
 /* darshan_core_wtime()
  *
  * Returns the elapsed time relative to (roughly) the start of


=====================================
darshan-runtime/lib/darshan-common.c
=====================================
--- a/darshan-runtime/lib/darshan-common.c
+++ b/darshan-runtime/lib/darshan-common.c
@@ -126,7 +126,11 @@ char* darshan_clean_file_path(const char* path)
     char* cwd = NULL;
     char* filter = NULL;
 
-    if(!path || strlen(path) < 1)
+    /* NOTE: the last check in this if statement is for path strings that
+     * begin with the '<' character.  We assume that these are special
+     * reserved paths used by Darshan, like <STDIN>.
+     */
+    if(!path || strlen(path) < 1 || path[0] == '<')
         return(NULL);
 
     if(path[0] == '/')


=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -80,6 +80,13 @@ void (*mod_static_init_fns[])(void) =
     NULL
 };
 
+#ifdef DARSHAN_LUSTRE
+/* XXX need to use extern to get Lustre module's instrumentation function
+ * since modules have no way of providing this to darshan-core
+ */
+extern void darshan_instrument_lustre_file(const char *filepath, int fd);
+#endif
+
 #define DARSHAN_CORE_LOCK() pthread_mutex_lock(&darshan_core_mutex)
 #define DARSHAN_CORE_UNLOCK() pthread_mutex_unlock(&darshan_core_mutex)
 
@@ -1764,7 +1771,7 @@ void darshan_shutdown_bench(int argc, char **argv)
     darshan_mpiio_shutdown_bench_setup(1);
 
     if(my_rank == 0)
-        printf("# 1 unique file per proc\n");
+        fprintf(stderr, "# 1 unique file per proc\n");
     DARSHAN_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
     darshan_core_shutdown();
     darshan_core = NULL;
@@ -1779,7 +1786,7 @@ void darshan_shutdown_bench(int argc, char **argv)
     darshan_mpiio_shutdown_bench_setup(2);
 
     if(my_rank == 0)
-        printf("# 1 shared file per proc\n");
+        fprintf(stderr, "# 1 shared file per proc\n");
     DARSHAN_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
     darshan_core_shutdown();
     darshan_core = NULL;
@@ -1794,7 +1801,7 @@ void darshan_shutdown_bench(int argc, char **argv)
     darshan_mpiio_shutdown_bench_setup(3);
 
     if(my_rank == 0)
-        printf("# 1024 unique files per proc\n");
+        fprintf(stderr, "# 1024 unique files per proc\n");
     DARSHAN_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
     darshan_core_shutdown();
     darshan_core = NULL;
@@ -1809,7 +1816,7 @@ void darshan_shutdown_bench(int argc, char **argv)
     darshan_mpiio_shutdown_bench_setup(4);
 
     if(my_rank == 0)
-        printf("# 1024 shared files per proc\n");
+        fprintf(stderr, "# 1024 shared files per proc\n");
     DARSHAN_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
     darshan_core_shutdown();
     darshan_core = NULL;
@@ -1986,6 +1993,19 @@ void *darshan_core_register_record(
     return(rec_buf);;
 }
 
+void darshan_instrument_fs_data(int fs_type, const char *path, int fd)
+{
+#ifdef DARSHAN_LUSTRE
+    /* allow lustre to generate a record if we configured with lustre support */
+    if(fs_type == LL_SUPER_MAGIC)
+    {
+        darshan_instrument_lustre_file(path, fd);
+        return;
+    }
+#endif
+    return;
+}
+
 double darshan_core_wtime()
 {
     DARSHAN_CORE_LOCK();


=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
--- a/darshan-runtime/lib/darshan-hdf5.c
+++ b/darshan-runtime/lib/darshan-hdf5.c
@@ -69,11 +69,12 @@ static int my_rank = -1;
 
 #define HDF5_PRE_RECORD() do { \
     HDF5_LOCK(); \
-    if(!hdf5_runtime && !instrumentation_disabled) hdf5_runtime_initialize(); \
-    if(!hdf5_runtime) { \
-        HDF5_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!hdf5_runtime) hdf5_runtime_initialize(); \
+        if(hdf5_runtime) break; \
     } \
+    HDF5_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 #define HDF5_POST_RECORD() do { \
@@ -339,6 +340,7 @@ static void hdf5_cleanup_runtime()
 
     free(hdf5_runtime);
     hdf5_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -365,6 +367,10 @@ static void hdf5_shutdown(
 
     HDF5_LOCK();
     assert(hdf5_runtime);
+
+    /* disable further instrumentation */
+    instrumentation_disabled = 1;
+
     hdf5_rec_count = hdf5_runtime->file_rec_count;
 
     /* if there are globally shared files, do a shared file reduction */
@@ -440,9 +446,6 @@ static void hdf5_shutdown(
     /* shutdown internal structures used for instrumenting */
     hdf5_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     HDF5_UNLOCK();
     return;
 }


=====================================
darshan-runtime/lib/darshan-lustre.c
=====================================
--- a/darshan-runtime/lib/darshan-lustre.c
+++ b/darshan-runtime/lib/darshan-lustre.c
@@ -61,10 +61,14 @@ void darshan_instrument_lustre_file(const char* filepath, int fd)
     int ret;
 
     LUSTRE_LOCK();
+    if(instrumentation_disabled)
+    {
+        LUSTRE_UNLOCK();
+        return;
+    }
 
-    /* try to init module if not already and if instrumentation isn't disabled */
-    if(!lustre_runtime && !instrumentation_disabled)
-        lustre_runtime_initialize();
+    /* try to init module if not already */
+    if(!lustre_runtime) lustre_runtime_initialize();
 
     /* if we aren't initialized, just back out */
     if(!lustre_runtime)
@@ -226,6 +230,10 @@ static void lustre_shutdown(
 
     LUSTRE_LOCK();
     assert(lustre_runtime);
+
+    /* disable further instrumentation while we shutdown */
+    instrumentation_disabled = 1;
+
     lustre_runtime->record_buffer = *lustre_buf;
     lustre_runtime->record_buffer_size = *lustre_buf_sz;
 
@@ -268,9 +276,7 @@ static void lustre_shutdown(
     darshan_clear_record_refs(&(lustre_runtime->record_id_hash), 1);
     free(lustre_runtime);
     lustre_runtime = NULL;
-
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
+    instrumentation_disabled = 0;
 
     LUSTRE_UNLOCK();
     return;


=====================================
darshan-runtime/lib/darshan-mpiio.c
=====================================
--- a/darshan-runtime/lib/darshan-mpiio.c
+++ b/darshan-runtime/lib/darshan-mpiio.c
@@ -97,11 +97,12 @@ static int my_rank = -1;
 
 #define MPIIO_PRE_RECORD() do { \
     MPIIO_LOCK(); \
-    if(!mpiio_runtime && !instrumentation_disabled) mpiio_runtime_initialize(); \
-    if(!mpiio_runtime) { \
-        MPIIO_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!mpiio_runtime) mpiio_runtime_initialize(); \
+        if(mpiio_runtime) break; \
     } \
+    MPIIO_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 #define MPIIO_POST_RECORD() do { \
@@ -1169,6 +1170,7 @@ static void mpiio_cleanup_runtime()
 
     free(mpiio_runtime);
     mpiio_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -1247,6 +1249,9 @@ void darshan_mpiio_shutdown_bench_setup(int test_case)
             return;
     }
 
+    free(fh_array);
+    free(size_array);
+
     return;
 }
 
@@ -1273,6 +1278,10 @@ static void mpiio_shutdown(
 
     MPIIO_LOCK();
     assert(mpiio_runtime);
+
+    /* disable further instrumentation while we shutdown */
+    instrumentation_disabled = 1;
+
     mpiio_rec_count = mpiio_runtime->file_rec_count;
 
     /* perform any final transformations on MPIIO file records before
@@ -1381,9 +1390,6 @@ static void mpiio_shutdown(
     /* shutdown internal structures used for instrumenting */
     mpiio_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     MPIIO_UNLOCK();
     return;
 }


=====================================
darshan-runtime/lib/darshan-null.c
=====================================
--- a/darshan-runtime/lib/darshan-null.c
+++ b/darshan-runtime/lib/darshan-null.c
@@ -116,11 +116,12 @@ static int my_rank = -1;
  */
 #define NULL_PRE_RECORD() do { \
     NULL_LOCK(); \
-    if(!null_runtime && !instrumentation_disabled) null_runtime_initialize(); \
-    if(!null_runtime) { \
-        NULL_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!null_runtime) null_runtime_initialize(); \
+        if(null_runtime) break; \
     } \
+    NULL_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 /* the NULL_POST_RECORD macro is executed after performing NULL
@@ -294,6 +295,7 @@ static void null_cleanup_runtime()
 
     free(null_runtime);
     null_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -315,6 +317,9 @@ static void null_shutdown(
     NULL_LOCK();
     assert(null_runtime);
 
+    /* disable further instrumentation while we shutdown */
+    instrumentation_disabled = 1;
+
     /* NOTE: this function can be used to run collective operations prior to
      * shutting down the module, as implied by the MPI communicator passed in
      * as the first agrument. Typically, module developers will want to run a
@@ -336,9 +341,6 @@ static void null_shutdown(
     /* shutdown internal structures used for instrumenting */
     null_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     NULL_UNLOCK();
     return;
 }


=====================================
darshan-runtime/lib/darshan-pnetcdf.c
=====================================
--- a/darshan-runtime/lib/darshan-pnetcdf.c
+++ b/darshan-runtime/lib/darshan-pnetcdf.c
@@ -65,11 +65,12 @@ static int my_rank = -1;
 
 #define PNETCDF_PRE_RECORD() do { \
     PNETCDF_LOCK(); \
-    if(!pnetcdf_runtime && !instrumentation_disabled) pnetcdf_runtime_initialize(); \
-    if(!pnetcdf_runtime) { \
-        PNETCDF_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!pnetcdf_runtime) pnetcdf_runtime_initialize(); \
+        if(pnetcdf_runtime) break; \
     } \
+    PNETCDF_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 #define PNETCDF_POST_RECORD() do { \
@@ -336,6 +337,7 @@ static void pnetcdf_cleanup_runtime()
 
     free(pnetcdf_runtime);
     pnetcdf_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -363,6 +365,10 @@ static void pnetcdf_shutdown(
 
     PNETCDF_LOCK();
     assert(pnetcdf_runtime);
+
+    /* disable further instrumentation while we shutdown */
+    instrumentation_disabled = 1;
+
     pnetcdf_rec_count = pnetcdf_runtime->file_rec_count;
 
     /* if there are globally shared files, do a shared file reduction */
@@ -439,9 +445,6 @@ static void pnetcdf_shutdown(
     /* shutdown internal structures used for instrumenting */
     pnetcdf_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     PNETCDF_UNLOCK();
     return;
 }


=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -37,9 +37,6 @@ typedef int64_t off64_t;
 #define aiocb64 aiocb
 #endif
 
-#ifdef DARSHAN_LUSTRE
-#include <lustre/lustre_user.h>
-#endif
 
 DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
 DARSHAN_FORWARD_DECL(open64, int, (const char *path, int flags, ...));
@@ -142,8 +139,6 @@ static void posix_runtime_initialize(
     void);
 static struct posix_file_record_ref *posix_track_new_file_record(
     darshan_record_id rec_id, const char *path);
-static void posix_instrument_fs_data(
-    int fs_type, const char *path, int fd);
 static void posix_aio_tracker_add(
     int fd, void *aiocbp);
 static struct posix_aio_tracker* posix_aio_tracker_del(
@@ -162,13 +157,6 @@ static void posix_shutdown(
     MPI_Comm mod_comm, darshan_record_id *shared_recs,
     int shared_rec_count, void **posix_buf, int *posix_buf_sz);
 
-#ifdef DARSHAN_LUSTRE
-/* XXX modules don't expose an API for other modules, so use extern to get
- * Lustre instrumentation function
- */
-extern void darshan_instrument_lustre_file(const char *filepath, int fd);
-#endif
-
 static struct posix_runtime *posix_runtime = NULL;
 static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 static int instrumentation_disabled = 0;
@@ -180,11 +168,12 @@ static int darshan_mem_alignment = 1;
 
 #define POSIX_PRE_RECORD() do { \
     POSIX_LOCK(); \
-    if(!posix_runtime && !instrumentation_disabled) posix_runtime_initialize(); \
-    if(!posix_runtime) { \
-        POSIX_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!posix_runtime) posix_runtime_initialize(); \
+        if(posix_runtime) break; \
     } \
+    POSIX_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 #define POSIX_POST_RECORD() do { \
@@ -221,7 +210,7 @@ static int darshan_mem_alignment = 1;
     DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[POSIX_F_META_TIME], \
         __tm1, __tm2, rec_ref->last_meta_end); \
     darshan_add_record_ref(&(posix_runtime->fd_hash), &__ret, sizeof(int), rec_ref); \
-    posix_instrument_fs_data(rec_ref->fs_type, newpath, __ret); \
+    darshan_instrument_fs_data(rec_ref->fs_type, newpath, __ret); \
     if(newpath != __path) free(newpath); \
 } while(0)
 
@@ -1313,26 +1302,13 @@ static struct posix_file_record_ref *posix_track_new_file_record(
     file_rec->base_rec.rank = my_rank;
     file_rec->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
     file_rec->counters[POSIX_FILE_ALIGNMENT] = fs_info.block_size;
-    rec_ref->file_rec = file_rec;
     rec_ref->fs_type = fs_info.fs_type;
+    rec_ref->file_rec = file_rec;
     posix_runtime->file_rec_count++;
 
     return(rec_ref);
 }
 
-static void posix_instrument_fs_data(int fs_type, const char *path, int fd)
-{
-#ifdef DARSHAN_LUSTRE
-    /* allow lustre to generate a record if we configured with lustre support */
-    if(fs_type == LL_SUPER_MAGIC)
-    {
-        darshan_instrument_lustre_file(path, fd);
-        return;
-    }
-#endif
-    return;
-}
-
 /* finds the tracker structure for a given aio operation, removes it from
  * the associated linked list for this file record, and returns a pointer.  
  *
@@ -1709,6 +1685,7 @@ static void posix_cleanup_runtime()
 
     free(posix_runtime);
     posix_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -1808,6 +1785,10 @@ static void posix_shutdown(
 
     POSIX_LOCK();
     assert(posix_runtime);
+
+    /* disable instrumentation while we shutdown */
+    instrumentation_disabled = 1;
+
     posix_rec_count = posix_runtime->file_rec_count;
 
     /* perform any final transformations on POSIX file records before
@@ -1917,9 +1898,6 @@ static void posix_shutdown(
     /* shutdown internal structures used for instrumenting */
     posix_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     POSIX_UNLOCK();
     return;
 }


=====================================
darshan-runtime/lib/darshan-stdio.c
=====================================
--- a/darshan-runtime/lib/darshan-stdio.c
+++ b/darshan-runtime/lib/darshan-stdio.c
@@ -94,7 +94,9 @@ DARSHAN_FORWARD_DECL(fputc, int, (int c, FILE *stream));
 DARSHAN_FORWARD_DECL(putw, int, (int w, FILE *stream));
 DARSHAN_FORWARD_DECL(fputs, int, (const char *s, FILE *stream));
 DARSHAN_FORWARD_DECL(fprintf, int, (FILE *stream, const char *format, ...));
+DARSHAN_FORWARD_DECL(printf, int, (const char *format, ...));
 DARSHAN_FORWARD_DECL(vfprintf, int, (FILE *stream, const char *format, va_list));
+DARSHAN_FORWARD_DECL(vprintf, int, (const char *format, va_list));
 DARSHAN_FORWARD_DECL(fread, size_t, (void *ptr, size_t size, size_t nmemb, FILE *stream));
 DARSHAN_FORWARD_DECL(fgetc, int, (FILE *stream));
 DARSHAN_FORWARD_DECL(getw, int, (FILE *stream));
@@ -119,6 +121,7 @@ struct stdio_file_record_ref
     double last_meta_end;
     double last_read_end;
     double last_write_end;
+    int fs_type;
 };
 
 /* The stdio_runtime structure maintains necessary state for storing
@@ -159,11 +162,12 @@ static void stdio_cleanup_runtime();
 
 #define STDIO_PRE_RECORD() do { \
     STDIO_LOCK(); \
-    if(!stdio_runtime && !instrumentation_disabled) stdio_runtime_initialize(); \
-    if(!stdio_runtime) { \
-        STDIO_UNLOCK(); \
-        return(ret); \
+    if(!instrumentation_disabled) { \
+        if(!stdio_runtime) stdio_runtime_initialize(); \
+        if(stdio_runtime) break; \
     } \
+    STDIO_UNLOCK(); \
+    return(ret); \
 } while(0)
 
 #define STDIO_POST_RECORD() do { \
@@ -174,6 +178,7 @@ static void stdio_cleanup_runtime();
     darshan_record_id rec_id; \
     struct stdio_file_record_ref* rec_ref; \
     char *newpath; \
+    int __fd; \
     if(__ret == NULL) break; \
     newpath = darshan_clean_file_path(__path); \
     if(!newpath) newpath = (char*)__path; \
@@ -196,6 +201,8 @@ static void stdio_cleanup_runtime();
     rec_ref->file_rec->fcounters[STDIO_F_OPEN_END_TIMESTAMP] = __tm2; \
     DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[STDIO_F_META_TIME], __tm1, __tm2, rec_ref->last_meta_end); \
     darshan_add_record_ref(&(stdio_runtime->stream_hash), &(__ret), sizeof(__ret), rec_ref); \
+    __fd = fileno(__ret); \
+    darshan_instrument_fs_data(rec_ref->fs_type, newpath, __fd); \
     if(newpath != (char*)__path) free(newpath); \
 } while(0)
 
@@ -458,6 +465,25 @@ int DARSHAN_DECL(fputs)(const char *s, FILE *stream)
     return(ret);
 }
 
+int DARSHAN_DECL(vprintf)(const char *format, va_list ap)
+{
+    int ret;
+    double tm1, tm2;
+
+    MAP_OR_FAIL(vprintf);
+
+    tm1 = darshan_core_wtime();
+    ret = __real_vprintf(format, ap);
+    tm2 = darshan_core_wtime();
+
+    STDIO_PRE_RECORD();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
+    STDIO_POST_RECORD();
+
+    return(ret);
+}
+
 int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
 {
     int ret;
@@ -467,14 +493,38 @@ int DARSHAN_DECL(vfprintf)(FILE *stream, const char *format, va_list ap)
     MAP_OR_FAIL(vfprintf);
 
     tm1 = darshan_core_wtime();
-    start_off = ftell(stream);
     ret = __real_vfprintf(stream, format, ap);
-    end_off = ftell(stream);
     tm2 = darshan_core_wtime();
 
     STDIO_PRE_RECORD();
     if(ret > 0)
-        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+        STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
+    STDIO_POST_RECORD();
+
+    return(ret);
+}
+
+
+int DARSHAN_DECL(printf)(const char *format, ...)
+{
+    int ret;
+    double tm1, tm2;
+    va_list ap;
+
+    MAP_OR_FAIL(vprintf);
+
+    tm1 = darshan_core_wtime();
+    /* NOTE: we intentionally switch to vprintf here to handle the variable
+     * length arguments.
+     */
+    va_start(ap, format);
+    ret = __real_vprintf(format, ap);
+    va_end(ap);
+    tm2 = darshan_core_wtime();
+
+    STDIO_PRE_RECORD();
+    if(ret > 0)
+        STDIO_RECORD_WRITE(stdout, ret, tm1, tm2, 0);
     STDIO_POST_RECORD();
 
     return(ret);
@@ -486,7 +536,6 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
     int ret;
     double tm1, tm2;
     va_list ap;
-    long start_off, end_off;
 
     MAP_OR_FAIL(vfprintf);
 
@@ -494,16 +543,14 @@ int DARSHAN_DECL(fprintf)(FILE *stream, const char *format, ...)
     /* NOTE: we intentionally switch to vfprintf here to handle the variable
      * length arguments.
      */
-    start_off = ftell(stream);
     va_start(ap, format);
     ret = __real_vfprintf(stream, format, ap);
     va_end(ap);
-    end_off = ftell(stream);
     tm2 = darshan_core_wtime();
 
     STDIO_PRE_RECORD();
     if(ret > 0)
-        STDIO_RECORD_WRITE(stream, (end_off-start_off), tm1, tm2, 0);
+        STDIO_RECORD_WRITE(stream, ret, tm1, tm2, 0);
     STDIO_POST_RECORD();
 
     return(ret);
@@ -724,7 +771,11 @@ void DARSHAN_DECL(rewind)(FILE *stream)
      * value in this wrapper.
      */
     STDIO_LOCK();
-    if(!stdio_runtime && !instrumentation_disabled) stdio_runtime_initialize();
+    if(instrumentation_disabled) {
+        STDIO_UNLOCK();
+        return;
+    }
+    if(!stdio_runtime) stdio_runtime_initialize();
     if(!stdio_runtime) {
         STDIO_UNLOCK();
         return;
@@ -908,10 +959,6 @@ static void stdio_runtime_initialize()
     /* try to store default number of records for this module */
     stdio_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_stdio_file);
 
-    /* don't do anything if already initialized or instrumenation is disabled */
-    if(stdio_runtime || instrumentation_disabled)
-        return;
-
     /* register the stdio module with darshan core */
     darshan_core_register_module(
         DARSHAN_STDIO_MOD,
@@ -934,6 +981,11 @@ static void stdio_runtime_initialize()
         return;
     }
     memset(stdio_runtime, 0, sizeof(*stdio_runtime));
+
+    /* instantiate records for stdin, stdout, and stderr */
+    STDIO_RECORD_OPEN(stdin, "<STDIN>", 0, 0);
+    STDIO_RECORD_OPEN(stdout, "<STDOUT>", 0, 0);
+    STDIO_RECORD_OPEN(stderr, "<STDERR>", 0, 0);
 }
 
 /************************************************************************
@@ -1066,6 +1118,10 @@ static void stdio_shutdown(
 
     STDIO_LOCK();
     assert(stdio_runtime);
+
+    /* disable further instrumentation */
+    instrumentation_disabled = 1;
+
     stdio_rec_count = stdio_runtime->file_rec_count;
 
     /* if there are globally shared files, do a shared file reduction */
@@ -1169,9 +1225,6 @@ static void stdio_shutdown(
     /* shutdown internal structures used for instrumenting */
     stdio_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     STDIO_UNLOCK();
     
     return;
@@ -1182,6 +1235,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
 {
     struct darshan_stdio_file *file_rec = NULL;
     struct stdio_file_record_ref *rec_ref = NULL;
+    struct darshan_fs_info fs_info;
     int ret;
 
     rec_ref = malloc(sizeof(*rec_ref));
@@ -1206,7 +1260,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
         path,
         DARSHAN_STDIO_MOD,
         sizeof(struct darshan_stdio_file),
-        NULL);
+        &fs_info);
 
     if(!file_rec)
     {
@@ -1219,6 +1273,7 @@ static struct stdio_file_record_ref *stdio_track_new_file_record(
     /* registering this file record was successful, so initialize some fields */
     file_rec->base_rec.id = rec_id;
     file_rec->base_rec.rank = my_rank;
+    rec_ref->fs_type = fs_info.fs_type;
     rec_ref->file_rec = file_rec;
     stdio_runtime->file_rec_count++;
 
@@ -1233,6 +1288,7 @@ static void stdio_cleanup_runtime()
 
     free(stdio_runtime);
     stdio_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }


=====================================
darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
=====================================
--- a/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
+++ b/darshan-runtime/share/ld-opts/darshan-stdio-ld-opts
@@ -20,6 +20,7 @@
 --wrap=fseeko64
 --wrap=fprintf
 --wrap=vfprintf
+--wrap=vprintf
 --wrap=fputc
 --wrap=fputs
 --wrap=putw
@@ -27,3 +28,4 @@
 --wrap=fsetpos64
 --wrap=rewind
 --wrap=__isoc99_fscanf
+--wrap=printf


=====================================
darshan-util/darshan-bgq-logutils.c
=====================================
--- a/darshan-util/darshan-bgq-logutils.c
+++ b/darshan-util/darshan-bgq-logutils.c
@@ -120,7 +120,7 @@ static int darshan_log_put_bgq_rec(darshan_fd fd, void* bgq_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_BGQ_MOD, rec,
-        sizeof(struct darshan_bgq_record), ver);
+        sizeof(struct darshan_bgq_record), DARSHAN_BGQ_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-hdf5-logutils.c
=====================================
--- a/darshan-util/darshan-hdf5-logutils.c
+++ b/darshan-util/darshan-hdf5-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_hdf5_file(darshan_fd fd, void* hdf5_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_HDF5_MOD, file,
-        sizeof(struct darshan_hdf5_file), ver);
+        sizeof(struct darshan_hdf5_file), DARSHAN_HDF5_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-logutils.c
=====================================
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -593,15 +593,15 @@ int darshan_log_put_namehash(darshan_fd fd, struct darshan_name_record_ref *hash
     assert(state);
 
     /* allocate memory for largest possible hash record */
-    name_rec = malloc(sizeof(struct darshan_name_record) + PATH_MAX);
+    name_rec = malloc(sizeof(darshan_record_id) + PATH_MAX + 1);
     if(!name_rec)
         return(-1);
-    memset(name_rec, 0, sizeof(struct darshan_name_record) + PATH_MAX);
+    memset(name_rec, 0, sizeof(darshan_record_id) + PATH_MAX + 1);
 
     /* individually serialize each hash record and write to log file */
     HASH_ITER(hlink, hash, ref, tmp)
     {
-        name_rec_len = sizeof(struct darshan_name_record) + strlen(ref->name_record->name);
+        name_rec_len = sizeof(darshan_record_id) + strlen(ref->name_record->name) + 1;
         memcpy(name_rec, ref->name_record, name_rec_len);
 
         /* write this hash entry to log file */


=====================================
darshan-util/darshan-lustre-logutils.c
=====================================
--- a/darshan-util/darshan-lustre-logutils.c
+++ b/darshan-util/darshan-lustre-logutils.c
@@ -94,7 +94,7 @@ static int darshan_log_put_lustre_record(darshan_fd fd, void* lustre_buf, int ve
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_LUSTRE_MOD, rec,
-        LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), ver);
+        LUSTRE_RECORD_SIZE(rec->counters[LUSTRE_STRIPE_WIDTH]), DARSHAN_LUSTRE_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-mpiio-logutils.c
=====================================
--- a/darshan-util/darshan-mpiio-logutils.c
+++ b/darshan-util/darshan-mpiio-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_mpiio_file(darshan_fd fd, void* mpiio_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_MPIIO_MOD, file,
-        sizeof(struct darshan_mpiio_file), ver);
+        sizeof(struct darshan_mpiio_file), DARSHAN_MPIIO_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-null-logutils.c
=====================================
--- a/darshan-util/darshan-null-logutils.c
+++ b/darshan-util/darshan-null-logutils.c
@@ -102,7 +102,7 @@ static int darshan_log_put_null_record(darshan_fd fd, void* null_buf, int ver)
 
     /* append NULL record to darshan log file */
     ret = darshan_log_put_mod(fd, DARSHAN_NULL_MOD, rec,
-        sizeof(struct darshan_null_record), ver);
+        sizeof(struct darshan_null_record), DARSHAN_NULL_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-pnetcdf-logutils.c
=====================================
--- a/darshan-util/darshan-pnetcdf-logutils.c
+++ b/darshan-util/darshan-pnetcdf-logutils.c
@@ -85,7 +85,7 @@ static int darshan_log_put_pnetcdf_file(darshan_fd fd, void* pnetcdf_buf, int ve
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_PNETCDF_MOD, file,
-        sizeof(struct darshan_pnetcdf_file), ver);
+        sizeof(struct darshan_pnetcdf_file), DARSHAN_PNETCDF_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-posix-logutils.c
=====================================
--- a/darshan-util/darshan-posix-logutils.c
+++ b/darshan-util/darshan-posix-logutils.c
@@ -120,7 +120,7 @@ static int darshan_log_put_posix_file(darshan_fd fd, void* posix_buf, int ver)
     int ret;
 
     ret = darshan_log_put_mod(fd, DARSHAN_POSIX_MOD, file,
-        sizeof(struct darshan_posix_file), ver);
+        sizeof(struct darshan_posix_file), DARSHAN_POSIX_VER);
     if(ret < 0)
         return(-1);
 


=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
--- a/darshan-util/darshan-stdio-logutils.c
+++ b/darshan-util/darshan-stdio-logutils.c
@@ -99,7 +99,7 @@ static int darshan_log_put_stdio_record(darshan_fd fd, void* stdio_buf, int ver)
 
     /* append STDIO record to darshan log file */
     ret = darshan_log_put_mod(fd, DARSHAN_STDIO_MOD, rec,
-        sizeof(struct darshan_stdio_file), ver);
+        sizeof(struct darshan_stdio_file), DARSHAN_STDIO_VER);
     if(ret < 0)
         return(-1);
 



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/4ba7a24d00dfb8e805e7018b9c577522777f10d5...76d33b226bd7cf9f748dbf2e8607c25523097e72
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160820/2a4f3439/attachment-0001.html>


More information about the Darshan-commits mailing list