Commit def2fe28 authored by Shane Snyder's avatar Shane Snyder

bug fixes in disabling instr. in modules

parent 81c31e82
...@@ -69,11 +69,12 @@ static int my_rank = -1; ...@@ -69,11 +69,12 @@ static int my_rank = -1;
#define HDF5_PRE_RECORD() do { \ #define HDF5_PRE_RECORD() do { \
HDF5_LOCK(); \ HDF5_LOCK(); \
if(!hdf5_runtime && !instrumentation_disabled) hdf5_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!hdf5_runtime) { \ if(!hdf5_runtime) hdf5_runtime_initialize(); \
HDF5_UNLOCK(); \ if(hdf5_runtime) break; \
return(ret); \
} \ } \
HDF5_UNLOCK(); \
return(ret); \
} while(0) } while(0)
#define HDF5_POST_RECORD() do { \ #define HDF5_POST_RECORD() do { \
...@@ -339,6 +340,7 @@ static void hdf5_cleanup_runtime() ...@@ -339,6 +340,7 @@ static void hdf5_cleanup_runtime()
free(hdf5_runtime); free(hdf5_runtime);
hdf5_runtime = NULL; hdf5_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -365,6 +367,10 @@ static void hdf5_shutdown( ...@@ -365,6 +367,10 @@ static void hdf5_shutdown(
HDF5_LOCK(); HDF5_LOCK();
assert(hdf5_runtime); assert(hdf5_runtime);
/* disable further instrumentation */
instrumentation_disabled = 1;
hdf5_rec_count = hdf5_runtime->file_rec_count; hdf5_rec_count = hdf5_runtime->file_rec_count;
/* if there are globally shared files, do a shared file reduction */ /* if there are globally shared files, do a shared file reduction */
...@@ -440,9 +446,6 @@ static void hdf5_shutdown( ...@@ -440,9 +446,6 @@ static void hdf5_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
hdf5_cleanup_runtime(); hdf5_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
HDF5_UNLOCK(); HDF5_UNLOCK();
return; return;
} }
......
...@@ -61,10 +61,14 @@ void darshan_instrument_lustre_file(const char* filepath, int fd) ...@@ -61,10 +61,14 @@ void darshan_instrument_lustre_file(const char* filepath, int fd)
int ret; int ret;
LUSTRE_LOCK(); LUSTRE_LOCK();
if(instrumentation_disabled)
{
LUSTRE_UNLOCK();
return;
}
/* try to init module if not already and if instrumentation isn't disabled */ /* try to init module if not already */
if(!lustre_runtime && !instrumentation_disabled) if(!lustre_runtime) lustre_runtime_initialize();
lustre_runtime_initialize();
/* if we aren't initialized, just back out */ /* if we aren't initialized, just back out */
if(!lustre_runtime) if(!lustre_runtime)
...@@ -226,6 +230,10 @@ static void lustre_shutdown( ...@@ -226,6 +230,10 @@ static void lustre_shutdown(
LUSTRE_LOCK(); LUSTRE_LOCK();
assert(lustre_runtime); assert(lustre_runtime);
/* disable further instrumentation while we shutdown */
instrumentation_disabled = 1;
lustre_runtime->record_buffer = *lustre_buf; lustre_runtime->record_buffer = *lustre_buf;
lustre_runtime->record_buffer_size = *lustre_buf_sz; lustre_runtime->record_buffer_size = *lustre_buf_sz;
...@@ -268,9 +276,7 @@ static void lustre_shutdown( ...@@ -268,9 +276,7 @@ static void lustre_shutdown(
darshan_clear_record_refs(&(lustre_runtime->record_id_hash), 1); darshan_clear_record_refs(&(lustre_runtime->record_id_hash), 1);
free(lustre_runtime); free(lustre_runtime);
lustre_runtime = NULL; lustre_runtime = NULL;
instrumentation_disabled = 0;
/* disable further instrumentation */
instrumentation_disabled = 1;
LUSTRE_UNLOCK(); LUSTRE_UNLOCK();
return; return;
......
...@@ -97,11 +97,12 @@ static int my_rank = -1; ...@@ -97,11 +97,12 @@ static int my_rank = -1;
#define MPIIO_PRE_RECORD() do { \ #define MPIIO_PRE_RECORD() do { \
MPIIO_LOCK(); \ MPIIO_LOCK(); \
if(!mpiio_runtime && !instrumentation_disabled) mpiio_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!mpiio_runtime) { \ if(!mpiio_runtime) mpiio_runtime_initialize(); \
MPIIO_UNLOCK(); \ if(mpiio_runtime) break; \
return(ret); \
} \ } \
MPIIO_UNLOCK(); \
return(ret); \
} while(0) } while(0)
#define MPIIO_POST_RECORD() do { \ #define MPIIO_POST_RECORD() do { \
...@@ -1169,6 +1170,7 @@ static void mpiio_cleanup_runtime() ...@@ -1169,6 +1170,7 @@ static void mpiio_cleanup_runtime()
free(mpiio_runtime); free(mpiio_runtime);
mpiio_runtime = NULL; mpiio_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -1276,6 +1278,10 @@ static void mpiio_shutdown( ...@@ -1276,6 +1278,10 @@ static void mpiio_shutdown(
MPIIO_LOCK(); MPIIO_LOCK();
assert(mpiio_runtime); assert(mpiio_runtime);
/* disable further instrumentation while we shutdown */
instrumentation_disabled = 1;
mpiio_rec_count = mpiio_runtime->file_rec_count; mpiio_rec_count = mpiio_runtime->file_rec_count;
/* perform any final transformations on MPIIO file records before /* perform any final transformations on MPIIO file records before
...@@ -1384,9 +1390,6 @@ static void mpiio_shutdown( ...@@ -1384,9 +1390,6 @@ static void mpiio_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
mpiio_cleanup_runtime(); mpiio_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
MPIIO_UNLOCK(); MPIIO_UNLOCK();
return; return;
} }
......
...@@ -116,11 +116,12 @@ static int my_rank = -1; ...@@ -116,11 +116,12 @@ static int my_rank = -1;
*/ */
#define NULL_PRE_RECORD() do { \ #define NULL_PRE_RECORD() do { \
NULL_LOCK(); \ NULL_LOCK(); \
if(!null_runtime && !instrumentation_disabled) null_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!null_runtime) { \ if(!null_runtime) null_runtime_initialize(); \
NULL_UNLOCK(); \ if(null_runtime) break; \
return(ret); \
} \ } \
NULL_UNLOCK(); \
return(ret); \
} while(0) } while(0)
/* the NULL_POST_RECORD macro is executed after performing NULL /* the NULL_POST_RECORD macro is executed after performing NULL
...@@ -294,6 +295,7 @@ static void null_cleanup_runtime() ...@@ -294,6 +295,7 @@ static void null_cleanup_runtime()
free(null_runtime); free(null_runtime);
null_runtime = NULL; null_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -315,6 +317,9 @@ static void null_shutdown( ...@@ -315,6 +317,9 @@ static void null_shutdown(
NULL_LOCK(); NULL_LOCK();
assert(null_runtime); assert(null_runtime);
/* disable further instrumentation while we shutdown */
instrumentation_disabled = 1;
/* NOTE: this function can be used to run collective operations prior to /* NOTE: this function can be used to run collective operations prior to
* shutting down the module, as implied by the MPI communicator passed in * shutting down the module, as implied by the MPI communicator passed in
* as the first agrument. Typically, module developers will want to run a * as the first agrument. Typically, module developers will want to run a
...@@ -336,9 +341,6 @@ static void null_shutdown( ...@@ -336,9 +341,6 @@ static void null_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
null_cleanup_runtime(); null_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
NULL_UNLOCK(); NULL_UNLOCK();
return; return;
} }
......
...@@ -65,11 +65,12 @@ static int my_rank = -1; ...@@ -65,11 +65,12 @@ static int my_rank = -1;
#define PNETCDF_PRE_RECORD() do { \ #define PNETCDF_PRE_RECORD() do { \
PNETCDF_LOCK(); \ PNETCDF_LOCK(); \
if(!pnetcdf_runtime && !instrumentation_disabled) pnetcdf_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!pnetcdf_runtime) { \ if(!pnetcdf_runtime) pnetcdf_runtime_initialize(); \
PNETCDF_UNLOCK(); \ if(pnetcdf_runtime) break; \
return(ret); \
} \ } \
PNETCDF_UNLOCK(); \
return(ret); \
} while(0) } while(0)
#define PNETCDF_POST_RECORD() do { \ #define PNETCDF_POST_RECORD() do { \
...@@ -336,6 +337,7 @@ static void pnetcdf_cleanup_runtime() ...@@ -336,6 +337,7 @@ static void pnetcdf_cleanup_runtime()
free(pnetcdf_runtime); free(pnetcdf_runtime);
pnetcdf_runtime = NULL; pnetcdf_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -363,6 +365,10 @@ static void pnetcdf_shutdown( ...@@ -363,6 +365,10 @@ static void pnetcdf_shutdown(
PNETCDF_LOCK(); PNETCDF_LOCK();
assert(pnetcdf_runtime); assert(pnetcdf_runtime);
/* disable further instrumentation while we shutdown */
instrumentation_disabled = 1;
pnetcdf_rec_count = pnetcdf_runtime->file_rec_count; pnetcdf_rec_count = pnetcdf_runtime->file_rec_count;
/* if there are globally shared files, do a shared file reduction */ /* if there are globally shared files, do a shared file reduction */
...@@ -439,9 +445,6 @@ static void pnetcdf_shutdown( ...@@ -439,9 +445,6 @@ static void pnetcdf_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
pnetcdf_cleanup_runtime(); pnetcdf_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
PNETCDF_UNLOCK(); PNETCDF_UNLOCK();
return; return;
} }
......
...@@ -168,11 +168,12 @@ static int darshan_mem_alignment = 1; ...@@ -168,11 +168,12 @@ static int darshan_mem_alignment = 1;
#define POSIX_PRE_RECORD() do { \ #define POSIX_PRE_RECORD() do { \
POSIX_LOCK(); \ POSIX_LOCK(); \
if(!posix_runtime && !instrumentation_disabled) posix_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!posix_runtime) { \ if(!posix_runtime) posix_runtime_initialize(); \
POSIX_UNLOCK(); \ if(posix_runtime) break; \
return(ret); \
} \ } \
POSIX_UNLOCK(); \
return(ret); \
} while(0) } while(0)
#define POSIX_POST_RECORD() do { \ #define POSIX_POST_RECORD() do { \
...@@ -1684,6 +1685,7 @@ static void posix_cleanup_runtime() ...@@ -1684,6 +1685,7 @@ static void posix_cleanup_runtime()
free(posix_runtime); free(posix_runtime);
posix_runtime = NULL; posix_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -1783,6 +1785,10 @@ static void posix_shutdown( ...@@ -1783,6 +1785,10 @@ static void posix_shutdown(
POSIX_LOCK(); POSIX_LOCK();
assert(posix_runtime); assert(posix_runtime);
/* disable instrumentation while we shutdown */
instrumentation_disabled = 1;
posix_rec_count = posix_runtime->file_rec_count; posix_rec_count = posix_runtime->file_rec_count;
/* perform any final transformations on POSIX file records before /* perform any final transformations on POSIX file records before
...@@ -1892,9 +1898,6 @@ static void posix_shutdown( ...@@ -1892,9 +1898,6 @@ static void posix_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
posix_cleanup_runtime(); posix_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
POSIX_UNLOCK(); POSIX_UNLOCK();
return; return;
} }
......
...@@ -160,11 +160,12 @@ static void stdio_cleanup_runtime(); ...@@ -160,11 +160,12 @@ static void stdio_cleanup_runtime();
#define STDIO_PRE_RECORD() do { \ #define STDIO_PRE_RECORD() do { \
STDIO_LOCK(); \ STDIO_LOCK(); \
if(!stdio_runtime && !instrumentation_disabled) stdio_runtime_initialize(); \ if(!instrumentation_disabled) { \
if(!stdio_runtime) { \ if(!stdio_runtime) stdio_runtime_initialize(); \
STDIO_UNLOCK(); \ if(stdio_runtime) break; \
return(ret); \
} \ } \
STDIO_UNLOCK(); \
return(ret); \
} while(0) } while(0)
#define STDIO_POST_RECORD() do { \ #define STDIO_POST_RECORD() do { \
...@@ -728,7 +729,11 @@ void DARSHAN_DECL(rewind)(FILE *stream) ...@@ -728,7 +729,11 @@ void DARSHAN_DECL(rewind)(FILE *stream)
* value in this wrapper. * value in this wrapper.
*/ */
STDIO_LOCK(); 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) { if(!stdio_runtime) {
STDIO_UNLOCK(); STDIO_UNLOCK();
return; return;
...@@ -912,10 +917,6 @@ static void stdio_runtime_initialize() ...@@ -912,10 +917,6 @@ static void stdio_runtime_initialize()
/* try to store default number of records for this module */ /* try to store default number of records for this module */
stdio_buf_size = DARSHAN_DEF_MOD_REC_COUNT * sizeof(struct darshan_stdio_file); 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 */ /* register the stdio module with darshan core */
darshan_core_register_module( darshan_core_register_module(
DARSHAN_STDIO_MOD, DARSHAN_STDIO_MOD,
...@@ -1070,6 +1071,10 @@ static void stdio_shutdown( ...@@ -1070,6 +1071,10 @@ static void stdio_shutdown(
STDIO_LOCK(); STDIO_LOCK();
assert(stdio_runtime); assert(stdio_runtime);
/* disable further instrumentation */
instrumentation_disabled = 1;
stdio_rec_count = stdio_runtime->file_rec_count; stdio_rec_count = stdio_runtime->file_rec_count;
/* if there are globally shared files, do a shared file reduction */ /* if there are globally shared files, do a shared file reduction */
...@@ -1173,9 +1178,6 @@ static void stdio_shutdown( ...@@ -1173,9 +1178,6 @@ static void stdio_shutdown(
/* shutdown internal structures used for instrumenting */ /* shutdown internal structures used for instrumenting */
stdio_cleanup_runtime(); stdio_cleanup_runtime();
/* disable further instrumentation */
instrumentation_disabled = 1;
STDIO_UNLOCK(); STDIO_UNLOCK();
return; return;
...@@ -1239,6 +1241,7 @@ static void stdio_cleanup_runtime() ...@@ -1239,6 +1241,7 @@ static void stdio_cleanup_runtime()
free(stdio_runtime); free(stdio_runtime);
stdio_runtime = NULL; stdio_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment