Commit b59326f4 authored by Philip Carns's avatar Philip Carns

new framework for tracking multiple concurrent open references per MPI rank


git-svn-id: https://svn.mcs.anl.gov/repos/darshan/trunk@563 3b7491f3-a168-0410-bf4b-c445ed680a29
parent 95b6fc75
......@@ -62,12 +62,6 @@ lib/darshan-posix.o: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-file.o: lib/darshan-file.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@
lib/darshan-file.po: lib/darshan-file.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup3.o: lib/lookup3.c
$(CC) $(CFLAGS) -c $< -o $@
......@@ -86,10 +80,10 @@ lib/lookup8.po: lib/lookup8.c
lib/libdarshan-mpi-io.a: lib/darshan-mpi-io.o lib/darshan-mpi-init-finalize.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 lib/darshan-file.o
lib/libdarshan-posix.a: lib/darshan-posix.o lib/lookup3.o lib/lookup8.o
ar rcs $@ $^
lib/libdarshan.so: lib/darshan-mpi-io.po lib/darshan-mpi-init-finalize.po lib/darshan-pnetcdf.po lib/darshan-hdf5.po lib/darshan-posix.po lib/lookup3.po lib/lookup8.po lib/darshan-file.po
lib/libdarshan.so: lib/darshan-mpi-io.po lib/darshan-mpi-init-finalize.po lib/darshan-pnetcdf.po lib/darshan-hdf5.po lib/darshan-posix.po lib/lookup3.po lib/lookup8.po
$(CC) $(CFLAGS_SHARED) $(LDFLAGS) -ldl -o $@ $^ -lpthread -lrt -lz
install:: all
......
......@@ -64,20 +64,8 @@ struct cp_access_counter
struct darshan_file_runtime
{
struct darshan_file* log_file;
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;
int access_count;
void* stride_root;
......@@ -88,6 +76,29 @@ struct darshan_file_runtime
enum cp_io_type last_io_type;
};
/* handles used by various APIs to refer to files */
enum darshan_handle_type
{
DARSHAN_FD = 1,
DARSHAN_FH,
DARSHAN_NCID,
DARSHAN_HID
};
#define DARSHAN_FILE_HANDLE_MAX (sizeof(MPI_File))
/* This struct is used to track a reference to a file by file
* descriptor, MPI file handle, ncdf id, etc.
*/
struct darshan_file_ref
{
struct darshan_file_runtime* file;
char handle[DARSHAN_FILE_HANDLE_MAX];
int handle_sz;
enum darshan_handle_type handle_type;
struct darshan_file_ref* next;
struct darshan_file_ref* prev;
};
/* in memory structure to keep up with job level data */
struct darshan_job_runtime
{
......@@ -99,11 +110,7 @@ struct darshan_job_runtime
int flags;
int file_count;
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;
struct darshan_file_ref* handle_table[CP_HASH_SIZE];
};
extern pthread_mutex_t cp_mutex;
......@@ -199,8 +206,6 @@ enum cp_counter_type
extern struct darshan_job_runtime* darshan_global_job;
struct darshan_file_runtime* darshan_file_by_name(const char* name);
struct darshan_file_runtime* darshan_file_by_fd(int fd);
void darshan_initialize(int argc, char** argv, int nprocs, int rank);
void darshan_finalize(struct darshan_job_runtime* job);
void darshan_condense(void);
......@@ -211,6 +216,24 @@ void darshan_walk_file_accesses(struct darshan_job_runtime* final_job);
double darshan_wtime(void);
uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
uint64_t darshan_hash(register unsigned char *k, register uint64_t length, register uint64_t level);
uint64_t darshan_hash(const register unsigned char *k, register uint64_t length, register uint64_t level);
struct darshan_file_runtime* darshan_file_by_name(const char* name);
struct darshan_file_runtime* darshan_file_by_name_sethandle(
const char* name,
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
struct darshan_file_runtime* darshan_file_by_handle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
void darshan_file_closehandle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
#endif /* __DARSHAN_H */
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This is an API for finding and tracking file records by file name and/or
* various file handles
*/
#include <pthread.h>
#include "mpi.h"
#include "darshan-file.h"
static pthread_mutex_t darshan_file_lock = PTHREAD_MUTEX_INITIALIZER;
#define DARSHAN_FILE_HANDLE_MAX (sizeof(MPI_File))
struct darshan_file_ref
{
struct darshan_file_runtime* file;
char handle[DARSHAN_FILE_HANDLE_MAX];
int handle_sz;
enum darshan_handle_type type;
struct darshan_file_ref* next;
struct darshan_file_ref* prev;
};
#define DARSHAN_FILE_TABLE_SIZE 16
static struct darshan_file_ref* darshan_file_table[DARSHAN_FILE_TABLE_SIZE] = {NULL};
struct darshan_file_runtime* darshan_file_by_name(const char* name)
{
return(NULL);
}
struct darshan_file_runtime* darshan_file_by_name_sethandle(
const char* name,
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type)
{
return(NULL);
}
struct darshan_file_runtime* darshan_file_by_handle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type)
{
return(NULL);
}
struct darshan_file_runtime* darshan_file_closehandle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type)
{
return(NULL);
}
/*
* (C) 2009 by Argonne National Laboratory.
* See COPYRIGHT in top-level directory.
*/
/* This is an API for finding and tracking file records by file name and/or
* various file handles
*/
#ifndef __DARSHAN_FILE_H
#define __DARSHAN_FILE_H
#include "darshan.h"
enum darshan_handle_type
{
DARSHAN_FD = 1,
DARSHAN_FH,
DARSHAN_NCID,
DARSHAN_HID
};
struct darshan_file_runtime* darshan_file_by_name(const char* name);
struct darshan_file_runtime* darshan_file_by_name_sethandle(
const char* name,
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
struct darshan_file_runtime* darshan_file_by_handle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
struct darshan_file_runtime* darshan_file_closehandle(
const void* handle,
int handle_sz,
enum darshan_handle_type handle_type);
#endif /* __DARSHAN_FILE_H */
......@@ -51,6 +51,8 @@ DARSHAN_FORWARD_DECL(H5Fopen, hid_t, (const char *filename, unsigned flags, hid_
DARSHAN_FORWARD_DECL(H5Fclose, herr_t, (hid_t file_id));
static struct darshan_file_runtime* darshan_file_by_hid(int hid);
static void darshan_file_close_hid(int hid);
static struct darshan_file_runtime* darshan_file_by_name_sethid(const char* name, int hid);
hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
hid_t create_plist, hid_t access_plist)
......@@ -58,7 +60,6 @@ hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
int ret;
struct darshan_file_runtime* file;
char* tmp;
int hash_index;
MAP_OR_FAIL(H5Fcreate);
......@@ -76,21 +77,13 @@ hid_t DARSHAN_DECL(H5Fcreate)(const char *filename, unsigned flags,
filename = tmp + 1;
}
file = darshan_file_by_name(filename);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->hid == -1))
file = darshan_file_by_name_sethid(filename, ret);
if(file)
{
file->hid = ret;
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
PMPI_Wtime());
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();
}
......@@ -104,7 +97,6 @@ hid_t DARSHAN_DECL(H5Fopen)(const char *filename, unsigned flags,
int ret;
struct darshan_file_runtime* file;
char* tmp;
int hash_index;
MAP_OR_FAIL(H5Fopen);
......@@ -122,21 +114,13 @@ hid_t DARSHAN_DECL(H5Fopen)(const char *filename, unsigned flags,
filename = tmp + 1;
}
file = darshan_file_by_name(filename);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->hid == -1))
file = darshan_file_by_name_sethid(filename, ret);
if(file)
{
file->hid = ret;
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
PMPI_Wtime());
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();
......@@ -149,8 +133,6 @@ hid_t DARSHAN_DECL(H5Fopen)(const char *filename, unsigned flags,
herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
{
struct darshan_file_runtime* file;
int hash_index;
int tmp_hid = file_id;
int ret;
MAP_OR_FAIL(H5Fclose);
......@@ -161,26 +143,8 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
file = darshan_file_by_hid(file_id);
if(file)
{
file->hid = -1;
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, PMPI_Wtime());
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 */
darshan_file_close_hid(file_id);
}
CP_UNLOCK();
......@@ -188,44 +152,27 @@ herr_t DARSHAN_DECL(H5Fclose)(hid_t file_id)
}
static struct darshan_file_runtime* darshan_file_by_hid(int hid)
static struct darshan_file_runtime* darshan_file_by_name_sethid(const char* name, 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]);
}
tmp_file = darshan_file_by_name_sethandle(name, &hid, sizeof(hid), DARSHAN_HID);
return(tmp_file);
}
/* 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);
}
static void darshan_file_close_hid(int hid)
{
darshan_file_closehandle(&hid, sizeof(hid), DARSHAN_HID);
return;
}
/* 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;
}
static struct darshan_file_runtime* darshan_file_by_hid(int hid)
{
struct darshan_file_runtime* tmp_file;
return(NULL);
tmp_file = darshan_file_by_handle(&hid, sizeof(hid), DARSHAN_HID);
return(tmp_file);
}
......
......@@ -178,7 +178,6 @@ extern char* __progname;
CP_F_SET(file, CP_F_READ_END_TIMESTAMP, __tm2); \
} while(0)
static struct darshan_file_runtime* darshan_file_by_fh(MPI_File fh);
static void cp_log_construct_indices(struct darshan_job_runtime* final_job,
int rank, int* inout_count, int* lengths, void** pointers, char*
trailing_data);
......@@ -203,6 +202,9 @@ static void pairwise_variance_reduce (
void *invec, void *inoutvec, int *len, MPI_Datatype *dt);
static void debug_mounts(const char* mtab_file, const char* out_file);
static struct darshan_file_runtime* darshan_file_by_fh(MPI_File fh);
static void darshan_file_close_fh(MPI_File fh);
static struct darshan_file_runtime* darshan_file_by_name_setfh(const char* name, MPI_File fh);
#define CP_MAX_MNTS 32
uint64_t mnt_hash_array[CP_MAX_MNTS] = {0};
......@@ -695,8 +697,6 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_F
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
int hash_index;
uint64_t tmp_hash;
double tm1, tm2;
tm1 = darshan_wtime();
......@@ -717,11 +717,9 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_F
filename = tmp + 1;
}
file = darshan_file_by_name(filename);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->fh == MPI_FILE_NULL))
file = darshan_file_by_name_setfh(filename, (*fh));
if(file)
{
file->fh = *fh;
CP_SET(file, CP_MODE, amode);
CP_F_INC(file, CP_F_MPI_META_TIME, (tm2-tm1));
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
......@@ -740,14 +738,8 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_F
{
CP_INC(file, CP_HINTS, 1);
}
tmp_hash = darshan_hash((void*)fh, sizeof(*fh), 0);
hash_index = tmp_hash & CP_HASH_MASK;
file->fh_prev = NULL;
file->fh_next = darshan_global_job->fh_table[hash_index];
if(file->fh_next)
file->fh_next->fh_prev = file;
darshan_global_job->fh_table[hash_index] = file;
}
CP_UNLOCK();
}
......@@ -756,8 +748,6 @@ int MPI_File_open(MPI_Comm comm, char *filename, int amode, MPI_Info info, MPI_F
int MPI_File_close(MPI_File *fh)
{
int hash_index;
uint64_t tmp_hash;
struct darshan_file_runtime* file;
MPI_File tmp_fh = *fh;
double tm1, tm2;
......@@ -771,28 +761,9 @@ int MPI_File_close(MPI_File *fh)
file = darshan_file_by_fh(tmp_fh);
if(file)
{
file->fh = MPI_FILE_NULL;
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, DARSHAN_MPI_CALL(PMPI_Wtime)());
CP_F_INC(file, CP_F_MPI_META_TIME, (tm2-tm1));
if(file->fh_prev == NULL)
{
/* head of fh hash table list */
tmp_hash = darshan_hash((void*)&tmp_fh, sizeof(tmp_fh), 0);
hash_index = tmp_hash & CP_HASH_MASK;
darshan_global_job->fh_table[hash_index] = file->fh_next;
if(file->fh_next)
file->fh_next->fh_prev = NULL;
}
else
{
if(file->fh_prev)
file->fh_prev->fh_next = file->fh_next;
if(file->fh_next)
file->fh_next->fh_prev = file->fh_prev;
}
file->fh_prev = NULL;
file->fh_next = NULL;
darshan_global_job->darshan_mru_file = file; /* in case we open it again, or hit posix calls */
darshan_file_close_fh(tmp_fh);
}
CP_UNLOCK();
......@@ -1224,47 +1195,6 @@ int MPI_File_iwrite_shared(MPI_File fh, void * buf, int count,
return(ret);
}
static struct darshan_file_runtime* darshan_file_by_fh(MPI_File fh)
{
struct darshan_file_runtime* tmp_file;
uint64_t tmp_hash = 0;
int hash_index;
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]);
}
/* check most recently used */
if(darshan_global_job->darshan_mru_file && darshan_global_job->darshan_mru_file->fh == fh)
{
return(darshan_global_job->darshan_mru_file);
}
tmp_hash = darshan_hash((void*)(&fh), sizeof(fh), 0);
/* search hash table */
hash_index = tmp_hash & CP_HASH_MASK;
tmp_file = darshan_global_job->fh_table[hash_index];
while(tmp_file)
{
if(tmp_file->fh == fh)
{
darshan_global_job->darshan_mru_file = tmp_file;
return(tmp_file);
}
tmp_file = tmp_file->fh_next;
}
return(NULL);
}
/* cp_log_reduction()
*
* Identify shared files and reduce them to one log entry
......@@ -2411,6 +2341,29 @@ static void debug_mounts(const char* mtab_file, const char* out_file)
return;
}
static struct darshan_file_runtime* darshan_file_by_name_setfh(const char* name, MPI_File fh)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_name_sethandle(name, &fh, sizeof(fh), DARSHAN_FH);
return(tmp_file);
}
static void darshan_file_close_fh(MPI_File fh)
{
darshan_file_closehandle(&fh, sizeof(fh), DARSHAN_FH);
return;
}
static struct darshan_file_runtime* darshan_file_by_fh(MPI_File fh)
{
struct darshan_file_runtime* tmp_file;
tmp_file = darshan_file_by_handle(&fh, sizeof(fh), DARSHAN_FH);
return(tmp_file);
}
/*
* Local variables:
* c-indent-level: 4
......
......@@ -46,6 +46,8 @@ DARSHAN_FORWARD_DECL(ncmpi_open, int, (MPI_Comm comm, const char *path, int omod
DARSHAN_FORWARD_DECL(ncmpi_close, int, (int ncid));
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid);
static void darshan_file_close_ncid(int ncid);
static struct darshan_file_runtime* darshan_file_by_name_setncid(const char* name, int ncid);
int DARSHAN_DECL(ncmpi_create)(MPI_Comm comm, const char *path,
int cmode, MPI_Info info, int *ncidp)
......@@ -54,7 +56,6 @@ int DARSHAN_DECL(ncmpi_create)(MPI_Comm comm, const char *path,
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
int hash_index;
MAP_OR_FAIL(ncmpi_create);
......@@ -72,11 +73,9 @@ int DARSHAN_DECL(ncmpi_create)(MPI_Comm comm, const char *path,
path = tmp + 1;
}
file = darshan_file_by_name(path);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->ncid == -1))
file = darshan_file_by_name_setncid(path, (*ncidp));
if(file)
{
file->ncid = *ncidp;
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
PMPI_Wtime());
......@@ -89,13 +88,6 @@ int DARSHAN_DECL(ncmpi_create)(MPI_Comm comm, const char *path,
{
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();
}
......@@ -110,7 +102,6 @@ int DARSHAN_DECL(ncmpi_open)(MPI_Comm comm, const char *path,
struct darshan_file_runtime* file;
char* tmp;
int comm_size;
int hash_index;
MAP_OR_FAIL(ncmpi_open);
......@@ -128,11 +119,9 @@ int DARSHAN_DECL(ncmpi_open)(MPI_Comm comm, const char *path,
path = tmp + 1;
}
file = darshan_file_by_name(path);
/* TODO: handle the case of multiple concurrent opens */
if(file && (file->ncid == -1))
file = darshan_file_by_name_setncid(path, (*ncidp));
if(file)
{
file->ncid = *ncidp;
if(CP_F_VALUE(file, CP_F_OPEN_TIMESTAMP) == 0)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP,
PMPI_Wtime());
......@@ -145,13 +134,6 @@ int DARSHAN_DECL(ncmpi_open)(MPI_Comm comm, const char *path,
{
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();
}
......@@ -163,8 +145,6 @@ int DARSHAN_DECL(ncmpi_open)(MPI_Comm comm, const char *path,
int DARSHAN_DECL(ncmpi_close)(int ncid)
{
struct darshan_file_runtime* file;
int hash_index;
int tmp_ncid = ncid;
int ret;
MAP_OR_FAIL(ncmpi_close);
......@@ -175,74 +155,39 @@ int DARSHAN_DECL(ncmpi_close)(int ncid)
file = darshan_file_by_ncid(ncid);
if(file)
{
file->ncid = -1;
CP_F_SET(file, CP_F_CLOSE_TIMESTAMP, PMPI_Wtime());
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 */
darshan_file_close_ncid(ncid);
}
CP_UNLOCK();
return(ret);
}
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid)
static struct darshan_file_runtime* darshan_file_by_name_setncid(const char* name, 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]);
}
tmp_file = darshan_file_by_name_sethandle(name, &ncid, sizeof(ncid), DARSHAN_NCID);
return(tmp_file);
}
/* 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);
}
static void darshan_file_close_ncid(int ncid)
{
darshan_file_closehandle(&ncid, sizeof(ncid), DARSHAN_NCID);
return;
}
/* 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;
}
static struct darshan_file_runtime* darshan_file_by_ncid(int ncid)
{
struct darshan_file_runtime* tmp_file;
return(NULL);