Commit 80b3182a authored by Philip Carns's avatar Philip Carns

completed tracking of pnetcdf opens and closes


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@96 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 11fb5ddc
......@@ -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"
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"
# ,-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"
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"
# ,-u,__wrap___fxstat64,-u,pthread_mutex_lock,-u,pthread_mutex_unlock
......
......@@ -16,6 +16,7 @@ extern int __real_ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp);
extern int __real_ncmpi_close(int ncid);
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid);
int __wrap_ncmpi_create(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp)
......@@ -42,7 +43,7 @@ int __wrap_ncmpi_create(MPI_Comm comm, const char *path,
file = darshan_file_by_name(path);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->ncid == 0))
if(file && (file->ncid == -1))
{
file->ncid = *ncidp;
}
......@@ -70,6 +71,140 @@ int __wrap_ncmpi_create(MPI_Comm comm, const char *path,
return(ret);
}
int __wrap_ncmpi_open(MPI_Comm comm, const char *path,
int omode, MPI_Info info, int *ncidp)
{
int ret;
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
int hash_index;
ret = __real_ncmpi_open(comm, path, omode, info, ncidp);
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(path, ':');
if (tmp > path + 1) {
path = tmp + 1;
}
file = darshan_file_by_name(path);
/* TODO: handle the case of multiple concurrent opens */
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);
}
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();
}
return(ret);
}
int __wrap_ncmpi_close(int ncid)
{
struct darshan_file_runtime* file;
int hash_index;
int tmp_ncid = ncid;
int ret;
ret = __real_ncmpi_close(ncid);
CP_LOCK();
file = darshan_file_by_ncid(ncid);
if(file)
{
file->ncid = -1;
if(file->ncid_prev == NULL)
{
/* head of ncid hash table list */
hash_index = tmp_ncid & CP_HASH_MASK;
darshan_global_job->ncid_table[hash_index] = file->ncid_next;
if(file->ncid_next)
file->ncid_next->ncid_prev = NULL;
}
else
{
if(file->ncid_prev)
file->ncid_prev->ncid_next = file->ncid_next;
if(file->ncid_next)
file->ncid_next->ncid_prev = file->ncid_prev;
}
file->ncid_prev = NULL;
file->ncid_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_ncid(int ncid)
{
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->ncid == ncid)
{
return(darshan_global_job->darshan_mru_file);
}
/* search hash table */
hash_index = ncid & CP_HASH_MASK;
tmp_file = darshan_global_job->ncid_table[hash_index];
while(tmp_file)
{
if(tmp_file->ncid == ncid)
{
darshan_global_job->darshan_mru_file = tmp_file;
return(tmp_file);
}
tmp_file = tmp_file->ncid_next;
}
return(NULL);
}
/*
* Local variables:
* c-indent-level: 4
......
......@@ -978,6 +978,7 @@ void darshan_initialize(int argc, char** argv, int nprocs, int rank)
darshan_global_job->file_runtime_array[i].log_file =
&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].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