Commit 6d9894c4 authored by Shane Snyder's avatar Shane Snyder
Browse files

Merge branch 'issue-229-negative-stdio-timers' into 'master'

Fix for Issue 229 negative stdio timers

See merge request !15
parents bd252d0e 37b50d6a
...@@ -173,4 +173,13 @@ double darshan_core_wtime(void); ...@@ -173,4 +173,13 @@ double darshan_core_wtime(void);
int darshan_core_excluded_path( int darshan_core_excluded_path(
const char * path); const char * path);
/* darshan_core_disabled_instrumentation
*
* Returns true (1) if Darshan has currently disabled instrumentation,
* false (0) otherwise. If instrumentation is disabled, modules should
* no longer update any file records as part of the intercepted function
* wrappers.
*/
int darshan_core_disabled_instrumentation(void);
#endif /* __DARSHAN_H */ #endif /* __DARSHAN_H */
...@@ -2166,6 +2166,20 @@ int darshan_core_excluded_path(const char *path) ...@@ -2166,6 +2166,20 @@ int darshan_core_excluded_path(const char *path)
return(0); return(0);
} }
int darshan_core_disabled_instrumentation()
{
int ret;
DARSHAN_CORE_LOCK();
if(darshan_core)
ret = 0;
else
ret = 1;
DARSHAN_CORE_UNLOCK();
return(ret);
}
/* /*
* Local variables: * Local variables:
* c-indent-level: 4 * c-indent-level: 4
......
...@@ -67,7 +67,6 @@ static void hdf5_shutdown( ...@@ -67,7 +67,6 @@ static void hdf5_shutdown(
static struct hdf5_runtime *hdf5_runtime = NULL; static struct hdf5_runtime *hdf5_runtime = NULL;
static pthread_mutex_t hdf5_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t hdf5_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int my_rank = -1; static int my_rank = -1;
#define HDF5_LOCK() pthread_mutex_lock(&hdf5_runtime_mutex) #define HDF5_LOCK() pthread_mutex_lock(&hdf5_runtime_mutex)
...@@ -75,7 +74,7 @@ static int my_rank = -1; ...@@ -75,7 +74,7 @@ static int my_rank = -1;
#define HDF5_PRE_RECORD() do { \ #define HDF5_PRE_RECORD() do { \
HDF5_LOCK(); \ HDF5_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!hdf5_runtime) hdf5_runtime_initialize(); \ if(!hdf5_runtime) hdf5_runtime_initialize(); \
if(hdf5_runtime) break; \ if(hdf5_runtime) break; \
} \ } \
...@@ -382,7 +381,6 @@ static void hdf5_cleanup_runtime() ...@@ -382,7 +381,6 @@ static void hdf5_cleanup_runtime()
free(hdf5_runtime); free(hdf5_runtime);
hdf5_runtime = NULL; hdf5_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -410,9 +408,6 @@ static void hdf5_shutdown( ...@@ -410,9 +408,6 @@ 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 */
......
...@@ -41,7 +41,6 @@ static void lustre_shutdown( ...@@ -41,7 +41,6 @@ static void lustre_shutdown(
struct lustre_runtime *lustre_runtime = NULL; struct lustre_runtime *lustre_runtime = NULL;
static pthread_mutex_t lustre_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t lustre_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int my_rank = -1; static int my_rank = -1;
#define LUSTRE_LOCK() pthread_mutex_lock(&lustre_runtime_mutex) #define LUSTRE_LOCK() pthread_mutex_lock(&lustre_runtime_mutex)
...@@ -64,11 +63,6 @@ void darshan_instrument_lustre_file(const char* filepath, int fd) ...@@ -64,11 +63,6 @@ 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 */ /* try to init module if not already */
if(!lustre_runtime) lustre_runtime_initialize(); if(!lustre_runtime) lustre_runtime_initialize();
...@@ -234,9 +228,6 @@ static void lustre_shutdown( ...@@ -234,9 +228,6 @@ 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;
...@@ -279,7 +270,6 @@ static void lustre_shutdown( ...@@ -279,7 +270,6 @@ 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;
LUSTRE_UNLOCK(); LUSTRE_UNLOCK();
return; return;
......
...@@ -95,7 +95,6 @@ extern void dxt_mpiio_read(darshan_record_id rec_id, int64_t length, ...@@ -95,7 +95,6 @@ extern void dxt_mpiio_read(darshan_record_id rec_id, int64_t length,
static struct mpiio_runtime *mpiio_runtime = NULL; static struct mpiio_runtime *mpiio_runtime = NULL;
static pthread_mutex_t mpiio_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t mpiio_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int my_rank = -1; static int my_rank = -1;
static int enable_dxt_io_trace = 0; static int enable_dxt_io_trace = 0;
...@@ -104,7 +103,7 @@ static int enable_dxt_io_trace = 0; ...@@ -104,7 +103,7 @@ static int enable_dxt_io_trace = 0;
#define MPIIO_PRE_RECORD() do { \ #define MPIIO_PRE_RECORD() do { \
MPIIO_LOCK(); \ MPIIO_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!mpiio_runtime) { \ if(!mpiio_runtime) { \
mpiio_runtime_initialize(); \ mpiio_runtime_initialize(); \
} \ } \
...@@ -1192,7 +1191,6 @@ static void mpiio_cleanup_runtime() ...@@ -1192,7 +1191,6 @@ static void mpiio_cleanup_runtime()
free(mpiio_runtime); free(mpiio_runtime);
mpiio_runtime = NULL; mpiio_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -1301,9 +1299,6 @@ static void mpiio_shutdown( ...@@ -1301,9 +1299,6 @@ 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
......
...@@ -100,8 +100,6 @@ static struct null_runtime *null_runtime = NULL; ...@@ -100,8 +100,6 @@ static struct null_runtime *null_runtime = NULL;
* may not be necessary for all instrumentation modules. * may not be necessary for all instrumentation modules.
*/ */
static pthread_mutex_t null_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t null_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
/* the instrumentation_disabled flag is used to toggle wrapper functions on/off */
static int instrumentation_disabled = 0;
/* my_rank indicates the MPI rank of this process */ /* my_rank indicates the MPI rank of this process */
static int my_rank = -1; static int my_rank = -1;
...@@ -116,7 +114,7 @@ static int my_rank = -1; ...@@ -116,7 +114,7 @@ static int my_rank = -1;
*/ */
#define NULL_PRE_RECORD() do { \ #define NULL_PRE_RECORD() do { \
NULL_LOCK(); \ NULL_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!null_runtime) null_runtime_initialize(); \ if(!null_runtime) null_runtime_initialize(); \
if(null_runtime) break; \ if(null_runtime) break; \
} \ } \
...@@ -295,7 +293,6 @@ static void null_cleanup_runtime() ...@@ -295,7 +293,6 @@ static void null_cleanup_runtime()
free(null_runtime); free(null_runtime);
null_runtime = NULL; null_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -317,9 +314,6 @@ static void null_shutdown( ...@@ -317,9 +314,6 @@ 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
......
...@@ -57,7 +57,6 @@ static void pnetcdf_shutdown( ...@@ -57,7 +57,6 @@ static void pnetcdf_shutdown(
static struct pnetcdf_runtime *pnetcdf_runtime = NULL; static struct pnetcdf_runtime *pnetcdf_runtime = NULL;
static pthread_mutex_t pnetcdf_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t pnetcdf_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int my_rank = -1; static int my_rank = -1;
#define PNETCDF_LOCK() pthread_mutex_lock(&pnetcdf_runtime_mutex) #define PNETCDF_LOCK() pthread_mutex_lock(&pnetcdf_runtime_mutex)
...@@ -65,7 +64,7 @@ static int my_rank = -1; ...@@ -65,7 +64,7 @@ static int my_rank = -1;
#define PNETCDF_PRE_RECORD() do { \ #define PNETCDF_PRE_RECORD() do { \
PNETCDF_LOCK(); \ PNETCDF_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!pnetcdf_runtime) pnetcdf_runtime_initialize(); \ if(!pnetcdf_runtime) pnetcdf_runtime_initialize(); \
if(pnetcdf_runtime) break; \ if(pnetcdf_runtime) break; \
} \ } \
...@@ -337,7 +336,6 @@ static void pnetcdf_cleanup_runtime() ...@@ -337,7 +336,6 @@ static void pnetcdf_cleanup_runtime()
free(pnetcdf_runtime); free(pnetcdf_runtime);
pnetcdf_runtime = NULL; pnetcdf_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -366,9 +364,6 @@ static void pnetcdf_shutdown( ...@@ -366,9 +364,6 @@ 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 */
......
...@@ -167,7 +167,6 @@ extern void dxt_posix_read(darshan_record_id rec_id, int64_t offset, ...@@ -167,7 +167,6 @@ extern void dxt_posix_read(darshan_record_id rec_id, int64_t offset,
static struct posix_runtime *posix_runtime = NULL; static struct posix_runtime *posix_runtime = NULL;
static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t posix_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int my_rank = -1; static int my_rank = -1;
static int darshan_mem_alignment = 1; static int darshan_mem_alignment = 1;
static int enable_dxt_io_trace = 0; static int enable_dxt_io_trace = 0;
...@@ -177,7 +176,7 @@ static int enable_dxt_io_trace = 0; ...@@ -177,7 +176,7 @@ static int enable_dxt_io_trace = 0;
#define POSIX_PRE_RECORD() do { \ #define POSIX_PRE_RECORD() do { \
POSIX_LOCK(); \ POSIX_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!posix_runtime) { \ if(!posix_runtime) { \
posix_runtime_initialize(); \ posix_runtime_initialize(); \
} \ } \
...@@ -1736,7 +1735,6 @@ static void posix_cleanup_runtime() ...@@ -1736,7 +1735,6 @@ static void posix_cleanup_runtime()
free(posix_runtime); free(posix_runtime);
posix_runtime = NULL; posix_runtime = NULL;
instrumentation_disabled = 0;
return; return;
} }
...@@ -1837,9 +1835,6 @@ static void posix_shutdown( ...@@ -1837,9 +1835,6 @@ 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
......
...@@ -139,7 +139,6 @@ struct stdio_runtime ...@@ -139,7 +139,6 @@ struct stdio_runtime
static struct stdio_runtime *stdio_runtime = NULL; static struct stdio_runtime *stdio_runtime = NULL;
static pthread_mutex_t stdio_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP; static pthread_mutex_t stdio_runtime_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
static int instrumentation_disabled = 0;
static int darshan_mem_alignment = 1; static int darshan_mem_alignment = 1;
static int my_rank = -1; static int my_rank = -1;
...@@ -164,7 +163,7 @@ static void stdio_cleanup_runtime(); ...@@ -164,7 +163,7 @@ static void stdio_cleanup_runtime();
#define STDIO_PRE_RECORD() do { \ #define STDIO_PRE_RECORD() do { \
STDIO_LOCK(); \ STDIO_LOCK(); \
if(!instrumentation_disabled) { \ if(!darshan_core_disabled_instrumentation()) { \
if(!stdio_runtime) stdio_runtime_initialize(); \ if(!stdio_runtime) stdio_runtime_initialize(); \
if(stdio_runtime) break; \ if(stdio_runtime) break; \
} \ } \
...@@ -224,7 +223,7 @@ static void stdio_cleanup_runtime(); ...@@ -224,7 +223,7 @@ static void stdio_cleanup_runtime();
rec_ref->file_rec->fcounters[STDIO_F_READ_START_TIMESTAMP] > __tm1) \ rec_ref->file_rec->fcounters[STDIO_F_READ_START_TIMESTAMP] > __tm1) \
rec_ref->file_rec->fcounters[STDIO_F_READ_START_TIMESTAMP] = __tm1; \ rec_ref->file_rec->fcounters[STDIO_F_READ_START_TIMESTAMP] = __tm1; \
rec_ref->file_rec->fcounters[STDIO_F_READ_END_TIMESTAMP] = __tm2; \ rec_ref->file_rec->fcounters[STDIO_F_READ_END_TIMESTAMP] = __tm2; \
DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[STDIO_F_READ_TIME], __tm1, __tm2, rec_ref->last_write_end); \ DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[STDIO_F_READ_TIME], __tm1, __tm2, rec_ref->last_read_end); \
} while(0) } while(0)
#define STDIO_RECORD_WRITE(__fp, __bytes, __tm1, __tm2, __fflush_flag) do{ \ #define STDIO_RECORD_WRITE(__fp, __bytes, __tm1, __tm2, __fflush_flag) do{ \
...@@ -772,7 +771,7 @@ void DARSHAN_DECL(rewind)(FILE *stream) ...@@ -772,7 +771,7 @@ void DARSHAN_DECL(rewind)(FILE *stream)
* value in this wrapper. * value in this wrapper.
*/ */
STDIO_LOCK(); STDIO_LOCK();
if(instrumentation_disabled) { if(darshan_core_disabled_instrumentation()) {
STDIO_UNLOCK(); STDIO_UNLOCK();
return; return;
} }
...@@ -1120,9 +1119,6 @@ static void stdio_shutdown( ...@@ -1120,9 +1119,6 @@ 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 */
...@@ -1238,9 +1234,9 @@ static void stdio_shutdown( ...@@ -1238,9 +1234,9 @@ static void stdio_shutdown(
{ {
memmove(&stdio_rec_buf[i], &stdio_rec_buf[i+1], memmove(&stdio_rec_buf[i], &stdio_rec_buf[i+1],
(stdio_rec_count-i-1)*sizeof(stdio_rec_buf[i])); (stdio_rec_count-i-1)*sizeof(stdio_rec_buf[i]));
stdio_rec_count--;
i--; i--;
} }
stdio_rec_count--;
} }
} }
...@@ -1313,7 +1309,6 @@ static void stdio_cleanup_runtime() ...@@ -1313,7 +1309,6 @@ 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