[Darshan-commits] [Git][darshan/darshan][mmap-dev] 14 commits: small fixes for COPYRIGHT, ChangeLog, & comments
Shane Snyder
xgitlab at cels.anl.gov
Wed Dec 2 14:37:13 CST 2015
Shane Snyder pushed to branch mmap-dev at darshan / darshan
Commits:
1fae7e7c by Shane Snyder at 2015-10-06T16:09:09Z
small fixes for COPYRIGHT, ChangeLog, & comments
- - - - -
4150a0f9 by Shane Snyder at 2015-10-12T12:03:16Z
update makefile to install uthash header
- - - - -
df02ace5 by Shane Snyder at 2015-10-12T16:44:25Z
make uthash header install in correct directory
- - - - -
32096856 by Shane Snyder at 2015-10-13T09:50:02Z
make install updates to support external tools
- - - - -
48352d36 by Shane Snyder at 2015-10-29T16:13:28Z
make maximum runtime records configurable
use --with-max-records at configure time to change from default
of 2048 records
- - - - -
98c93e0f by Shane Snyder at 2015-11-02T12:34:38Z
darshan-runtime commits for configurable mem
user can now give a config option or use a runtime environment
variable to control darshan's per module memory requirements.
- - - - -
40d1dc03 by Shane Snyder at 2015-11-02T13:31:25Z
darshan-util updates to support partial logs
- - - - -
2950f613 by Shane Snyder at 2015-11-02T16:45:56Z
fix random typos in comments
- - - - -
45eb36b1 by Shane Snyder at 2015-11-03T13:09:06Z
update darshan version in configure
- - - - -
8731ade9 by Shane Snyder at 2015-11-03T13:09:40Z
update darshan modularization docs
- - - - -
e810279e by Shane Snyder at 2015-11-11T15:43:27Z
Merge branch 'dev-modular' into mmap-dev
Conflicts:
darshan-runtime/darshan-core.h
darshan-runtime/lib/darshan-core.c
- - - - -
799d9890 by Shane Snyder at 2015-11-24T14:45:31Z
update logutils to allow logs with only job info
- - - - -
bdb2a5f0 by Shane Snyder at 2015-12-01T12:40:28Z
runtime now mmaps header and job data to tmp log
- - - - -
3b0c668b by Shane Snyder at 2015-12-02T14:36:19Z
update logutils to read uncompressed log files
- - - - -
25 changed files:
- COPYRIGHT
- ChangeLog
- darshan-log-format.h
- darshan-runtime/Makefile.in
- darshan-runtime/configure
- darshan-runtime/configure.in
- darshan-runtime/darshan-core.h
- darshan-runtime/darshan-runtime-config.h.in
- darshan-runtime/darshan.h
- darshan-runtime/doc/darshan-runtime.txt
- darshan-runtime/lib/darshan-bgq.c
- darshan-runtime/lib/darshan-core.c
- darshan-runtime/lib/darshan-hdf5.c
- darshan-runtime/lib/darshan-mpiio.c
- darshan-runtime/lib/darshan-null.c
- darshan-runtime/lib/darshan-pnetcdf.c
- darshan-runtime/lib/darshan-posix.c
- darshan-util/configure
- darshan-util/configure.in
- darshan-util/darshan-convert.c
- darshan-util/darshan-job-summary/bin/darshan-job-summary.pl.in
- darshan-util/darshan-logutils.c
- darshan-util/darshan-logutils.h
- darshan-util/darshan-parser.c
- doc/darshan-modularization.txt
Changes:
=====================================
COPYRIGHT
=====================================
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -6,7 +6,7 @@ which must be included in the prologue of the code and in all source listings
of the code.
Copyright Notice
- + 2009 University of Chicago
+ + 2015 University of Chicago
Permission is hereby granted to use, reproduce, prepare derivative works, and
to redistribute to others. This software was authored by:
=====================================
ChangeLog
=====================================
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,16 @@
Darshan Release Change Log
--------------------------
+Darshan-3.0.0-pre2
+=============
+* add fix to install appropriate headers for linking external
+ applications with darshan-util (reported by Matthieu Dorier)
+* add darshan-util Ruby bindings for the new modularized version
+ of Darshan (3.0) (Matthieu Dorier)
+* add enhancement to darshan-runtime to allow per-module instrumentation
+ memory to be user configurable using a configure option or a runtime
+ environment variable
+
Darshan-3.0.0-pre1
=============
* new version of Darshan with the following features/improvements:
@@ -18,6 +28,7 @@ Darshan-3.0.0-pre1
suffixes
- a new instrumentation module for capturing BG/Q-specific parameters
(BG/Q environment is automatically detected at configure time)
+ (implemented by Kevin Harms)
- new darshan-parser and darshan-job-summary output to utilize the
new modularized log format
* updated documentation outlining changes in this release, as well as
=====================================
darshan-log-format.h
=====================================
--- a/darshan-log-format.h
+++ b/darshan-log-format.h
@@ -69,21 +69,25 @@ static char * const darshan_module_names[] =
};
#undef X
+/* simple macros for accessing module flag bitfields */
+#define DARSHAN_MOD_FLAG_SET(flags, id) flags = (flags | (1 << id))
+#define DARSHAN_MOD_FLAG_UNSET(flags, id) flags = (flags & ~(1 << id))
+#define DARSHAN_MOD_FLAG_ISSET(flags, id) (flags & (1 << id))
+
/* compression method used on darshan log file */
enum darshan_comp_type
{
DARSHAN_ZLIB_COMP,
DARSHAN_BZIP2_COMP,
+ DARSHAN_NO_COMP,
};
typedef uint64_t darshan_record_id;
/* the darshan_log_map structure is used to indicate the location of
* specific module data in a Darshan log. Note that 'off' and 'len' are
- * the respective offset and length of the data in the file, in *uncompressed*
- * terms -- this is nonintuitive since the data is compressed, but this is
- * done so we can utilize the gzread interface for all Darshan log reading
- * utilities.
+ * the respective offset and length of the data in the file, in
+ * *compressed* terms
*/
struct darshan_log_map
{
@@ -99,7 +103,7 @@ struct darshan_header
char version_string[8];
int64_t magic_nr;
unsigned char comp_type;
- unsigned char partial_flag;
+ uint32_t partial_flag;
struct darshan_log_map rec_map;
struct darshan_log_map mod_map[DARSHAN_MAX_MODS];
};
=====================================
darshan-runtime/Makefile.in
=====================================
--- a/darshan-runtime/Makefile.in
+++ b/darshan-runtime/Makefile.in
@@ -1,4 +1,5 @@
-all: lib/libdarshan.a lib/libdarshan-stubs.a lib/darshan-null.o
+all: lib/libdarshan.a lib/libdarshan-stubs.a
+#TODO: lib/darshan-null.o
#TODO: each module provides own makefile with module-specific objects, build options, etc.
=====================================
darshan-runtime/configure
=====================================
--- a/darshan-runtime/configure
+++ b/darshan-runtime/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for darshan-runtime 3.0.0-pre1.
+# Generated by GNU Autoconf 2.69 for darshan-runtime 3.0.0-pre2.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='darshan-runtime'
PACKAGE_TARNAME='darshan-runtime'
-PACKAGE_VERSION='3.0.0-pre1'
-PACKAGE_STRING='darshan-runtime 3.0.0-pre1'
+PACKAGE_VERSION='3.0.0-pre2'
+PACKAGE_STRING='darshan-runtime 3.0.0-pre2'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -693,6 +693,7 @@ with_log_hints
with_log_path
with_jobid_env
enable_bgq_mod
+with_mod_mem
'
ac_precious_vars='build_alias
host_alias
@@ -1243,7 +1244,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures darshan-runtime 3.0.0-pre1 to adapt to many kinds of systems.
+\`configure' configures darshan-runtime 3.0.0-pre2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1304,7 +1305,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of darshan-runtime 3.0.0-pre1:";;
+ short | recursive ) echo "Configuration of darshan-runtime 3.0.0-pre2:";;
esac
cat <<\_ACEOF
@@ -1330,6 +1331,7 @@ Optional Packages:
--with-jobid-env=<name> Name of environment variable that stores the jobid
(specify "NONE" if no appropriate environment variable is available:
Darshan will use rank 0's pid instead)
+ --with-mod-mem=<num> Maximum amount of memory (in MiB) for each Darshan module
Some influential environment variables:
CC C compiler command
@@ -1407,7 +1409,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-darshan-runtime configure 3.0.0-pre1
+darshan-runtime configure 3.0.0-pre2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1759,7 +1761,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by darshan-runtime $as_me 3.0.0-pre1, which was
+It was created by darshan-runtime $as_me 3.0.0-pre2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -4278,7 +4280,23 @@ fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
-DARSHAN_VERSION="3.0.0-pre1"
+
+# Check whether --with-mod-mem was given.
+if test "${with_mod_mem+set}" = set; then :
+ withval=$with_mod_mem; if test x$withval = xyes; then
+ as_fn_error $? "--with-mod-mem must be given a number" "$LINENO" 5
+ else
+
+cat >>confdefs.h <<_ACEOF
+#define __DARSHAN_MOD_MEM_MAX ${withval}
+_ACEOF
+
+ fi
+
+fi
+
+
+DARSHAN_VERSION="3.0.0-pre2"
@@ -4797,7 +4815,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by darshan-runtime $as_me 3.0.0-pre1, which was
+This file was extended by darshan-runtime $as_me 3.0.0-pre2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4859,7 +4877,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-darshan-runtime config.status 3.0.0-pre1
+darshan-runtime config.status 3.0.0-pre2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
=====================================
darshan-runtime/configure.in
=====================================
--- a/darshan-runtime/configure.in
+++ b/darshan-runtime/configure.in
@@ -5,7 +5,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl You may need to use autoheader as well if changing any DEFINEs
dnl sanity checks, output header, location of scripts used here
-AC_INIT([darshan-runtime], [3.0.0-pre1])
+AC_INIT([darshan-runtime], [3.0.0-pre2])
AC_CONFIG_SRCDIR([darshan.h])
AC_CONFIG_AUX_DIR(../maint/config)
AC_CONFIG_HEADER(darshan-runtime-config.h)
@@ -300,6 +300,15 @@ if test x$enable_bgq_mod != xno; then
[]))
fi
+AC_ARG_WITH(mod-mem,
+[ --with-mod-mem=<num> Maximum amount of memory (in MiB) for each Darshan module],
+ if test x$withval = xyes; then
+ AC_MSG_ERROR(--with-mod-mem must be given a number)
+ else
+ AC_DEFINE_UNQUOTED(__DARSHAN_MOD_MEM_MAX, ${withval}, Maximum memory (in MiB) for each Darshan module)
+ fi
+)
+
DARSHAN_VERSION="AC_PACKAGE_VERSION"
AC_SUBST(darshan_lib_path)
=====================================
darshan-runtime/darshan-core.h
=====================================
--- a/darshan-runtime/darshan-core.h
+++ b/darshan-runtime/darshan-core.h
@@ -26,33 +26,32 @@
/* Environment variable to override __DARSHAN_MEM_ALIGNMENT */
#define DARSHAN_MEM_ALIGNMENT_OVERRIDE "DARSHAN_MEMALIGN"
-/* maximum number of records that can be tracked on a single process */
-#define DARSHAN_CORE_MAX_RECORDS 2048
+/* Environment variable to override memory per module */
+#define DARSHAN_MOD_MEM_OVERRIDE "DARSHAN_MODMEM"
-/* TODO: revisit this default size if we change memory per module */
-#define DARSHAN_CORE_COMP_BUF_SIZE (2 * 1024 * 1024)
+/* Maximum amount of memory per instrumentation module in MiB */
+#ifdef __DARSHAN_MOD_MEM_MAX
+#define DARSHAN_MOD_MEM_MAX (__DARSHAN_MOD_MEM_MAX * 1024 * 1024)
+#else
+#define DARSHAN_MOD_MEM_MAX (2 * 1024 * 1024) /* 2 MiB default */
+#endif
-/* this controls the maximum mmapped memory each module can use */
-#define DARSHAN_MMAP_CHUNK_SIZE (4 * 1024)
-
-#define DARSHAN_CORE_MOD_SET(flags, id) (flags | (1 << id))
-#define DARSHAN_CORE_MOD_UNSET(flags, id) (flags & ~(1 << id))
-#define DARSHAN_CORE_MOD_ISSET(flags, id) (flags & (1 << id))
+/* Default runtime compression buffer size */
+#define DARSHAN_COMP_BUF_SIZE DARSHAN_MOD_MEM_MAX
/* in memory structure to keep up with job level data */
struct darshan_core_runtime
{
- /* XXX-MMAP */
+ struct darshan_header *log_hdr_p;
+ struct darshan_job *log_job_p;
+ char *log_exemnt_p;
+ /* XXX: MMAP */
void *mmap_p;
- struct darshan_job *mmap_job_p;
- char *mmap_exe_mnt_p;
- void *mmap_mod_p;
- /* XXX-MMAP */
struct darshan_core_record_ref *rec_hash;
int rec_count;
struct darshan_core_module* mod_array[DARSHAN_MAX_MODS];
- char comp_buf[DARSHAN_CORE_COMP_BUF_SIZE];
+ char comp_buf[DARSHAN_COMP_BUF_SIZE]; /* TODO: why is this allocated statically? */
double wtime_offset;
};
=====================================
darshan-runtime/darshan-runtime-config.h.in
=====================================
--- a/darshan-runtime/darshan-runtime-config.h.in
+++ b/darshan-runtime/darshan-runtime-config.h.in
@@ -105,5 +105,8 @@
/* Memory alignment in bytes */
#undef __DARSHAN_MEM_ALIGNMENT
+/* Maximum memory (in MiB) for each Darshan module */
+#undef __DARSHAN_MOD_MEM_MAX
+
/* Generalized request type for MPI-IO */
#undef __D_MPI_REQUEST
=====================================
darshan-runtime/darshan.h
=====================================
--- a/darshan-runtime/darshan.h
+++ b/darshan-runtime/darshan.h
@@ -98,10 +98,9 @@ struct darshan_module_funcs
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
+ void **mod_buf,
+ int *mod_buf_size,
int *my_rank,
- int *mod_mem_limit,
- void **mmap_buf,
- int *mmap_buf_size,
int *sys_mem_alignment);
/* darshan_core_unregister_module()
@@ -117,18 +116,21 @@ void darshan_core_unregister_module(
* Register the Darshan record given by 'name' with the darshan-core
* runtime, allowing it to be properly tracked and (potentially)
* correlated with records from other modules. 'len' is the size of
- * the name pointer (string length for string names), 'printable_flag'
- * indicates whether the name is a string, and 'mod_id' is the identifier
- * of the calling module. 'rec_id' is an output pointer storing the
- * correspoing Darshan record identifier and 'file_alignment' is an
- * output pointer storing the file system alignment value for the given
- * record.
+ * the name pointer (string length for string names), and 'printable_flag'
+ * indicates whether the name is a string. 'mod_limit_flag' is set if
+ * the calling module is out of memory (to prevent darshan-core from
+ * creating new records and to just search existing records) and 'mod_id'
+ * is the identifier of the calling module. 'rec_id' is an output pointer
+ * storing the correspoing Darshan record identifier and 'file_alignment'
+ * is an output pointer storing the file system alignment value for the
+ * given record.
*/
void darshan_core_register_record(
void *name,
int len,
- int printable_flag,
darshan_module_id mod_id,
+ int printable_flag,
+ int mod_limit_flag,
darshan_record_id *rec_id,
int *file_alignment);
=====================================
darshan-runtime/doc/darshan-runtime.txt
=====================================
--- a/darshan-runtime/doc/darshan-runtime.txt
+++ b/darshan-runtime/doc/darshan-runtime.txt
@@ -57,6 +57,8 @@ will be placed.
determine the log path at run time.
* `--with-log-hints=`: specifies hints to use when writing the Darshan log
file. See `./configure --help` for details.
+* `--with-mod-mem=`: specifies the maximum amount of memory (in MiB) that
+each Darshan module can consume.
* `--with-zlib=`: specifies an alternate location for the zlib development
header and library.
* `CC=`: specifies the MPI C compiler to use for compilation.
@@ -474,3 +476,4 @@ behavior at runtime:
* DARSHAN_DISABLE_SHARED_REDUCTION: disables the step in Darshan aggregation in which files that were accessed by all ranks are collapsed into a single cumulative file record at rank 0. This option retains more per-process information at the expense of creating larger log files. Note that it is up to individual instrumentation module implementations whether this environment variable is actually honored.
* DARSHAN_LOGPATH: specifies the path to write Darshan log files to. Note that this directory needs to be formatted using the darshan-mk-log-dirs script.
* DARSHAN_LOGFILE: specifies the path (directory + Darshan log file name) to write the output Darshan log to. This overrides the default Darshan behavior of automatically generating a log file name and adding it to a log file directory formatted using darshan-mk-log-dirs script.
+* DARSHAN_MODMEM: specifies the maximum amount of memory (in MiB) a Darshan instrumentation module can consume at runtime.
=====================================
darshan-runtime/lib/darshan-bgq.c
=====================================
--- a/darshan-runtime/lib/darshan-bgq.c
+++ b/darshan-runtime/lib/darshan-bgq.c
@@ -163,8 +163,9 @@ void bgq_runtime_initialize()
darshan_core_register_record(
recname,
strlen(recname),
- 1,
DARSHAN_BGQ_MOD,
+ 1,
+ 0,
&bgq_runtime->record.f_id,
&bgq_runtime->record.alignment);
=====================================
darshan-runtime/lib/darshan-core.c
=====================================
--- a/darshan-runtime/lib/darshan-core.c
+++ b/darshan-runtime/lib/darshan-core.c
@@ -100,7 +100,8 @@ static void darshan_get_exe_and_mounts(
static void darshan_block_size_from_path(
const char *path, int *block_size);
static void darshan_get_shared_records(
- struct darshan_core_runtime *core, darshan_record_id *shared_recs);
+ struct darshan_core_runtime *core, darshan_record_id **shared_recs,
+ int *shared_rec_cnt);
static int darshan_log_open_all(
char *logfile_name, MPI_File *log_fh);
static int darshan_deflate_buffer(
@@ -199,11 +200,8 @@ void darshan_core_initialize(int argc, char **argv)
sys_page_size = sysconf(_SC_PAGESIZE);
assert(sys_page_size > 0);
- /* set the size of the mmap, making sure to round up to the
- * nearest page size. One mmap chunk is used for the job-level
- * metadata, and the rest are statically assigned to modules
- */
- mmap_size = (1 + DARSHAN_MAX_MODS) * DARSHAN_MMAP_CHUNK_SIZE;
+ /* XXX: MMAP */
+ mmap_size = sizeof(struct darshan_header) + DARSHAN_JOB_RECORD_SIZE + DARSHAN_MOD_MEM_MAX;
if(mmap_size % sys_page_size)
mmap_size = ((mmap_size / sys_page_size) + 1) * sys_page_size;
@@ -223,6 +221,7 @@ void darshan_core_initialize(int argc, char **argv)
return;
}
+ /* TODO: what's more expensive? truncate or write zeros? perf test this call and later accesses */
/* allocate the necessary space in the log file */
ret = ftruncate(mmap_fd, mmap_size);
if(ret < 0)
@@ -253,18 +252,27 @@ void darshan_core_initialize(int argc, char **argv)
/* close darshan log file (this does *not* unmap the log file) */
close(mmap_fd);
- /* set the pointers for each log file region */
- init_core->mmap_job_p = (struct darshan_job *)(init_core->mmap_p);
- init_core->mmap_exe_mnt_p =
- (char *)(((char *)init_core->mmap_p) + sizeof(struct darshan_job));
- init_core->mmap_mod_p =
- (void *)(((char *)init_core->mmap_p) + DARSHAN_MMAP_CHUNK_SIZE);
+ /* set the memory pointers for each log file region */
+ init_core->log_hdr_p = (struct darshan_header *)
+ (init_core->mmap_p);
+ init_core->log_job_p = (struct darshan_job *)
+ (init_core->log_hdr_p + sizeof(struct darshan_header));
+ init_core->log_exemnt_p = (char *)
+ (((char *)init_core->log_job_p) + sizeof(struct darshan_job));
+ /* TODO: file hash & module memory */
+
+ /* XXX: MMAP */
+
+ /* set known header fields for the log file */
+ strcpy(init_core->log_hdr_p->version_string, DARSHAN_LOG_VERSION);
+ init_core->log_hdr_p->magic_nr = DARSHAN_MAGIC_NR;
+ init_core->log_hdr_p->comp_type = DARSHAN_NO_COMP;
- /* set known job-level metadata files for the log file */
- init_core->mmap_job_p->uid = getuid();
- init_core->mmap_job_p->start_time = time(NULL);
- init_core->mmap_job_p->nprocs = nprocs;
- init_core->mmap_job_p->jobid = (int64_t)jobid;
+ /* set known job-level metadata fields for the log file */
+ init_core->log_job_p->uid = getuid();
+ init_core->log_job_p->start_time = time(NULL);
+ init_core->log_job_p->nprocs = nprocs;
+ init_core->log_job_p->jobid = (int64_t)jobid;
/* if we are using any hints to write the log file, then record those
* hints with the darshan job information
@@ -274,9 +282,7 @@ void darshan_core_initialize(int argc, char **argv)
/* collect information about command line and mounted file systems */
darshan_get_exe_and_mounts(init_core, argc, argv);
- /* TODO: what would be needed in a termination routine? set job end time? */
-
- /* maybe bootstrap modules with static initializers */
+ /* bootstrap any modules with static initialization routines */
i = 0;
while(mod_static_init_fns[i])
{
@@ -336,7 +342,7 @@ void darshan_core_shutdown()
}
DARSHAN_CORE_UNLOCK();
- final_core->mmap_job_p->end_time = time(NULL);
+ final_core->log_job_p->end_time = time(NULL);
darshan_core_cleanup(final_core);
@@ -518,11 +524,11 @@ static void darshan_get_logfile_name(char* logfile_name, int jobid, struct tm* s
return;
}
-/* record any hints used to write the darshan log in the log header */
+/* record any hints used to write the darshan log in the job data */
static void darshan_log_record_hints_and_ver(struct darshan_core_runtime* core)
{
char* hints;
- char* header_hints;
+ char* job_hints;
int meta_remain = 0;
char* m;
@@ -538,28 +544,28 @@ static void darshan_log_record_hints_and_ver(struct darshan_core_runtime* core)
if(!hints || strlen(hints) < 1)
return;
- header_hints = strdup(hints);
- if(!header_hints)
+ job_hints = strdup(hints);
+ if(!job_hints)
return;
meta_remain = DARSHAN_JOB_METADATA_LEN -
- strlen(core->mmap_job_p->metadata) - 1;
+ strlen(core->log_job_p->metadata) - 1;
if(meta_remain >= (strlen(PACKAGE_VERSION) + 9))
{
- sprintf(core->mmap_job_p->metadata, "lib_ver=%s\n", PACKAGE_VERSION);
+ sprintf(core->log_job_p->metadata, "lib_ver=%s\n", PACKAGE_VERSION);
meta_remain -= (strlen(PACKAGE_VERSION) + 9);
}
- if(meta_remain >= (3 + strlen(header_hints)))
+ if(meta_remain >= (3 + strlen(job_hints)))
{
- m = core->mmap_job_p->metadata + strlen(core->mmap_job_p->metadata);
+ m = core->log_job_p->metadata + strlen(core->log_job_p->metadata);
/* We have room to store the hints in the metadata portion of
- * the job header. We just prepend an h= to the hints list. The
+ * the job structure. We just prepend an h= to the hints list. The
* metadata parser will ignore = characters that appear in the value
* portion of the metadata key/value pair.
*/
- sprintf(m, "h=%s\n", header_hints);
+ sprintf(m, "h=%s\n", job_hints);
}
- free(header_hints);
+ free(job_hints);
return;
}
@@ -603,7 +609,7 @@ static void add_entry(char* buf, int* space_left, struct mntent *entry)
else
mnt_data_array[mnt_data_count].block_size = 4096;
- /* store mount information for use in header of darshan log */
+ /* store mount information with the job-level metadata in darshan log */
ret = snprintf(tmp_mnt, 256, "\n%s\t%s",
entry->mnt_type, entry->mnt_dir);
if(ret < 256 && strlen(tmp_mnt) <= (*space_left))
@@ -619,7 +625,7 @@ static void add_entry(char* buf, int* space_left, struct mntent *entry)
/* 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
+ * will be stored with the job-level metadata
*/
static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
int argc, char **argv)
@@ -655,12 +661,12 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
/* record exe and arguments */
for(i=0; i<argc; i++)
{
- strncat(core->mmap_exe_mnt_p, argv[i], space_left);
- space_left = DARSHAN_EXE_LEN-strlen(core->mmap_exe_mnt_p);
+ strncat(core->log_exemnt_p, argv[i], space_left);
+ space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
if(i < (argc-1))
{
- strncat(core->mmap_exe_mnt_p, " ", space_left);
- space_left = DARSHAN_EXE_LEN-strlen(core->mmap_exe_mnt_p);
+ strncat(core->log_exemnt_p, " ", space_left);
+ space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
}
}
@@ -669,21 +675,20 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
*/
if(argc == 0)
{
- strncat(core->mmap_exe_mnt_p, __progname_full, space_left);
- space_left = DARSHAN_EXE_LEN-strlen(core->mmap_exe_mnt_p);
- strncat(core->mmap_exe_mnt_p, " <unknown args>", space_left);
- space_left = DARSHAN_EXE_LEN-strlen(core->mmap_exe_mnt_p);
+ strncat(core->log_exemnt_p, __progname_full, space_left);
+ space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
+ strncat(core->log_exemnt_p, " <unknown args>", space_left);
+ space_left = DARSHAN_EXE_LEN-strlen(core->log_exemnt_p);
}
if(space_left == 0)
{
/* we ran out of room; mark that string was truncated */
truncate_offset = DARSHAN_EXE_LEN - strlen(truncate_string);
- sprintf(&core->mmap_exe_mnt_p[truncate_offset], "%s",
+ sprintf(&(core->log_exemnt_p[truncate_offset]), "%s",
truncate_string);
}
-
/* 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
@@ -711,7 +716,7 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
if(skip || (strcmp(entry->mnt_type, "nfs") == 0))
continue;
- add_entry(core->mmap_exe_mnt_p, &space_left, entry);
+ add_entry(core->log_exemnt_p, &space_left, entry);
}
endmntent(tab);
@@ -724,7 +729,7 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
if(strcmp(entry->mnt_type, "nfs") != 0)
continue;
- add_entry(core->mmap_exe_mnt_p, &space_left, entry);
+ add_entry(core->log_exemnt_p, &space_left, entry);
}
endmntent(tab);
@@ -739,7 +744,7 @@ static void darshan_get_exe_and_mounts_root(struct darshan_core_runtime *core,
/* 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
+ * will be stored with the job-level metadata
*/
static void darshan_get_exe_and_mounts(struct darshan_core_runtime *core,
int argc, char **argv)
@@ -777,32 +782,45 @@ static void darshan_block_size_from_path(const char *path, int *block_size)
}
static void darshan_get_shared_records(struct darshan_core_runtime *core,
- darshan_record_id *shared_recs)
+ darshan_record_id **shared_recs, int *shared_rec_cnt)
{
- int i;
- int ndx;
+ int i, j;
+ int tmp_cnt = core->rec_count;
struct darshan_core_record_ref *tmp, *ref;
- darshan_record_id id_array[DARSHAN_CORE_MAX_RECORDS] = {0};
- uint64_t mod_flags[DARSHAN_CORE_MAX_RECORDS] = {0};
- uint64_t global_mod_flags[DARSHAN_CORE_MAX_RECORDS] = {0};
+ darshan_record_id *id_array;
+ uint64_t *mod_flags;
+ uint64_t *global_mod_flags;
+
+ /* broadcast root's number of records to all other processes */
+ DARSHAN_MPI_CALL(PMPI_Bcast)(&tmp_cnt, 1, MPI_INT, 0, MPI_COMM_WORLD);
+
+ /* use root record count to allocate data structures */
+ id_array = malloc(tmp_cnt * sizeof(darshan_record_id));
+ mod_flags = malloc(tmp_cnt * sizeof(uint64_t));
+ global_mod_flags = malloc(tmp_cnt * sizeof(uint64_t));
+ *shared_recs = malloc(tmp_cnt * sizeof(darshan_record_id));
+ assert(id_array && mod_flags && global_mod_flags && *shared_recs);
+
+ memset(mod_flags, 0, tmp_cnt * sizeof(uint64_t));
+ memset(global_mod_flags, 0, tmp_cnt * sizeof(uint64_t));
+ memset(*shared_recs, 0, tmp_cnt * sizeof(darshan_record_id));
/* first, determine list of records root process has opened */
if(my_rank == 0)
{
- ndx = 0;
+ i = 0;
HASH_ITER(hlink, core->rec_hash, ref, tmp)
{
- id_array[ndx++] = ref->rec.id;
+ id_array[i++] = ref->rec.id;
}
}
/* broadcast root's list of records to all other processes */
- DARSHAN_MPI_CALL(PMPI_Bcast)(id_array,
- (DARSHAN_CORE_MAX_RECORDS * sizeof(darshan_record_id)),
+ DARSHAN_MPI_CALL(PMPI_Bcast)(id_array, (tmp_cnt * sizeof(darshan_record_id)),
MPI_BYTE, 0, MPI_COMM_WORLD);
/* everyone looks to see if they opened the same records as root */
- for(i=0; (i<DARSHAN_CORE_MAX_RECORDS && id_array[i] != 0); i++)
+ for(i=0; i<tmp_cnt; i++)
{
HASH_FIND(hlink, core->rec_hash, &id_array[i], sizeof(darshan_record_id), ref);
if(ref)
@@ -815,15 +833,15 @@ static void darshan_get_shared_records(struct darshan_core_runtime *core,
/* now allreduce so everyone agrees which files are shared and
* which modules accessed them collectively
*/
- DARSHAN_MPI_CALL(PMPI_Allreduce)(mod_flags, global_mod_flags,
- DARSHAN_CORE_MAX_RECORDS, MPI_UINT64_T, MPI_BAND, MPI_COMM_WORLD);
+ DARSHAN_MPI_CALL(PMPI_Allreduce)(mod_flags, global_mod_flags, tmp_cnt,
+ MPI_UINT64_T, MPI_BAND, MPI_COMM_WORLD);
- ndx = 0;
- for(i=0; (i<DARSHAN_CORE_MAX_RECORDS && id_array[i] != 0); i++)
+ j = 0;
+ for(i=0; i<tmp_cnt; i++)
{
if(global_mod_flags[i] != 0)
{
- shared_recs[ndx++] = id_array[i];
+ (*shared_recs)[j++] = id_array[i];
/* set global_mod_flags so we know which modules collectively
* accessed this module. we need this info to support shared
@@ -834,6 +852,7 @@ static void darshan_get_shared_records(struct darshan_core_runtime *core,
ref->global_mod_flags = global_mod_flags[i];
}
}
+ *shared_rec_cnt = j;
return;
}
@@ -938,7 +957,7 @@ static int darshan_deflate_buffer(void **pointers, int *lengths, int count,
}
tmp_stream.next_out = (unsigned char *)comp_buf;
- tmp_stream.avail_out = DARSHAN_CORE_COMP_BUF_SIZE;
+ tmp_stream.avail_out = DARSHAN_COMP_BUF_SIZE;
/* loop over the input pointers */
for(i = 0; i < count; i++)
@@ -999,9 +1018,9 @@ static int darshan_log_write_record_hash(MPI_File log_fh, struct darshan_core_ru
char *hash_buf;
char *hash_buf_off;
- /* allocate a buffer to store at most 64 bytes for each of a max number of records */
+ /* allocate a buffer to store at most 64 bytes for each registered record */
/* NOTE: this buffer may be reallocated if estimate is too small */
- hash_buf_sz = DARSHAN_CORE_MAX_RECORDS * 64;
+ hash_buf_sz = core->rec_count * 64;
hash_buf = malloc(hash_buf_sz);
if(!hash_buf)
{
@@ -1165,38 +1184,37 @@ static void darshan_core_cleanup(struct darshan_core_runtime* core)
void darshan_core_register_module(
darshan_module_id mod_id,
struct darshan_module_funcs *funcs,
+ void **mod_buf,
+ int *mod_buf_size,
int *my_rank,
- int *mod_mem_limit,
- void **mmap_buf,
- int *mmap_buf_size,
int *sys_mem_alignment)
{
+ int ret;
+ int tmpval;
struct darshan_core_module* mod;
- *mod_mem_limit = 0;
+ char *mod_mem_str = NULL;
+
+ *mod_buf_size = 0;
+ *mod_buf = NULL;
if(!darshan_core || (mod_id >= DARSHAN_MAX_MODS))
return;
+ /* XXX */
+ return;
+ /* XXX how do we assign size and address */
+
if(sys_mem_alignment)
*sys_mem_alignment = darshan_mem_alignment;
/* get the calling process's rank */
DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, my_rank);
- /* pass back the mmap buffer this module can use to persist
- * some module data (mmap_buf_size at max) even in the case
- * where darshan is not finalized
- */
- *mmap_buf =
- (void *)(((char *)darshan_core->mmap_mod_p) + (mod_id * DARSHAN_MMAP_CHUNK_SIZE));
- *mmap_buf_size = DARSHAN_MMAP_CHUNK_SIZE;
-
/* see if this module is already registered */
DARSHAN_CORE_LOCK();
if(darshan_core->mod_array[mod_id])
{
/* if module is already registered just return */
- /* NOTE: we do not recalculate memory limit here, just set to 0 */
DARSHAN_CORE_UNLOCK();
return;
}
@@ -1215,9 +1233,8 @@ void darshan_core_register_module(
/* register module with darshan */
darshan_core->mod_array[mod_id] = mod;
- /* TODO: something smarter than just 2 MiB per module */
- *mod_mem_limit = 2 * 1024 * 1024;
-
+ /* get the calling process's rank */
+ DARSHAN_MPI_CALL(PMPI_Comm_rank)(MPI_COMM_WORLD, my_rank);
DARSHAN_CORE_UNLOCK();
return;
@@ -1251,8 +1268,9 @@ void darshan_core_unregister_module(
void darshan_core_register_record(
void *name,
int len,
- int printable_flag,
darshan_module_id mod_id,
+ int printable_flag,
+ int mod_limit_flag,
darshan_record_id *rec_id,
int *file_alignment)
{
@@ -1274,19 +1292,19 @@ void darshan_core_register_record(
HASH_FIND(hlink, darshan_core->rec_hash, &tmp_rec_id, sizeof(darshan_record_id), ref);
if(!ref)
{
- /* record not found -- add it to the hash if we aren't already tracking the
- * maximum number of records
+ /* record not found -- add it to the hash if this module has not already used
+ * all of its memory
*/
-
- if(darshan_core->rec_count >= DARSHAN_CORE_MAX_RECORDS)
+
+#if 0
+ if(mod_limit_flag)
{
- /* if we are already tracking the max records, set a flag to indicate
- * that this log file has partial results
- */
- //darshan_core->logfile_header_p->partial_flag = 1;
+ /* if this module is OOM, set a flag in the header to indicate this */
+ DARSHAN_MOD_FLAG_SET(darshan_core->log_header.partial_flag, mod_id);
DARSHAN_CORE_UNLOCK();
return;
}
+#endif
ref = malloc(sizeof(struct darshan_core_record_ref));
if(ref)
@@ -1301,7 +1319,7 @@ void darshan_core_register_record(
darshan_core->rec_count++;
}
}
- ref->mod_flags = DARSHAN_CORE_MOD_SET(ref->mod_flags, mod_id);
+ DARSHAN_MOD_FLAG_SET(ref->mod_flags, mod_id);
DARSHAN_CORE_UNLOCK();
if(file_alignment)
@@ -1326,7 +1344,7 @@ void darshan_core_unregister_record(
assert(ref);
/* disassociate this module from the given record id */
- ref->mod_flags = DARSHAN_CORE_MOD_UNSET(ref->mod_flags, mod_id);
+ DARSHAN_MOD_FLAG_UNSET(ref->mod_flags, mod_id);
if(!(ref->mod_flags))
{
/* if no other modules are associated with this rec, delete it */
=====================================
darshan-runtime/lib/darshan-hdf5.c
=====================================
--- a/darshan-runtime/lib/darshan-hdf5.c
+++ b/darshan-runtime/lib/darshan-hdf5.c
@@ -263,6 +263,7 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
struct hdf5_file_runtime *file = NULL;
char *newname = NULL;
darshan_record_id file_id;
+ int limit_flag;
if(!hdf5_runtime || instrumentation_disabled)
return(NULL);
@@ -271,12 +272,15 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
if(!newname)
newname = (char*)name;
+ limit_flag = (hdf5_runtime->file_array_ndx >= hdf5_runtime->file_array_size);
+
/* get a unique id for this file from darshan core */
darshan_core_register_record(
(void*)newname,
strlen(newname),
- 1,
DARSHAN_HDF5_MOD,
+ 1,
+ limit_flag,
&file_id,
NULL);
@@ -299,19 +303,15 @@ static struct hdf5_file_runtime* hdf5_file_by_name(const char *name)
return(file);
}
- if(hdf5_runtime->file_array_ndx < hdf5_runtime->file_array_size);
- {
- /* no existing record, assign a new file record from the global array */
- file = &(hdf5_runtime->file_runtime_array[hdf5_runtime->file_array_ndx]);
- file->file_record = &(hdf5_runtime->file_record_array[hdf5_runtime->file_array_ndx]);
- file->file_record->f_id = file_id;
- file->file_record->rank = my_rank;
-
- /* add new record to file hash table */
- HASH_ADD(hlink, hdf5_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ /* no existing record, assign a new file record from the global array */
+ file = &(hdf5_runtime->file_runtime_array[hdf5_runtime->file_array_ndx]);
+ file->file_record = &(hdf5_runtime->file_record_array[hdf5_runtime->file_array_ndx]);
+ file->file_record->f_id = file_id;
+ file->file_record->rank = my_rank;
- hdf5_runtime->file_array_ndx++;
- }
+ /* add new record to file hash table */
+ HASH_ADD(hlink, hdf5_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ hdf5_runtime->file_array_ndx++;
if(newname != name)
free(newname);
=====================================
darshan-runtime/lib/darshan-mpiio.c
=====================================
--- a/darshan-runtime/lib/darshan-mpiio.c
+++ b/darshan-runtime/lib/darshan-mpiio.c
@@ -884,6 +884,7 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
struct mpiio_file_runtime *file = NULL;
char *newname = NULL;
darshan_record_id file_id;
+ int limit_flag;
if(!mpiio_runtime || instrumentation_disabled)
return(NULL);
@@ -892,17 +893,20 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
if(!newname)
newname = (char*)name;
+ limit_flag = (mpiio_runtime->file_array_ndx >= mpiio_runtime->file_array_size);
+
/* get a unique id for this file from darshan core */
darshan_core_register_record(
(void*)newname,
strlen(newname),
- 1,
DARSHAN_MPIIO_MOD,
+ 1,
+ limit_flag,
&file_id,
NULL);
- /* if record is set to 0, darshan-core is out of space and will not
- * track this record, so we should avoid tracking it, too
+ /* the file record id is set to 0 if no memory is available for tracking
+ * new records -- just fall through and ignore this record
*/
if(file_id == 0)
{
@@ -920,19 +924,15 @@ static struct mpiio_file_runtime* mpiio_file_by_name(const char *name)
return(file);
}
- if(mpiio_runtime->file_array_ndx < mpiio_runtime->file_array_size);
- {
- /* no existing record, assign a new file record from the global array */
- file = &(mpiio_runtime->file_runtime_array[mpiio_runtime->file_array_ndx]);
- file->file_record = &(mpiio_runtime->file_record_array[mpiio_runtime->file_array_ndx]);
- file->file_record->f_id = file_id;
- file->file_record->rank = my_rank;
-
- /* add new record to file hash table */
- HASH_ADD(hlink, mpiio_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ /* no existing record, assign a new file record from the global array */
+ file = &(mpiio_runtime->file_runtime_array[mpiio_runtime->file_array_ndx]);
+ file->file_record = &(mpiio_runtime->file_record_array[mpiio_runtime->file_array_ndx]);
+ file->file_record->f_id = file_id;
+ file->file_record->rank = my_rank;
- mpiio_runtime->file_array_ndx++;
- }
+ /* add new record to file hash table */
+ HASH_ADD(hlink, mpiio_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ mpiio_runtime->file_array_ndx++;
if(newname != name)
free(newname);
=====================================
darshan-runtime/lib/darshan-null.c
=====================================
--- a/darshan-runtime/lib/darshan-null.c
+++ b/darshan-runtime/lib/darshan-null.c
@@ -275,6 +275,7 @@ static struct null_record_runtime* null_record_by_name(const char *name)
{
struct null_record_runtime *rec = NULL;
darshan_record_id rec_id;
+ int limit_flag;
/* Don't search for a record if the "NULL" module is not initialized or
* if instrumentation has been toggled off.
@@ -282,15 +283,27 @@ static struct null_record_runtime* null_record_by_name(const char *name)
if(!null_runtime || instrumentation_disabled)
return(NULL);
+ /* stop tracking new records if we are tracking our maximum count */
+ limit_flag = (null_runtime->rec_array_ndx >= null_runtime->rec_array_size);
+
/* get a unique record identifier for this record from darshan-core */
darshan_core_register_record(
(void*)name,
strlen(name),
- 1,
DARSHAN_NULL_MOD,
+ 1,
+ limit_flag,
&rec_id,
NULL);
+ /* the file record id is set to 0 if no memory is available for tracking
+ * new records -- just fall through and ignore this record
+ */
+ if(rec_id == 0)
+ {
+ return(NULL);
+ }
+
/* search the hash table for this file record, and return if found */
HASH_FIND(hlink, null_runtime->record_hash, &rec_id, sizeof(darshan_record_id), rec);
if(rec)
@@ -298,21 +311,17 @@ static struct null_record_runtime* null_record_by_name(const char *name)
return(rec);
}
- if(null_runtime->rec_array_ndx < null_runtime->rec_array_size);
- {
- /* no existing record, assign a new one from the global array */
- rec = &(null_runtime->runtime_record_array[null_runtime->rec_array_ndx]);
- rec->record_p = &(null_runtime->record_array[null_runtime->rec_array_ndx]);
+ /* no existing record, assign a new one from the global array */
+ rec = &(null_runtime->runtime_record_array[null_runtime->rec_array_ndx]);
+ rec->record_p = &(null_runtime->record_array[null_runtime->rec_array_ndx]);
- /* set the darshan record id and corresponding process rank for this record */
- rec->record_p->f_id = rec_id;
- rec->record_p->rank = my_rank;
+ /* set the darshan record id and corresponding process rank for this record */
+ rec->record_p->f_id = rec_id;
+ rec->record_p->rank = my_rank;
- /* add new record to file hash table */
- HASH_ADD(hlink, null_runtime->record_hash, record_p->f_id, sizeof(darshan_record_id), rec);
-
- null_runtime->rec_array_ndx++;
- }
+ /* add new record to file hash table */
+ HASH_ADD(hlink, null_runtime->record_hash, record_p->f_id, sizeof(darshan_record_id), rec);
+ null_runtime->rec_array_ndx++;
return(rec);
}
=====================================
darshan-runtime/lib/darshan-pnetcdf.c
=====================================
--- a/darshan-runtime/lib/darshan-pnetcdf.c
+++ b/darshan-runtime/lib/darshan-pnetcdf.c
@@ -275,6 +275,7 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
struct pnetcdf_file_runtime *file = NULL;
char *newname = NULL;
darshan_record_id file_id;
+ int limit_flag;
if(!pnetcdf_runtime || instrumentation_disabled)
return(NULL);
@@ -283,17 +284,20 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
if(!newname)
newname = (char*)name;
+ limit_flag = (pnetcdf_runtime->file_array_ndx >= pnetcdf_runtime->file_array_size);
+
/* get a unique id for this file from darshan core */
darshan_core_register_record(
(void*)newname,
strlen(newname),
- 1,
DARSHAN_PNETCDF_MOD,
+ 1,
+ limit_flag,
&file_id,
NULL);
- /* if record is set to 0, darshan-core is out of space and will not
- * track this record, so we should avoid tracking it, too
+ /* the file record id is set to 0 if no memory is available for tracking
+ * new records -- just fall through and ignore this record
*/
if(file_id == 0)
{
@@ -311,19 +315,15 @@ static struct pnetcdf_file_runtime* pnetcdf_file_by_name(const char *name)
return(file);
}
- if(pnetcdf_runtime->file_array_ndx < pnetcdf_runtime->file_array_size);
- {
- /* no existing record, assign a new file record from the global array */
- file = &(pnetcdf_runtime->file_runtime_array[pnetcdf_runtime->file_array_ndx]);
- file->file_record = &(pnetcdf_runtime->file_record_array[pnetcdf_runtime->file_array_ndx]);
- file->file_record->f_id = file_id;
- file->file_record->rank = my_rank;
-
- /* add new record to file hash table */
- HASH_ADD(hlink, pnetcdf_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ /* no existing record, assign a new file record from the global array */
+ file = &(pnetcdf_runtime->file_runtime_array[pnetcdf_runtime->file_array_ndx]);
+ file->file_record = &(pnetcdf_runtime->file_record_array[pnetcdf_runtime->file_array_ndx]);
+ file->file_record->f_id = file_id;
+ file->file_record->rank = my_rank;
- pnetcdf_runtime->file_array_ndx++;
- }
+ /* add new record to file hash table */
+ HASH_ADD(hlink, pnetcdf_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ pnetcdf_runtime->file_array_ndx++;
if(newname != name)
free(newname);
=====================================
darshan-runtime/lib/darshan-posix.c
=====================================
--- a/darshan-runtime/lib/darshan-posix.c
+++ b/darshan-runtime/lib/darshan-posix.c
@@ -177,8 +177,6 @@ struct posix_runtime
int file_array_ndx;
struct posix_file_runtime* file_hash;
struct posix_file_runtime_ref* fd_hash;
-
- struct posix_file_runtime agg_file_runtime;
};
static struct posix_runtime *posix_runtime = NULL;
@@ -1625,9 +1623,8 @@ static void posix_runtime_initialize()
.get_output_data = &posix_get_output_data,
.shutdown = &posix_shutdown
};
- int mem_limit;
- void *mmap_buf;
- int mmap_buf_size;
+ void *psx_buf;
+ int psx_buf_size;
/* don't do anything if already initialized or instrumenation is disabled */
if(posix_runtime || instrumentation_disabled)
@@ -1637,14 +1634,13 @@ static void posix_runtime_initialize()
darshan_core_register_module(
DARSHAN_POSIX_MOD,
&posix_mod_fns,
+ &psx_buf,
+ &psx_buf_size,
&my_rank,
- &mem_limit,
- &mmap_buf,
- &mmap_buf_size,
&darshan_mem_alignment);
- /* return if no memory assigned by darshan core */
- if(mem_limit == 0)
+ /* return if no memory assigned by darshan-core */
+ if(psx_buf_size == 0)
return;
posix_runtime = malloc(sizeof(*posix_runtime));
@@ -1654,35 +1650,22 @@ static void posix_runtime_initialize()
/* set maximum number of file records according to max memory limit */
/* NOTE: maximum number of records is based on the size of a posix file record */
- /* TODO: should we base memory usage off file record or total runtime structure sizes? */
- posix_runtime->file_array_size = mem_limit / sizeof(struct darshan_posix_file);
+ posix_runtime->file_array_size = psx_buf_size / sizeof(struct darshan_posix_file);
posix_runtime->file_array_ndx = 0;
/* allocate array of runtime file records */
posix_runtime->file_runtime_array = malloc(posix_runtime->file_array_size *
sizeof(struct posix_file_runtime));
- posix_runtime->file_record_array = malloc(posix_runtime->file_array_size *
- sizeof(struct darshan_posix_file));
- if(!posix_runtime->file_runtime_array || !posix_runtime->file_record_array)
+ if(!posix_runtime->file_runtime_array)
{
posix_runtime->file_array_size = 0;
return;
}
memset(posix_runtime->file_runtime_array, 0, posix_runtime->file_array_size *
sizeof(struct posix_file_runtime));
- memset(posix_runtime->file_record_array, 0, posix_runtime->file_array_size *
- sizeof(struct darshan_posix_file));
- /* XXX-MMAP */
- if(mmap_buf_size >= sizeof(struct darshan_posix_file))
- {
- memset(&(posix_runtime->agg_file_runtime), 0,
- sizeof(struct posix_file_runtime));
- posix_runtime->agg_file_runtime.file_record =
- (struct darshan_posix_file *)mmap_buf;
- posix_runtime->agg_file_runtime.file_record->f_id = DARSHAN_POSIX_MOD;
- posix_runtime->agg_file_runtime.file_record->rank = my_rank;
- }
+ /* store pointer to POSIX record buffer given by darshan-core */
+ posix_runtime->file_record_array = (struct darshan_posix_file *)psx_buf;
return;
}
@@ -1694,27 +1677,29 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
char *newname = NULL;
darshan_record_id file_id;
int file_alignment;
+ int limit_flag;
if(!posix_runtime || instrumentation_disabled)
return(NULL);
- return(&(posix_runtime->agg_file_runtime));
-#if 0
newname = darshan_clean_file_path(name);
if(!newname)
newname = (char*)name;
+ limit_flag = (posix_runtime->file_array_ndx >= posix_runtime->file_array_size);
+
/* get a unique id for this file from darshan core */
darshan_core_register_record(
(void*)newname,
strlen(newname),
- 1,
DARSHAN_POSIX_MOD,
+ 1,
+ limit_flag,
&file_id,
&file_alignment);
- /* if record is set to 0, darshan-core is out of space and will not
- * track this record, so we should avoid tracking it, too
+ /* the file record id is set to 0 if no memory is available for tracking
+ * new records -- just fall through and ignore this record
*/
if(file_id == 0)
{
@@ -1732,26 +1717,21 @@ static struct posix_file_runtime* posix_file_by_name(const char *name)
return(file);
}
- if(posix_runtime->file_array_ndx < posix_runtime->file_array_size);
- {
- /* no existing record, assign a new file record from the global array */
- file = &(posix_runtime->file_runtime_array[posix_runtime->file_array_ndx]);
- file->file_record = &(posix_runtime->file_record_array[posix_runtime->file_array_ndx]);
- file->file_record->f_id = file_id;
- file->file_record->rank = my_rank;
- file->file_record->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
- file->file_record->counters[POSIX_FILE_ALIGNMENT] = file_alignment;
-
- /* add new record to file hash table */
- HASH_ADD(hlink, posix_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
-
- posix_runtime->file_array_ndx++;
- }
+ /* no existing record, assign a new file record from the global array */
+ file = &(posix_runtime->file_runtime_array[posix_runtime->file_array_ndx]);
+ file->file_record = &(posix_runtime->file_record_array[posix_runtime->file_array_ndx]);
+ file->file_record->f_id = file_id;
+ file->file_record->rank = my_rank;
+ file->file_record->counters[POSIX_MEM_ALIGNMENT] = darshan_mem_alignment;
+ file->file_record->counters[POSIX_FILE_ALIGNMENT] = file_alignment;
+
+ /* add new record to file hash table */
+ HASH_ADD(hlink, posix_runtime->file_hash, file_record->f_id, sizeof(darshan_record_id), file);
+ posix_runtime->file_array_ndx++;
if(newname != name)
free(newname);
return(file);
-#endif
}
/* get a POSIX file record for the given file path, and also create a
@@ -1768,7 +1748,6 @@ static struct posix_file_runtime* posix_file_by_name_setfd(const char* name, int
/* find file record by name first */
file = posix_file_by_name(name);
-#if 0
if(!file)
return(NULL);
@@ -1794,7 +1773,6 @@ static struct posix_file_runtime* posix_file_by_name_setfd(const char* name, int
ref->file = file;
ref->fd = fd;
HASH_ADD(hlink, posix_runtime->fd_hash, fd, sizeof(int), ref);
-#endif
return(file);
}
@@ -1807,16 +1785,12 @@ static struct posix_file_runtime* posix_file_by_fd(int fd)
if(!posix_runtime || instrumentation_disabled)
return(NULL);
- return(posix_file_by_name(NULL));
-
-#if 0
/* search hash table for existing file ref for this fd */
HASH_FIND(hlink, posix_runtime->fd_hash, &fd, sizeof(int), ref);
if(ref)
return(ref->file);
return(NULL);
-#endif
}
/* free up reference data structures for the given file descriptor */
@@ -1827,7 +1801,6 @@ static void posix_file_close_fd(int fd)
if(!posix_runtime || instrumentation_disabled)
return;
-#if 0
/* search hash table for this fd */
HASH_FIND(hlink, posix_runtime->fd_hash, &fd, sizeof(int), ref);
if(ref)
@@ -1836,7 +1809,6 @@ static void posix_file_close_fd(int fd)
HASH_DELETE(hlink, posix_runtime->fd_hash, ref);
free(ref);
}
-#endif
return;
}
=====================================
darshan-util/configure
=====================================
--- a/darshan-util/configure
+++ b/darshan-util/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for darshan-util 3.0.0-pre1.
+# Generated by GNU Autoconf 2.69 for darshan-util 3.0.0-pre2.
#
#
# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
@@ -577,8 +577,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='darshan-util'
PACKAGE_TARNAME='darshan-util'
-PACKAGE_VERSION='3.0.0-pre1'
-PACKAGE_STRING='darshan-util 3.0.0-pre1'
+PACKAGE_VERSION='3.0.0-pre2'
+PACKAGE_STRING='darshan-util 3.0.0-pre2'
PACKAGE_BUGREPORT=''
PACKAGE_URL=''
@@ -1236,7 +1236,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures darshan-util 3.0.0-pre1 to adapt to many kinds of systems.
+\`configure' configures darshan-util 3.0.0-pre2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1297,7 +1297,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of darshan-util 3.0.0-pre1:";;
+ short | recursive ) echo "Configuration of darshan-util 3.0.0-pre2:";;
esac
cat <<\_ACEOF
@@ -1393,7 +1393,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-darshan-util configure 3.0.0-pre1
+darshan-util configure 3.0.0-pre2
generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1758,7 +1758,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by darshan-util $as_me 3.0.0-pre1, which was
+It was created by darshan-util $as_me 3.0.0-pre2, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@
@@ -4105,7 +4105,7 @@ fi
done
-DARSHAN_UTIL_VERSION="3.0.0-pre1"
+DARSHAN_UTIL_VERSION="3.0.0-pre2"
@@ -4621,7 +4621,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by darshan-util $as_me 3.0.0-pre1, which was
+This file was extended by darshan-util $as_me 3.0.0-pre2, which was
generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -4683,7 +4683,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
-darshan-util config.status 3.0.0-pre1
+darshan-util config.status 3.0.0-pre2
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"
=====================================
darshan-util/configure.in
=====================================
--- a/darshan-util/configure.in
+++ b/darshan-util/configure.in
@@ -5,7 +5,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl You may need to use autoheader as well if changing any DEFINEs
dnl sanity checks, output header, location of scripts used here
-AC_INIT([darshan-util], [3.0.0-pre1])
+AC_INIT([darshan-util], [3.0.0-pre2])
AC_CONFIG_SRCDIR([darshan-logutils.h])
AC_CONFIG_AUX_DIR(../maint/config)
AC_CONFIG_HEADER(darshan-util-config.h)
=====================================
darshan-util/darshan-convert.c
=====================================
--- a/darshan-util/darshan-convert.c
+++ b/darshan-util/darshan-convert.c
@@ -250,7 +250,7 @@ int main(int argc, char **argv)
if(!infile)
return(-1);
- comp_type = bzip2 ? comp_type = DARSHAN_BZIP2_COMP : DARSHAN_ZLIB_COMP;
+ comp_type = bzip2 ? DARSHAN_BZIP2_COMP : DARSHAN_ZLIB_COMP;
outfile = darshan_log_create(outfile_name, comp_type, infile->partial_flag);
if(!outfile)
{
=====================================
darshan-util/darshan-job-summary/bin/darshan-job-summary.pl.in
=====================================
--- a/darshan-util/darshan-job-summary/bin/darshan-job-summary.pl.in
+++ b/darshan-util/darshan-job-summary/bin/darshan-job-summary.pl.in
@@ -97,7 +97,6 @@ while($line = <PARSE_OUT>)
$f_save = "";
($junk, $cmdline) = split(':', $line, 2);
- print("PRE: $cmdline\n");
# add escape characters if needed for special characters in
# command line
if ($cmdline =~ /<unknown args>/)
@@ -108,7 +107,6 @@ while($line = <PARSE_OUT>)
$cmdline = substr($cmdline, 0, -14);
}
$cmdline = encode('latex', $cmdline) . $f_save;
- print("POST: $cmdline\n");
}
elsif ($line =~ /^# nprocs: /)
{
@@ -135,7 +133,7 @@ while($line = <PARSE_OUT>)
($junk, $version) = split(':', $line, 2);
$version =~ s/^\s+//;
}
- elsif ($line =~ /^# \*WARNING\*: This Darshan log contains incomplete data!/)
+ elsif ($line =~ /^# \*WARNING\*: .* contains incomplete data!/)
{
$partial_flag = 1;
}
=====================================
darshan-util/darshan-logutils.c
=====================================
--- a/darshan-util/darshan-logutils.c
+++ b/darshan-util/darshan-logutils.c
@@ -31,16 +31,18 @@
struct darshan_dz_state
{
- /* (libz/bzip2) stream data structure for managing
- * compression and decompression state */
- void *strm;
+ /* pointer to arbitrary data structure used for managing
+ * compression/decompression state (e.g., z_stream
+ * structure needed for libz)
+ */
+ void *comp_dat;
/* buffer for staging compressed data to/from log file */
unsigned char *buf;
/* size of staging buffer */
- int size;
+ unsigned int size;
/* for reading logs, flag indicating end of log file region */
int eor;
- /* the region we last tried reading/writing */
+ /* the region id we last tried reading/writing */
int prev_reg_id;
};
@@ -53,8 +55,6 @@ struct darshan_fd_int_state
int64_t pos;
/* flag indicating whether log file was created (and written) */
int creat_flag;
- /* compression type used on log file (libz or bzip2) */
- enum darshan_comp_type comp_type;
/* log file path name */
char logfile_path[PATH_MAX];
/* pointer to exe & mount data in darshan job data structure */
@@ -62,7 +62,7 @@ struct darshan_fd_int_state
/* whether previous file operations have failed */
int err;
- /* compression/decompression state */
+ /* compression/decompression stream read/write state */
struct darshan_dz_state dz;
};
@@ -71,20 +71,26 @@ static int darshan_log_putheader(darshan_fd fd);
static int darshan_log_seek(darshan_fd fd, off_t offset);
static int darshan_log_read(darshan_fd fd, void *buf, int len);
static int darshan_log_write(darshan_fd fd, void *buf, int len);
-static int darshan_log_dzinit(struct darshan_fd_int_state *state);
-static void darshan_log_dzdestroy(struct darshan_fd_int_state *state);
+static int darshan_log_dzinit(darshan_fd fd);
+static void darshan_log_dzdestroy(darshan_fd fd);
static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len);
static int darshan_log_dzwrite(darshan_fd fd, int region_id, void *buf, int len);
-static int darshan_log_libz_read(darshan_fd fd, int region_id, void *buf, int len);
-static int darshan_log_libz_write(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_libz_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_strm_flag);
+static int darshan_log_libz_write(darshan_fd fd, struct darshan_log_map *map_p,
+ void *buf, int len, int flush_strm_flag);
static int darshan_log_libz_flush(darshan_fd fd, int region_id);
#ifdef HAVE_LIBBZ2
-static int darshan_log_bzip2_read(darshan_fd fd, int region_id, void *buf, int len);
-static int darshan_log_bzip2_write(darshan_fd fd, int region_id, void *buf, int len);
+static int darshan_log_bzip2_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_strm_flag);
+static int darshan_log_bzip2_write(darshan_fd fd, struct darshan_log_map *map_p,
+ void *buf, int len, int flush_strm_flag);
static int darshan_log_bzip2_flush(darshan_fd fd, int region_id);
#endif
static int darshan_log_dzload(darshan_fd fd, struct darshan_log_map map);
static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p);
+static int darshan_log_noz_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_strm_flag);
/* each module's implementation of the darshan logutil functions */
#define X(a, b, c) c,
@@ -140,7 +146,7 @@ darshan_fd darshan_log_open(const char *name)
}
/* initialize compression data structures */
- ret = darshan_log_dzinit(tmp_fd->state);
+ ret = darshan_log_dzinit(tmp_fd);
if(ret < 0)
{
fprintf(stderr, "Error: failed to initialize decompression data structures.\n");
@@ -177,6 +183,7 @@ darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type
return(NULL);
}
memset(tmp_fd->state, 0, sizeof(struct darshan_fd_int_state));
+ tmp_fd->comp_type = comp_type;
/* create the log for writing, making sure to not overwrite existing log */
tmp_fd->state->fildes = creat(name, 0400);
@@ -188,7 +195,6 @@ darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type
return(NULL);
}
tmp_fd->state->creat_flag = 1;
- tmp_fd->state->comp_type = comp_type;
tmp_fd->partial_flag = partial_flag;
strncpy(tmp_fd->state->logfile_path, name, PATH_MAX);
@@ -208,7 +214,7 @@ darshan_fd darshan_log_create(const char *name, enum darshan_comp_type comp_type
}
/* initialize compression data structures */
- ret = darshan_log_dzinit(tmp_fd->state);
+ ret = darshan_log_dzinit(tmp_fd);
if(ret < 0)
{
fprintf(stderr, "Error: failed to initialize compression data structures.\n");
@@ -240,7 +246,7 @@ int darshan_log_getjob(darshan_fd fd, struct darshan_job *job)
/* read the compressed job data from the log file */
ret = darshan_log_dzread(fd, DARSHAN_JOB_REGION_ID, job_buf, job_buf_sz);
- if(ret <= sizeof(*job))
+ if(ret <= (int)sizeof(*job))
{
fprintf(stderr, "Error: failed to read darshan log file job data.\n");
return(-1);
@@ -774,7 +780,7 @@ void darshan_log_close(darshan_fd fd)
if(state->creat_flag)
{
/* flush the last region of the log to file */
- switch(state->comp_type)
+ switch(fd->comp_type)
{
case DARSHAN_ZLIB_COMP:
ret = darshan_log_libz_flush(fd, state->dz.prev_reg_id);
@@ -812,7 +818,7 @@ void darshan_log_close(darshan_fd fd)
unlink(state->logfile_path);
}
- darshan_log_dzdestroy(state);
+ darshan_log_dzdestroy(fd);
if(state->exe_mnt_data)
free(state->exe_mnt_data);
free(state);
@@ -830,7 +836,6 @@ void darshan_log_close(darshan_fd fd)
*/
static int darshan_log_getheader(darshan_fd fd)
{
- struct darshan_fd_int_state *state = fd->state;
struct darshan_header header;
int i;
int ret;
@@ -844,7 +849,7 @@ static int darshan_log_getheader(darshan_fd fd)
/* read uncompressed header from log file */
ret = darshan_log_read(fd, &header, sizeof(header));
- if(ret != sizeof(header))
+ if(ret != (int)sizeof(header))
{
fprintf(stderr, "Error: failed to read darshan log file header.\n");
return(-1);
@@ -883,15 +888,42 @@ static int darshan_log_getheader(darshan_fd fd)
}
}
- state->comp_type = header.comp_type;
+ fd->comp_type = header.comp_type;
fd->partial_flag = header.partial_flag;
/* save the mapping of data within log file to this file descriptor */
- fd->job_map.off = sizeof(struct darshan_header);
- fd->job_map.len = header.rec_map.off - fd->job_map.off;
memcpy(&fd->rec_map, &(header.rec_map), sizeof(struct darshan_log_map));
memcpy(&fd->mod_map, &(header.mod_map), DARSHAN_MAX_MODS * sizeof(struct darshan_log_map));
+ /* there may be nothing following the job data, so safety check map */
+ fd->job_map.off = sizeof(struct darshan_header);
+ if(fd->rec_map.off == 0)
+ {
+ for(i = 0; i < DARSHAN_MAX_MODS; i++)
+ {
+ if(fd->mod_map[i].off != 0)
+ {
+ fd->job_map.len = fd->mod_map[i].off - fd->job_map.off;
+ break;
+ }
+ }
+
+ if(fd->job_map.len == 0)
+ {
+ struct stat sbuf;
+ if(fstat(fd->state->fildes, &sbuf) != 0)
+ {
+ fprintf(stderr, "Error: unable to stat darshan log file.\n");
+ return(-1);
+ }
+ fd->job_map.len = sbuf.st_size - fd->job_map.off;
+ }
+ }
+ else
+ {
+ fd->job_map.len = fd->rec_map.off - fd->job_map.off;
+ }
+
return(0);
}
@@ -901,7 +933,6 @@ static int darshan_log_getheader(darshan_fd fd)
*/
static int darshan_log_putheader(darshan_fd fd)
{
- struct darshan_fd_int_state *state = fd->state;
struct darshan_header header;
int ret;
@@ -915,7 +946,7 @@ static int darshan_log_putheader(darshan_fd fd)
memset(&header, 0, sizeof(header));
strcpy(header.version_string, DARSHAN_LOG_VERSION);
header.magic_nr = DARSHAN_MAGIC_NR;
- header.comp_type = state->comp_type;
+ header.comp_type = fd->comp_type;
header.partial_flag = fd->partial_flag;
/* copy the mapping information to the header */
@@ -924,7 +955,7 @@ static int darshan_log_putheader(darshan_fd fd)
/* write header to file */
ret = darshan_log_write(fd, &header, sizeof(header));
- if(ret != sizeof(header))
+ if(ret != (int)sizeof(header))
{
fprintf(stderr, "Error: failed to write Darshan log file header.\n");
return(-1);
@@ -959,13 +990,20 @@ static int darshan_log_read(darshan_fd fd, void* buf, int len)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
+ unsigned int read_so_far = 0;
- /* read data from the log file using the given map */
- ret = read(state->fildes, buf, len);
- if(ret > 0)
- state->pos += ret;
+ do
+ {
+ ret = read(state->fildes, buf + read_so_far, len - read_so_far);
+ if(ret <= 0)
+ break;
+ read_so_far += ret;
+ } while(read_so_far < len);
+ if(ret < 0)
+ return(-1);
- return(ret);
+ state->pos += read_so_far;
+ return(read_so_far);
}
/* return amount written on success, -1 on failure.
@@ -974,26 +1012,37 @@ static int darshan_log_write(darshan_fd fd, void* buf, int len)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
+ unsigned int wrote_so_far = 0;
- ret = write(state->fildes, buf, len);
- if(ret > 0)
- state->pos += ret;
+ do
+ {
+ ret = write(state->fildes, buf + wrote_so_far, len - wrote_so_far);
+ if(ret <= 0)
+ break;
+ wrote_so_far += ret;
+ } while(wrote_so_far < len);
+ if(ret < 0)
+ return(-1);
- return(ret);
+ state->pos += wrote_so_far;
+ return(wrote_so_far);
}
-static int darshan_log_dzinit(struct darshan_fd_int_state *state)
+static int darshan_log_dzinit(darshan_fd fd)
{
+ struct darshan_fd_int_state *state = fd->state;
int ret;
- /* initialize buffers for staging compressed data to/from log file */
+ /* initialize buffers for staging compressed data
+ * to/from log file
+ */
state->dz.buf = malloc(DARSHAN_DEF_COMP_BUF_SZ);
if(state->dz.buf == NULL)
return(-1);
-
+ state->dz.size = 0;
state->dz.prev_reg_id = DARSHAN_HEADER_REGION_ID;
- switch(state->comp_type)
+ switch(fd->comp_type)
{
case DARSHAN_ZLIB_COMP:
{
@@ -1028,7 +1077,7 @@ static int darshan_log_dzinit(struct darshan_fd_int_state *state)
free(state->dz.buf);
return(-1);
}
- state->dz.strm = tmp_zstrm;
+ state->dz.comp_dat = tmp_zstrm;
break;
}
#ifdef HAVE_LIBBZ2
@@ -1044,9 +1093,9 @@ static int darshan_log_dzinit(struct darshan_fd_int_state *state)
tmp_bzstrm->bzfree = NULL;
tmp_bzstrm->opaque = NULL;
tmp_bzstrm->avail_in = 0;
- tmp_bzstrm->next_in = Z_NULL;
+ tmp_bzstrm->next_in = NULL;
- if(state->creat_flag)
+ if(!(state->creat_flag))
{
/* read only file, init decompress algorithm */
ret = BZ2_bzDecompressInit(tmp_bzstrm, 1, 0);
@@ -1064,10 +1113,18 @@ static int darshan_log_dzinit(struct darshan_fd_int_state *state)
free(state->dz.buf);
return(-1);
}
- state->dz.strm = tmp_bzstrm;
+ state->dz.comp_dat = tmp_bzstrm;
break;
}
#endif
+ case DARSHAN_NO_COMP:
+ {
+ /* we just track an offset into the staging buffers for no_comp */
+ int *buf_off = malloc(sizeof(int));
+ *buf_off = 0;
+ state->dz.comp_dat = buf_off;
+ break;
+ }
default:
fprintf(stderr, "Error: invalid compression type.\n");
return(-1);
@@ -1076,30 +1133,36 @@ static int darshan_log_dzinit(struct darshan_fd_int_state *state)
return(0);
}
-static void darshan_log_dzdestroy(struct darshan_fd_int_state *state)
+static void darshan_log_dzdestroy(darshan_fd fd)
{
- switch(state->comp_type)
+ struct darshan_fd_int_state *state = fd->state;
+
+ switch(fd->comp_type)
{
case DARSHAN_ZLIB_COMP:
if(!(state->creat_flag))
- inflateEnd(state->dz.strm);
+ inflateEnd((z_stream *)state->dz.comp_dat);
else
- deflateEnd(state->dz.strm);
- free(state->dz.strm);
+ deflateEnd((z_stream *)state->dz.comp_dat);
break;
#ifdef HAVE_LIBBZ2
case DARSHAN_BZIP2_COMP:
if(!(state->creat_flag))
- BZ2_bzDecompressEnd(state->dz.strm);
+ BZ2_bzDecompressEnd((bz_stream *)state->dz.comp_dat);
else
- BZ2_bzCompressEnd(state->dz.strm);
- free(state->dz.strm);
+ BZ2_bzCompressEnd((bz_stream *)state->dz.comp_dat);
break;
#endif
+ case DARSHAN_NO_COMP:
+ {
+ /* do nothing */
+ break;
+ }
default:
fprintf(stderr, "Error: invalid compression type.\n");
}
+ free(state->dz.comp_dat);
free(state->dz.buf);
return;
}
@@ -1107,74 +1170,111 @@ static void darshan_log_dzdestroy(struct darshan_fd_int_state *state)
static int darshan_log_dzread(darshan_fd fd, int region_id, void *buf, int len)
{
struct darshan_fd_int_state *state = fd->state;
+ struct darshan_log_map map;
+ int reset_strm_flag = 0;
int ret;
- switch(state->comp_type)
+ /* if new log region, we reload buffers and clear eor flag */
+ if(region_id != state->dz.prev_reg_id)
+ {
+ state->dz.eor = 0;
+ reset_strm_flag = 1; /* reset libz/bzip2 streams */
+ }
+
+ if(region_id == DARSHAN_JOB_REGION_ID)
+ map = fd->job_map;
+ else if(region_id == DARSHAN_REC_MAP_REGION_ID)
+ map = fd->rec_map;
+ else
+ map = fd->mod_map[region_id];
+
+ switch(fd->comp_type)
{
case DARSHAN_ZLIB_COMP:
- ret = darshan_log_libz_read(fd, region_id, buf, len);
+ ret = darshan_log_libz_read(fd, map, buf, len, reset_strm_flag);
break;
#ifdef HAVE_LIBBZ2
case DARSHAN_BZIP2_COMP:
- ret = darshan_log_bzip2_read(fd, region_id, buf, len);
+ ret = darshan_log_bzip2_read(fd, map, buf, len, reset_strm_flag);
break;
#endif
+ case DARSHAN_NO_COMP:
+ {
+ ret = darshan_log_noz_read(fd, map, buf, len, reset_strm_flag);
+ break;
+ }
default:
fprintf(stderr, "Error: invalid compression type.\n");
return(-1);
}
+ state->dz.prev_reg_id = region_id;
return(ret);
}
static int darshan_log_dzwrite(darshan_fd fd, int region_id, void *buf, int len)
{
struct darshan_fd_int_state *state = fd->state;
+ struct darshan_log_map *map_p;
+ int flush_strm_flag = 0;
int ret;
- switch(state->comp_type)
+ /* if new log region, finish prev region's zstream and flush to log file */
+ if(region_id != state->dz.prev_reg_id)
+ {
+ /* error out if the region we are writing to precedes the previous
+ * region we wrote -- we shouldn't be moving backwards in the log
+ */
+ if(region_id < state->dz.prev_reg_id)
+ return(-1);
+
+ if(state->dz.prev_reg_id != DARSHAN_HEADER_REGION_ID)
+ flush_strm_flag = 1;
+ }
+
+ if(region_id == DARSHAN_JOB_REGION_ID)
+ map_p = &(fd->job_map);
+ else if(region_id == DARSHAN_REC_MAP_REGION_ID)
+ map_p = &(fd->rec_map);
+ else
+ map_p = &(fd->mod_map[region_id]);
+
+ switch(fd->comp_type)
{
case DARSHAN_ZLIB_COMP:
- ret = darshan_log_libz_write(fd, region_id, buf, len);
+ ret = darshan_log_libz_write(fd, map_p, buf, len, flush_strm_flag);
break;
#ifdef HAVE_LIBBZ2
case DARSHAN_BZIP2_COMP:
- ret = darshan_log_bzip2_write(fd, region_id, buf, len);
+ ret = darshan_log_bzip2_write(fd, map_p, buf, len, flush_strm_flag);
break;
#endif
+ case DARSHAN_NO_COMP:
+ fprintf(stderr,
+ "Error: uncompressed writing of log files is not supported.\n");
+ return(-1);
default:
fprintf(stderr, "Error: invalid compression type.\n");
return(-1);
}
+ state->dz.prev_reg_id = region_id;
return(ret);
}
-static int darshan_log_libz_read(darshan_fd fd, int region_id, void *buf, int len)
+static int darshan_log_libz_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_stream_flag)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
int total_bytes = 0;
int tmp_out_bytes;
- struct darshan_log_map map;
- z_stream *z_strmp = (z_stream *)state->dz.strm;
+ z_stream *z_strmp = (z_stream *)state->dz.comp_dat;
assert(z_strmp);
- /* if new log region, we reload buffers and clear eor flag */
- if(region_id != state->dz.prev_reg_id)
- {
+ if(reset_stream_flag)
z_strmp->avail_in = 0;
- state->dz.eor = 0;
- state->dz.prev_reg_id = region_id;
- }
-
- if(region_id == DARSHAN_JOB_REGION_ID)
- map = fd->job_map;
- else if(region_id == DARSHAN_REC_MAP_REGION_ID)
- map = fd->rec_map;
- else
- map = fd->mod_map[region_id];
z_strmp->avail_out = len;
z_strmp->next_out = buf;
@@ -1223,44 +1323,26 @@ static int darshan_log_libz_read(darshan_fd fd, int region_id, void *buf, int le
return(total_bytes);
}
-static int darshan_log_libz_write(darshan_fd fd, int region_id, void *buf, int len)
+static int darshan_log_libz_write(darshan_fd fd, struct darshan_log_map *map_p,
+ void *buf, int len, int flush_strm_flag)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
int total_bytes = 0;
int tmp_in_bytes;
int tmp_out_bytes;
- struct darshan_log_map *map_p;
- z_stream *z_strmp = (z_stream *)state->dz.strm;
+ z_stream *z_strmp = (z_stream *)state->dz.comp_dat;
assert(z_strmp);
- /* if new log region, finish prev region's zstream and flush to log file */
- if(region_id != state->dz.prev_reg_id)
+ /* flush compressed output buffer if we are moving to a new log region */
+ if(flush_strm_flag)
{
- /* error out if the region we are writing to precedes the previous
- * region we wrote -- we shouldn't be moving backwards in the log
- */
- if(region_id < state->dz.prev_reg_id)
+ ret = darshan_log_libz_flush(fd, state->dz.prev_reg_id);
+ if(ret < 0)
return(-1);
-
- if(state->dz.prev_reg_id != DARSHAN_HEADER_REGION_ID)
- {
- ret = darshan_log_libz_flush(fd, state->dz.prev_reg_id);
- if(ret < 0)
- return(-1);
- }
-
- state->dz.prev_reg_id = region_id;
}
- if(region_id == DARSHAN_JOB_REGION_ID)
- map_p = &(fd->job_map);
- else if(region_id == DARSHAN_REC_MAP_REGION_ID)
- map_p = &(fd->rec_map);
- else
- map_p = &(fd->mod_map[region_id]);
-
z_strmp->avail_in = len;
z_strmp->next_in = buf;
@@ -1301,7 +1383,7 @@ static int darshan_log_libz_flush(darshan_fd fd, int region_id)
int ret;
int tmp_out_bytes;
struct darshan_log_map *map_p;
- z_stream *z_strmp = (z_stream *)state->dz.strm;
+ z_stream *z_strmp = (z_stream *)state->dz.comp_dat;
assert(z_strmp);
@@ -1342,32 +1424,19 @@ static int darshan_log_libz_flush(darshan_fd fd, int region_id)
}
#ifdef HAVE_LIBBZ2
-
-static int darshan_log_bzip2_read(darshan_fd fd, int region_id, void *buf, int len)
+static int darshan_log_bzip2_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_strm_flag)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
int total_bytes = 0;
int tmp_out_bytes;
- struct darshan_log_map map;
- bz_stream *bz_strmp = (bz_stream *)state->dz.strm;
+ bz_stream *bz_strmp = (bz_stream *)state->dz.comp_dat;
assert(bz_strmp);
- /* if new log region, we reload buffers and clear eor flag */
- if(region_id != state->dz.prev_reg_id)
- {
+ if(reset_strm_flag)
bz_strmp->avail_in = 0;
- state->dz.eor = 0;
- state->dz.prev_reg_id = region_id;
- }
-
- if(region_id == DARSHAN_JOB_REGION_ID)
- map = fd->job_map;
- else if(region_id == DARSHAN_REC_MAP_REGION_ID)
- map = fd->rec_map;
- else
- map = fd->mod_map[region_id];
bz_strmp->avail_out = len;
bz_strmp->next_out = buf;
@@ -1419,44 +1488,26 @@ static int darshan_log_bzip2_read(darshan_fd fd, int region_id, void *buf, int l
return(total_bytes);
}
-static int darshan_log_bzip2_write(darshan_fd fd, int region_id, void *buf, int len)
+static int darshan_log_bzip2_write(darshan_fd fd, struct darshan_log_map *map_p,
+ void *buf, int len, int flush_strm_flag)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
int total_bytes = 0;
int tmp_in_bytes;
int tmp_out_bytes;
- struct darshan_log_map *map_p;
- bz_stream *bz_strmp = (bz_stream *)state->dz.strm;
+ bz_stream *bz_strmp = (bz_stream *)state->dz.comp_dat;
assert(bz_strmp);
- /* if new log region, finish prev region's zstream and flush to log file */
- if(region_id != state->dz.prev_reg_id)
+ /* flush compressed output buffer if we are moving to a new log region */
+ if(flush_strm_flag)
{
- /* error out if the region we are writing to precedes the previous
- * region we wrote -- we shouldn't be moving backwards in the log
- */
- if(region_id < state->dz.prev_reg_id)
+ ret = darshan_log_bzip2_flush(fd, state->dz.prev_reg_id);
+ if(ret < 0)
return(-1);
-
- if(state->dz.prev_reg_id != DARSHAN_HEADER_REGION_ID)
- {
- ret = darshan_log_bzip2_flush(fd, state->dz.prev_reg_id);
- if(ret < 0)
- return(-1);
- }
-
- state->dz.prev_reg_id = region_id;
}
- if(region_id == DARSHAN_JOB_REGION_ID)
- map_p = &(fd->job_map);
- else if(region_id == DARSHAN_REC_MAP_REGION_ID)
- map_p = &(fd->rec_map);
- else
- map_p = &(fd->mod_map[region_id]);
-
bz_strmp->avail_in = len;
bz_strmp->next_in = buf;
@@ -1497,7 +1548,7 @@ static int darshan_log_bzip2_flush(darshan_fd fd, int region_id)
int ret;
int tmp_out_bytes;
struct darshan_log_map *map_p;
- bz_stream *bz_strmp = (bz_stream *)state->dz.strm;
+ bz_stream *bz_strmp = (bz_stream *)state->dz.comp_dat;
assert(bz_strmp);
@@ -1532,22 +1583,65 @@ static int darshan_log_bzip2_flush(darshan_fd fd, int region_id)
bz_strmp->next_out = (char *)state->dz.buf;
}
} while (ret != BZ_STREAM_END);
-
BZ2_bzCompressEnd(bz_strmp);
BZ2_bzCompressInit(bz_strmp, 9, 1, 30);
return(0);
}
-
#endif
+static int darshan_log_noz_read(darshan_fd fd, struct darshan_log_map map,
+ void *buf, int len, int reset_strm_flag)
+{
+ struct darshan_fd_int_state *state = fd->state;
+ int ret;
+ int total_bytes = 0;
+ int cp_size;
+ int *buf_off = (int *)state->dz.comp_dat;
+
+ if(reset_strm_flag)
+ *buf_off = state->dz.size;
+
+ /* we just decompress until the output buffer is full, assuming there
+ * is enough compressed data in file to satisfy the request size.
+ */
+ while(total_bytes < len)
+ {
+ /* check if we need more compressed data */
+ if(*buf_off == state->dz.size)
+ {
+ /* if the eor flag is set, clear it and return -- future
+ * reads of this log region will restart at the beginning
+ */
+ if(state->dz.eor)
+ {
+ state->dz.eor = 0;
+ break;
+ }
+
+ /* read more data from input file */
+ ret = darshan_log_dzload(fd, map);
+ if(ret < 0)
+ return(-1);
+ assert(state->dz.size > 0);
+ }
+
+ cp_size = (len > (state->dz.size - *buf_off)) ?
+ state->dz.size - *buf_off : len;
+ memcpy(buf, state->dz.buf + *buf_off, cp_size);
+ total_bytes += cp_size;
+ *buf_off += cp_size;
+ }
+
+ return(total_bytes);
+}
+
static int darshan_log_dzload(darshan_fd fd, struct darshan_log_map map)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
unsigned int remaining;
unsigned int read_size;
- unsigned int read_so_far = 0;
state->dz.size = 0;
@@ -1566,24 +1660,18 @@ static int darshan_log_dzload(darshan_fd fd, struct darshan_log_map map)
remaining = (map.off + map.len) - state->pos;
read_size = (remaining > DARSHAN_DEF_COMP_BUF_SZ) ?
DARSHAN_DEF_COMP_BUF_SZ : remaining;
- do
- {
- ret = darshan_log_read(fd, state->dz.buf + read_so_far,
- read_size - read_so_far);
- if(ret <= 0)
- break;
- read_so_far += ret;
- } while(read_so_far < read_size);
- if(ret < 0)
+
+ ret = darshan_log_read(fd, state->dz.buf, read_size);
+ if(ret < (int)read_size)
{
fprintf(stderr, "Error: unable to read compressed data from file.\n");
return(-1);
}
- if((read_size == remaining) || (ret == 0))
+
+ if(ret == (int)remaining)
{
state->dz.eor = 1;
}
-
state->dz.size = read_size;
return(0);
}
@@ -1592,24 +1680,18 @@ static int darshan_log_dzunload(darshan_fd fd, struct darshan_log_map *map_p)
{
struct darshan_fd_int_state *state = fd->state;
int ret;
- unsigned int write_so_far = 0;
/* initialize map structure for this log region */
if(map_p->off == 0)
map_p->off = state->pos;
/* write more compressed data from staging buffer to file */
- do
+ ret = darshan_log_write(fd, state->dz.buf, state->dz.size);
+ if(ret < (int)state->dz.size)
{
- ret = darshan_log_write(fd, state->dz.buf + write_so_far,
- state->dz.size - write_so_far);
- if(ret <= 0)
- {
- fprintf(stderr, "Error: unable to write compressed data to file.\n");
- return(-1);
- }
- write_so_far += ret;
- } while(write_so_far < state->dz.size);
+ fprintf(stderr, "Error: unable to write compressed data to file.\n");
+ return(-1);
+ }
map_p->len += state->dz.size;
state->dz.size = 0;
=====================================
darshan-util/darshan-logutils.h
=====================================
--- a/darshan-util/darshan-logutils.h
+++ b/darshan-util/darshan-logutils.h
@@ -29,6 +29,8 @@ struct darshan_fd_s
int swap_flag;
/* flag indicating whether a log file contains partial data */
int partial_flag;
+ /* compression type used on log file */
+ enum darshan_comp_type comp_type;
/* log file offset/length maps for each log file region */
struct darshan_log_map job_map;
struct darshan_log_map rec_map;
=====================================
darshan-util/darshan-parser.c
=====================================
--- a/darshan-util/darshan-parser.c
+++ b/darshan-util/darshan-parser.c
@@ -199,6 +199,7 @@ int main(int argc, char **argv)
int mask;
int i, j;
char *filename;
+ char *comp_str;
char tmp_string[4096] = {0};
darshan_fd fd;
struct darshan_job job;
@@ -263,8 +264,18 @@ int main(int argc, char **argv)
return(-1);
}
+ if(fd->comp_type == DARSHAN_ZLIB_COMP)
+ comp_str = "ZLIB";
+ else if (fd->comp_type == DARSHAN_BZIP2_COMP)
+ comp_str = "BZIP2";
+ else if (fd->comp_type == DARSHAN_NO_COMP)
+ comp_str = "NONE";
+ else
+ comp_str = "UNKNOWN";
+
/* print job summary */
printf("# darshan log version: %s\n", fd->version);
+ printf("# compression method: %s\n", comp_str);
printf("# exe: %s\n", tmp_string);
printf("# uid: %" PRId64 "\n", job.uid);
printf("# jobid: %" PRId64 "\n", job.jobid);
@@ -322,11 +333,6 @@ int main(int argc, char **argv)
}
/* warn user if this log file is incomplete */
- if(fd->partial_flag)
- printf("\n# *WARNING*: This Darshan log contains incomplete data!\n"
- "# This happens when an application creates\n"
- "# more records than Darshan can track.\n");
-
pdata.rank_cumul_io_time = malloc(sizeof(double)*job.nprocs);
pdata.rank_cumul_md_time = malloc(sizeof(double)*job.nprocs);
if (!pdata.rank_cumul_io_time || !pdata.rank_cumul_md_time)
@@ -370,6 +376,13 @@ int main(int argc, char **argv)
printf("# %s module data\n", darshan_module_names[i]);
printf("# *******************************************************\n");
+ /* print warning if this module only stored partial data */
+ if(DARSHAN_MOD_FLAG_ISSET(fd->partial_flag, i))
+ printf("\n# *WARNING*: The %s module contains incomplete data!\n"
+ "# This happens when a module runs out of\n"
+ "# memory to store new record data.\n",
+ darshan_module_names[i]);
+
if(mask & OPTION_BASE)
{
/* TODO: does each module print header of what each counter means??? */
=====================================
doc/darshan-modularization.txt
=====================================
--- a/doc/darshan-modularization.txt
+++ b/doc/darshan-modularization.txt
@@ -224,9 +224,10 @@ a module developer must provide to interface with the darshan-core runtime.
* _my_rank_ is a pointer to an integer to store the calling process's application MPI rank in
* _mod_mem_limit_ is a pointer to an integer which will store the amount of memory Darshan
-allows this module to use at runtime. Currently, `darshan-core` will hardcode this value to 2 MiB,
-but in the future this may be changed to optimize Darshan's memory footprint. Note that Darshan
-does not allocate any memory for modules, it just informs a module how much memory it can use.
+allows this module to use at runtime. Darshan's default module memory limit is currently set to
+2 MiB, but the user can choose a different value at configure time (using the `--with-mod-mem`
+configure option) or at runtime (using the DARSHAN_MODMEM environment variable). Note that Darshan
+does not allocate any memory for modules; it just informs a module how much memory it can use.
* _sys_mem_alignment_ is a pointer to an integer which will store the system memory alignment value
Darshan was configured with. This parameter may be set to `NULL` if a module is not concerned with the
@@ -248,8 +249,9 @@ any I/O data.
void darshan_core_register_record(
void *name,
int len,
- int printable_flag,
darshan_module_id mod_id,
+ int printable_flag,
+ int mod_limit_flag,
darshan_record_id *rec_id,
int *file_alignment);
@@ -269,9 +271,13 @@ been previously registered.
string length, but for nonprintable record names (e.g., an integer object identifier), this
is the size of the record name type.
+* _mod_id_ is the identifier for the module attempting to register this record.
+
* _printable_flag_ indicates whether the input record name is a printable ASCII string.
-* _mod_id_ is the identifier for the module attempting to register this record.
+* _mod_limit_flag_ indicates whether the calling module is out of memory to instrument new
+records or not. If this flag is set, darshan-core will not create new records and instead just
+search existing records for one corresponding to input _name_.
* _rec_id_ is a pointer to a variable which will store the unique record identifier generated
by Darshan.
View it on GitLab: https://xgitlab.cels.anl.gov/darshan/darshan/compare/c3c5e59770b89b2d00aeb45a1dccbbf132a0514d...3b0c668b50b84b4407f57b5ea40336ef14d0e9d2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/darshan-commits/attachments/20151202/f9d8eb81/attachment-0001.html>
More information about the Darshan-commits
mailing list