[Darshan-commits] [Git][darshan/darshan][lustre-mod] 2 commits: don't pull in the full Lustre API just for a few consts

Glenn K. Lockwood xgitlab at cels.anl.gov
Thu Jun 2 18:54:51 CDT 2016


Glenn K. Lockwood pushed to branch lustre-mod at darshan / darshan


Commits:
a2a9e135 by Glenn K. Lockwood at 2016-05-25T13:02:53-07:00
don't pull in the full Lustre API just for a few consts

- - - - -
a61ebca2 by Glenn K. Lockwood at 2016-06-02T16:54:11-07:00
added some infrastructure to facilitate unit testing of the darshan lustre module

- - - - -


7 changed files:

- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-lustre.c
- + darshan-test/lustre/.gitignore
- + darshan-test/lustre/Makefile
- + darshan-test/lustre/darshan-core-stub.c
- + darshan-test/lustre/mpi.h
- + darshan-test/lustre/test-darshan.sh


Changes:

=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -33,7 +33,7 @@
 #include "darshan-dynamic.h"
 
 /* XXX stick this into autoconf .h */
-#include <lustre/lustreapi.h>
+#include <lustre/lustre_user.h>
 
 extern char* __progname;
 extern char* __progname_full;


=====================================
darshan-runtime/lib/darshan-lustre.c
=====================================
--- a/darshan-runtime/lib/darshan-lustre.c
+++ b/darshan-runtime/lib/darshan-lustre.c
@@ -19,7 +19,7 @@
 #include <sys/ioctl.h>
 
 /* XXX stick this into autoconf .h */
-#include <lustre/lustreapi.h>
+#include <lustre/lustre_user.h>
 
 #include "uthash.h"
 


=====================================
darshan-test/lustre/.gitignore
=====================================
--- /dev/null
+++ b/darshan-test/lustre/.gitignore
@@ -0,0 +1,2 @@
+*.o
+darshan-tester


=====================================
darshan-test/lustre/Makefile
=====================================
--- /dev/null
+++ b/darshan-test/lustre/Makefile
@@ -0,0 +1,19 @@
+.PHONY: clean
+BINS = darshan-tester darshan-tester-mpi
+OBJS = darshan-core-stub.o darshan-lustre.o
+CFLAGS = -O0 -g -I../.. -I../../darshan-runtime
+
+### Include -I. when building non-MPI tests to include the mpi.h stub header
+CFLAGS += -I.
+
+darshan-tester: $(OBJS)
+	$(CC) $(LDFLAGS) $? $(LOADLIBES) $(LDLIBS) -o $@
+
+darshan-tester-mpi: $(OBJS)
+	$(CC) $(LDFLAGS) $? $(LOADLIBES) $(LDLIBS) -o $@
+
+darshan-lustre.o: ../../darshan-runtime/lib/darshan-lustre.c
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c $? -o $@
+
+clean:
+	- at rm -v $(OBJS) $(BINS)


=====================================
darshan-test/lustre/darshan-core-stub.c
=====================================
--- /dev/null
+++ b/darshan-test/lustre/darshan-core-stub.c
@@ -0,0 +1,98 @@
+#define _XOPEN_SOURCE 500
+#define _GNU_SOURCE
+
+#include "darshan-runtime-config.h"
+#include "darshan.h"
+#include "darshan-core.h"
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+/*
+ *  Global variables
+ */
+static darshan_record_id next_rec_id = 0;
+static int my_rank = 0;
+static struct darshan_module_funcs mod_funcs;
+
+/*
+ *  Import routines from Lustre module
+ */
+
+void darshan_core_register_record(
+    void *name,
+    int len,
+    darshan_module_id mod_id,
+    int printable_flag,
+    int mod_limit_flag,
+    darshan_record_id *rec_id,
+    struct darshan_fs_info *fs_info)
+{
+    *rec_id = next_rec_id++;
+ 
+    if (fs_info)
+    {
+        memset( fs_info, 0, sizeof(struct darshan_fs_info) );
+        fs_info->fs_type = -1;
+    }
+
+    return;
+}
+
+void darshan_core_register_module(
+    darshan_module_id mod_id,
+    struct darshan_module_funcs *funcs,
+    int *rank,
+    int *mod_mem_limit,
+    int *sys_mem_alignment)
+{
+/*  if (sys_mem_alignment) *sys_mem_alignment = darshan_mem_alignment; */
+    if (rank) *rank = my_rank;
+    *mod_mem_limit = DARSHAN_MOD_MEM_MAX;
+    mod_funcs = *funcs;
+
+    return;
+}
+
+void darshan_core_shutdown()
+{
+    darshan_record_id *mod_shared_recs = NULL;
+    int mod_shared_rec_cnt = 0;
+    void* mod_buf = NULL;
+    int mod_buf_sz = 0;
+
+    mod_funcs.begin_shutdown();
+    mod_funcs.get_output_data( MPI_COMM_WORLD, mod_shared_recs, mod_shared_rec_cnt, &mod_buf, &mod_buf_sz );
+
+    print_lustre_runtime();
+
+    mod_funcs.shutdown();
+
+    return;
+}
+
+int main( int argc, char **argv )
+{
+    int fd, i;
+    char *fname;
+
+    srand(234);
+
+    /* build Darshan records */
+    for ( i = 1; i < argc; i++ )
+    {
+        fname = argv[i];
+        printf( "\nProcessing %s\n", fname );
+        fd = open( fname, O_RDONLY );
+        darshan_instrument_lustre_file( fname, fd );
+        close(fd);
+    }
+
+    print_lustre_runtime();
+
+    darshan_core_shutdown();
+
+    return 0;
+}


=====================================
darshan-test/lustre/mpi.h
=====================================
--- /dev/null
+++ b/darshan-test/lustre/mpi.h
@@ -0,0 +1,8 @@
+/*
+ *  VERY primitive stubs that allow darshan.h to be included in non-MPI
+ *  applications like darshan-tester
+ */
+typedef int MPI_Comm;
+typedef int MPI_Datatype;
+typedef int MPI_Op;
+#define MPI_COMM_WORLD 0


=====================================
darshan-test/lustre/test-darshan.sh
=====================================
--- /dev/null
+++ b/darshan-test/lustre/test-darshan.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+#
+#  Run the test program through Valgrind to expose memory leaks and buffer
+#  overflows on a variety of different file locations and geometries
+#
+
+### Make some files to test.  Assume $SCRATCH points at Lustre
+for stripe in 1 2 4 8 16 32
+do
+    if [ ! -f $SCRATCH/stripe${stripe} ]; then
+        lfs setstripe -c $stripe $SCRATCH/stripe${stripe}
+    fi
+done
+
+set -x
+
+valgrind --tool=memcheck \
+         --leak-check=yes \
+         --show-reachable=yes \
+         --num-callers=20 \
+         --track-fds=yes \
+         --read-var-info=yes \
+         ./darshan-tester \
+         $SCRATCH/stripe4 \
+         $SCRATCH/stripe32 \
+         $SCRATCH/stripe1 \
+         $SCRATCH/stripe16 \
+         $SCRATCH/stripe8 \
+         $HOME/.bashrc \
+         $SCRATCH/stripe2
+
+set +x



View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/3e5753e437f9572fc8efc06af98a07dbafa17812...a61ebca2580f403acfd8c472d2fbb1356003a6b3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160602/498be7d9/attachment.html>


More information about the Darshan-commits mailing list