Commit 2b243814 authored by Philip Carns's avatar Philip Carns

added basic tracking of hdf5 opens


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@97 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 80b3182a
......@@ -51,9 +51,13 @@ test/gz-bench: test/gz-bench.c mktestdir
lib/darshan-mpi-io.o: lib/darshan-mpi-io.c darshan.h darshan-log-format.h mklibdir
$(CC) $(cp_zlib_include_flags) $(CFLAGS) -c $< -o $@
lib/darshan-pnetcdf.o: lib/darshan-pnetcdf.c darshan.h darshan-log-format.h mklibdir
$(CC) $(cp_zlib_include_flags) $(CFLAGS) -c $< -o $@
lib/darshan-hdf5.o: lib/darshan-hdf5.c darshan.h darshan-log-format.h mklibdir
$(CC) $(cp_zlib_include_flags) $(CFLAGS) -c $< -o $@
lib/darshan-posix.o: lib/darshan-posix.c darshan.h darshan-log-format.h mklibdir
$(CC) $(cp_zlib_include_flags) $(CFLAGS) -c $< -o $@
......@@ -61,7 +65,7 @@ lookup3.o: lookup3.c
lookup8.o: lookup8.c
lib/libdarshan-mpi-io.a: lib/darshan-mpi-io.o lib/darshan-pnetcdf.o
lib/libdarshan-mpi-io.a: lib/darshan-mpi-io.o lib/darshan-pnetcdf.o lib/darshan-hdf5.o
ar rcs $@ $^
lib/libdarshan-posix.a: lib/darshan-posix.o lib/lookup3.o lib/lookup8.o
......
......@@ -3377,7 +3377,7 @@ fi
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
# libc functions wrapped by darshan
CP_WRAPPERS="-Wl,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close"
CP_WRAPPERS="-Wl,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close,-wrap,H5Fcreate,-wrap,H5Fopen,-wrap,H5Fclose"
# ,-u,__wrap___fxstat64,-u,pthread_mutex_lock,-u,pthread_mutex_unlock
......
......@@ -83,7 +83,7 @@ AC_TRY_COMPILE([#include <mpi.h>], [int ret = MPI_Init(0, (void*)0)],
)
# libc functions wrapped by darshan
CP_WRAPPERS="-Wl,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close"
CP_WRAPPERS="-Wl,-wrap,write,-wrap,open,-wrap,creat,-wrap,creat64,-wrap,open64,-wrap,close,-wrap,read,-wrap,lseek,-wrap,lseek64,-wrap,pread,-wrap,pwrite,-wrap,readv,-wrap,writev,-wrap,__xstat,-wrap,__lxstat,-wrap,__fxstat,-wrap,__xstat64,-wrap,__lxstat64,-wrap,__fxstat64,-wrap,mmap,-wrap,fopen,-wrap,fclose,-wrap,fread,-wrap,fwrite,-wrap,fseek,-wrap,fopen64,-wrap,pread64,-wrap,pwrite64,-wrap,fsync,-wrap,fdatasync,-wrap,ncmpi_create,-wrap,ncmpi_open,-wrap,ncmpi_close,-wrap,H5Fcreate,-wrap,H5Fopen,-wrap,H5Fclose"
# ,-u,__wrap___fxstat64,-u,pthread_mutex_lock,-u,pthread_mutex_unlock
......
......@@ -55,6 +55,8 @@ enum darshan_indices
/* pnetcdf stuff */
CP_INDEP_NC_OPENS,
CP_COLL_NC_OPENS,
/* HDF5 stuff */
CP_HDF5_OPENS,
/* type categories */
CP_COMBINER_NAMED, /* count of each MPI datatype category */
CP_COMBINER_DUP,
......
......@@ -34,6 +34,9 @@ char *darshan_names[] = {
"CP_POSIX_FDSYNCS",
"CP_POSIX_FOPENS",
"CP_POSIX_FSEEKS",
"CP_INDEP_NC_OPENS",
"CP_COLL_NC_OPENS",
"CP_HDF5_OPENS",
"CP_COMBINER_NAMED", /* count of each MPI datatype category */
"CP_COMBINER_DUP",
"CP_COMBINER_CONTIGUOUS",
......
......@@ -112,6 +112,7 @@ int main(int argc, char **argv)
printf("# CP_NB_*: MPI non blocking operation counts.\n");
printf("# READS,WRITES,OPENS,SEEKS,STATS, and MMAPS are types of operations.\n");
printf("# CP_*_NC_OPENS: number of indep. and collective pnetcdf opens.\n");
printf("# CP_HDF5_OPENS: number of hdf5 opens.\n");
printf("# CP_COMBINER_*: combiner counts for MPI mem and file datatypes.\n");
printf("# CP_HINTS: number of times MPI hints were used.\n");
printf("# CP_VIEWS: number of times MPI file views were used.\n");
......@@ -188,6 +189,7 @@ int main(int argc, char **argv)
CP_PRINT(&job, &cp_file, CP_COMBINER_RESIZED);
CP_PRINT(&job, &cp_file, CP_INDEP_NC_OPENS);
CP_PRINT(&job, &cp_file, CP_COLL_NC_OPENS);
CP_PRINT(&job, &cp_file, CP_HDF5_OPENS);
CP_PRINT(&job, &cp_file, CP_HINTS);
CP_PRINT(&job, &cp_file, CP_VIEWS);
CP_PRINT(&job, &cp_file, CP_MODE);
......
......@@ -61,12 +61,15 @@ struct darshan_file_runtime
MPI_File fh;
int fd;
int ncid;
int hid;
struct darshan_file_runtime* name_next;
struct darshan_file_runtime* name_prev;
struct darshan_file_runtime* fd_next;
struct darshan_file_runtime* fd_prev;
struct darshan_file_runtime* ncid_next;
struct darshan_file_runtime* ncid_prev;
struct darshan_file_runtime* hid_next;
struct darshan_file_runtime* hid_prev;
struct darshan_file_runtime* fh_next;
struct darshan_file_runtime* fh_prev;
void* access_root;
......@@ -92,6 +95,7 @@ struct darshan_job_runtime
struct darshan_file_runtime* name_table[CP_HASH_SIZE];
struct darshan_file_runtime* fd_table[CP_HASH_SIZE];
struct darshan_file_runtime* ncid_table[CP_HASH_SIZE];
struct darshan_file_runtime* hid_table[CP_HASH_SIZE];
struct darshan_file_runtime* fh_table[CP_HASH_SIZE];
struct darshan_file_runtime* darshan_mru_file;
};
......
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
#include <stdio.h>
#include <pthread.h>
#include <string.h>
#include "mpi.h"
#include "darshan.h"
#include "darshan-config.h"
/* hope this doesn't change any time soon */
typedef int hid_t;
typedef int herr_t;
extern hid_t __real_H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist);
extern hid_t __real_H5Fopen(const char *filename, unsigned flags,
hid_t access_plist);
extern herr_t __real_H5Fclose(hid_t file_id);
static struct darshan_file_runtime* darshan_file_by_hid(int hid);
hid_t __wrap_H5Fcreate(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
int hash_index;
ret = __real_H5Fcreate(filename, flags, create_plist, access_plist);
if(ret >= 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(filename, ':');
if (tmp > filename + 1) {
filename = tmp + 1;
}
file = darshan_file_by_name(filename);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->hid == -1))
{
file->hid = ret;
CP_INC(file, CP_HDF5_OPENS, 1);
hash_index = file->hid & CP_HASH_MASK;
file->hid_prev = NULL;
file->hid_next = darshan_global_job->hid_table[hash_index];
if(file->hid_next)
file->hid_next->hid_prev = file;
darshan_global_job->hid_table[hash_index] = file;
}
CP_UNLOCK();
}
return(ret);
}
hid_t __wrap_H5Fopen(const char *filename, unsigned flags,
hid_t access_plist)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
int hash_index;
ret = __real_H5Fopen(filename, flags, access_plist);
if(ret >= 0)
{
CP_LOCK();
/* use ROMIO approach to strip prefix if present */
/* strip off prefix if there is one, but only skip prefixes
* if they are greater than length one to allow for windows
* drive specifications (e.g. c:\...)
*/
tmp = strchr(filename, ':');
if (tmp > filename + 1) {
filename = tmp + 1;
}
file = darshan_file_by_name(filename);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->hid == -1))
{
file->hid = ret;
CP_INC(file, CP_HDF5_OPENS, 1);
hash_index = file->hid & CP_HASH_MASK;
file->hid_prev = NULL;
file->hid_next = darshan_global_job->hid_table[hash_index];
if(file->hid_next)
file->hid_next->hid_prev = file;
darshan_global_job->hid_table[hash_index] = file;
}
CP_UNLOCK();
}
return(ret);
}
herr_t __wrap_H5Fclose(hid_t file_id)
{
struct darshan_file_runtime* file;
int hash_index;
int tmp_hid = file_id;
int ret;
ret = __real_H5Fclose(file_id);
CP_LOCK();
file = darshan_file_by_hid(file_id);
if(file)
{
file->hid = -1;
if(file->hid_prev == NULL)
{
/* head of hid hash table list */
hash_index = tmp_hid & CP_HASH_MASK;
darshan_global_job->hid_table[hash_index] = file->hid_next;
if(file->hid_next)
file->hid_next->hid_prev = NULL;
}
else
{
if(file->hid_prev)
file->hid_prev->hid_next = file->hid_next;
if(file->hid_next)
file->hid_next->hid_prev = file->hid_prev;
}
file->hid_prev = NULL;
file->hid_next = NULL;
darshan_global_job->darshan_mru_file = file; /* in case we open it again */
}
CP_UNLOCK();
return(ret);
}
static struct darshan_file_runtime* darshan_file_by_hid(int hid)
{
int hash_index;
struct darshan_file_runtime* tmp_file;
if(!darshan_global_job)
{
return(NULL);
}
/* if we have already condensed the data, then just hand the first file
* back
*/
if(darshan_global_job->flags & CP_FLAG_CONDENSED)
{
return(&darshan_global_job->file_runtime_array[0]);
}
/* try mru first */
if(darshan_global_job->darshan_mru_file && darshan_global_job->darshan_mru_file->hid == hid)
{
return(darshan_global_job->darshan_mru_file);
}
/* search hash table */
hash_index = hid & CP_HASH_MASK;
tmp_file = darshan_global_job->hid_table[hash_index];
while(tmp_file)
{
if(tmp_file->hid == hid)
{
darshan_global_job->darshan_mru_file = tmp_file;
return(tmp_file);
}
tmp_file = tmp_file->hid_next;
}
return(NULL);
}
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ts=8 sts=4 sw=4 expandtab
*/
......@@ -46,25 +46,24 @@ int __wrap_ncmpi_create(MPI_Comm comm, const char *path,
if(file && (file->ncid == -1))
{
file->ncid = *ncidp;
}
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
}
hash_index = file->ncid & CP_HASH_MASK;
file->ncid_prev = NULL;
file->ncid_next = darshan_global_job->ncid_table[hash_index];
if(file->ncid_next)
file->ncid_next->ncid_prev = file;
darshan_global_job->ncid_table[hash_index] = file;
}
hash_index = file->ncid & CP_HASH_MASK;
file->ncid_prev = NULL;
file->ncid_next = darshan_global_job->ncid_table[hash_index];
if(file->ncid_next)
file->ncid_next->ncid_prev = file;
darshan_global_job->ncid_table[hash_index] = file;
CP_UNLOCK();
}
......@@ -99,25 +98,24 @@ int __wrap_ncmpi_open(MPI_Comm comm, const char *path,
if(file && (file->ncid == -1))
{
file->ncid = *ncidp;
}
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
PMPI_Comm_size(comm, &comm_size);
if(comm_size == 1)
{
CP_INC(file, CP_INDEP_NC_OPENS, 1);
}
else
{
CP_INC(file, CP_COLL_NC_OPENS, 1);
}
hash_index = file->ncid & CP_HASH_MASK;
file->ncid_prev = NULL;
file->ncid_next = darshan_global_job->ncid_table[hash_index];
if(file->ncid_next)
file->ncid_next->ncid_prev = file;
darshan_global_job->ncid_table[hash_index] = file;
}
hash_index = file->ncid & CP_HASH_MASK;
file->ncid_prev = NULL;
file->ncid_next = darshan_global_job->ncid_table[hash_index];
if(file->ncid_next)
file->ncid_next->ncid_prev = file;
darshan_global_job->ncid_table[hash_index] = file;
CP_UNLOCK();
}
......
......@@ -979,6 +979,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
&darshan_global_job->file_array[i];
darshan_global_job->file_runtime_array[i].fd = -1;
darshan_global_job->file_runtime_array[i].ncid = -1;
darshan_global_job->file_runtime_array[i].hid = -1;
darshan_global_job->file_runtime_array[i].fh = MPI_FILE_NULL;
}
......
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