Commit 76d33b22 authored by Philip Carns's avatar Philip Carns
Browse files

Merge branch 'master' into dev-stdio-utils

parents 4ba7a24d 173d3d49
...@@ -144,6 +144,12 @@ void *darshan_core_register_record( ...@@ -144,6 +144,12 @@ void *darshan_core_register_record(
int rec_len, int rec_len,
struct darshan_fs_info *fs_info); struct darshan_fs_info *fs_info);
/* TODO */
void darshan_instrument_fs_data(
int fs_type,
const char *path,
int fd);
/* darshan_core_wtime() /* darshan_core_wtime()
* *
* Returns the elapsed time relative to (roughly) the start of * Returns the elapsed time relative to (roughly) the start of
......
...@@ -126,7 +126,11 @@ char* darshan_clean_file_path(const char* path) ...@@ -126,7 +126,11 @@ char* darshan_clean_file_path(const char* path)
char* cwd = NULL; char* cwd = NULL;
char* filter = 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); return(NULL);
if(path[0] == '/') if(path[0] == '/')
......
...@@ -80,6 +80,13 @@ void (*mod_static_init_fns[])(void) = ...@@ -80,6 +80,13 @@ void (*mod_static_init_fns[])(void) =
NULL 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_LOCK() pthread_mutex_lock(&darshan_core_mutex)
#define DARSHAN_CORE_UNLOCK() pthread_mutex_unlock(&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) ...@@ -1764,7 +1771,7 @@ void darshan_shutdown_bench(int argc, char **argv)
darshan_mpiio_shutdown_bench_setup(1); darshan_mpiio_shutdown_bench_setup(1);
if(my_rank == 0) 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_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
darshan_core_shutdown(); darshan_core_shutdown();
darshan_core = NULL; darshan_core = NULL;
...@@ -1779,7 +1786,7 @@ void darshan_shutdown_bench(int argc, char **argv) ...@@ -1779,7 +1786,7 @@ void darshan_shutdown_bench(int argc, char **argv)
darshan_mpiio_shutdown_bench_setup(2); darshan_mpiio_shutdown_bench_setup(2);
if(my_rank == 0) 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_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
darshan_core_shutdown(); darshan_core_shutdown();
darshan_core = NULL; darshan_core = NULL;
...@@ -1794,7 +1801,7 @@ void darshan_shutdown_bench(int argc, char **argv) ...@@ -1794,7 +1801,7 @@ void darshan_shutdown_bench(int argc, char **argv)
darshan_mpiio_shutdown_bench_setup(3); darshan_mpiio_shutdown_bench_setup(3);
if(my_rank == 0) 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_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
darshan_core_shutdown(); darshan_core_shutdown();
darshan_core = NULL; darshan_core = NULL;
...@@ -1809,7 +1816,7 @@ void darshan_shutdown_bench(int argc, char **argv) ...@@ -1809,7 +1816,7 @@ void darshan_shutdown_bench(int argc, char **argv)
darshan_mpiio_shutdown_bench_setup(4); darshan_mpiio_shutdown_bench_setup(4);
if(my_rank == 0) 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_MPI_CALL(PMPI_Barrier)(MPI_COMM_WORLD);
darshan_core_shutdown(); darshan_core_shutdown();
darshan_core = NULL; darshan_core = NULL;
...@@ -1986,6 +1993,19 @@ void *darshan_core_register_record( ...@@ -1986,6 +1993,19 @@ void *darshan_core_register_record(
return(rec_buf);; 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() double darshan_core_wtime()
{ {
DARSHAN_CORE_LOCK(); DARSHAN_CORE_LOCK();
......
...@@ -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;
} }
...@@ -1247,6 +1249,9 @@ void darshan_mpiio_shutdown_bench_setup(int test_case) ...@@ -1247,6 +1249,9 @@ void darshan_mpiio_shutdown_bench_setup(int test_case)
return; return;
} }
free(fh_array);
free(size_array);
return; return;
} }
...@@ -1273,6 +1278,10 @@ static void mpiio_shutdown( ...@@ -1273,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
...@@ -1381,9 +1390,6 @@ static void mpiio_shutdown( ...@@ -1381,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;
} }
......
...@@ -37,9 +37,6 @@ typedef int64_t off64_t; ...@@ -37,9 +37,6 @@ typedef int64_t off64_t;
#define aiocb64 aiocb #define aiocb64 aiocb
#endif #endif
#ifdef DARSHAN_LUSTRE
#include <lustre/lustre_user.h>
#endif
DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...)); DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(open64, 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( ...@@ -142,8 +139,6 @@ static void posix_runtime_initialize(
void); void);
static struct posix_file_record_ref *posix_track_new_file_record( static struct posix_file_record_ref *posix_track_new_file_record(
darshan_record_id rec_id, const char *path); 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( static void posix_aio_tracker_add(
int fd, void *aiocbp); int fd, void *aiocbp);
static struct posix_aio_tracker* posix_aio_tracker_del( static struct posix_aio_tracker* posix_aio_tracker_del(
...@@ -162,13 +157,6 @@ static void posix_shutdown( ...@@ -162,13 +157,6 @@ static void posix_shutdown(
MPI_Comm mod_comm, darshan_record_id *shared_recs, MPI_Comm mod_comm, darshan_record_id *shared_recs,
int shared_rec_count, void **posix_buf, int *posix_buf_sz); 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 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 instrumentation_disabled = 0;
...@@ -180,11 +168,12 @@ static int darshan_mem_alignment = 1; ...@@ -180,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 { \
...@@ -221,7 +210,7 @@ static int darshan_mem_alignment = 1; ...@@ -221,7 +210,7 @@ static int darshan_mem_alignment = 1;
DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[POSIX_F_META_TIME], \ DARSHAN_TIMER_INC_NO_OVERLAP(rec_ref->file_rec->fcounters[POSIX_F_META_TIME], \
__tm1, __tm2, rec_ref->last_meta_end); \ __tm1, __tm2, rec_ref->last_meta_end); \
darshan_add_record_ref(&(posix_runtime->fd_hash), &__ret, sizeof(int), rec_ref); \ 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); \ if(newpath != __path) free(newpath); \
} while(0) } while(0)
...@@ -1313,26 +1302,13 @@ static struct posix_file_record_ref *posix_track_new_file_record( ...@@ -1313,26 +1302,13 @@ static struct posix_file_record_ref *posix_track_new_file_record(
file_rec->base_rec.rank = my_rank; file_rec->base_rec.rank = my_rank;
file_rec->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment; file_rec->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
file_rec->counters[POSIX_FILE_ALIGNMENT] = fs_info.block_size; 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->fs_type = fs_info.fs_type;
rec_ref->file_rec = file_rec;
posix_runtime->file_rec_count++; posix_runtime->file_rec_count++;
return(rec_ref); 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 /* finds the tracker structure for a given aio operation, removes it from
* the associated linked list for this file record, and returns a pointer. * the associated linked list for this file record, and returns a pointer.
* *
...@@ -1709,6 +1685,7 @@ static void posix_cleanup_runtime() ...@@ -1709,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;
} }
...@@ -1808,6 +1785,10 @@ static void posix_shutdown( ...@@ -1808,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
...@@ -1917,9 +1898,6 @@ static void posix_shutdown( ...@@ -1917,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;
} }
......
...@@ -94,7 +94,9 @@ DARSHAN_FORWARD_DECL(fputc, int, (int c, FILE *stream)); ...@@ -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(putw, int, (int w, FILE *stream));