[Darshan-commits] [Git][darshan/darshan][master] bug fixes in disabling instr. in modules

Shane Snyder xgitlab at cels.anl.gov
Tue Aug 9 17:07:58 CDT 2016


Shane Snyder pushed to branch master at darshan / darshan


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

- - - - -


7 changed files:

- 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


Changes:

=====================================
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;
 }
@@ -1276,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
@@ -1384,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
@@ -168,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 { \
@@ -1684,6 +1685,7 @@ static void posix_cleanup_runtime()
 
     free(posix_runtime);
     posix_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }
@@ -1783,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
@@ -1892,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
@@ -160,11 +160,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 { \
@@ -728,7 +729,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;
@@ -912,10 +917,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,
@@ -1070,6 +1071,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 */
@@ -1173,9 +1178,6 @@ static void stdio_shutdown(
     /* shutdown internal structures used for instrumenting */
     stdio_cleanup_runtime();
 
-    /* disable further instrumentation */
-    instrumentation_disabled = 1;
-
     STDIO_UNLOCK();
     
     return;
@@ -1239,6 +1241,7 @@ static void stdio_cleanup_runtime()
 
     free(stdio_runtime);
     stdio_runtime = NULL;
+    instrumentation_disabled = 0;
 
     return;
 }



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/def2fe28c7684ac6662866baac07737df019c54f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160809/2d1d43e6/attachment-0001.html>


More information about the Darshan-commits mailing list