[Darshan-commits] [Git][darshan/darshan][dev-stdio] skeleton stubs for stdio module
Philip Carns
xgitlab at cels.anl.gov
Thu Apr 14 14:45:51 CDT 2016
Philip Carns pushed to branch dev-stdio at darshan / darshan
Commits:
78ebc882 by Phil Carns at 2016-04-14T15:42:50-04:00
skeleton stubs for stdio module
- - - - -
6 changed files:
- darshan-log-format.h
- + darshan-stdio-log-format.h
- darshan-util/Makefile.in
- darshan-util/darshan-logutils.h
- + darshan-util/darshan-stdio-logutils.c
- + darshan-util/darshan-stdio-logutils.h
Changes:
=====================================
darshan-log-format.h
=====================================
--- a/darshan-log-format.h
+++ b/darshan-log-format.h
@@ -103,6 +103,7 @@ struct darshan_record
#include "darshan-hdf5-log-format.h"
#include "darshan-pnetcdf-log-format.h"
#include "darshan-bgq-log-format.h"
+#include "darshan-stdio-log-format.h"
/* X-macro for keeping module ordering consistent */
/* NOTE: first val used to define module enum values,
@@ -120,7 +121,8 @@ struct darshan_record
X(DARSHAN_MPIIO_MOD, "MPI-IO", DARSHAN_MPIIO_VER, &mpiio_logutils) \
X(DARSHAN_HDF5_MOD, "HDF5", DARSHAN_HDF5_VER, &hdf5_logutils) \
X(DARSHAN_PNETCDF_MOD, "PNETCDF", DARSHAN_PNETCDF_VER, &pnetcdf_logutils) \
- X(DARSHAN_BGQ_MOD, "BG/Q", DARSHAN_BGQ_VER, &bgq_logutils)
+ X(DARSHAN_BGQ_MOD, "BG/Q", DARSHAN_BGQ_VER, &bgq_logutils) \
+ X(DARSHAN_STDIO_MOD, "STDIO", DARSHAN_STDIO_VER, &stdio_logutils)
/* unique identifiers to distinguish between available darshan modules */
/* NOTES: - valid ids range from [0...DARSHAN_MAX_MODS-1]
=====================================
darshan-stdio-log-format.h
=====================================
--- /dev/null
+++ b/darshan-stdio-log-format.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2015 University of Chicago.
+ * See COPYRIGHT notice in top-level directory.
+ *
+ */
+
+#ifndef __DARSHAN_STDIO_LOG_FORMAT_H
+#define __DARSHAN_STDIO_LOG_FORMAT_H
+
+/* current log format version, to support backwards compatibility */
+#define DARSHAN_STDIO_VER 1
+
+#define STDIO_COUNTERS \
+ /* count of number of 'bar' function calls */\
+ X(STDIO_BARS) \
+ /* arbitrary data value set by last call to 'bar' */\
+ X(STDIO_BAR_DAT) \
+ /* end of counters */\
+ X(STDIO_NUM_INDICES)
+
+#define STDIO_F_COUNTERS \
+ /* timestamp of the first call to function 'bar' */\
+ X(STDIO_F_BAR_TIMESTAMP) \
+ /* timer indicating duration of last call to 'bar' */\
+ X(STDIO_F_BAR_DURATION) \
+ /* end of counters */\
+ X(STDIO_F_NUM_INDICES)
+
+#define X(a) a,
+/* integer counters for the "STDIO" example module */
+enum darshan_stdio_indices
+{
+ STDIO_COUNTERS
+};
+
+/* floating point counters for the "STDIO" example module */
+enum darshan_stdio_f_indices
+{
+ STDIO_F_COUNTERS
+};
+#undef X
+
+/* the darshan_stdio_record structure encompasses the high-level data/counters
+ * which would actually be logged to file by Darshan for the "STDIO"
+ * module. This logs the following data for each record:
+ * - a corresponding Darshan record identifier
+ * - the rank of the process responsible for the record
+ * - integer I/O counters (operation counts, I/O sizes, etc.)
+ * - floating point I/O counters (timestamps, cumulative timers, etc.)
+ */
+struct darshan_stdio_record
+{
+ darshan_record_id f_id;
+ int64_t rank;
+ int64_t counters[STDIO_NUM_INDICES];
+ double fcounters[STDIO_F_NUM_INDICES];
+};
+
+#endif /* __DARSHAN_STDIO_LOG_FORMAT_H */
=====================================
darshan-util/Makefile.in
=====================================
--- a/darshan-util/Makefile.in
+++ b/darshan-util/Makefile.in
@@ -15,8 +15,8 @@ pkgconfigdir = $(DESTDIR)$(libdir)/pkgconfig
DARSHAN_LOG_FORMAT = $(srcdir)/../darshan-log-format.h
DARSHAN_MOD_LOG_FORMATS = $(srcdir)/../darshan-posix-log-format.h $(srcdir)/../darshan-mpiio-log-format.h $(srcdir)/../darshan-hdf5-log-format.h $(srcdir)/../darshan-pnetcdf-log-format.h
DARSHAN_MOD_LOGUTIL_HEADERS = darshan-posix-logutils.h darshan-mpiio-logutils.h darshan-hdf5-logutils.h darshan-pnetcdf-logutils.h
-DARSHAN_STATIC_MOD_OBJS = darshan-posix-logutils.o darshan-mpiio-logutils.o darshan-hdf5-logutils.o darshan-pnetcdf-logutils.o darshan-bgq-logutils.o
-DARSHAN_DYNAMIC_MOD_OBJS = darshan-posix-logutils.po darshan-mpiio-logutils.po darshan-hdf5-logutils.po darshan-pnetcdf-logutils.po darshan-bgq-logutils.po
+DARSHAN_STATIC_MOD_OBJS = darshan-posix-logutils.o darshan-mpiio-logutils.o darshan-hdf5-logutils.o darshan-pnetcdf-logutils.o darshan-bgq-logutils.o darshan-stdio-logutils.o
+DARSHAN_DYNAMIC_MOD_OBJS = darshan-posix-logutils.po darshan-mpiio-logutils.po darshan-hdf5-logutils.po darshan-pnetcdf-logutils.po darshan-bgq-logutils.po darshan-stdio-logutios.po
DARSHAN_ENABLE_SHARED=@DARSHAN_ENABLE_SHARED@
@@ -81,6 +81,11 @@ darshan-bgq-logutils.o: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-lo
darshan-bgq-logutils.po: darshan-bgq-logutils.c darshan-logutils.h darshan-bgq-logutils.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-bgq-log-format.h | uthash-1.9.2
$(CC) $(CFLAGS_SHARED) -c $< -o $@
+darshan-stdio-logutils.o: darshan-stdio-logutils.c darshan-logutils.h darshan-stdio-logutils.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-stdio-log-format.h | uthash-1.9.2
+ $(CC) $(CFLAGS) -c $< -o $@
+darshan-stdio-logutils.po: darshan-stdio-logutils.c darshan-logutils.h darshan-stdio-logutils.h $(DARSHAN_LOG_FORMAT) $(srcdir)/../darshan-stdio-log-format.h | uthash-1.9.2
+ $(CC) $(CFLAGS_SHARED) -c $< -o $@
+
libdarshan-util.a: darshan-logutils.o $(DARSHAN_STATIC_MOD_OBJS)
ar rcs libdarshan-util.a $^
@@ -132,12 +137,14 @@ endif
install -m 644 $(srcdir)/darshan-pnetcdf-logutils.h $(includedir)
install -m 644 $(srcdir)/darshan-bgq-logutils.h $(includedir)
install -m 644 $(srcdir)/darshan-null-logutils.h $(includedir)
+ install -m 644 $(srcdir)/darshan-stdio-logutils.h $(includedir)
install -m 644 $(srcdir)/../darshan-null-log-format.h $(includedir)
install -m 644 $(srcdir)/../darshan-posix-log-format.h $(includedir)
install -m 644 $(srcdir)/../darshan-mpiio-log-format.h $(includedir)
install -m 644 $(srcdir)/../darshan-hdf5-log-format.h $(includedir)
install -m 644 $(srcdir)/../darshan-pnetcdf-log-format.h $(includedir)
install -m 644 $(srcdir)/../darshan-bgq-log-format.h $(includedir)
+ install -m 644 $(srcdir)/../darshan-stdio-log-format.h $(includedir)
install -d $(includedir)/uthash-1.9.2
install -d $(includedir)/uthash-1.9.2/src
install -m 644 uthash-1.9.2/src/uthash.h $(includedir)/uthash-1.9.2/src/
=====================================
darshan-util/darshan-logutils.h
=====================================
--- a/darshan-util/darshan-logutils.h
+++ b/darshan-util/darshan-logutils.h
@@ -107,6 +107,7 @@ extern struct darshan_mod_logutil_funcs *mod_logutils[];
#include "darshan-hdf5-logutils.h"
#include "darshan-pnetcdf-logutils.h"
#include "darshan-bgq-logutils.h"
+#include "darshan-stdio-logutils.h"
darshan_fd darshan_log_open(const char *name);
darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type,
=====================================
darshan-util/darshan-stdio-logutils.c
=====================================
--- /dev/null
+++ b/darshan-util/darshan-stdio-logutils.c
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2015 University of Chicago.
+ * See COPYRIGHT notice in top-level directory.
+ *
+ */
+
+#define _GNU_SOURCE
+#include "darshan-util-config.h"
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "darshan-logutils.h"
+
+/* integer counter name strings for the STDIO module */
+#define X(a) #a,
+char *stdio_counter_names[] = {
+ STDIO_COUNTERS
+};
+
+/* floating point counter name strings for the STDIO module */
+char *stdio_f_counter_names[] = {
+ STDIO_F_COUNTERS
+};
+#undef X
+
+/* prototypes for each of the STDIO module's logutil functions */
+static int darshan_log_get_stdio_record(darshan_fd fd, void* stdio_buf,
+ darshan_record_id* rec_id);
+static int darshan_log_put_stdio_record(darshan_fd fd, void* stdio_buf, int ver);
+static void darshan_log_print_stdio_record(void *file_rec,
+ char *file_name, char *mnt_pt, char *fs_type, int ver);
+static void darshan_log_print_stdio_description(void);
+static void darshan_log_print_stdio_record_diff(void *file_rec1, char *file_name1,
+ void *file_rec2, char *file_name2);
+
+/* structure storing each function needed for implementing the darshan
+ * logutil interface. these functions are used for reading, writing, and
+ * printing module data in a consistent manner.
+ */
+struct darshan_mod_logutil_funcs stdio_logutils =
+{
+ .log_get_record = &darshan_log_get_stdio_record,
+ .log_put_record = &darshan_log_put_stdio_record,
+ .log_print_record = &darshan_log_print_stdio_record,
+ .log_print_description = &darshan_log_print_stdio_description,
+ .log_print_diff = &darshan_log_print_stdio_record_diff
+};
+
+/* retrieve a STDIO record from log file descriptor 'fd', storing the
+ * buffer in 'stdio_buf' and the corresponding Darshan record id in
+ * 'rec_id'. Return 1 on successful record read, 0 on no more data,
+ * and -1 on error.
+ */
+static int darshan_log_get_stdio_record(darshan_fd fd, void* stdio_buf,
+ darshan_record_id* rec_id)
+{
+ struct darshan_stdio_record *rec;
+ int i;
+ int ret;
+
+ /* read a STDIO module record from the darshan log file */
+ ret = darshan_log_getmod(fd, DARSHAN_STDIO_MOD, stdio_buf,
+ sizeof(struct darshan_stdio_record));
+ if(ret < 0)
+ return(-1);
+ else if(ret < sizeof(struct darshan_stdio_record))
+ return(0);
+ else
+ {
+ /* if the read was successful, do any necessary byte-swapping */
+ rec = (struct darshan_stdio_record *)stdio_buf;
+ if(fd->swap_flag)
+ {
+ /* swap bytes if necessary */
+ DARSHAN_BSWAP64(&rec->f_id);
+ DARSHAN_BSWAP64(&rec->rank);
+ for(i=0; i<STDIO_NUM_INDICES; i++)
+ DARSHAN_BSWAP64(&rec->counters[i]);
+ for(i=0; i<STDIO_F_NUM_INDICES; i++)
+ DARSHAN_BSWAP64(&rec->fcounters[i]);
+ }
+
+ /* set the output record id */
+ *rec_id = rec->f_id;
+ return(1);
+ }
+}
+
+/* write the STDIO record stored in 'stdio_buf' to log file descriptor 'fd'.
+ * Return 0 on success, -1 on failure
+ */
+static int darshan_log_put_stdio_record(darshan_fd fd, void* stdio_buf, int ver)
+{
+ struct darshan_stdio_record *rec = (struct darshan_stdio_record *)stdio_buf;
+ int ret;
+
+ /* append STDIO record to darshan log file */
+ ret = darshan_log_putmod(fd, DARSHAN_STDIO_MOD, rec,
+ sizeof(struct darshan_stdio_record), ver);
+ if(ret < 0)
+ return(-1);
+
+ return(0);
+}
+
+/* print all I/O data record statistics for the given STDIO record */
+static void darshan_log_print_stdio_record(void *file_rec, char *file_name,
+ char *mnt_pt, char *fs_type, int ver)
+{
+ int i;
+ struct darshan_stdio_record *stdio_rec =
+ (struct darshan_stdio_record *)file_rec;
+
+ /* print each of the integer and floating point counters for the STDIO module */
+ for(i=0; i<STDIO_NUM_INDICES; i++)
+ {
+ /* macro defined in darshan-logutils.h */
+ DARSHAN_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ stdio_rec->rank, stdio_rec->f_id, stdio_counter_names[i],
+ stdio_rec->counters[i], file_name, mnt_pt, fs_type);
+ }
+
+ for(i=0; i<STDIO_F_NUM_INDICES; i++)
+ {
+ /* macro defined in darshan-logutils.h */
+ DARSHAN_F_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ stdio_rec->rank, stdio_rec->f_id, stdio_f_counter_names[i],
+ stdio_rec->fcounters[i], file_name, mnt_pt, fs_type);
+ }
+
+ return;
+}
+
+/* print out a description of the STDIO module record fields */
+static void darshan_log_print_stdio_description()
+{
+ printf("\n# description of STDIO counters:\n");
+ printf("# STDIO_BARS: number of 'bar' function calls.\n");
+ printf("# STDIO_BAR_DAT: value set by last call to function 'bar'.\n");
+ printf("# STDIO_F_BAR_TIMESTAMP: timestamp of the first call to function 'bar'.\n");
+ printf("# STDIO_F_BAR_DURATION: duration of the last call to function 'bar'.\n");
+
+ return;
+}
+
+static void darshan_log_print_stdio_record_diff(void *file_rec1, char *file_name1,
+ void *file_rec2, char *file_name2)
+{
+ struct darshan_stdio_record *file1 = (struct darshan_stdio_record *)file_rec1;
+ struct darshan_stdio_record *file2 = (struct darshan_stdio_record *)file_rec2;
+ int i;
+
+ /* NOTE: we assume that both input records are the same module format version */
+
+ for(i=0; i<STDIO_NUM_INDICES; i++)
+ {
+ if(!file2)
+ {
+ printf("- ");
+ DARSHAN_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file1->rank, file1->f_id, stdio_counter_names[i],
+ file1->counters[i], file_name1, "", "");
+
+ }
+ else if(!file1)
+ {
+ printf("+ ");
+ DARSHAN_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file2->rank, file2->f_id, stdio_counter_names[i],
+ file2->counters[i], file_name2, "", "");
+ }
+ else if(file1->counters[i] != file2->counters[i])
+ {
+ printf("- ");
+ DARSHAN_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file1->rank, file1->f_id, stdio_counter_names[i],
+ file1->counters[i], file_name1, "", "");
+ printf("+ ");
+ DARSHAN_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file2->rank, file2->f_id, stdio_counter_names[i],
+ file2->counters[i], file_name2, "", "");
+ }
+ }
+
+ for(i=0; i<STDIO_F_NUM_INDICES; i++)
+ {
+ if(!file2)
+ {
+ printf("- ");
+ DARSHAN_F_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file1->rank, file1->f_id, stdio_f_counter_names[i],
+ file1->fcounters[i], file_name1, "", "");
+
+ }
+ else if(!file1)
+ {
+ printf("+ ");
+ DARSHAN_F_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file2->rank, file2->f_id, stdio_f_counter_names[i],
+ file2->fcounters[i], file_name2, "", "");
+ }
+ else if(file1->fcounters[i] != file2->fcounters[i])
+ {
+ printf("- ");
+ DARSHAN_F_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file1->rank, file1->f_id, stdio_f_counter_names[i],
+ file1->fcounters[i], file_name1, "", "");
+ printf("+ ");
+ DARSHAN_F_COUNTER_PRINT(darshan_module_names[DARSHAN_STDIO_MOD],
+ file2->rank, file2->f_id, stdio_f_counter_names[i],
+ file2->fcounters[i], file_name2, "", "");
+ }
+ }
+
+ return;
+}
+
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
=====================================
darshan-util/darshan-stdio-logutils.h
=====================================
--- /dev/null
+++ b/darshan-util/darshan-stdio-logutils.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (C) 2015 University of Chicago.
+ * See COPYRIGHT notice in top-level directory.
+ *
+ */
+
+#ifndef __DARSHAN_STDIO_LOG_UTILS_H
+#define __DARSHAN_STDIO_LOG_UTILS_H
+
+/* declare STDIO module counter name strings and logutil definition as
+ * extern variables so they can be used in other utilities
+ */
+extern char *stdio_counter_names[];
+extern char *stdio_f_counter_names[];
+
+extern struct darshan_mod_logutil_funcs stdio_logutils;
+
+#endif
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/commit/78ebc882035bca0f1b4d6ed3e73cfae28644756e
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20160414/f26df968/attachment-0001.html>
More information about the Darshan-commits
mailing list