[Darshan-commits] [Darshan] branch, dev-modular, updated. f9e5a24e9b089cd60ae3e9bd330d702c05a7884c
Service Account
git at mcs.anl.gov
Thu Oct 9 13:14:39 CDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "".
The branch, dev-modular has been updated
via f9e5a24e9b089cd60ae3e9bd330d702c05a7884c (commit)
via 0843817664ce9c4648fcbb63bed987f0a6aa7359 (commit)
via bd6ef3089a15eea6df6a0e1af9d85104aec27ec0 (commit)
from 66a491402851fa417e01c8e571ddf68fe06ee5e9 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit f9e5a24e9b089cd60ae3e9bd330d702c05a7884c
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date: Thu Oct 9 13:14:15 2014 -0500
updated code for darshan modularization
commit 0843817664ce9c4648fcbb63bed987f0a6aa7359
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date: Mon Sep 29 16:20:48 2014 -0500
slight update to code structure/naming
commit bd6ef3089a15eea6df6a0e1af9d85104aec27ec0
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date: Mon Sep 29 14:09:50 2014 -0500
Update with some TODO notes
-----------------------------------------------------------------------
Summary of changes:
darshan-modularization-design-notes.txt | 4 +
darshan-runtime/darshan-core.h | 46 ++--
darshan-runtime/darshan.h | 248 +---------------
darshan-runtime/lib/darshan-core.c | 129 +++++----
darshan-runtime/lib/darshan-posix.c | 468 ++++++++++---------------------
5 files changed, 261 insertions(+), 634 deletions(-)
Diff of changes:
diff --git a/darshan-modularization-design-notes.txt b/darshan-modularization-design-notes.txt
index be6673e..012fd88 100644
--- a/darshan-modularization-design-notes.txt
+++ b/darshan-modularization-design-notes.txt
@@ -110,3 +110,7 @@ API:
- strip down to basic example
- just do one or two posix counters to start, but exercise all of the
API and code organization stuff
+
+TODO NOTES:
+ - why are darshan mutexes recursive?
+ - how do we allow modules to specify there necessary linker/wrapper flags
diff --git a/darshan-runtime/darshan-core.h b/darshan-runtime/darshan-core.h
index adc1a4f..5387887 100644
--- a/darshan-runtime/darshan-core.h
+++ b/darshan-runtime/darshan-core.h
@@ -10,31 +10,41 @@
#include <sys/types.h>
#include <stdint.h>
+#include "darshan.h"
+
#define DARSHAN_MPI_CALL(func) func
-typedef uint64_t darshan_file_id;
+/* calculation of compression buffer size (defaults to 50% of the maximum
+ * memory that Darshan is allowed to consume on a process)
+ */
+//#define CP_COMP_BUF_SIZE ((CP_MAX_FILES * sizeof(struct darshan_file))/2)
+#define CP_COMP_BUF_SIZE 0
-struct darshan_module_funcs
-{
- void (*prepare_for_shutdown)(void);
- void (*get_output_data)(void **, int);
-};
+/* max length of module name string (not counting \0) */
+#define DARSHAN_MOD_NAME_LEN 31
-struct darshan_module
+/* flags to indicate properties of file records */
+#define CP_FLAG_CONDENSED 1<<0
+#define CP_FLAG_NOTIMING 1<<1
+
+struct darshan_core_module
{
- char *name;
+ char name[DARSHAN_MOD_NAME_LEN+1];
struct darshan_module_funcs mod_funcs;
+ struct darshan_core_module *next_mod;
};
-void darshan_core_register_module(
- char *name,
- struct darshan_module_funcs *funcs,
- int *runtime_mem_limit);
-
-void darshan_core_lookup_id(
- void *name,
- int len,
- int printable_flag,
- darshan_file_id *id);
+/* in memory structure to keep up with job level data */
+struct darshan_core_job_runtime
+{
+ struct darshan_job log_job;
+ char exe[CP_EXE_LEN+1];
+ struct darshan_core_module *mod_list_head;
+ char comp_buf[CP_COMP_BUF_SIZE];
+ int flags;
+ int file_count;
+ double wtime_offset;
+ char* trailing_data;
+};
#endif /* __DARSHAN_CORE_H */
diff --git a/darshan-runtime/darshan.h b/darshan-runtime/darshan.h
index ad6a421..89a79b1 100644
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -12,245 +12,25 @@
#include <mpi.h>
#include "darshan-log-format.h"
-/* Environment variable to override CP_JOBID */
-#define CP_JOBID_OVERRIDE "DARSHAN_JOBID"
+typedef uint64_t darshan_file_id;
-/* Environment variable to override __CP_LOG_PATH */
-#define CP_LOG_PATH_OVERRIDE "DARSHAN_LOGPATH"
-
-/* Environment variable to override __CP_LOG_PATH */
-#define CP_LOG_HINTS_OVERRIDE "DARSHAN_LOGHINTS"
-
-/* Environment variable to override __CP_MEM_ALIGNMENT */
-#define CP_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN"
-
-/* maximum number of files per process we will track */
-#define CP_MAX_FILES 1024
-
-/* TODO: figure out how to pick good value here */
-/* hash table size parameters */
-#define CP_HASH_BITS 8
-#define CP_HASH_SIZE (1 << CP_HASH_BITS)
-#define CP_HASH_MASK (CP_HASH_SIZE - 1)
-
-/* maximum number of access sizes and stride sizes that darshan will track
- * per file at runtime; at log time they will be reduced into the 4 most
- * frequently occurring ones
- */
-#define CP_MAX_ACCESS_COUNT_RUNTIME 32
-
-/* flags to indicate properties of file records */
-#define CP_FLAG_CONDENSED 1<<0
-#define CP_FLAG_NOTIMING 1<<1
-
-/* calculation of compression buffer size (defaults to 50% of the maximum
- * memory that Darshan is allowed to consume on a process)
- */
-#define CP_COMP_BUF_SIZE ((CP_MAX_FILES * sizeof(struct darshan_file))/2)
-
-enum cp_io_type
-{
- CP_READ = 1,
- CP_WRITE = 2,
-};
-
-struct cp_access_counter
-{
- int64_t size;
- int freq;
-};
-
-struct darshan_io_tracker;
-
-/* in memory structure to keep up with file level data */
-struct darshan_file_runtime
-{
- struct darshan_file* log_file;
- struct darshan_file_runtime* name_next;
- struct darshan_file_runtime* name_prev;
- void* access_root;
- int access_count;
- void* stride_root;
- int stride_count;
- int64_t last_byte_read;
- int64_t last_byte_written;
- int64_t offset;
- enum cp_io_type last_io_type;
- double last_posix_write_end;
- double last_mpi_write_end;
- double last_posix_read_end;
- double last_mpi_read_end;
- double last_posix_meta_end;
- double last_mpi_meta_end;
- struct darshan_aio_tracker* aio_list_head;
- struct darshan_aio_tracker* aio_list_tail;
-};
-
-/* 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
+struct darshan_module_funcs
{
- struct darshan_job log_job;
- char exe[CP_EXE_LEN+1];
- struct darshan_file file_array[CP_MAX_FILES];
- struct darshan_file_runtime file_runtime_array[CP_MAX_FILES];
- char comp_buf[CP_COMP_BUF_SIZE];
- int flags;
- int file_count;
- struct darshan_file_runtime* name_table[CP_HASH_SIZE];
- struct darshan_file_ref* handle_table[CP_HASH_SIZE];
- double wtime_offset;
- char* trailing_data;
+ void (*prepare_for_shutdown)(void);
+ void (*get_output_data)(void **, int);
};
-extern pthread_mutex_t cp_mutex;
-#define CP_LOCK() pthread_mutex_lock(&cp_mutex)
-#define CP_UNLOCK() pthread_mutex_unlock(&cp_mutex)
-
-#define CP_SET(__file, __counter, __value) do {\
- (__file)->log_file->counters[__counter] = __value; \
-} while(0)
-
-#define CP_F_SET(__file, __counter, __value) do {\
- (__file)->log_file->fcounters[__counter] = __value; \
-} while(0)
-
-#define CP_INC(__file, __counter, __value) do {\
- (__file)->log_file->counters[__counter] += __value; \
-} while(0)
-
-#define CP_F_INC(__file, __counter, __value) do {\
- (__file)->log_file->fcounters[__counter] += __value; \
-} while(0)
-
-#define CP_F_INC_NO_OVERLAP(__file, __tm1, __tm2, __last, __counter) do { \
- if(__tm1 > __last) \
- CP_F_INC(__file, __counter, (__tm2-__tm1)); \
- else \
- CP_F_INC(__file, __counter, (__tm2 - __last)); \
- if(__tm2 > __last) \
- __last = __tm2; \
-} while(0)
-
-#define CP_VALUE(__file, __counter) \
- ((__file)->log_file->counters[__counter])
-
-#define CP_F_VALUE(__file, __counter) \
- ((__file)->log_file->fcounters[__counter])
-
-#define CP_MAX(__file, __counter, __value) do {\
- if((__file)->log_file->counters[__counter] < __value) \
- { \
- (__file)->log_file->counters[__counter] = __value; \
- } \
-} while(0)
-
-#define CP_COUNTER_INC(__file, __value, __count, __maxflag, __validx, __cntidx) do {\
- int i; \
- int set = 0; \
- int64_t min = CP_VALUE(__file, __cntidx); \
- int min_index = 0; \
- if(__value == 0) break; \
- for(i=0; i<4; i++) { \
- /* increment bucket if already exists */ \
- if(CP_VALUE(__file, __validx + i) == __value) { \
- CP_INC(__file, __cntidx + i, (__count)); \
- set = 1; \
- break; \
- } \
- /* otherwise find the least frequently used bucket */ \
- else if(CP_VALUE(__file, __cntidx + i) < min) { \
- min = CP_VALUE(__file, __cntidx + i); \
- min_index = i; \
- } \
- } \
- if((!set && !__maxflag) || (!set && __maxflag && (__count) > min)) { \
- CP_INC(__file, __cntidx+min_index, (__count)); \
- CP_SET(__file, __validx+min_index, __value); \
- } \
-} while(0)
-
-#define CP_BUCKET_INC(__file, __counter_base, __value) do {\
- if(__value < 101) \
- (__file)->log_file->counters[__counter_base] += 1; \
- else if(__value < 1025) \
- (__file)->log_file->counters[__counter_base+1] += 1; \
- else if(__value < 10241) \
- (__file)->log_file->counters[__counter_base+2] += 1; \
- else if(__value < 102401) \
- (__file)->log_file->counters[__counter_base+3] += 1; \
- else if(__value < 1048577) \
- (__file)->log_file->counters[__counter_base+4] += 1; \
- else if(__value < 4194305) \
- (__file)->log_file->counters[__counter_base+5] += 1; \
- else if(__value < 10485761) \
- (__file)->log_file->counters[__counter_base+6] += 1; \
- else if(__value < 104857601) \
- (__file)->log_file->counters[__counter_base+7] += 1; \
- else if(__value < 1073741825) \
- (__file)->log_file->counters[__counter_base+8] += 1; \
- else \
- (__file)->log_file->counters[__counter_base+9] += 1; \
-} while(0)
-
-enum cp_counter_type
-{
- CP_COUNTER_ACCESS,
- CP_COUNTER_STRIDE
-};
-
-/* checking alignment according to this document:
- * http://publib.boulder.ibm.com/infocenter/compbgpl/v9v111/index.jsp?topic=/com.ibm.bg9111.doc/bgusing/data_alignment.htm
- */
-
-void darshan_finalize(struct darshan_job_runtime* job);
-void darshan_condense(void);
-void darshan_walk_file_accesses(struct darshan_job_runtime* final_job);
-double darshan_wtime(void);
-void darshan_mnt_id_from_path(const char* path, int64_t* device_id, int64_t* block_size);
-void darshan_mpi_initialize(int *argc, char ***argv);
-
-uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
-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);
+void darshan_core_register_module(
+ char *name,
+ struct darshan_module_funcs *funcs,
+ int *runtime_mem_limit);
-struct darshan_file_runtime* darshan_file_by_handle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type);
+void darshan_core_lookup_id(
+ void *name,
+ int len,
+ int printable_flag,
+ darshan_file_id *id);
-void darshan_file_closehandle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type);
+double darshan_core_wtime(void);
#endif /* __DARSHAN_H */
diff --git a/darshan-runtime/lib/darshan-core.c b/darshan-runtime/lib/darshan-core.c
index 8ba9f61..d8f170d 100644
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -14,32 +14,38 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/vfs.h>
+#include <pthread.h>
#include <mpi.h>
-#include "darshan.h"
+
#include "darshan-core.h"
extern char* __progname_full;
-static void darshan_initialize(int *argc, char ***argv);
-static void darshan_shutdown(void);
+static void darshan_core_initialize(int *argc, char ***argv);
+static void darshan_core_shutdown(void);
+
static char *darshan_get_exe_and_mounts(int rank);
static void darshan_get_exe_and_mounts_root(char* trailing_data, int space_left);
-static struct darshan_job_runtime *darshan_global_job = NULL;
-static int darshan_mem_alignment = 1;
+/* internal variables */
+static struct darshan_core_job_runtime *darshan_global_job = NULL;
+static pthread_mutex_t darshan_mutex = PTHREAD_MUTEX_INITIALIZER;
+
+#define DARSHAN_LOCK() pthread_mutex_lock(&darshan_mutex)
+#define DARSHAN_UNLOCK() pthread_mutex_unlock(&darshan_mutex)
-#define CP_MAX_MNTS 64
-#define CP_MAX_MNT_PATH 256
-#define CP_MAX_MNT_TYPE 32
+#define DARSHAN_MAX_MNTS 64
+#define DARSHAN_MAX_MNT_PATH 256
+#define DARSHAN_MAX_MNT_TYPE 32
struct mnt_data
{
int64_t hash;
int64_t block_size;
- char path[CP_MAX_MNT_PATH];
- char type[CP_MAX_MNT_TYPE];
+ char path[DARSHAN_MAX_MNT_PATH];
+ char type[DARSHAN_MAX_MNT_TYPE];
};
-static struct mnt_data mnt_data_array[CP_MAX_MNTS];
+static struct mnt_data mnt_data_array[DARSHAN_MAX_MNTS];
static int mnt_data_count = 0;
/* intercept MPI initialize and finalize to initialize darshan */
@@ -53,12 +59,12 @@ int MPI_Init(int *argc, char ***argv)
return(ret);
}
- darshan_initialize(argc, argv);
+ darshan_core_initialize(argc, argv);
return(ret);
}
-int MPI_Init_thread (int *argc, char ***argv, int required, int *provided)
+int MPI_Init_thread(int *argc, char ***argv, int required, int *provided)
{
int ret;
@@ -68,7 +74,7 @@ int MPI_Init_thread (int *argc, char ***argv, int required, int *provided)
return(ret);
}
- darshan_initialize(argc, argv);
+ darshan_core_initialize(argc, argv);
return(ret);
}
@@ -77,25 +83,22 @@ int MPI_Finalize(void)
{
int ret;
- darshan_shutdown();
+ darshan_core_shutdown();
ret = DARSHAN_MPI_CALL(PMPI_Finalize)();
return(ret);
}
-static void darshan_initialize(int *argc, char ***argv)
+static void darshan_core_initialize(int *argc, char ***argv)
{
int i;
int nprocs;
int rank;
int internal_timing_flag = 0;
double init_start, init_time, init_max;
- char *mem_align;
char* truncate_string = "<TRUNCATED>";
int truncate_offset;
int chars_left = 0;
- int ret;
- int tmpval;
DARSHAN_MPI_CALL(PMPI_Comm_size)(MPI_COMM_WORLD, &nprocs);
DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, &rank);
@@ -109,30 +112,6 @@ static void darshan_initialize(int *argc, char ***argv)
/* setup darshan runtime if darshan is enabled and hasn't been initialized already */
if (!getenv("DARSHAN_DISABLE") && !darshan_global_job)
{
- #if (__CP_MEM_ALIGNMENT < 1)
- #error Darshan must be configured with a positive value for --with-mem-align
- #endif
- mem_align = getenv("DARSHAN_MEMALIGN");
- if (mem_align)
- {
- ret = sscanf(mem_align, "%d", &tmpval);
- /* silently ignore if the env variable is set poorly */
- if(ret == 1 && tmpval > 0)
- {
- darshan_mem_alignment = tmpval;
- }
- }
- else
- {
- darshan_mem_alignment == __CP_MEM_ALIGNMENT;
- }
-
- /* avoid floating point errors on faulty input */
- if (darshan_mem_alignment < 1)
- {
- darshan_mem_alignment = 1;
- }
-
/* allocate structure to track darshan_global_job information */
darshan_global_job = malloc(sizeof(*darshan_global_job));
if (darshan_global_job)
@@ -144,19 +123,13 @@ static void darshan_initialize(int *argc, char ***argv)
darshan_global_job->flags |= CP_FLAG_NOTIMING;
}
- /* set up file records */
- for(i=0; i<CP_MAX_FILES; i++)
- {
- darshan_global_job->file_runtime_array[i].log_file =
- &darshan_global_job->file_array[i];
- }
-
strcpy(darshan_global_job->log_job.version_string, CP_VERSION);
darshan_global_job->log_job.magic_nr = CP_MAGIC_NR;
darshan_global_job->log_job.uid = getuid();
darshan_global_job->log_job.start_time = time(NULL);
darshan_global_job->log_job.nprocs = nprocs;
darshan_global_job->wtime_offset = DARSHAN_MPI_CALL(PMPI_Wtime)();
+ darshan_global_job->mod_list_head = NULL;
/* record exe and arguments */
for(i=0; i<(*argc); i++)
@@ -211,7 +184,7 @@ static void darshan_initialize(int *argc, char ***argv)
return;
}
-static void darshan_shutdown()
+static void darshan_core_shutdown()
{
int internal_timing_flag = 0;
@@ -244,9 +217,9 @@ static void add_entry(char* trailing_data, int* space_left, struct mntent *entry
struct statfs statfsbuf;
strncpy(mnt_data_array[mnt_data_count].path, entry->mnt_dir,
- CP_MAX_MNT_PATH-1);
+ DARSHAN_MAX_MNT_PATH-1);
strncpy(mnt_data_array[mnt_data_count].type, entry->mnt_type,
- CP_MAX_MNT_TYPE-1);
+ DARSHAN_MAX_MNT_TYPE-1);
mnt_data_array[mnt_data_count].hash =
darshan_hash((void*)mnt_data_array[mnt_data_count].path,
strlen(mnt_data_array[mnt_data_count].path), 0);
@@ -323,7 +296,7 @@ static void darshan_get_exe_and_mounts_root(char* trailing_data, int space_left)
if(!tab)
return;
/* loop through list of mounted file systems */
- while(mnt_data_count<CP_MAX_MNTS && (entry = getmntent(tab)) != NULL)
+ while(mnt_data_count<DARSHAN_MAX_MNTS && (entry = getmntent(tab)) != NULL)
{
/* filter out excluded fs types */
tmp_index = 0;
@@ -349,7 +322,7 @@ static void darshan_get_exe_and_mounts_root(char* trailing_data, int space_left)
if(!tab)
return;
/* loop through list of mounted file systems */
- while(mnt_data_count<CP_MAX_MNTS && (entry = getmntent(tab)) != NULL)
+ while(mnt_data_count<DARSHAN_MAX_MNTS && (entry = getmntent(tab)) != NULL)
{
if(strcmp(entry->mnt_type, "nfs") != 0)
continue;
@@ -407,9 +380,42 @@ void darshan_core_register_module(
struct darshan_module_funcs *funcs,
int *runtime_mem_limit)
{
- struct darshan_module mod;
+ struct darshan_core_module *tmp;
+ struct darshan_core_module *new_mod;
- printf("%s MODULE REGISTERED\n", name);
+ if (!darshan_global_job)
+ return;
+
+ DARSHAN_LOCK();
+ tmp = darshan_global_job->mod_list_head;
+ while(tmp)
+ {
+ /* silently return if this module is already registered */
+ if (strcmp(tmp->name, name) == 0)
+ {
+ DARSHAN_UNLOCK();
+ return;
+ }
+ tmp = tmp->next_mod;
+ }
+
+ /* allocate new module and add to the head of the linked list of darshan modules */
+ new_mod = malloc(sizeof(*new_mod));
+ if (!new_mod)
+ {
+ DARSHAN_UNLOCK();
+ return;
+ }
+
+ memset(new_mod, 0, sizeof(*new_mod));
+ strncpy(new_mod->name, name, DARSHAN_MOD_NAME_LEN);
+ new_mod->mod_funcs = *funcs;
+ new_mod->next_mod = darshan_global_job->mod_list_head;
+ darshan_global_job->mod_list_head = new_mod;
+ DARSHAN_UNLOCK();
+
+ /* TODO: something smarter than just 2 MiB per module */
+ *runtime_mem_limit = 2 * 1024 * 1024;
return;
}
@@ -424,6 +430,15 @@ void darshan_core_lookup_id(
return;
}
+double darshan_core_wtime()
+{
+ if(!darshan_global_job || darshan_global_job->flags & CP_FLAG_NOTIMING)
+ {
+ return(0);
+ }
+
+ return DARSHAN_MPI_CALL(PMPI_Wtime)();
+}
/*
* Local variables:
diff --git a/darshan-runtime/lib/darshan-posix.c b/darshan-runtime/lib/darshan-posix.c
index f25b850..381a8c4 100644
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -25,7 +25,6 @@
#include <pthread.h>
#include "darshan.h"
-#include "darshan-core.h"
#ifndef HAVE_OFF64_T
typedef int64_t off64_t;
@@ -83,9 +82,6 @@ DARSHAN_FORWARD_DECL(lio_listio64, int, (int mode, struct aiocb64 *const aiocb_l
DARSHAN_FORWARD_DECL(aio_return, ssize_t, (struct aiocb *aiocbp));
DARSHAN_FORWARD_DECL(aio_return64, ssize_t, (struct aiocb64 *aiocbp));
-pthread_mutex_t cp_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
-static struct stat64 cp_stat_buf;
-
/* struct to track information about aio operations in flight */
struct darshan_aio_tracker
{
@@ -109,24 +105,25 @@ static char* exclusions[] = {
NULL
};
-static int posix_mod_registered = 0;
-static struct darshan_module_funcs posix_mod_funcs =
-{
+static int darshan_mem_alignment = 1;
-};
-static int posix_runtime_mem_limit = 0;
-
-#define DARSHAN_REGISTER_POSIX_MOD() do{ \
- if (!posix_mod_registered) { \
- darshan_core_register_module("POSIX", &posix_mod_funcs, &posix_runtime_mem_limit); \
- posix_mod_registered = 1; \
- } \
-} while(0)
+static int posix_mod_initialized = 0;
+static pthread_mutex_t posix_mod_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
+static void posix_runtime_initialize(void);
static double posix_wtime(void);
+
+static void posix_prepare_for_shutdown(void);
+static void posix_get_output_data(void **buffer, int size);
+
+#define POSIX_LOCK() pthread_mutex_lock(&posix_mod_mutex)
+#define POSIX_UNLOCK() pthread_mutex_unlock(&posix_mod_mutex)
+
+#if 0
static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size, enum cp_counter_type type);
static void darshan_aio_tracker_add(int fd, void *aiocbp);
static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp);
+#endif
#if 0
#define CP_RECORD_WRITE(__ret, __fd, __count, __pwrite_flag, __pwrite_offset, __aligned, __stream_flag, __tm1, __tm2) do{ \
@@ -269,7 +266,6 @@ static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp)
#else
#define CP_STAT_FILE(_f, _p, _r) do { }while(0)
#endif
-#endif
#define CP_RECORD_OPEN(__ret, __path, __mode, __stream_flag, __tm1, __tm2) do { \
struct darshan_file_runtime* file; \
@@ -299,8 +295,8 @@ static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp)
CP_F_SET(file, CP_F_OPEN_TIMESTAMP, __tm1); \
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME); \
} while (0)
+#endif
-#if 0
int DARSHAN_DECL(close)(int fd)
{
struct darshan_file_runtime* file;
@@ -310,13 +306,14 @@ int DARSHAN_DECL(close)(int fd)
MAP_OR_FAIL(close);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_close(fd);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
- CP_LOCK();
+ POSIX_LOCK();
+ posix_runtime_initialize();
+
+#if 0
file = darshan_file_by_fd(tmp_fd);
if(file)
{
@@ -326,11 +323,14 @@ int DARSHAN_DECL(close)(int fd)
CP_F_INC_NO_OVERLAP(file, tm1, tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME);
darshan_file_close_fd(tmp_fd);
}
- CP_UNLOCK();
+#endif
+
+ POSIX_UNLOCK();
return(ret);
}
+#if 0
int DARSHAN_DECL(fclose)(FILE *fp)
{
struct darshan_file_runtime* file;
@@ -340,11 +340,9 @@ int DARSHAN_DECL(fclose)(FILE *fp)
MAP_OR_FAIL(fclose);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fclose(fp);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
file = darshan_file_by_fd(tmp_fd);
@@ -370,11 +368,9 @@ int DARSHAN_DECL(fsync)(int fd)
MAP_OR_FAIL(fsync);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fsync(fd);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0)
return(ret);
@@ -399,11 +395,9 @@ int DARSHAN_DECL(fdatasync)(int fd)
MAP_OR_FAIL(fdatasync);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fdatasync(fd);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0)
return(ret);
@@ -428,8 +422,6 @@ void* DARSHAN_DECL(mmap64)(void *addr, size_t length, int prot, int flags,
MAP_OR_FAIL(mmap64);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_mmap64(addr, length, prot, flags, fd, offset);
if(ret == MAP_FAILED)
return(ret);
@@ -454,8 +446,6 @@ void* DARSHAN_DECL(mmap)(void *addr, size_t length, int prot, int flags,
MAP_OR_FAIL(mmap);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_mmap(addr, length, prot, flags, fd, offset);
if(ret == MAP_FAILED)
return(ret);
@@ -478,11 +468,9 @@ int DARSHAN_DECL(creat)(const char* path, mode_t mode)
MAP_OR_FAIL(creat);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_creat(path, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_OPEN(ret, path, mode, 0, tm1, tm2);
@@ -498,11 +486,9 @@ int DARSHAN_DECL(creat64)(const char* path, mode_t mode)
MAP_OR_FAIL(creat64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_creat64(path, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_OPEN(ret, path, mode, 0, tm1, tm2);
@@ -519,8 +505,6 @@ int DARSHAN_DECL(open64)(const char* path, int flags, ...)
MAP_OR_FAIL(open64);
- DARSHAN_REGISTER_POSIX_MOD();
-
if (flags & O_CREAT)
{
va_list arg;
@@ -528,15 +512,15 @@ int DARSHAN_DECL(open64)(const char* path, int flags, ...)
mode = va_arg(arg, int);
va_end(arg);
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_open64(path, flags, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
}
else
{
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_open64(path, flags);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
}
CP_LOCK();
@@ -555,8 +539,6 @@ int DARSHAN_DECL(open)(const char *path, int flags, ...)
MAP_OR_FAIL(open);
- DARSHAN_REGISTER_POSIX_MOD();
-#if 0
if (flags & O_CREAT)
{
va_list arg;
@@ -564,21 +546,22 @@ int DARSHAN_DECL(open)(const char *path, int flags, ...)
mode = va_arg(arg, int);
va_end(arg);
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_open(path, flags, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
}
else
{
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_open(path, flags);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
}
- CP_LOCK();
- CP_RECORD_OPEN(ret, path, mode, 0, tm1, tm2);
- CP_UNLOCK();
-#endif
+ POSIX_LOCK();
+ posix_runtime_initialize();
+
+// POSIX_RECORD_OPEN(ret, path, mode, 0, tm1, tm2);
+ POSIX_UNLOCK();
return(ret);
}
@@ -592,11 +575,9 @@ FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
MAP_OR_FAIL(fopen64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fopen64(path, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret == 0)
fd = -1;
else
@@ -617,11 +598,9 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
MAP_OR_FAIL(fopen);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fopen(path, mode);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret == 0)
fd = -1;
else
@@ -641,11 +620,9 @@ int DARSHAN_DECL(__xstat64)(int vers, const char *path, struct stat64 *buf)
MAP_OR_FAIL(__xstat64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___xstat64(vers, path, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -663,11 +640,9 @@ int DARSHAN_DECL(__lxstat64)(int vers, const char *path, struct stat64 *buf)
MAP_OR_FAIL(__lxstat64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___lxstat64(vers, path, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -686,11 +661,9 @@ int DARSHAN_DECL(__fxstat64)(int vers, int fd, struct stat64 *buf)
MAP_OR_FAIL(__fxstat64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___fxstat64(vers, fd, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -717,11 +690,9 @@ int DARSHAN_DECL(__xstat)(int vers, const char *path, struct stat *buf)
MAP_OR_FAIL(__xstat);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___xstat(vers, path, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -739,11 +710,9 @@ int DARSHAN_DECL(__lxstat)(int vers, const char *path, struct stat *buf)
MAP_OR_FAIL(__lxstat);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___lxstat(vers, path, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -762,11 +731,9 @@ int DARSHAN_DECL(__fxstat)(int vers, int fd, struct stat *buf)
MAP_OR_FAIL(__fxstat);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real___fxstat(vers, fd, buf);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret < 0 || !S_ISREG(buf->st_mode))
return(ret);
@@ -793,14 +760,12 @@ ssize_t DARSHAN_DECL(pread64)(int fd, void *buf, size_t count, off64_t offset)
MAP_OR_FAIL(pread64);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_pread64(fd, buf, count, offset);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_READ(ret, fd, count, 1, offset, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -815,14 +780,12 @@ ssize_t DARSHAN_DECL(pread)(int fd, void *buf, size_t count, off_t offset)
MAP_OR_FAIL(pread);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_pread(fd, buf, count, offset);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_READ(ret, fd, count, 1, offset, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -838,14 +801,12 @@ ssize_t DARSHAN_DECL(pwrite)(int fd, const void *buf, size_t count, off_t offset
MAP_OR_FAIL(pwrite);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_pwrite(fd, buf, count, offset);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_WRITE(ret, fd, count, 1, offset, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -860,14 +821,12 @@ ssize_t DARSHAN_DECL(pwrite64)(int fd, const void *buf, size_t count, off64_t of
MAP_OR_FAIL(pwrite64);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_pwrite64(fd, buf, count, offset);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_WRITE(ret, fd, count, 1, offset, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -883,17 +842,15 @@ ssize_t DARSHAN_DECL(readv)(int fd, const struct iovec *iov, int iovcnt)
MAP_OR_FAIL(readv);
- DARSHAN_REGISTER_POSIX_MOD();
-
for(i=0; i<iovcnt; i++)
{
if(((unsigned long)iov[i].iov_base % darshan_mem_alignment) != 0)
aligned_flag = 0;
}
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_readv(fd, iov, iovcnt);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_READ(ret, fd, count, 0, 0, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -909,17 +866,15 @@ ssize_t DARSHAN_DECL(writev)(int fd, const struct iovec *iov, int iovcnt)
MAP_OR_FAIL(writev);
- DARSHAN_REGISTER_POSIX_MOD();
-
for(i=0; i<iovcnt; i++)
{
if(!((unsigned long)iov[i].iov_base % darshan_mem_alignment == 0))
aligned_flag = 0;
}
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_writev(fd, iov, iovcnt);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_WRITE(ret, fd, count, 0, 0, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -934,14 +889,12 @@ size_t DARSHAN_DECL(fread)(void *ptr, size_t size, size_t nmemb, FILE *stream)
MAP_OR_FAIL(fread);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)ptr % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fread(ptr, size, nmemb, stream);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
if(ret > 0)
CP_RECORD_READ(size*ret, fileno(stream), (size*nmemb), 0, 0, aligned_flag, 1, tm1, tm2);
@@ -959,14 +912,12 @@ ssize_t DARSHAN_DECL(read)(int fd, void *buf, size_t count)
MAP_OR_FAIL(read);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_read(fd, buf, count);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_READ(ret, fd, count, 0, 0, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -981,14 +932,12 @@ ssize_t DARSHAN_DECL(write)(int fd, const void *buf, size_t count)
MAP_OR_FAIL(write);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)buf % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_write(fd, buf, count);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
CP_RECORD_WRITE(ret, fd, count, 0, 0, aligned_flag, 0, tm1, tm2);
CP_UNLOCK();
@@ -1003,14 +952,12 @@ size_t DARSHAN_DECL(fwrite)(const void *ptr, size_t size, size_t nmemb, FILE *st
MAP_OR_FAIL(fwrite);
- DARSHAN_REGISTER_POSIX_MOD();
-
if((unsigned long)ptr % darshan_mem_alignment == 0)
aligned_flag = 1;
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fwrite(ptr, size, nmemb, stream);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
CP_LOCK();
if(ret > 0)
CP_RECORD_WRITE(size*ret, fileno(stream), (size*nmemb), 0, 0, aligned_flag, 1, tm1, tm2);
@@ -1028,11 +975,9 @@ off64_t DARSHAN_DECL(lseek64)(int fd, off64_t offset, int whence)
MAP_OR_FAIL(lseek64);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_lseek64(fd, offset, whence);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret >= 0)
{
CP_LOCK();
@@ -1056,11 +1001,9 @@ off_t DARSHAN_DECL(lseek)(int fd, off_t offset, int whence)
MAP_OR_FAIL(lseek);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_lseek(fd, offset, whence);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret >= 0)
{
CP_LOCK();
@@ -1085,10 +1028,8 @@ ssize_t DARSHAN_DECL(aio_return64)(struct aiocb64 *aiocbp)
MAP_OR_FAIL(aio_return64);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_return64(aiocbp);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
tmp = darshan_aio_tracker_del(aiocbp->aio_fildes, aiocbp);
if(tmp)
@@ -1122,10 +1063,8 @@ ssize_t DARSHAN_DECL(aio_return)(struct aiocb *aiocbp)
MAP_OR_FAIL(aio_return);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_return(aiocbp);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
tmp = darshan_aio_tracker_del(aiocbp->aio_fildes, aiocbp);
if(tmp)
@@ -1150,8 +1089,6 @@ int DARSHAN_DECL(lio_listio)(int mode, struct aiocb *const aiocb_list[],
MAP_OR_FAIL(lio_listio);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_lio_listio(mode, aiocb_list, nitems, sevp);
if(ret == 0)
{
@@ -1172,8 +1109,6 @@ int DARSHAN_DECL(lio_listio64)(int mode, struct aiocb64 *const aiocb_list[],
MAP_OR_FAIL(lio_listio);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_lio_listio64(mode, aiocb_list, nitems, sevp);
if(ret == 0)
{
@@ -1192,8 +1127,6 @@ int DARSHAN_DECL(aio_write64)(struct aiocb64 *aiocbp)
MAP_OR_FAIL(aio_write64);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_write64(aiocbp);
if(ret == 0)
darshan_aio_tracker_add(aiocbp->aio_fildes, aiocbp);
@@ -1207,8 +1140,6 @@ int DARSHAN_DECL(aio_write)(struct aiocb *aiocbp)
MAP_OR_FAIL(aio_write);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_write(aiocbp);
if(ret == 0)
darshan_aio_tracker_add(aiocbp->aio_fildes, aiocbp);
@@ -1222,8 +1153,6 @@ int DARSHAN_DECL(aio_read64)(struct aiocb64 *aiocbp)
MAP_OR_FAIL(aio_read64);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_read64(aiocbp);
if(ret == 0)
darshan_aio_tracker_add(aiocbp->aio_fildes, aiocbp);
@@ -1237,8 +1166,6 @@ int DARSHAN_DECL(aio_read)(struct aiocb *aiocbp)
MAP_OR_FAIL(aio_read);
- DARSHAN_REGISTER_POSIX_MOD();
-
ret = __real_aio_read(aiocbp);
if(ret == 0)
darshan_aio_tracker_add(aiocbp->aio_fildes, aiocbp);
@@ -1254,11 +1181,9 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
MAP_OR_FAIL(fseek);
- DARSHAN_REGISTER_POSIX_MOD();
-
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
ret = __real_fseek(stream, offset, whence);
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
if(ret >= 0)
{
CP_LOCK();
@@ -1275,82 +1200,68 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
}
#endif
-static int access_comparison(const void* a_p, const void* b_p)
+static void posix_runtime_initialize()
{
- const struct cp_access_counter* a = a_p;
- const struct cp_access_counter* b = b_p;
-
- if(a->size < b->size)
- return(-1);
- if(a->size > b->size)
- return(1);
- return(0);
-}
+ char *alignstr;
+ int tmpval;
+ int ret;
+ int posix_mod_mem_limit = 0;
+ struct darshan_module_funcs posix_mod_funcs =
+ {
+ .prepare_for_shutdown = &posix_prepare_for_shutdown,
+ .get_output_data = &posix_get_output_data
+ };
-/* cp_access_counter()
- *
- * records the occurance of a particular access size for a file,
- * current implementation uses glibc red black tree
- */
-static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size, enum cp_counter_type type)
-{
- struct cp_access_counter* counter;
- struct cp_access_counter* found;
- void* tmp;
- void** root;
- int* count;
- struct cp_access_counter tmp_counter;
-
- /* don't count sizes or strides of 0 */
- if(size == 0)
+ if (posix_mod_initialized)
return;
-
- switch(type)
+
+ /* set the memory alignment according to config or environment variables */
+ #if (__CP_MEM_ALIGNMENT < 1)
+ #error Darshan must be configured with a positive value for --with-mem-align
+ #endif
+ alignstr = getenv("DARSHAN_MEMALIGN");
+ if (alignstr)
{
- case CP_COUNTER_ACCESS:
- root = &file->access_root;
- count = &file->access_count;
- break;
- case CP_COUNTER_STRIDE:
- root = &file->stride_root;
- count = &file->stride_count;
- break;
- default:
- return;
+ ret = sscanf(alignstr, "%d", &tmpval);
+ /* silently ignore if the env variable is set poorly */
+ if(ret == 1 && tmpval > 0)
+ {
+ darshan_mem_alignment = tmpval;
+ }
}
-
- /* check to see if this size is already recorded */
- tmp_counter.size = size;
- tmp_counter.freq = 1;
- tmp = tfind(&tmp_counter, root, access_comparison);
- if(tmp)
+ else
{
- found = *(struct cp_access_counter**)tmp;
- found->freq++;
- return;
+ darshan_mem_alignment = __CP_MEM_ALIGNMENT;
}
- /* we can add a new one as long as we haven't hit the limit */
- if(*count < CP_MAX_ACCESS_COUNT_RUNTIME)
+ /* avoid floating point errors on faulty input */
+ if (darshan_mem_alignment < 1)
{
- counter = malloc(sizeof(*counter));
- if(!counter)
- {
- return;
- }
+ darshan_mem_alignment = 1;
+ }
- counter->size = size;
- counter->freq = 1;
+ /* register the posix module with darshan core */
+ darshan_core_register_module("POSIX", &posix_mod_funcs, &posix_mod_mem_limit);
- tmp = tsearch(counter, root, access_comparison);
- found = *(struct cp_access_counter**)tmp;
- /* if we get a new answer out here we are in trouble; this was
- * already checked with the tfind()
- */
- assert(found == counter);
+ /* TODO: allocate memory for saving i/o stats */
- (*count)++;
- }
+ posix_mod_initialized = 1;
+ return;
+}
+
+static double posix_wtime()
+{
+ return DARSHAN_MPI_CALL(PMPI_Wtime)();
+}
+
+static void posix_prepare_for_shutdown()
+{
+
+ return;
+}
+
+static void posix_get_output_data(void **buffer, int size)
+{
return;
}
@@ -1571,7 +1482,7 @@ void darshan_search_bench(int argc, char** argv, int iters)
CP_RECORD_OPEN(fd_array[i], path, 777, 0, 0, 0);
}
- tm1 = darshan_wtime();
+ tm1 = darshan_core_wtime();
for(i=0; i<iters; i++)
{
if(j==0)
@@ -1583,7 +1494,7 @@ void darshan_search_bench(int argc, char** argv, int iters)
CP_RECORD_WRITE(size_array[0], fd_array[i%nfiles], size_array[0], 0, 0, 1, 0, 1, 2);
}
}
- tm2 = darshan_wtime();
+ tm2 = darshan_core_wtime();
/* printf("#<iters>\t<numfiles>\t<numsizes>\t<total time>\t<per iter>\n"); */
printf("%d\t%d\t%d\t%f\t%.12f\n", iters, nfiles, (j==0?CP_MAX_ACCESS_COUNT_RUNTIME:1), tm2-tm1, (tm2-tm1)/iters);
@@ -1598,99 +1509,6 @@ void darshan_search_bench(int argc, char** argv, int iters)
}
#endif
-static double posix_wtime(void)
-{
- return DARSHAN_MPI_CALL(PMPI_Wtime)();
-}
-
-#if 0
-double darshan_wtime(void)
-{
- if(!darshan_global_job || darshan_global_job->flags & CP_FLAG_NOTIMING)
- {
- return(0);
- }
-
- return(posix_wtime());
-}
-
-/* adds a tracker for the given aio operation */
-static void darshan_aio_tracker_add(int fd, void *aiocbp)
-{
- struct darshan_aio_tracker* tracker;
- struct darshan_file_runtime* file;
-
- CP_LOCK();
- file = darshan_file_by_fd(fd);
- if(file)
- {
- tracker = malloc(sizeof(*tracker));
- if(tracker)
- {
- tracker->tm1 = darshan_wtime();
- tracker->aiocbp = aiocbp;
- tracker->next = NULL;
- if(file->aio_list_tail)
- {
- file->aio_list_tail->next = tracker;
- file->aio_list_tail = tracker;
- }
- else
- {
- file->aio_list_head = file->aio_list_tail = tracker;
- }
- }
- }
- CP_UNLOCK();
-
- return;
-}
-
-/* finds the tracker structure for a given aio operation, removes it from
- * the linked list for the darshan_file structure, and returns a pointer.
- *
- * returns NULL if aio operation not found
- */
-static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp)
-{
- struct darshan_aio_tracker *tmp=NULL, *prev;
- struct darshan_file_runtime* file;
-
- CP_LOCK();
- file = darshan_file_by_fd(fd);
- if(file)
- {
- /* is there a tracker struct for this operation? */
- tmp = file->aio_list_head;
- prev = NULL;
- while(tmp)
- {
- if(tmp->aiocbp == aiocbp)
- {
- if(prev)
- prev->next = tmp->next;
- else
- file->aio_list_head = tmp->next;
-
- if(tmp == file->aio_list_tail)
- file->aio_list_tail = prev;
-
- break;
- }
- else
- {
- prev = tmp;
- tmp = tmp->next;
- }
- }
- }
-
- CP_UNLOCK();
-
- return(tmp);
-}
-#endif
-
/*
* Local variables:
* c-indent-level: 4
hooks/post-receive
--
More information about the Darshan-commits
mailing list