Commit 75eee950 authored by Shane Snyder's avatar Shane Snyder
Browse files

initial shared lib support + more TODOs

parent 1c3f3690
...@@ -28,50 +28,60 @@ CFLAGS = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I ../ -I $(srcdir ...@@ -28,50 +28,60 @@ CFLAGS = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I ../ -I $(srcdir
# #
CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir) -I$(srcdir)/../ @CFLAGS@ @CPPFLAGS@ -D_LARGEFILE64_SOURCE -shared -fpic -DPIC -DDARSHAN_PRELOAD CFLAGS_SHARED = -DDARSHAN_CONFIG_H=\"darshan-runtime-config.h\" -I . -I$(srcdir) -I$(srcdir)/../ @CFLAGS@ @CPPFLAGS@ -D_LARGEFILE64_SOURCE -shared -fpic -DPIC -DDARSHAN_PRELOAD
# TODO: BZ2?
LIBS = -lz @LIBBZ2@ LIBS = -lz @LIBBZ2@
lib:: lib::
@mkdir -p $@ @mkdir -p $@
# TODO make sure the headers are right in these prereqs
lib/darshan-core.o: lib/darshan-core.c darshan-core.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-core.o: lib/darshan-core.c darshan-core.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
lib/darshan-core.po: lib/darshan-core.c darshan-core.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/darshan-common.o: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-common.o: lib/darshan-common.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
lib/darshan-common.po: lib/darshan-common.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 lib/darshan-posix.o: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
#lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib lib/darshan-posix.po: lib/darshan-posix.c darshan.h $(DARSHAN_LOG_FORMAT) | lib
# $(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup3.o: lib/lookup3.c lib/lookup3.o: lib/lookup3.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
#lib/lookup3.po: lib/lookup3.c lib/lookup3.po: lib/lookup3.c
# $(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
lib/lookup8.o: lib/lookup8.c lib/lookup8.o: lib/lookup8.c
$(CC) $(CFLAGS) -c $< -o $@ $(CC) $(CFLAGS) -c $< -o $@
#lib/lookup8.po: lib/lookup8.c lib/lookup8.po: lib/lookup8.c
# $(CC) $(CFLAGS_SHARED) -c $< -o $@ $(CC) $(CFLAGS_SHARED) -c $< -o $@
# TODO: huh?
#%.i: %.c #%.i: %.c
# $(CC) -E $(CFLAGS) -c $< -o $@ # $(CC) -E $(CFLAGS) -c $< -o $@
lib/libdarshan.a: lib/darshan-posix.o lib/darshan-core.o lib/darshan-common.o lib/lookup3.o lib/lookup8.o lib/libdarshan.a: lib/darshan-posix.o lib/darshan-core.o lib/darshan-common.o lib/lookup3.o lib/lookup8.o
ar rcs $@ $^ ar rcs $@ $^
#lib/libdarshan.so: lib/darshan-mpi-io.po lib/darshan-mpi-init-finalize.po lib/darshan-pnetcdf.po lib/darshan-hdf5.po lib/darshan-posix.po lib/lookup3.po lib/lookup8.po lib/libdarshan.so: lib/darshan-core.po lib/darshan-common.po lib/darshan-posix.po lib/lookup3.po lib/lookup8.po
# $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $@ $^ -lpthread -lrt -lz -ldl $(CC) $(CFLAGS_SHARED) $(LDFLAGS) -o $@ $^ -lpthread -lrt -lz -ldl
install:: all install:: all
install -d $(libdir) install -d $(libdir)
install -m 755 lib/libdarshan.a $(libdir) install -m 755 lib/libdarshan.a $(libdir)
#ifndef DISABLE_LDPRELOAD ifndef DISABLE_LDPRELOAD
# install -m 755 lib/libdarshan.so $(libdir) install -m 755 lib/libdarshan.so $(libdir)
#endif endif
install -d $(bindir) 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-cc.pl $(bindir)
......
...@@ -25,9 +25,6 @@ ...@@ -25,9 +25,6 @@
/* Environment variable to override __CP_MEM_ALIGNMENT */ /* Environment variable to override __CP_MEM_ALIGNMENT */
#define CP_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN" #define CP_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN"
/* TODO where does this go? */
#define DARSHAN_MPI_CALL(func) func
struct darshan_module_funcs struct darshan_module_funcs
{ {
/* disable futher instrumentation within a module */ /* disable futher instrumentation within a module */
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
/* TODO is __progname_full needed here */ /* TODO is __progname_full needed here */
extern char* __progname; extern char* __progname;
#define DARSHAN_MPI_CALL(func) func
/* internal variable delcarations */ /* internal variable delcarations */
static struct darshan_core_runtime *darshan_core = NULL; static struct darshan_core_runtime *darshan_core = NULL;
static pthread_mutex_t darshan_core_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t darshan_core_mutex = PTHREAD_MUTEX_INITIALIZER;
...@@ -255,7 +257,7 @@ static void darshan_core_shutdown() ...@@ -255,7 +257,7 @@ static void darshan_core_shutdown()
final_core = darshan_core; final_core = darshan_core;
darshan_core = NULL; darshan_core = NULL;
/* we also need to set which modules were registerd on this process and /* we also need to set which modules were registered on this process and
* disable tracing within those modules while we shutdown * disable tracing within those modules while we shutdown
*/ */
for(i = 0; i < DARSHAN_MAX_MODS; i++) for(i = 0; i < DARSHAN_MAX_MODS; i++)
......
...@@ -3,10 +3,7 @@ ...@@ -3,10 +3,7 @@
* See COPYRIGHT in top-level directory. * See COPYRIGHT in top-level directory.
*/ */
#define _GNU_SOURCE
#include "darshan-runtime-config.h" #include "darshan-runtime-config.h"
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -23,6 +20,7 @@ ...@@ -23,6 +20,7 @@
#include <assert.h> #include <assert.h>
#include <libgen.h> #include <libgen.h>
#include <aio.h> #include <aio.h>
#define __USE_GNU
#include <pthread.h> #include <pthread.h>
#include "uthash.h" #include "uthash.h"
...@@ -36,15 +34,45 @@ typedef int64_t off64_t; ...@@ -36,15 +34,45 @@ typedef int64_t off64_t;
#define aiocb64 aiocb #define aiocb64 aiocb
#endif #endif
/* TODO these go where ? */ #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); \
} \
}
#else
#define DARSHAN_FORWARD_DECL(name,ret,args) \ #define DARSHAN_FORWARD_DECL(name,ret,args) \
extern ret __real_ ## name args; extern ret __real_ ## name args;
#define DARSHAN_DECL(__name) __wrap_ ## __name #define DARSHAN_DECL(__name) __wrap_ ## __name
#define DARSHAN_MPI_CALL(func) func
#define MAP_OR_FAIL(func) #define MAP_OR_FAIL(func)
#endif
DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(open64, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(close, int, (int fd));
struct posix_runtime_file struct posix_runtime_file
{ {
struct darshan_posix_file* file_record; struct darshan_posix_file* file_record;
...@@ -90,12 +118,7 @@ static char* exclusions[] = { ...@@ -90,12 +118,7 @@ static char* exclusions[] = {
NULL NULL
}; };
DARSHAN_FORWARD_DECL(open, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(open64, int, (const char *path, int flags, ...));
DARSHAN_FORWARD_DECL(close, int, (int fd));
static void posix_runtime_initialize(void); static void posix_runtime_initialize(void);
static struct posix_runtime_file* posix_file_by_name(const char *name); static struct posix_runtime_file* posix_file_by_name(const char *name);
static struct posix_runtime_file* posix_file_by_name_setfd(const char* name, int fd); static struct posix_runtime_file* posix_file_by_name_setfd(const char* name, int fd);
static struct posix_runtime_file* posix_file_by_fd(int fd); static struct posix_runtime_file* posix_file_by_fd(int fd);
...@@ -216,7 +239,7 @@ int DARSHAN_DECL(open64)(const char *path, int flags, ...) ...@@ -216,7 +239,7 @@ int DARSHAN_DECL(open64)(const char *path, int flags, ...)
int ret; int ret;
double tm1, tm2; double tm1, tm2;
MAP_OR_FAIL(open); MAP_OR_FAIL(open64);
if(flags & O_CREAT) if(flags & O_CREAT)
{ {
......
...@@ -362,6 +362,7 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash) ...@@ -362,6 +362,7 @@ int darshan_log_gethash(darshan_fd fd, struct darshan_record_ref **hash)
} }
free(comp_buf); free(comp_buf);
/* TODO: check for duplicate entries? */
buf_ptr = hash_buf; buf_ptr = hash_buf;
while(buf_ptr < (hash_buf + hash_buf_sz)) while(buf_ptr < (hash_buf + hash_buf_sz))
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment