[Darshan-commits] [Darshan] branch, dev-modular, updated. 66a491402851fa417e01c8e571ddf68fe06ee5e9
Service Account
git at mcs.anl.gov
Mon Sep 29 10:29:31 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 66a491402851fa417e01c8e571ddf68fe06ee5e9 (commit)
from e60076aee7f5ebe7d7a0303c880a6cb61c8e5fcd (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 66a491402851fa417e01c8e571ddf68fe06ee5e9
Author: Shane Snyder <ssnyder at mcs.anl.gov>
Date: Mon Sep 29 10:20:40 2014 -0500
First commit for modularing darshan runtime
New darshan-core source files which intercept MPI init/finalize,
initialize darshan job information, and first attempt at a POSIX
module.
-----------------------------------------------------------------------
Summary of changes:
darshan-runtime/Makefile.in | 118 +++---
darshan-runtime/darshan-config.in | 7 +-
darshan-runtime/darshan-core.h | 40 ++
darshan-runtime/darshan.h | 5 -
darshan-runtime/lib/darshan-core.c | 435 +++++++++++++++++++++
darshan-runtime/lib/darshan-posix.c | 725 +++++------------------------------
6 files changed, 646 insertions(+), 684 deletions(-)
create mode 100644 darshan-runtime/darshan-core.h
create mode 100644 darshan-runtime/lib/darshan-core.c
Diff of changes:
diff --git a/darshan-runtime/Makefile.in b/darshan-runtime/Makefile.in
index 36b4a52..a882bab 100644
--- a/darshan-runtime/Makefile.in
+++ b/darshan-runtime/Makefile.in
@@ -1,4 +1,5 @@
-all: lib/libdarshan-posix.a lib/libdarshan-mpi-io.a lib/libdarshan-stubs.a
+all: lib/libdarshan-core.a
+#all: lib/libdarshan-posix.a lib/libdarshan-mpi-io.a lib/libdarshan-stubs.a
DESTDIR =
srcdir = @srcdir@
@@ -18,14 +19,14 @@ DISABLE_LDPRELOAD = @DISABLE_LDPRELOAD@
DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_VERSION = @DARSHAN_VERSION@
-ifndef DISABLE_LDPRELOAD
-all: lib/libdarshan.so
-endif
+#ifndef DISABLE_LDPRELOAD
+#all: lib/libdarshan.so
+#endif
VPATH = $(srcdir)
CFLAGS = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I ../ -I $(srcdir) -I$(srcdir)/../ @CFLAGS@ @CPPFLAGS@ -D_LARGEFILE64_SOURCE
-
+#
CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir) -I$(srcdir)/../ @CFLAGS@ @CPPFLAGS@ -D_LARGEFILE64_SOURCE -shared -fpic -DPIC -DDARSHAN_PRELOAD
LIBS = -lz @LIBBZ2@
@@ -33,89 +34,96 @@ LIBS = -lz @LIBBZ2@
lib::
@mkdir -p $@
-lib/darshan-mpi-io.o: lib/darshan-mpi-io.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
+lib/darshan-core.o: lib/darshan-core.c darshan-core.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-mpi-io.po: lib/darshan-mpi-io.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/darshan-mpi-io.o: lib/darshan-mpi-io.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-mpi-init-finalize.o: lib/darshan-mpi-init-finalize.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS) -c $< -o $@
+#lib/darshan-mpi-io.po: lib/darshan-mpi-io.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
-lib/darshan-mpi-init-finalize.po: lib/darshan-mpi-init-finalize.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/darshan-mpi-init-finalize.o: lib/darshan-mpi-init-finalize.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-pnetcdf-stubs.o: lib/darshan-pnetcdf-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS) -c $< -o $@
+#lib/darshan-mpi-init-finalize.po: lib/darshan-mpi-init-finalize.c darshan.h darshan-dynamic.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
-lib/darshan-pnetcdf.o: lib/darshan-pnetcdf.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS) -c $< -o $@
+#lib/darshan-pnetcdf-stubs.o: lib/darshan-pnetcdf-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-pnetcdf.po: lib/darshan-pnetcdf.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/darshan-pnetcdf.o: lib/darshan-pnetcdf.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-hdf5.o: lib/darshan-hdf5.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS) -c $< -o $@
+#lib/darshan-pnetcdf.po: lib/darshan-pnetcdf.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
-lib/darshan-hdf5-stubs.o: lib/darshan-hdf5-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS) -c $< -o $@
+#lib/darshan-hdf5.o: lib/darshan-hdf5.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
+
+#lib/darshan-hdf5-stubs.o: lib/darshan-hdf5-stubs.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-hdf5.po: lib/darshan-hdf5.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/darshan-hdf5.po: lib/darshan-hdf5.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-posix.o: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@
-lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup3.o: lib/lookup3.c
$(CC) $(CFLAGS) -c $< -o $@
-lib/lookup3.po: lib/lookup3.c
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/lookup3.po: lib/lookup3.c
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup8.o: lib/lookup8.c
$(CC) $(CFLAGS) -c $< -o $@
-lib/lookup8.po: lib/lookup8.c
- $(CC) $(CFLAGS_SHARED) -c $< -o $@
+#lib/lookup8.po: lib/lookup8.c
+# $(CC) $(CFLAGS_SHARED) -c $< -o $@
-%.i: %.c
- $(CC) -E $(CFLAGS) -c $< -o $@
+#%.i: %.c
+# $(CC) -E $(CFLAGS) -c $< -o $@
-lib/libdarshan-mpi-io.a: lib/darshan-mpi-io.o lib/darshan-mpi-init-finalize.o lib/darshan-pnetcdf.o lib/darshan-hdf5.o
+lib/libdarshan-core.a: lib/darshan-core.o lib/lookup3.o lib/lookup8.o lib/darshan-posix.o
ar rcs $@ $^
-lib/libdarshan-stubs.a: lib/darshan-pnetcdf-stubs.o lib/darshan-hdf5-stubs.o
- ar rcs $@ $^
+#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
- ar rcs $@ $^
+#lib/libdarshan-stubs.a: lib/darshan-pnetcdf-stubs.o lib/darshan-hdf5-stubs.o
+# ar rcs $@ $^
+
+#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
- $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $@ $^ -lpthread -lrt -lz -ldl
+#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) -o $@ $^ -lpthread -lrt -lz -ldl
install:: all
install -d $(libdir)
- install -m 755 lib/libdarshan-posix.a $(libdir)
- install -m 755 lib/libdarshan-mpi-io.a $(libdir)
- install -m 755 lib/libdarshan-stubs.a $(libdir)
-ifndef DISABLE_LDPRELOAD
- install -m 755 lib/libdarshan.so $(libdir)
-endif
+ install -m 755 lib/libdarshan-core.a $(libdir)
+# install -m 755 lib/libdarshan-posix.a $(libdir)
+# install -m 755 lib/libdarshan-mpi-io.a $(libdir)
+# install -m 755 lib/libdarshan-stubs.a $(libdir)
+#ifndef DISABLE_LDPRELOAD
+# install -m 755 lib/libdarshan.so $(libdir)
+#endif
install -d $(bindir)
- install -m 755 darshan-mk-log-dirs.pl $(bindir)
+# install -m 755 darshan-mk-log-dirs.pl $(bindir)
install -m 755 darshan-gen-cc.pl $(bindir)
- install -m 755 darshan-gen-cxx.pl $(bindir)
- install -m 755 darshan-gen-fortran.pl $(bindir)
- install -m 755 darshan-config $(bindir)
- install -d $(datarootdir)/craype-1.x/modulefiles/darshan
- install -m 755 share/craype-1.x/darshan-module $(datarootdir)/craype-1.x/modulefiles/darshan/$(DARSHAN_VERSION)
- install -d $(datarootdir)/craype-2.x/modulefiles/darshan
- install -m 755 share/craype-2.x/darshan-module $(datarootdir)/craype-2.x/modulefiles/darshan/$(DARSHAN_VERSION)
- install -d $(libdir)/pkgconfig
- install -m 644 lib/pkgconfig/darshan-runtime.pc $(libdir)/pkgconfig/darshan-runtime.pc
+# install -m 755 darshan-gen-cxx.pl $(bindir)
+# install -m 755 darshan-gen-fortran.pl $(bindir)
+# install -m 755 darshan-config $(bindir)
+# install -d $(datarootdir)/craype-1.x/modulefiles/darshan
+# install -m 755 share/craype-1.x/darshan-module $(datarootdir)/craype-1.x/modulefiles/darshan/$(DARSHAN_VERSION)
+# install -d $(datarootdir)/craype-2.x/modulefiles/darshan
+# install -m 755 share/craype-2.x/darshan-module $(datarootdir)/craype-2.x/modulefiles/darshan/$(DARSHAN_VERSION)
+# install -d $(libdir)/pkgconfig
+# install -m 644 lib/pkgconfig/darshan-runtime.pc $(libdir)/pkgconfig/darshan-runtime.pc
clean::
rm -f *.o *.a lib/*.o lib/*.po lib/*.a lib/*.so
diff --git a/darshan-runtime/darshan-config.in b/darshan-runtime/darshan-config.in
index f8429a1..0227b45 100755
--- a/darshan-runtime/darshan-config.in
+++ b/darshan-runtime/darshan-config.in
@@ -10,9 +10,10 @@ DARSHAN_LD_FLAGS="@LDFLAGS@"
# final one is necessary to give the linker a change to resolve indirect
# dependencies on PnetCDF and HDF5 symbols (if the app used a library which
# in turn used one of those HLLs).
-PRE_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan-mpi-io -lz $CP_WRAPPERS"
-POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -ldarshan-posix -ldarshan-mpi-io -lz -lrt -lpthread"
-
+PRE_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan-core -lz $CP_WRAPPERS"
+POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -ldarshan-core -lz -lrt -lpthread"
+#PRE_LD_FLAGS="-L$DARSHAN_LIB_PATH $DARSHAN_LD_FLAGS -ldarshan-mpi-io -lz $CP_WRAPPERS"
+#POST_LD_FLAGS="-L$DARSHAN_LIB_PATH -ldarshan-posix -ldarshan-mpi-io -lz -lrt -lpthread"
usage="\
Usage: darshan-config [--pre-ld-flags] [--post-ld-flags]"
diff --git a/darshan-runtime/darshan-core.h b/darshan-runtime/darshan-core.h
new file mode 100644
index 0000000..adc1a4f
--- /dev/null
+++ b/darshan-runtime/darshan-core.h
@@ -0,0 +1,40 @@
+/*
+ * (C) 2014 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#ifndef __DARSHAN_CORE_H
+#define __DARSHAN_CORE_H
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <stdint.h>
+
+#define DARSHAN_MPI_CALL(func) func
+
+typedef uint64_t darshan_file_id;
+
+struct darshan_module_funcs
+{
+ void (*prepare_for_shutdown)(void);
+ void (*get_output_data)(void **, int);
+};
+
+struct darshan_module
+{
+ char *name;
+ struct darshan_module_funcs mod_funcs;
+};
+
+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);
+
+#endif /* __DARSHAN_CORE_H */
diff --git a/darshan-runtime/darshan.h b/darshan-runtime/darshan.h
index 803e3d4..ad6a421 100644
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -225,16 +225,11 @@ enum cp_counter_type
* http://publib.boulder.ibm.com/infocenter/compbgpl/v9v111/index.jsp?topic=/com.ibm.bg9111.doc/bgusing/data_alignment.htm
*/
-extern struct darshan_job_runtime* darshan_global_job;
-
-void darshan_initialize(int argc, char** argv, int nprocs, int rank);
void darshan_finalize(struct darshan_job_runtime* job);
void darshan_condense(void);
-void darshan_shutdown(int timing_flag);
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);
-char* darshan_get_exe_and_mounts(struct darshan_job_runtime* final_job);
void darshan_mpi_initialize(int *argc, char ***argv);
uint32_t darshan_hashlittle(const void *key, size_t length, uint32_t initval);
diff --git a/darshan-runtime/lib/darshan-core.c b/darshan-runtime/lib/darshan-core.c
new file mode 100644
index 0000000..8ba9f61
--- /dev/null
+++ b/darshan-runtime/lib/darshan-core.c
@@ -0,0 +1,435 @@
+/*
+ * (C) 2009 by Argonne National Laboratory.
+ * See COPYRIGHT in top-level directory.
+ */
+
+#include "darshan-runtime-config.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef HAVE_MNTENT_H
+#include <mntent.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/vfs.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 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;
+
+#define CP_MAX_MNTS 64
+#define CP_MAX_MNT_PATH 256
+#define CP_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];
+};
+static struct mnt_data mnt_data_array[CP_MAX_MNTS];
+static int mnt_data_count = 0;
+
+/* intercept MPI initialize and finalize to initialize darshan */
+int MPI_Init(int *argc, char ***argv)
+{
+ int ret;
+
+ ret = DARSHAN_MPI_CALL(PMPI_Init)(argc, argv);
+ if(ret != MPI_SUCCESS)
+ {
+ return(ret);
+ }
+
+ darshan_initialize(argc, argv);
+
+ return(ret);
+}
+
+int MPI_Init_thread (int *argc, char ***argv, int required, int *provided)
+{
+ int ret;
+
+ ret = DARSHAN_MPI_CALL(PMPI_Init_thread)(argc, argv, required, provided);
+ if (ret != MPI_SUCCESS)
+ {
+ return(ret);
+ }
+
+ darshan_initialize(argc, argv);
+
+ return(ret);
+}
+
+int MPI_Finalize(void)
+{
+ int ret;
+
+ darshan_shutdown();
+
+ ret = DARSHAN_MPI_CALL(PMPI_Finalize)();
+ return(ret);
+}
+
+static void darshan_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);
+
+ if(getenv("DARSHAN_INTERNAL_TIMING"))
+ internal_timing_flag = 1;
+
+ if (internal_timing_flag)
+ init_start = DARSHAN_MPI_CALL(PMPI_Wtime)();
+
+ /* 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)
+ {
+ memset(darshan_global_job, 0, sizeof(*darshan_global_job));
+
+ if (getenv("DARSHAN_DISABLE_TIMING"))
+ {
+ 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)();
+
+ /* record exe and arguments */
+ for(i=0; i<(*argc); i++)
+ {
+ chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
+ strncat(darshan_global_job->exe, *(argv[i]), chars_left);
+ if(i < ((*argc)-1))
+ {
+ chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
+ strncat(darshan_global_job->exe, " ", chars_left);
+ }
+ }
+
+ /* if we don't see any arguments, then use glibc symbol to get
+ * program name at least (this happens in fortran)
+ */
+ if(argc == 0)
+ {
+ chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
+ strncat(darshan_global_job->exe, __progname_full, chars_left);
+ chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
+ strncat(darshan_global_job->exe, " <unknown args>", chars_left);
+ }
+
+ if(chars_left == 0)
+ {
+ /* we ran out of room; mark that string was truncated */
+ truncate_offset = CP_EXE_LEN - strlen(truncate_string);
+ sprintf(&darshan_global_job->exe[truncate_offset], "%s",
+ truncate_string);
+ }
+
+ /* collect information about command line and
+ * mounted file systems
+ */
+ darshan_global_job->trailing_data = darshan_get_exe_and_mounts(rank);
+ }
+ }
+
+ if(internal_timing_flag)
+ {
+ init_time = DARSHAN_MPI_CALL(PMPI_Wtime)() - init_start;
+ DARSHAN_MPI_CALL(PMPI_Reduce)(&init_time, &init_max, 1,
+ MPI_DOUBLE, MPI_MAX, 0, MPI_COMM_WORLD);
+ if(rank == 0)
+ {
+ printf("#darshan:<op>\t<nprocs>\t<time>\n");
+ printf("darshan:init\t%d\t%f\n", nprocs, init_max);
+ }
+ }
+
+ return;
+}
+
+static void darshan_shutdown()
+{
+ int internal_timing_flag = 0;
+
+ if(getenv("DARSHAN_INTERNAL_TIMING"))
+ internal_timing_flag = 1;
+
+ printf("darshan SHUTDOWN\n");
+
+ return;
+}
+
+static int mnt_data_cmp(const void* a, const void* b)
+{
+ const struct mnt_data *d_a = (const struct mnt_data*)a;
+ const struct mnt_data *d_b = (const struct mnt_data*)b;
+
+ if(strlen(d_a->path) > strlen(d_b->path))
+ return(-1);
+ else if(strlen(d_a->path) < strlen(d_b->path))
+ return(1);
+ else
+ return(0);
+}
+
+/* adds an entry to table of mounted file systems */
+static void add_entry(char* trailing_data, int* space_left, struct mntent *entry)
+{
+ int ret;
+ char tmp_mnt[256];
+ struct statfs statfsbuf;
+
+ strncpy(mnt_data_array[mnt_data_count].path, entry->mnt_dir,
+ CP_MAX_MNT_PATH-1);
+ strncpy(mnt_data_array[mnt_data_count].type, entry->mnt_type,
+ CP_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);
+ /* NOTE: we now try to detect the preferred block size for each file
+ * system using fstatfs(). On Lustre we assume a size of 1 MiB
+ * because fstatfs() reports 4 KiB.
+ */
+#ifndef LL_SUPER_MAGIC
+#define LL_SUPER_MAGIC 0x0BD00BD0
+#endif
+ ret = statfs(entry->mnt_dir, &statfsbuf);
+ if(ret == 0 && statfsbuf.f_type != LL_SUPER_MAGIC)
+ mnt_data_array[mnt_data_count].block_size = statfsbuf.f_bsize;
+ else if(ret == 0 && statfsbuf.f_type == LL_SUPER_MAGIC)
+ mnt_data_array[mnt_data_count].block_size = 1024*1024;
+ else
+ mnt_data_array[mnt_data_count].block_size = 4096;
+
+ /* store mount information for use in header of darshan log */
+ ret = snprintf(tmp_mnt, 256, "\n%" PRId64 "\t%s\t%s",
+ mnt_data_array[mnt_data_count].hash,
+ entry->mnt_type, entry->mnt_dir);
+ if(ret < 256 && strlen(tmp_mnt) <= (*space_left))
+ {
+ strcat(trailing_data, tmp_mnt);
+ (*space_left) -= strlen(tmp_mnt);
+ }
+
+ mnt_data_count++;
+ return;
+}
+
+/* darshan_get_exe_and_mounts_root()
+ *
+ * collects command line and list of mounted file systems into a string that
+ * will be stored with the job header
+ */
+static void darshan_get_exe_and_mounts_root(char* trailing_data, int space_left)
+{
+ FILE* tab;
+ struct mntent *entry;
+ char* exclude;
+ int tmp_index = 0;
+ int skip = 0;
+
+ /* skip these fs types */
+ static char* fs_exclusions[] = {
+ "tmpfs",
+ "proc",
+ "sysfs",
+ "devpts",
+ "binfmt_misc",
+ "fusectl",
+ "debugfs",
+ "securityfs",
+ "nfsd",
+ "none",
+ "rpc_pipefs",
+ "hugetlbfs",
+ "cgroup",
+ NULL
+ };
+
+ /* length of exe has already been safety checked in darshan-posix.c */
+ strcat(trailing_data, darshan_global_job->exe);
+ space_left = CP_EXE_LEN - strlen(trailing_data);
+
+ /* we make two passes through mounted file systems; in the first pass we
+ * grab any non-nfs mount points, then on the second pass we grab nfs
+ * mount points
+ */
+
+ tab = setmntent("/etc/mtab", "r");
+ if(!tab)
+ return;
+ /* loop through list of mounted file systems */
+ while(mnt_data_count<CP_MAX_MNTS && (entry = getmntent(tab)) != NULL)
+ {
+ /* filter out excluded fs types */
+ tmp_index = 0;
+ skip = 0;
+ while((exclude = fs_exclusions[tmp_index]))
+ {
+ if(!(strcmp(exclude, entry->mnt_type)))
+ {
+ skip =1;
+ break;
+ }
+ tmp_index++;
+ }
+
+ if(skip || (strcmp(entry->mnt_type, "nfs") == 0))
+ continue;
+
+ add_entry(trailing_data, &space_left, entry);
+ }
+ endmntent(tab);
+
+ tab = setmntent("/etc/mtab", "r");
+ if(!tab)
+ return;
+ /* loop through list of mounted file systems */
+ while(mnt_data_count<CP_MAX_MNTS && (entry = getmntent(tab)) != NULL)
+ {
+ if(strcmp(entry->mnt_type, "nfs") != 0)
+ continue;
+
+ add_entry(trailing_data, &space_left, entry);
+ }
+ endmntent(tab);
+
+ /* Sort mount points in order of longest path to shortest path. This is
+ * necessary so that if we try to match file paths to mount points later
+ * we don't match on "/" every time.
+ */
+ qsort(mnt_data_array, mnt_data_count, sizeof(mnt_data_array[0]), mnt_data_cmp);
+ return;
+}
+
+/* darshan_get_exe_and_mounts()
+ *
+ * collects command line and list of mounted file systems into a string that
+ * will be stored with the job header
+ */
+static char *darshan_get_exe_and_mounts(int rank)
+{
+ char* trailing_data;
+ int space_left;
+
+ space_left = CP_EXE_LEN + 1;
+ trailing_data = malloc(space_left);
+ if(!trailing_data)
+ {
+ return(NULL);
+ }
+ memset(trailing_data, 0, space_left);
+
+ if(rank == 0)
+ {
+ darshan_get_exe_and_mounts_root(trailing_data, space_left);
+ }
+
+ /* broadcast trailing data to all nodes */
+ DARSHAN_MPI_CALL(PMPI_Bcast)(trailing_data, space_left, MPI_CHAR, 0,
+ MPI_COMM_WORLD);
+ /* broadcast mount count to all nodes */
+ DARSHAN_MPI_CALL(PMPI_Bcast)(&mnt_data_count, 1, MPI_INT, 0,
+ MPI_COMM_WORLD);
+ /* broadcast mount data to all nodes */
+ DARSHAN_MPI_CALL(PMPI_Bcast)(mnt_data_array,
+ mnt_data_count*sizeof(mnt_data_array[0]), MPI_BYTE, 0, MPI_COMM_WORLD);
+
+ return(trailing_data);
+}
+
+void darshan_core_register_module(
+ char *name,
+ struct darshan_module_funcs *funcs,
+ int *runtime_mem_limit)
+{
+ struct darshan_module mod;
+
+ printf("%s MODULE REGISTERED\n", name);
+
+ return;
+}
+
+void darshan_core_lookup_id(
+ void *name,
+ int len,
+ int printable_flag,
+ darshan_file_id *id)
+{
+
+ return;
+}
+
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
diff --git a/darshan-runtime/lib/darshan-posix.c b/darshan-runtime/lib/darshan-posix.c
index 82a8ce0..f25b850 100644
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -25,6 +25,7 @@
#include <pthread.h>
#include "darshan.h"
+#include "darshan-core.h"
#ifndef HAVE_OFF64_T
typedef int64_t off64_t;
@@ -33,35 +34,6 @@ typedef int64_t off64_t;
#define aiocb64 aiocb
#endif
-extern char* __progname_full;
-
-#ifdef DARSHAN_PRELOAD
-#define __USE_GNU
-#include <dlfcn.h>
-#include <stdlib.h>
-
-#define DARSHAN_FORWARD_DECL(name,ret,args) \
- ret (*__real_ ## name)args = NULL;
-
-#define DARSHAN_DECL(__name) __name
-
-#define DARSHAN_MPI_CALL(func) __real_ ## func
-
-#define MAP_OR_FAIL(func) \
- if (!(__real_ ## func)) \
- { \
- __real_ ## func = dlsym(RTLD_NEXT, #func); \
- if(!(__real_ ## func)) { \
- fprintf(stderr, "Darshan failed to map symbol: %s\n", #func); \
- exit(1); \
- } \
- }
-
-
-extern double (*__real_PMPI_Wtime)(void);
-
-#else
-
#define DARSHAN_FORWARD_DECL(name,ret,args) \
extern ret __real_ ## name args;
@@ -71,8 +43,6 @@ extern double (*__real_PMPI_Wtime)(void);
#define DARSHAN_MPI_CALL(func) func
-#endif
-
DARSHAN_FORWARD_DECL(creat, int, (const char* path, mode_t mode));
DARSHAN_FORWARD_DECL(creat64, int, (const char* path, mode_t mode));
DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
@@ -85,8 +55,7 @@ DARSHAN_FORWARD_DECL(lseek64, off64_t, (int fd, off64_t offset, int whence));
DARSHAN_FORWARD_DECL(pread, ssize_t, (int fd, void *buf, size_t count, off_t offset));
DARSHAN_FORWARD_DECL(pread64, ssize_t, (int fd, void *buf, size_t count, off64_t offset));
DARSHAN_FORWARD_DECL(pwrite, ssize_t, (int fd, const void *buf, size_t count, off_t offset));
-DARSHAN_FORWARD_DECL(pwrite64, ssize_t, (int fd, const void *buf, size_t count, off64_t offset
-));
+DARSHAN_FORWARD_DECL(pwrite64, ssize_t, (int fd, const void *buf, size_t count, off64_t offset));
DARSHAN_FORWARD_DECL(readv, ssize_t, (int fd, const struct iovec *iov, int iovcnt));
DARSHAN_FORWARD_DECL(writev, ssize_t, (int fd, const struct iovec *iov, int iovcnt));
DARSHAN_FORWARD_DECL(__fxstat, int, (int vers, int fd, struct stat *buf));
@@ -115,10 +84,7 @@ 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;
-struct darshan_job_runtime* darshan_global_job = NULL;
-static int my_rank = -1;
static struct stat64 cp_stat_buf;
-static int darshan_mem_alignment = 1;
/* struct to track information about aio operations in flight */
struct darshan_aio_tracker
@@ -143,22 +109,26 @@ static char* exclusions[] = {
NULL
};
-static double posix_wtime(void);
+static int posix_mod_registered = 0;
+static struct darshan_module_funcs posix_mod_funcs =
+{
-static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size, enum cp_counter_type type);
+};
+static int posix_runtime_mem_limit = 0;
-static struct darshan_file_ref* ref_by_handle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type);
+#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 struct darshan_file_runtime* darshan_file_by_fd(int fd);
-static void darshan_file_close_fd(int fd);
-static struct darshan_file_runtime* darshan_file_by_name_setfd(const char* name, int fd);
-static char* clean_path(const char* path);
+static double posix_wtime(void);
+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);
+#if 0
#define CP_RECORD_WRITE(__ret, __fd, __count, __pwrite_flag, __pwrite_offset, __aligned, __stream_flag, __tm1, __tm2) do{ \
size_t stride; \
int64_t this_offset; \
@@ -299,6 +269,7 @@ 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; \
@@ -329,6 +300,7 @@ static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp)
CP_F_INC_NO_OVERLAP(file, __tm1, __tm2, file->last_posix_meta_end, CP_F_POSIX_META_TIME); \
} while (0)
+#if 0
int DARSHAN_DECL(close)(int fd)
{
struct darshan_file_runtime* file;
@@ -338,6 +310,8 @@ int DARSHAN_DECL(close)(int fd)
MAP_OR_FAIL(close);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_close(fd);
tm2 = darshan_wtime();
@@ -366,6 +340,8 @@ int DARSHAN_DECL(fclose)(FILE *fp)
MAP_OR_FAIL(fclose);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fclose(fp);
tm2 = darshan_wtime();
@@ -394,6 +370,8 @@ int DARSHAN_DECL(fsync)(int fd)
MAP_OR_FAIL(fsync);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fsync(fd);
tm2 = darshan_wtime();
@@ -421,6 +399,8 @@ int DARSHAN_DECL(fdatasync)(int fd)
MAP_OR_FAIL(fdatasync);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fdatasync(fd);
tm2 = darshan_wtime();
@@ -448,6 +428,8 @@ 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);
@@ -472,6 +454,8 @@ 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);
@@ -494,6 +478,8 @@ int DARSHAN_DECL(creat)(const char* path, mode_t mode)
MAP_OR_FAIL(creat);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_creat(path, mode);
tm2 = darshan_wtime();
@@ -512,6 +498,8 @@ int DARSHAN_DECL(creat64)(const char* path, mode_t mode)
MAP_OR_FAIL(creat64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_creat64(path, mode);
tm2 = darshan_wtime();
@@ -531,6 +519,8 @@ int DARSHAN_DECL(open64)(const char* path, int flags, ...)
MAP_OR_FAIL(open64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
if (flags & O_CREAT)
{
va_list arg;
@@ -555,6 +545,7 @@ int DARSHAN_DECL(open64)(const char* path, int flags, ...)
return(ret);
}
+#endif
int DARSHAN_DECL(open)(const char *path, int flags, ...)
{
@@ -564,6 +555,8 @@ 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;
@@ -585,10 +578,12 @@ int DARSHAN_DECL(open)(const char *path, int flags, ...)
CP_LOCK();
CP_RECORD_OPEN(ret, path, mode, 0, tm1, tm2);
CP_UNLOCK();
+#endif
return(ret);
}
+#if 0
FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
{
FILE* ret;
@@ -597,6 +592,8 @@ FILE* DARSHAN_DECL(fopen64)(const char *path, const char *mode)
MAP_OR_FAIL(fopen64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fopen64(path, mode);
tm2 = darshan_wtime();
@@ -620,6 +617,8 @@ FILE* DARSHAN_DECL(fopen)(const char *path, const char *mode)
MAP_OR_FAIL(fopen);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fopen(path, mode);
tm2 = darshan_wtime();
@@ -642,6 +641,8 @@ int DARSHAN_DECL(__xstat64)(int vers, const char *path, struct stat64 *buf)
MAP_OR_FAIL(__xstat64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___xstat64(vers, path, buf);
tm2 = darshan_wtime();
@@ -662,6 +663,8 @@ int DARSHAN_DECL(__lxstat64)(int vers, const char *path, struct stat64 *buf)
MAP_OR_FAIL(__lxstat64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___lxstat64(vers, path, buf);
tm2 = darshan_wtime();
@@ -683,6 +686,8 @@ int DARSHAN_DECL(__fxstat64)(int vers, int fd, struct stat64 *buf)
MAP_OR_FAIL(__fxstat64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___fxstat64(vers, fd, buf);
tm2 = darshan_wtime();
@@ -712,6 +717,8 @@ int DARSHAN_DECL(__xstat)(int vers, const char *path, struct stat *buf)
MAP_OR_FAIL(__xstat);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___xstat(vers, path, buf);
tm2 = darshan_wtime();
@@ -732,6 +739,8 @@ int DARSHAN_DECL(__lxstat)(int vers, const char *path, struct stat *buf)
MAP_OR_FAIL(__lxstat);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___lxstat(vers, path, buf);
tm2 = darshan_wtime();
@@ -753,6 +762,8 @@ int DARSHAN_DECL(__fxstat)(int vers, int fd, struct stat *buf)
MAP_OR_FAIL(__fxstat);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real___fxstat(vers, fd, buf);
tm2 = darshan_wtime();
@@ -782,6 +793,8 @@ 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;
@@ -802,6 +815,8 @@ 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;
@@ -823,6 +838,8 @@ 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;
@@ -843,6 +860,8 @@ 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;
@@ -864,6 +883,8 @@ 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)
@@ -888,6 +909,8 @@ 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))
@@ -911,6 +934,8 @@ 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;
@@ -934,6 +959,8 @@ 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;
@@ -954,6 +981,8 @@ 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;
@@ -974,6 +1003,8 @@ 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;
@@ -997,6 +1028,8 @@ off64_t DARSHAN_DECL(lseek64)(int fd, off64_t offset, int whence)
MAP_OR_FAIL(lseek64);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_lseek64(fd, offset, whence);
tm2 = darshan_wtime();
@@ -1023,6 +1056,8 @@ off_t DARSHAN_DECL(lseek)(int fd, off_t offset, int whence)
MAP_OR_FAIL(lseek);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_lseek(fd, offset, whence);
tm2 = darshan_wtime();
@@ -1050,6 +1085,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();
tmp = darshan_aio_tracker_del(aiocbp->aio_fildes, aiocbp);
@@ -1085,6 +1122,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();
tmp = darshan_aio_tracker_del(aiocbp->aio_fildes, aiocbp);
@@ -1111,6 +1150,8 @@ 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)
{
@@ -1131,6 +1172,8 @@ 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)
{
@@ -1149,6 +1192,8 @@ 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);
@@ -1162,6 +1207,8 @@ 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);
@@ -1175,6 +1222,8 @@ 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);
@@ -1188,6 +1237,8 @@ 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);
@@ -1203,6 +1254,8 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
MAP_OR_FAIL(fseek);
+ DARSHAN_REGISTER_POSIX_MOD();
+
tm1 = darshan_wtime();
ret = __real_fseek(stream, offset, whence);
tm2 = darshan_wtime();
@@ -1220,268 +1273,7 @@ int DARSHAN_DECL(fseek)(FILE *stream, long offset, int whence)
}
return(ret);
}
-
-void darshan_finalize(struct darshan_job_runtime* job)
-{
- if(!job)
- {
- return;
- }
-
- free(job);
-}
-
-void darshan_initialize(int argc, char** argv, int nprocs, int rank)
-{
- int i;
- char* disable;
- char* disable_timing;
- char* envstr;
- char* truncate_string = "<TRUNCATED>";
- int truncate_offset;
- int chars_left = 0;
- int ret;
- int tmpval;
-
- disable = getenv("DARSHAN_DISABLE");
- if(disable)
- {
- /* turn off tracing */
- return;
- }
-
- disable_timing = getenv("DARSHAN_DISABLE_TIMING");
-
- if(darshan_global_job != NULL)
- {
- return;
- }
-
- #if (__CP_MEM_ALIGNMENT < 1)
- #error Darshan must be configured with a positive value for --with-mem-align
- #endif
- envstr = getenv("DARSHAN_MEMALIGN");
- if (envstr)
- {
- ret = sscanf(envstr, "%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)
- {
- return;
- }
- memset(darshan_global_job, 0, sizeof(*darshan_global_job));
-
- if(disable_timing)
- {
- 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 = posix_wtime();
- my_rank = rank;
-
- /* record exe and arguments */
- for(i=0; i<argc; i++)
- {
- chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
- strncat(darshan_global_job->exe, argv[i], chars_left);
- if(i < (argc-1))
- {
- chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
- strncat(darshan_global_job->exe, " ", chars_left);
- }
- }
-
- /* if we don't see any arguments, then use glibc symbol to get
- * program name at least (this happens in fortran)
- */
- if(argc == 0)
- {
- chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
- strncat(darshan_global_job->exe, __progname_full, chars_left);
- chars_left = CP_EXE_LEN-strlen(darshan_global_job->exe);
- strncat(darshan_global_job->exe, " <unknown args>", chars_left);
- }
-
- if(chars_left == 0)
- {
- /* we ran out of room; mark that string was truncated */
- truncate_offset = CP_EXE_LEN - strlen(truncate_string);
- sprintf(&darshan_global_job->exe[truncate_offset], "%s",
- truncate_string);
- }
-
- /* collect information about command line and
- * mounted file systems
- */
- darshan_global_job->trailing_data =
- darshan_get_exe_and_mounts(darshan_global_job);
-
- return;
-}
-
-/* darshan_condense()
- *
- * collapses all file statistics into a single unified set of counters; used
- * when we have opened too many files to track independently
- */
-void darshan_condense(void)
-{
- struct darshan_file_runtime* base_file;
- struct darshan_file_runtime* iter_file;
- int i;
- int j;
-
- if(!darshan_global_job)
- return;
-
- base_file = &darshan_global_job->file_runtime_array[0];
-
- /* iterate through files */
- for(j=1; j<darshan_global_job->file_count; j++)
- {
- iter_file = &darshan_global_job->file_runtime_array[j];
-
- /* iterate through records */
- for(i=0; i<CP_NUM_INDICES; i++)
- {
- switch(i)
- {
- /* NOTE: several fields cease to make sense if the records
- * have been condensed. Just let them get summed anyway.
- */
- /* TODO: double check this */
-
- /* keep up with global maxes in case they are helpful */
- case CP_MAX_BYTE_READ:
- case CP_MAX_BYTE_WRITTEN:
- CP_MAX(base_file, i, CP_VALUE(iter_file, i));
- break;
-
- /* do nothing with these; they are handled in the floating
- * point loop
- */
- case CP_MAX_WRITE_TIME_SIZE:
- case CP_MAX_READ_TIME_SIZE:
- break;
-
- /* pick one */
- case CP_DEVICE:
- case CP_SIZE_AT_OPEN:
- CP_SET(base_file, i, CP_VALUE(iter_file, i));
- break;
-
- /* most records can simply be added */
- default:
- CP_INC(base_file, i, CP_VALUE(iter_file, i));
- break;
- }
- }
- for(i=0; i<CP_F_NUM_INDICES; i++)
- {
- switch(i)
- {
- case CP_F_MAX_WRITE_TIME:
- if(CP_F_VALUE(iter_file, i) > CP_F_VALUE(base_file, i))
- {
- CP_F_SET(base_file, i, CP_F_VALUE(iter_file, i));
- CP_SET(base_file, CP_MAX_WRITE_TIME_SIZE,
- CP_VALUE(iter_file, CP_MAX_WRITE_TIME_SIZE));
- }
- break;
- case CP_F_MAX_READ_TIME:
- if(CP_F_VALUE(iter_file, i) > CP_F_VALUE(base_file, i))
- {
- CP_F_SET(base_file, i, CP_F_VALUE(iter_file, i));
- CP_SET(base_file, CP_MAX_READ_TIME_SIZE,
- CP_VALUE(iter_file, CP_MAX_READ_TIME_SIZE));
- }
- break;
- default:
- CP_F_SET(base_file, i, CP_F_VALUE(iter_file, i) + CP_F_VALUE(base_file, i));
- break;
- }
- }
-
- if(base_file->aio_list_tail)
- {
- /* base has an aio list already; add on to it */
- assert(base_file->aio_list_head);
- base_file->aio_list_tail->next = iter_file->aio_list_head;
- if(iter_file->aio_list_tail)
- base_file->aio_list_tail = iter_file->aio_list_tail;
- }
- else
- {
- /* take on list from iter */
- base_file->aio_list_head = iter_file->aio_list_head;
- base_file->aio_list_tail = iter_file->aio_list_tail;
- }
- }
-
- base_file->log_file->hash = 0;
-
- darshan_global_job->flags |= CP_FLAG_CONDENSED;
- darshan_global_job->file_count = 1;
-
- /* clear hash tables for safety */
- memset(darshan_global_job->name_table, 0, CP_HASH_SIZE*sizeof(struct darshan_file_runtime*));
- memset(darshan_global_job->handle_table, 0, CP_HASH_SIZE*sizeof(*darshan_global_job->handle_table));
-
- return;
-}
-
-static struct darshan_file_runtime* darshan_file_by_name_setfd(const char* name, int fd)
-{
- struct darshan_file_runtime* tmp_file;
-
- tmp_file = darshan_file_by_name_sethandle(name, &fd, sizeof(fd), DARSHAN_FD);
- return(tmp_file);
-}
-
-static void darshan_file_close_fd(int fd)
-{
- darshan_file_closehandle(&fd, sizeof(fd), DARSHAN_FD);
- return;
-}
-
-static struct darshan_file_runtime* darshan_file_by_fd(int fd)
-{
- struct darshan_file_runtime* tmp_file;
-
- tmp_file = darshan_file_by_handle(&fd, sizeof(fd), DARSHAN_FD);
-
- return(tmp_file);
-}
+#endif
static int access_comparison(const void* a_p, const void* b_p)
{
@@ -1563,6 +1355,7 @@ static void cp_access_counter(struct darshan_file_runtime* file, ssize_t size, e
return;
}
+#if 0
/* NOTE: we disable internal benchmarking routines when building shared
* libraries so that when Darshan is loaded with LD_PRELOAD it does not
* depend on MPI routines.
@@ -1803,12 +1596,14 @@ void darshan_search_bench(int argc, char** argv, int iters)
free(fd_array);
free(size_array);
}
+#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)
@@ -1819,319 +1614,6 @@ double darshan_wtime(void)
return(posix_wtime());
}
-struct darshan_file_runtime* darshan_file_by_name(const char* name)
-{
- struct darshan_file_runtime* tmp_file;
- uint64_t tmp_hash = 0;
- char* suffix_pointer;
- int hash_index;
- char* newname = NULL;
- int64_t device_id;
- int64_t block_size;
-
- 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 to construct absolute path */
- newname = clean_path(name);
- if(!newname)
- newname = (char*)name;
-
- tmp_hash = darshan_hash((void*)newname, strlen(newname), 0);
-
- /* search hash table */
- hash_index = tmp_hash & CP_HASH_MASK;
- tmp_file = darshan_global_job->name_table[hash_index];
- while(tmp_file)
- {
- if(tmp_file->log_file->hash == tmp_hash)
- {
- if(newname != name)
- free(newname);
- return(tmp_file);
- }
- tmp_file = tmp_file->name_next;
- }
-
- /* see if we need to condense */
- if(darshan_global_job->file_count >= CP_MAX_FILES)
- {
- darshan_condense();
- if(newname != name)
- free(newname);
- return(&darshan_global_job->file_runtime_array[0]);
- }
-
- /* new, unique file */
- tmp_file = &darshan_global_job->file_runtime_array[darshan_global_job->file_count];
-
- darshan_mnt_id_from_path(newname, &device_id, &block_size);
- CP_SET(tmp_file, CP_DEVICE, device_id);
- CP_SET(tmp_file, CP_FILE_ALIGNMENT, block_size);
- CP_SET(tmp_file, CP_MEM_ALIGNMENT, darshan_mem_alignment);
- tmp_file->log_file->hash = tmp_hash;
-
- /* record last N characters of file name too */
- suffix_pointer = (char*)newname;
- if(strlen(newname) > CP_NAME_SUFFIX_LEN)
- {
- suffix_pointer += (strlen(newname) - CP_NAME_SUFFIX_LEN);
- }
- strcpy(tmp_file->log_file->name_suffix, suffix_pointer);
-
- /* if the "stat at open" functionality is disabled, then go ahead and
- * mark certain counters with invalid values to make sure that they are
- * not mis-interpretted.
- */
-#ifndef __CP_STAT_AT_OPEN
- CP_SET(tmp_file, CP_SIZE_AT_OPEN, -1);
- if(CP_VALUE(tmp_file, CP_FILE_ALIGNMENT) == -1)
- CP_SET(tmp_file, CP_FILE_NOT_ALIGNED, -1);
-#endif
-
- darshan_global_job->file_count++;
-
- /* put into hash table, head of list at that index */
- tmp_file->name_prev = NULL;
- tmp_file->name_next = darshan_global_job->name_table[hash_index];
- if(tmp_file->name_next)
- tmp_file->name_next->name_prev = tmp_file;
- darshan_global_job->name_table[hash_index] = tmp_file;
-
- if(newname != name)
- free(newname);
- return(tmp_file);
-}
-
-
-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* file;
- uint64_t tmp_hash;
- int hash_index;
- struct darshan_file_ref* tmp_ref;
-
- if(!darshan_global_job)
- {
- return(NULL);
- }
-
- /* find file record by name first */
- file = darshan_file_by_name(name);
-
- if(!file)
- return(NULL);
-
- /* search hash table */
- tmp_ref = ref_by_handle(handle, handle_sz, handle_type);
- if(tmp_ref)
- {
- /* we have a reference. Make sure it points to the correct file
- * and return it
- */
- tmp_ref->file = file;
- return(file);
- }
-
- /* if we hit this point, then we don't have a reference for this handle
- * in the table yet. Add it.
- */
- tmp_hash = darshan_hash(handle, handle_sz, 0);
- hash_index = tmp_hash & CP_HASH_MASK;
- tmp_ref = malloc(sizeof(*tmp_ref));
- if(!tmp_ref)
- return(NULL);
-
- memset(tmp_ref, 0, sizeof(*tmp_ref));
- tmp_ref->file = file;
- memcpy(tmp_ref->handle, handle, handle_sz);
- tmp_ref->handle_sz = handle_sz;
- tmp_ref->handle_type = handle_type;
- tmp_ref->prev = NULL;
- tmp_ref->next = darshan_global_job->handle_table[hash_index];
- if(tmp_ref->next)
- tmp_ref->next->prev = tmp_ref;
- darshan_global_job->handle_table[hash_index] = tmp_ref;
-
- return(file);
-}
-
-struct darshan_file_runtime* darshan_file_by_handle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type)
-{
- struct darshan_file_ref* tmp_ref;
-
- if(!darshan_global_job)
- {
- return(NULL);
- }
-
- tmp_ref = ref_by_handle(handle, handle_sz, handle_type);
- if(tmp_ref)
- return(tmp_ref->file);
- else
- return(NULL);
-
- return(NULL);
-}
-
-void darshan_file_closehandle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type)
-{
- struct darshan_file_ref* tmp_ref;
- uint64_t tmp_hash;
- int hash_index;
-
- if(!darshan_global_job)
- {
- return;
- }
-
- /* search hash table */
- tmp_hash = darshan_hash(handle, handle_sz, 0);
- hash_index = tmp_hash & CP_HASH_MASK;
- tmp_ref = darshan_global_job->handle_table[hash_index];
- while(tmp_ref)
- {
- if(tmp_ref->handle_sz == handle_sz &&
- tmp_ref->handle_type == handle_type &&
- memcmp(tmp_ref->handle, handle, handle_sz) == 0)
- {
- /* we have a reference. */
- if(!tmp_ref->prev)
- {
- /* head of list */
- darshan_global_job->handle_table[hash_index] = tmp_ref->next;
- if(tmp_ref->next)
- tmp_ref->next->prev = NULL;
- }
- else
- {
- /* not head of list */
- if(tmp_ref->prev)
- tmp_ref->prev->next = tmp_ref->next;
- if(tmp_ref->next)
- tmp_ref->next->prev = tmp_ref->prev;
- }
- free(tmp_ref);
- return;
- }
- tmp_ref = tmp_ref->next;
- }
-
- return;
-}
-
-static struct darshan_file_ref* ref_by_handle(
- const void* handle,
- int handle_sz,
- enum darshan_handle_type handle_type)
-{
- uint64_t tmp_hash;
- int hash_index;
- struct darshan_file_ref* tmp_ref;
-
- if(!darshan_global_job)
- {
- return(NULL);
- }
-
- /* search hash table */
- tmp_hash = darshan_hash(handle, handle_sz, 0);
- hash_index = tmp_hash & CP_HASH_MASK;
- tmp_ref = darshan_global_job->handle_table[hash_index];
- while(tmp_ref)
- {
- if(tmp_ref->handle_sz == handle_sz &&
- tmp_ref->handle_type == handle_type &&
- memcmp(tmp_ref->handle, handle, handle_sz) == 0)
- {
- /* we have a reference. */
- return(tmp_ref);
- }
- tmp_ref = tmp_ref->next;
- }
-
- return(NULL);
-}
-
-/* Allocate a new string that contains a cleaned-up version of the path
- * passed in as an argument. Converts relative paths to absolute paths and
- * filters out some potential noise in the path string.
- */
-static char* clean_path(const char* path)
-{
- char* newpath = NULL;
- char* cwd = NULL;
- char* filter = NULL;
-
- if(!path || strlen(path) < 1)
- return(NULL);
-
- if(path[0] == '/')
- {
- /* it is already an absolute path */
- newpath = malloc(strlen(path)+1);
- if(newpath)
- {
- strcpy(newpath, path);
- }
- }
- else
- {
- /* handle relative path */
- cwd = malloc(PATH_MAX);
- if(cwd)
- {
- if(getcwd(cwd, PATH_MAX))
- {
- newpath = malloc(strlen(path) + strlen(cwd) + 2);
- if(newpath)
- {
- sprintf(newpath, "%s/%s", cwd, path);
- }
- }
- free(cwd);
- }
- }
-
- if(!newpath)
- return(NULL);
-
- /* filter out any double slashes */
- while((filter = strstr(newpath, "//")))
- {
- /* shift down one character */
- memmove(filter, &filter[1], (strlen(&filter[1]) + 1));
- }
-
- /* filter out any /./ instances */
- while((filter = strstr(newpath, "/./")))
- {
- /* shift down two characters */
- memmove(filter, &filter[2], (strlen(&filter[2]) + 1));
- }
-
- /* return result */
- return(newpath);
-}
-
/* adds a tracker for the given aio operation */
static void darshan_aio_tracker_add(int fd, void *aiocbp)
{
@@ -2207,6 +1689,7 @@ static struct darshan_aio_tracker* darshan_aio_tracker_del(int fd, void *aiocbp)
return(tmp);
}
+#endif
/*
* Local variables:
hooks/post-receive
--
More information about the Darshan-commits
mailing list