Commit 66a49140 authored by Shane Snyder's avatar Shane Snyder

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.
parent e60076ae
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
......
......@@ -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]"
......
/*
* (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 */
......@@ -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);
......
/*
* (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
*/
......@@ -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