summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Chilan <chilan@hdfgroup.org>2008-04-10 22:32:53 (GMT)
committerChristian Chilan <chilan@hdfgroup.org>2008-04-10 22:32:53 (GMT)
commit66bb19b12fd951c8a277416f281d0ac3c0d634e0 (patch)
treecc65551a2d0228e7b1fdbb8e9652d3e9f3c1a32c
parent8c9c5356a3f8b7341726e8be575eaa9cb4734249 (diff)
downloadhdf5-66bb19b12fd951c8a277416f281d0ac3c0d634e0.zip
hdf5-66bb19b12fd951c8a277416f281d0ac3c0d634e0.tar.gz
hdf5-66bb19b12fd951c8a277416f281d0ac3c0d634e0.tar.bz2
[svn-r14826] Files for the serial benchmarking tool, h5perf_serial.
Tested on kagiso, smirom, and linew.
-rw-r--r--perform/sio_engine.c1747
-rw-r--r--perform/sio_perf.c1450
-rw-r--r--perform/sio_perf.h105
-rw-r--r--perform/sio_standalone.c286
-rw-r--r--perform/sio_standalone.h544
5 files changed, 4132 insertions, 0 deletions
diff --git a/perform/sio_engine.c b/perform/sio_engine.c
new file mode 100644
index 0000000..3519f9b
--- /dev/null
+++ b/perform/sio_engine.c
@@ -0,0 +1,1747 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Author: Christian Chilan, April 2008
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "hdf5.h"
+
+#ifdef H5_HAVE_GPFS
+# include <gpfs_fcntl.h>
+#endif /* H5_HAVE_GPFS */
+
+#include "sio_perf.h"
+#include "sio_timer.h"
+
+/* Macro definitions */
+
+/* sizes of various items. these sizes won't change during program execution */
+/* The following three must have the same type */
+#define ELMT_SIZE (sizeof(unsigned char)) /* we're doing bytes */
+#define ELMT_H5_TYPE H5T_NATIVE_UCHAR
+
+#define GOTOERROR(errcode) { ret_code = errcode; goto done; }
+#define GOTODONE { goto done; }
+#define ERRMSG(mesg) { \
+ fprintf(stderr, "*** Assertion failed (%s) at line %4d in %s\n", \
+ mesg, (int)__LINE__, __FILE__); \
+}
+
+#define MSG(mesg) { \
+ fprintf(stderr, "(%s) at line %4d in %s\n", \
+ mesg, (int)__LINE__, __FILE__); \
+}
+
+/* verify: if val is false (0), print mesg. */
+#define VRFY(val, mesg) do { \
+ if (!val) { \
+ ERRMSG(mesg); \
+ GOTOERROR(FAIL); \
+ } \
+} while(0)
+
+/* POSIX I/O macros */
+#define POSIXCREATE(fn) HDopen(fn, O_CREAT|O_TRUNC|O_RDWR, 0600)
+#define POSIXOPEN(fn, F) HDopen(fn, F, 0600)
+#define POSIXCLOSE(F) HDclose(F)
+#define POSIXSEEK(F,L) HDlseek(F, L, SEEK_SET)
+#define POSIXWRITE(F,B,S) HDwrite(F,B,S)
+#define POSIXREAD(F,B,S) HDread(F,B,S)
+
+enum {
+ SIO_CREATE = 1,
+ SIO_WRITE = 2,
+ SIO_READ = 4
+};
+
+/* Global variables */
+static int clean_file_g = -1; /*whether to cleanup temporary test */
+/*files. -1 is not defined; */
+/*0 is no cleanup; 1 is do cleanup */
+
+/*
+ * In a parallel machine, the filesystem suitable for compiling is
+ * unlikely a parallel file system that is suitable for parallel I/O.
+ * There is no standard pathname for the parallel file system. /tmp
+ * is about the best guess.
+ */
+#ifndef HDF5_PARAPREFIX
+# ifdef __PUMAGON__
+/* For the PFS of TFLOPS */
+# define HDF5_PARAPREFIX "pfs:/pfs_grande/multi/tmp_1"
+# else
+# define HDF5_PARAPREFIX ""
+# endif /* __PUMAGON__ */
+#endif /* !HDF5_PARAPREFIX */
+
+#ifndef MIN
+# define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif /* !MIN */
+
+/* the different types of file descriptors we can expect */
+typedef union _file_descr {
+ int posixfd; /* POSIX file handle*/
+ hid_t h5fd; /* HDF5 file */
+} file_descr;
+
+/* local functions */
+static char *sio_create_filename(iotype iot, const char *base_name,
+ char *fullname, size_t size, parameters *param);
+static herr_t do_write(results *res, file_descr *fd, parameters *parms, void *buffer);
+static herr_t do_read(results *res, file_descr *fd, parameters *parms, void *buffer);
+static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t dset_read(int localrank, file_descr *fd, parameters *parms, void *buffer);
+static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer);
+static herr_t do_fopen(parameters *param, char *fname, file_descr *fd /*out*/,
+ int flags);
+hid_t set_vfd(parameters *param);
+static herr_t do_fclose(iotype iot, file_descr *fd);
+static void do_cleanupfile(iotype iot, char *fname);
+
+/* GPFS-specific functions */
+#ifdef H5_HAVE_GPFS
+static void gpfs_access_range(int handle, off_t start, off_t length, int is_write);
+static void gpfs_free_range(int handle, off_t start, off_t length);
+static void gpfs_clear_file_cache(int handle);
+static void gpfs_cancel_hints(int handle);
+static void gpfs_start_data_shipping(int handle, int num_insts);
+static void gpfs_start_data_ship_map(int handle, int partition_size,
+ int agent_count, int *agent_node_num);
+static void gpfs_stop_data_shipping(int handle);
+static void gpfs_invalidate_file_cache(const char *filename);
+#endif /* H5_HAVE_GPFS */
+
+/* global variables */
+static off_t offset[MAX_DIMS]; /* dataset size in bytes */
+static size_t buf_offset[MAX_DIMS]; /* dataset size in bytes */
+static int order[MAX_DIMS]; /* dimension access order */
+static size_t linear_buf_size; /* linear buffer size */
+static int cont_dim; /* lowest dimension for contiguous POSIX
+ access */
+static size_t cont_size; /* size of contiguous POSIX access */
+static hid_t fapl; /* file access list */
+static unsigned char *buf_p; /* buffer pointer */
+static unsigned char *buf2_p; /* buffer pointer */
+static const char *multi_letters = "msbrglo"; /* string for multi driver */
+static char *buffer2=NULL; /* buffer for data verification */
+
+/* HDF5 global variables */
+static hsize_t h5count[MAX_DIMS]; /*selection count */
+static hssize_t h5offset[MAX_DIMS]; /* Selection offset within dataspace */
+static hid_t h5dset_space_id = -1; /*dataset space ID */
+static hid_t h5mem_space_id = -1; /*memory dataspace ID */
+static hid_t h5ds_id = -1; /*dataset handle */
+static hid_t h5dcpl = -1; /* Dataset creation property list */
+static hid_t h5dxpl = -1; /* Dataset transfer property list */
+
+/*
+ * Function: do_sio
+ * Purpose: SIO Engine where IO are executed.
+ * Return: results
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+ results
+do_sio(parameters param)
+{
+ char *buffer = NULL; /*data buffer pointer */
+ off_t nbytes; /* dataset raw size */
+ off_t dset_size[MAX_DIMS]; /* dataset size in bytes */
+ size_t buf_size[MAX_DIMS]; /* general buffer size in bytes */
+ size_t chk_size[MAX_DIMS]; /* chunk size in bytes */
+ file_descr fd; /* file handles */
+ iotype iot; /* API type */
+ char base_name[256]; /* test file base name */
+ /* return codes */
+ herr_t ret_code = 0; /*return code */
+ results res;
+
+ char fname[FILENAME_MAX]; /* test file name */
+ int i;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+
+ /* Sanity check parameters */
+
+ /* IO type */
+ iot = param.io_type;
+
+ switch (iot) {
+ case POSIXIO:
+ fd.posixfd = -1;
+ res.timers = sio_time_new();
+ break;
+ case HDF5:
+ fd.h5fd = -1;
+ res.timers = sio_time_new();
+ break;
+ default:
+ /* unknown request */
+ fprintf(stderr, "Unknown IO type request (%d)\n", iot);
+ GOTOERROR(FAIL);
+ }
+
+ nbytes = param.num_bytes;
+ linear_buf_size = 1;
+
+ for (i=0; i<param.rank; i++){
+ dset_size[i] = param.dset_size[i];
+ buf_size[i] = param.buf_size[i];
+ chk_size[i] = param.chk_size[i];
+ order[i] = param.order[i];
+ linear_buf_size *= buf_size[i];
+ buf_offset[i] = 0;
+ offset[i] = 0;
+
+ /* Validate transfer buffer size */
+ if (param.buf_size[i]<=0) {
+ HDfprintf(stderr,
+ "Transfer buffer size[%d] (%Hd) must be > 0\n", i,(long_long)buf_size[i]);
+ GOTOERROR(FAIL);
+ }
+
+ if ((param.dset_size[i]%param.buf_size[i])!=0) {
+ HDfprintf(stderr,
+ "Dataset size[%d] (%Hd) must be a multiple of the "
+ "trasfer buffer size[%d] (%Hd)\n",param.rank,
+ (long_long)param.dset_size[i], param.rank, (long_long)param.buf_size[i]);
+ GOTOERROR(FAIL);
+ }
+
+ }
+
+ /* Allocate transfer buffer */
+ buffer2 = malloc(linear_buf_size);
+ if ((buffer = malloc(linear_buf_size)) == NULL){
+ HDfprintf(stderr, "malloc for transfer buffer size (%Hd) failed\n",
+ (long_long)(linear_buf_size));
+ GOTOERROR(FAIL);
+ }
+
+ if (sio_debug_level >= 4)
+
+ /* output all of the times for all iterations */
+ fprintf(output, "Timer details:\n");
+
+ /*
+ * Write performance measurement
+ */
+ /* Open file for write */
+
+ strcpy(base_name, "#sio_tmp");
+ sio_create_filename(iot, base_name, fname, sizeof(fname), &param);
+
+ if (sio_debug_level > 0)
+ HDfprintf(output, "data filename=%s\n",
+ fname);
+
+ set_time(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, START);
+ hrc = do_fopen(&param, fname, &fd, SIO_CREATE | SIO_WRITE);
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ set_time(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, START);
+ hrc = do_write(&res, &fd, &param, buffer);
+ set_time(res.timers, HDF5_FINE_WRITE_FIXED_DIMS, STOP);
+ VRFY((hrc == SUCCESS), "do_write failed");
+
+ /* Close file for write */
+ hrc = do_fclose(iot, &fd);
+ set_time(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS, STOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+
+ if (!param.h5_write_only) {
+ /*
+ * Read performance measurement
+ */
+
+ /* Open file for read */
+ set_time(res.timers, HDF5_GROSS_READ_FIXED_DIMS, START);
+ hrc = do_fopen(&param, fname, &fd, SIO_READ);
+ VRFY((hrc == SUCCESS), "do_fopen failed");
+
+ set_time(res.timers, HDF5_FINE_READ_FIXED_DIMS, START);
+ hrc = do_read(&res, &fd, &param, buffer);
+ set_time(res.timers, HDF5_FINE_READ_FIXED_DIMS, STOP);
+ VRFY((hrc == SUCCESS), "do_read failed");
+
+ /* Close file for read */
+ hrc = do_fclose(iot, &fd);
+
+ set_time(res.timers, HDF5_GROSS_READ_FIXED_DIMS, STOP);
+ VRFY((hrc == SUCCESS), "do_fclose failed");
+ }
+
+ do_cleanupfile(iot, fname);
+
+done:
+ /* clean up */
+ /* release HDF5 objects */
+
+ /* close any opened files */
+ /* no remove(fname) because that should have happened normally. */
+ switch (iot) {
+ case POSIXIO:
+ if (fd.posixfd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ case HDF5:
+ if (fd.h5fd != -1)
+ hrc = do_fclose(iot, &fd);
+ break;
+ }
+
+ /* release generic resources */
+ if (buffer)
+ free(buffer);
+
+ res.ret_code = ret_code;
+ return res;
+}
+
+/*
+ * Function: sio_create_filename
+ * Purpose: Create a new filename to write to. Determine the correct
+ * suffix to append to the filename by the type of I/O we're
+ * doing. Also, place in the /tmp/{$USER,$LOGIN} directory if
+ * USER or LOGIN are specified in the environment.
+ * Return: Pointer to filename or NULL
+ * Programmer: Bill Wendling, 21. November 2001
+ * Modifications: Support for file drivers. Christian Chilan, April, 2008
+ */
+ static char *
+sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t size, parameters *param)
+{
+ const char *prefix, *suffix="";
+ char *ptr, last = '\0';
+ size_t i, j;
+ vfdtype vfd;
+ vfd = param->vfd;
+
+ if (!base_name || !fullname || size < 1)
+ return NULL;
+
+ memset(fullname, 0, size);
+
+ switch (iot) {
+ case POSIXIO:
+ suffix = ".posix";
+ break;
+ case HDF5:
+ suffix = ".h5";
+ if (vfd == family)
+ suffix = "%05d.h5";
+ else if (vfd == multi)
+ suffix = NULL;
+ break;
+ }
+
+ /* First use the environment variable and then try the constant */
+ prefix = getenv("HDF5_PARAPREFIX");
+
+#ifdef HDF5_PARAPREFIX
+ if (!prefix)
+ prefix = HDF5_PARAPREFIX;
+#endif /* HDF5_PARAPREFIX */
+
+ /* Prepend the prefix value to the base name */
+ if (prefix && *prefix) {
+ /* If the prefix specifies the HDF5_PARAPREFIX directory, then
+ * default to using the "/tmp/$USER" or "/tmp/$LOGIN"
+ * directory instead. */
+ register char *user, *login, *subdir;
+
+ user = getenv("USER");
+ login = getenv("LOGIN");
+ subdir = (user ? user : login);
+
+ if (subdir) {
+ for (i = 0; i < size && prefix[i]; i++)
+ fullname[i] = prefix[i];
+
+ fullname[i++] = '/';
+
+ for (j = 0; i < size && subdir[j]; i++, j++)
+ fullname[i] = subdir[j];
+ } else {
+ /* We didn't append the prefix yet */
+ strncpy(fullname, prefix, MIN(strlen(prefix), size));
+ }
+
+ if ((strlen(fullname) + strlen(base_name) + 1) < size) {
+ /* Append the base_name with a slash first. Multiple slashes are
+ * handled below. */
+ h5_stat_t buf;
+
+ if (HDstat(fullname, &buf) < 0)
+ /* The directory doesn't exist just yet */
+ if (mkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) {
+ /* We couldn't make the "/tmp/${USER,LOGIN}" subdirectory.
+ * Default to PREFIX's original prefix value. */
+ strcpy(fullname, prefix);
+ }
+
+ strcat(fullname, "/");
+ strcat(fullname, base_name);
+ } else {
+ /* Buffer is too small */
+ return NULL;
+ }
+ } else if (strlen(base_name) >= size) {
+ /* Buffer is too small */
+ return NULL;
+ } else {
+ strcpy(fullname, base_name);
+ }
+
+ /* Append a suffix */
+ if (suffix) {
+ if (strlen(fullname) + strlen(suffix) >= size)
+ return NULL;
+
+ strcat(fullname, suffix);
+ }
+
+ /* Remove any double slashes in the filename */
+ for (ptr = fullname, i = j = 0; ptr && i < size; i++, ptr++) {
+ if (*ptr != '/' || last != '/')
+ fullname[j++] = *ptr;
+
+ last = *ptr;
+ }
+
+ return fullname;
+}
+
+/*
+ * Function: do_write
+ * Purpose: Write the required amount of data to the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+static herr_t
+do_write(results *res, file_descr *fd, parameters *parms, void *buffer)
+{
+ int ret_code = SUCCESS;
+ char dname[64];
+ long i;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5block[MAX_DIMS]; /*dataspace selection */
+ hsize_t h5stride[MAX_DIMS]; /*selection stride */
+ hsize_t h5start[MAX_DIMS]; /*selection start */
+ hsize_t h5maxdims[MAX_DIMS];
+ int rank; /*rank of dataset */
+ /* Prepare buffer for verifying data */
+// if (parms->verify)
+ // memset(buffer,1,linear_buf_size);
+
+ buf_p=(unsigned char *)buffer;
+
+ for (i=0; i < linear_buf_size; i++)
+ buf_p[i]=i%128;
+
+ rank = parms->rank;
+
+ for (i=0; i<rank; i++) {
+ h5offset[i] = offset[i] = 0;
+ }
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+
+ /* determine lowest dimension for contiguous POSIX access */
+ cont_dim = rank;
+
+ for (i=rank-1; i>=0; i--) {
+ if (parms->buf_size[i]==parms->dset_size[i])
+ cont_dim = i;
+ else
+ break;
+ }
+
+ /* determine size of the contiguous POSIX access */
+ cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1];
+ for (i=cont_dim; i<rank; i++)
+ cont_size *= parms->buf_size[i];
+
+ break;
+
+ case HDF5: /* HDF5 setup */
+
+ for (i=0; i < rank; i++){
+ h5dims[i] = parms->dset_size[i];
+ h5start[i] = 0;
+ h5stride[i] = 1;
+ h5block[i] = 1;
+ h5count[i] = parms->buf_size[i];
+ h5chunk[i] = parms->chk_size[i];
+ h5maxdims[i] = H5S_UNLIMITED;
+
+ }
+
+ if (parms->h5_use_chunks && parms->h5_extendable) {
+ h5dset_space_id = H5Screate_simple(rank, h5count, h5maxdims);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+ }
+ else {
+ h5dset_space_id = H5Screate_simple(rank, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+ }
+
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET,
+ h5start, h5stride, h5count, h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ h5mem_space_id = H5Screate_simple(rank, h5count, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ fprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+ } /* end switch */
+
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ break;
+
+ case HDF5:
+ h5dcpl = H5Pcreate(H5P_DATASET_CREATE);
+
+ if (h5dcpl < 0) {
+ fprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ if(parms->h5_use_chunks) {
+ /* Set the chunk size to be the same as the buffer size */
+ hrc = H5Pset_chunk(h5dcpl, rank, h5chunk);
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Property List Set failed\n");
+ GOTOERROR(FAIL);
+ } /* end if */
+ } /* end if */
+
+ sprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes);
+ h5ds_id = H5Dcreate1(fd->h5fd, dname, ELMT_H5_TYPE,
+ h5dset_space_id, h5dcpl);
+
+ if (h5ds_id < 0) {
+ fprintf(stderr, "HDF5 Dataset Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ hrc = H5Pclose(h5dcpl);
+ /* verifying the close of the dcpl */
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Property List Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+ }
+
+ /* Start "raw data" write timer */
+ set_time(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, START);
+
+ /* Perform write */
+ hrc = dset_write(rank-1, fd, parms, buffer);
+
+ if (hrc < 0) {
+ fprintf(stderr, "Error in dataset write\n");
+ GOTOERROR(FAIL);
+ }
+
+
+ /* Stop "raw data" write timer */
+ set_time(res->timers, HDF5_RAW_WRITE_FIXED_DIMS, STOP);
+
+ /* Calculate write time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == HDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = -1;
+ } /* end if */
+
+done:
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0){
+ fprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5dset_space_id = -1;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5mem_space_id = -1;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5dxpl = -1;
+ }
+ }
+
+ return ret_code;
+}
+
+/*
+ * Function: dset_write
+ * Purpose: Write buffer into the dataset.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t dset_write(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int cur_dim = order[local_dim]-1;
+ int ret_code = SUCCESS;
+ int k;
+ hsize_t dims[MAX_DIMS], maxdims[MAX_DIMS];
+ long i,j;
+ herr_t hrc;
+
+ /* iterates according to the dimensions in order array */
+ for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){
+
+ h5offset[cur_dim] = offset[cur_dim] = i;
+
+ if (local_dim > 0){
+
+ dset_write(local_dim-1, fd, parms, buffer);
+
+ }else{
+
+ switch (parms->io_type) {
+
+ case POSIXIO:
+ /* initialize POSIX offset in the buffer */
+ for (j=0; j < parms->rank; j++) {
+ buf_offset[j]=0;
+ }
+ buf_p = (unsigned char *)buffer;
+ /* write POSIX buffer */
+ posix_buffer_write(0, fd, parms, buffer);
+ break;
+
+ case HDF5:
+ /* if dimensions are extendable, extend them as needed during
+ access */
+ if (parms->h5_use_chunks && parms->h5_extendable) {
+
+ hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims);
+ VRFY((hrc >= 0), "H5Sget_simple_extent_dims");
+
+ for (k=0; k < parms->rank; k++){
+
+ if (dims[k] <= h5offset[k]) {
+ dims[k] = dims[k]+h5count[k];
+ hrc=H5Sset_extent_simple(h5dset_space_id,parms->rank,dims,maxdims);
+ VRFY((hrc >= 0), "H5Sset_extent_simple");
+ hrc=H5Dextend(h5ds_id,dims);
+ VRFY((hrc >= 0), "H5Dextend");
+ }
+ }
+ }
+ /* applies offset */
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+
+ /* Write the buffer out */
+ hrc=H5Sget_simple_extent_dims(h5dset_space_id,dims,maxdims);
+ hrc = H5Dwrite(h5ds_id, ELMT_H5_TYPE, h5mem_space_id,
+ h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dwrite");
+
+ break;
+ } /* switch (parms->io_type) */
+ }
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: posix_buffer_write
+ * Purpose: Write buffer into the POSIX file considering contiguity.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t posix_buffer_write(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int dtype_size = 1;
+ int ret_code = SUCCESS;
+ long i;
+
+ /* if dimension is not contiguous, call recursively */
+ if (local_dim < parms->rank-1 && local_dim != cont_dim) {
+
+ for (i=0; i < parms->buf_size[local_dim]; i += dtype_size) {
+ buf_offset[local_dim] = i;
+ posix_buffer_write(local_dim+1, fd, parms, buffer);
+
+ /* if next dimension is cont_dim, it will fill out the buffer
+ traversing the entire dimension local_dim without the need
+ of performing iteration */
+ if (local_dim+1==cont_dim)
+ break;
+ }
+ /* otherwise, perform contiguous POSIX access */
+ } else {
+
+ buf_offset[local_dim] = 0;
+ size_t linear_dset_offset = 0, d_offset;
+ int j, rc;
+
+ /* determine offset in the buffer */
+ for (i=0; i < parms->rank; i++){
+ d_offset=1;
+
+ for (j=i+1; j < parms->rank; j++)
+ d_offset *= parms->dset_size[j];
+
+ linear_dset_offset += (offset[i]+buf_offset[i])*d_offset;
+ }
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0;
+ VRFY((rc==0), "POSIXSEEK");
+ /* check if all bytes are written */
+ rc = ((ssize_t)cont_size ==
+ POSIXWRITE(fd->posixfd, buf_p, cont_size));
+ VRFY((rc != 0), "POSIXWRITE");
+
+ /* Advance location in buffer */
+ buf_p += cont_size;
+
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: do_read
+ * Purpose: Read the required amount of data to the file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+static herr_t
+do_read(results *res, file_descr *fd, parameters *parms, void *buffer)
+{
+ int ret_code = SUCCESS;
+ char dname[64];
+ long i;
+ /* HDF5 variables */
+ herr_t hrc; /*HDF5 return code */
+ hsize_t h5dims[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5chunk[MAX_DIMS]; /*dataset dim sizes */
+ hsize_t h5block[MAX_DIMS]; /*dataspace selection */
+ hsize_t h5stride[MAX_DIMS]; /*selection stride */
+ hsize_t h5start[MAX_DIMS]; /*selection start */
+ int rank;
+
+ /* Prepare buffer for verifying data */
+ // if (parms->verify)
+ // memset(buffer,1,linear_buf_size);
+// if (parms->verify)
+ for (i=0; i < linear_buf_size; i++)
+ buffer2[i]=i%128;
+
+ rank = parms->rank;
+ for (i=0; i<rank; i++) {
+ h5offset[i] = offset[i] = 0;
+ }
+
+ /* I/O Access specific setup */
+ switch (parms->io_type) {
+ case POSIXIO:
+ cont_dim = rank;
+
+ for (i=rank-1; i>=0; i--) {
+ if (parms->buf_size[i]==parms->dset_size[i])
+ cont_dim = i;
+ else
+ break;
+ }
+ cont_size = (!cont_dim)? 1 : parms->buf_size[cont_dim-1];
+ for (i=cont_dim; i<rank; i++)
+ cont_size *= parms->buf_size[i];
+
+ break;
+
+ case HDF5: /* HDF5 setup */
+ for (i=0; i < rank; i++){
+ h5dims[i] = parms->dset_size[i];
+ h5start[i] = 0;
+ h5stride[i] = 1;
+ h5block[i] = 1;
+ h5count[i] = parms->buf_size[i];
+ h5chunk[i] = parms->chk_size[i];
+ }
+
+ h5dset_space_id = H5Screate_simple(rank, h5dims, NULL);
+ VRFY((h5dset_space_id >= 0), "H5Screate_simple");
+
+ hrc = H5Sselect_hyperslab(h5dset_space_id, H5S_SELECT_SET,
+ h5start, h5stride, h5count, h5block);
+ VRFY((hrc >= 0), "H5Sselect_hyperslab");
+
+ /* Create the memory dataspace that corresponds to the xfer buffer */
+ h5mem_space_id = H5Screate_simple(rank, h5count, NULL);
+ VRFY((h5mem_space_id >= 0), "H5Screate_simple");
+
+ /* Create the dataset transfer property list */
+ h5dxpl = H5Pcreate(H5P_DATASET_XFER);
+ if (h5dxpl < 0) {
+ fprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+ } /* end switch */
+
+
+ /* create dataset */
+ switch (parms->io_type) {
+ case POSIXIO:
+ break;
+
+ case HDF5:
+ sprintf(dname, "Dataset_%ld", parms->num_bytes);
+ h5ds_id = H5Dopen1(fd->h5fd, dname);
+ if (h5ds_id < 0) {
+ fprintf(stderr, "HDF5 Dataset open failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ break;
+
+ } /* end switch */
+
+ /* Start "raw data" read timer */
+ set_time(res->timers, HDF5_RAW_READ_FIXED_DIMS, START);
+ hrc = dset_read(rank-1, fd, parms, buffer);
+
+ if (hrc < 0) {
+ fprintf(stderr, "Error in dataset read\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* Stop "raw data" read timer */
+ set_time(res->timers, HDF5_RAW_READ_FIXED_DIMS, STOP);
+
+ /* Calculate read time */
+
+ /* Close dataset. Only HDF5 needs to do an explicit close. */
+ if (parms->io_type == HDF5) {
+ hrc = H5Dclose(h5ds_id);
+
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Dataset Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ h5ds_id = -1;
+ } /* end if */
+
+done:
+
+ /* release HDF5 objects */
+ if (h5dset_space_id != -1) {
+ hrc = H5Sclose(h5dset_space_id);
+ if (hrc < 0){
+ fprintf(stderr, "HDF5 Dataset Space Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5dset_space_id = -1;
+ }
+ }
+
+ if (h5mem_space_id != -1) {
+ hrc = H5Sclose(h5mem_space_id);
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Memory Space Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5mem_space_id = -1;
+ }
+ }
+
+ if (h5dxpl != -1) {
+ hrc = H5Pclose(h5dxpl);
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 Dataset Transfer Property List Close failed\n");
+ ret_code = FAIL;
+ } else {
+ h5dxpl = -1;
+ }
+ }
+
+ return ret_code;
+}
+
+/*
+ * Function: dset_read
+ * Purpose: Read buffer into the dataset.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t dset_read(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int cur_dim = order[local_dim]-1;
+ int ret_code = SUCCESS;
+ long i,j;
+ herr_t hrc;
+
+ /* iterate on the current dimension */
+ for (i=0; i < parms->dset_size[cur_dim]; i += parms->buf_size[cur_dim]){
+
+ h5offset[cur_dim] = offset[cur_dim] = i;
+
+ /* if traverse in order array is incomplete, recurse */
+ if (local_dim > 0){
+
+ ret_code = dset_read(local_dim-1, fd, parms, buffer);
+
+ /* otherwise, write buffer into dataset */
+ }else{
+
+ switch (parms->io_type) {
+
+ case POSIXIO:
+ for (j=0; j<parms->rank; j++) {
+ buf_offset[j] = 0;
+ }
+ buf_p = (unsigned char*)buffer;
+ buf2_p = (unsigned char*)buffer2;
+ posix_buffer_read(0, fd, parms, buffer);
+ break;
+
+ case HDF5:
+ hrc = H5Soffset_simple(h5dset_space_id, h5offset);
+ VRFY((hrc >= 0), "H5Soffset_simple");
+ /* Read the buffer out */
+ hrc = H5Dread(h5ds_id, ELMT_H5_TYPE, h5mem_space_id,
+ h5dset_space_id, h5dxpl, buffer);
+ VRFY((hrc >= 0), "H5Dread");
+#if 0
+ for (j=0; j<linear_buf_size; j++) {
+ buf_p = (unsigned char*)buffer;
+ if (buf_p[j]!=buffer2[j])
+ printf("Inconsistent data in %d\n", j);
+ }
+#endif
+ break;
+ } /* switch (parms->io_type) */
+ }
+ }
+done:
+ return ret_code;
+}
+
+/*
+ * Function: posix_buffer_read
+ * Purpose: Read buffer into the POSIX file considering contiguity.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+static herr_t posix_buffer_read(int local_dim, file_descr *fd, parameters *parms, void *buffer)
+{
+ int dtype_size = 1;
+ int ret_code = SUCCESS;
+ long i;
+
+ /* if local dimension is not contiguous, recurse */
+ if (local_dim < parms->rank-1 && local_dim != cont_dim) {
+
+ for (i=0; i < parms->buf_size[local_dim]; i += dtype_size) {
+ buf_offset[local_dim] = i;
+ ret_code = posix_buffer_read(local_dim+1, fd, parms, buffer);
+ if (local_dim+1==cont_dim)
+ break;
+ }
+ /* otherwise, perform contiguous POSIX access */
+ } else {
+
+ buf_offset[local_dim] = 0;
+ size_t linear_dset_offset = 0, d_offset;
+ int j, rc;
+ /* determine offset in buffer */
+ for (i=0; i<parms->rank; i++){
+ d_offset=1;
+
+ for (j=i+1; j<parms->rank; j++)
+ d_offset *= parms->dset_size[j];
+
+ linear_dset_offset += (offset[i]+buf_offset[i])*d_offset;
+ }
+
+ /* only care if seek returns error */
+ rc = POSIXSEEK(fd->posixfd, linear_dset_offset) < 0 ? -1 : 0;
+ VRFY((rc==0), "POSIXSEEK");
+ /* check if all bytes are read */
+ rc = ((ssize_t)cont_size ==
+ POSIXREAD(fd->posixfd, buf_p, cont_size));
+ VRFY((rc != 0), "POSIXREAD");
+#if 0
+ for (j=0; j<cont_size; j++) {
+ if (buf_p[j]!=buf2_p[j])
+ printf("Inconsistent data in %d\n", j);
+ }
+ buf2_p += cont_size;
+#endif
+
+ /* Advance location in buffer */
+ buf_p += cont_size;
+
+ }
+done:
+ return ret_code;
+}
+
+
+/*
+ * Function: do_fopen
+ * Purpose: Open the specified file.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications: Support for file drivers, Christian Chilan, April, 2008
+ */
+ static herr_t
+do_fopen(parameters *param, char *fname, file_descr *fd /*out*/, int flags)
+{
+ int ret_code = SUCCESS;
+
+ switch (param->io_type) {
+ case POSIXIO:
+ if (flags & (SIO_CREATE | SIO_WRITE))
+ fd->posixfd = POSIXCREATE(fname);
+ else
+ fd->posixfd = POSIXOPEN(fname, O_RDONLY);
+
+ if (fd->posixfd < 0 ) {
+ fprintf(stderr, "POSIX File Open failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+
+ break;
+
+ case HDF5:
+
+ fapl = set_vfd(param);
+
+ if (fapl < 0) {
+ fprintf(stderr, "HDF5 Property List Create failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ /* create the parallel file */
+ if (flags & (SIO_CREATE | SIO_WRITE)) {
+ fd->h5fd = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
+ } else {
+ fd->h5fd = H5Fopen(fname, H5F_ACC_RDONLY, fapl);
+ }
+
+
+ if (fd->h5fd < 0) {
+ fprintf(stderr, "HDF5 File Create failed(%s)\n", fname);
+ GOTOERROR(FAIL);
+ }
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+/*
+ * Function: set_vfd
+ * Purpose: Sets file driver.
+ * Return: SUCCESS or FAIL
+ * Programmer: Christian Chilan, April, 2008
+ * Modifications:
+ */
+
+hid_t
+set_vfd(parameters *param)
+{
+ hid_t fapl = -1;
+ vfdtype vfd;
+
+ vfd = param->vfd;
+
+ if ((fapl=H5Pcreate(H5P_FILE_ACCESS))<0) return -1;
+
+ if (vfd == sec2) {
+ /* Unix read() and write() system calls */
+ if (H5Pset_fapl_sec2(fapl)<0) return -1;
+ } else if (vfd == stdio) {
+ /* Standard C fread() and fwrite() system calls */
+ if (H5Pset_fapl_stdio(fapl)<0) return -1;
+ } else if (vfd == core) {
+ /* In-core temporary file with 1MB increment */
+ if (H5Pset_fapl_core(fapl, (size_t)1024*1024, TRUE)<0) return -1;
+ } else if (vfd == split) {
+ /* Split meta data and raw data each using default driver */
+ if (H5Pset_fapl_split(fapl,
+ "-m.h5", H5P_DEFAULT,
+ "-r.h5", H5P_DEFAULT)<0)
+ return -1;
+ } else if (vfd == multi) {
+ /* Multi-file driver, general case of the split driver */
+ H5FD_mem_t memb_map[H5FD_MEM_NTYPES];
+ hid_t memb_fapl[H5FD_MEM_NTYPES];
+ const char *memb_name[H5FD_MEM_NTYPES];
+ char sv[H5FD_MEM_NTYPES][1024];
+ haddr_t memb_addr[H5FD_MEM_NTYPES];
+ H5FD_mem_t mt;
+
+ HDmemset(memb_map, 0, sizeof memb_map);
+ HDmemset(memb_fapl, 0, sizeof memb_fapl);
+ HDmemset(memb_name, 0, sizeof memb_name);
+ HDmemset(memb_addr, 0, sizeof memb_addr);
+
+ assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+ for (mt=H5FD_MEM_DEFAULT; mt<H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ memb_fapl[mt] = H5P_DEFAULT;
+ sprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]);
+ memb_name[mt] = sv[mt];
+ memb_addr[mt] = MAX(mt-1,0)*(HADDR_MAX/10);
+ }
+
+ if (H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name,
+ memb_addr, FALSE)<0) {
+ return -1;
+ }
+ } else if (vfd == family) {
+ hsize_t fam_size = 1*1024*1024; /*100 MB*/
+
+ /* Family of files, each 1MB and using the default driver */
+ /* if ((val=HDstrtok(NULL, " \t\n\r")))
+ fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); */
+ if (H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0)
+ return -1;
+ } else if (vfd == direct) {
+#ifdef H5_HAVE_DIRECT
+ /* Linux direct read() and write() system calls. Set memory boundary, file block size,
+ * and copy buffer size to the default values. */
+ if (H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) return -1;
+#endif
+ } else {
+ /* Unknown driver */
+ return -1;
+ }
+
+ return fapl;
+}
+
+/*
+ * Function: do_fclose
+ * Purpose: Close the specified file descriptor.
+ * Return: SUCCESS or FAIL
+ * Programmer: Albert Cheng, Bill Wendling, 2001/12/13
+ * Modifications:
+ */
+ static herr_t
+do_fclose(iotype iot, file_descr *fd /*out*/)
+{
+ herr_t ret_code = SUCCESS, hrc;
+ int rc = 0;
+
+ switch (iot) {
+ case POSIXIO:
+ rc = POSIXCLOSE(fd->posixfd);
+
+ if (rc != 0){
+ fprintf(stderr, "POSIX File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->posixfd = -1;
+ break;
+
+ case HDF5:
+ hrc = H5Fclose(fd->h5fd);
+
+ if (hrc < 0) {
+ fprintf(stderr, "HDF5 File Close failed\n");
+ GOTOERROR(FAIL);
+ }
+
+ fd->h5fd = -1;
+ break;
+ }
+
+done:
+ return ret_code;
+}
+
+
+/*
+ * Function: do_cleanupfile
+ * Purpose: Cleanup temporary file unless HDF5_NOCLEANUP is set.
+ * Return: void
+ * Programmer: Albert Cheng 2001/12/12
+ * Modifications: Support for file drivers. Christian Chilan, April, 2008
+ */
+ static void
+do_cleanupfile(iotype iot, char *filename)
+{
+ char temp[2048];
+ int j;
+ hid_t driver;
+
+ if (clean_file_g == -1)
+ clean_file_g = (getenv("HDF5_NOCLEANUP")==NULL) ? 1 : 0;
+
+ if (clean_file_g){
+
+ switch (iot) {
+ case POSIXIO:
+ HDremove(filename);
+ break;
+
+ case HDF5:
+ driver = H5Pget_driver(fapl);
+
+ if (driver == H5FD_FAMILY) {
+ for (j = 0; /*void*/; j++) {
+ HDsnprintf(temp, sizeof temp, filename, j);
+
+ if (HDaccess(temp, F_OK) < 0)
+ break;
+
+ HDremove(temp);
+ }
+ } else if (driver == H5FD_CORE) {
+ hbool_t backing; /* Whether the core file has backing store */
+
+ H5Pget_fapl_core(fapl,NULL,&backing);
+
+ /* If the file was stored to disk with bacing store, remove it */
+ if(backing)
+ HDremove(filename);
+
+ } else if (driver == H5FD_MULTI) {
+ H5FD_mem_t mt;
+ assert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES);
+
+ for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t,mt)) {
+ HDsnprintf(temp, sizeof temp, "%s-%c.h5",
+ filename, multi_letters[mt]);
+ HDremove(temp); /*don't care if it fails*/
+ }
+ } else {
+ HDremove(filename);
+ }
+ H5Pclose(fapl);
+ break;
+ }
+}
+}
+
+#ifdef H5_HAVE_GPFS
+
+/* Descriptions here come from the IBM GPFS Manual */
+
+/*
+ * Function: gpfs_access_range
+ * Purpose: Declares an access range within a file for an
+ * application.
+ *
+ * The application will access file offsets within the given
+ * range, and will not access offsets outside the range.
+ * Violating this hint may produce worse performance than if
+ * no hint was specified.
+ *
+ * This hint is useful in situations where a file is
+ * partitioned coarsely among several nodes. If the ranges
+ * do not overlap, each node can specify which range of the
+ * file it will access, with a performance improvement in
+ * some cases, such as for sequential writing within a
+ * range.
+ *
+ * Subsequent GPFS_ACCESS_RANGE hints will replace a hint
+ * passed earlier.
+ *
+ * START - The start of the access range offset, in
+ * bytes, from the beginning of the file
+ * LENGTH - Length of the access range. 0 indicates to
+ * the end of the file
+ * IS_WRITE - 0 indicates READ access, 1 indicates WRITE access
+ * Return: Nothing
+ * Programmer: Bill Wendling, 03. June 2002
+ * Modifications:
+ */
+ static void
+gpfs_access_range(int handle, off_t start, off_t length, int is_write)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsAccessRange_t access;
+ } access_range;
+
+ access_range.hdr.totalLength = sizeof(access_range);
+ access_range.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ access_range.hdr.fcntlReserved = 0;
+ access_range.access.structLen = sizeof(gpfsAccessRange_t);
+ access_range.access.structType = GPFS_ACCESS_RANGE;
+ access_range.access.start = start;
+ access_range.access.length = length;
+ access_range.access.isWrite = is_write;
+
+ if (gpfs_fcntl(handle, &access_range) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl DS start directive failed. errno=%d errorOffset=%d\n",
+ errno, access_range.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_free_range
+ * Purpose: Undeclares an access range within a file for an
+ * application.
+ *
+ * The application will no longer access file offsets within
+ * the given range. GPFS flushes the data at the file
+ * offsets and removes it from the cache.
+ *
+ * Multi-node applications that have finished one phase of
+ * their computation may wish to use this hint before the
+ * file is accessed in a conflicting mode from another node
+ * in a later phase. The potential performance benefit is
+ * that GPFS can avoid later synchronous cache consistency
+ * operations.
+ *
+ * START - The start of the access range offset, in
+ * bytes from the beginning of the file.
+ * LENGTH - Length of the access range. 0 indicates to
+ * the end of the file.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 03. June 2002
+ * Modifications:
+ */
+ static void
+gpfs_free_range(int handle, off_t start, off_t length)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsFreeRange_t range;
+ } free_range;
+
+ /* Issue the invalidate hint */
+ free_range.hdr.totalLength = sizeof(free_range);
+ free_range.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ free_range.hdr.fcntlReserved = 0;
+ free_range.range.structLen = sizeof(gpfsFreeRange_t);
+ free_range.range.structType = GPFS_FREE_RANGE;
+ free_range.range.start = start;
+ free_range.range.length = length;
+
+ if (gpfs_fcntl(handle, &free_range) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl free range failed for range %d:%d. errno=%d errorOffset=%d\n",
+ start, length, errno, free_range.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_clear_file_cache
+ * Purpose: Indicates file access in the near future is not expected.
+ *
+ * The application does not expect to make any further
+ * accesses to the file in the near future, so GPFS removes
+ * any data or metadata pertaining to the file from its
+ * cache.
+ *
+ * Multi-node applications that have finished one phase of
+ * their computation may wish to use this hint before the
+ * file is accessed in a conflicting mode from another node
+ * in a later phase. The potential performance benefit is
+ * that GPFS can avoid later synchronous cache consistency
+ * operations.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 03. June 2002
+ * Modifications:
+ */
+ static void
+gpfs_clear_file_cache(int handle)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsClearFileCache_t clear;
+ } clear_cache;
+
+ clear_cache.hdr.totalLength = sizeof(clear_cache);
+ clear_cache.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ clear_cache.hdr.fcntlReserved = 0;
+ clear_cache.clear.structLen = sizeof(gpfsClearFileCache_t);
+ clear_cache.clear.structType = GPFS_CLEAR_FILE_CACHE;
+
+ if (gpfs_fcntl(handle, &clear_cache) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl clear file cache directive failed. errno=%d errorOffset=%d\n",
+ errno, clear_cache.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_cancel_hints
+ * Purpose: Indicates to remove any hints against the open file
+ * handle.
+ *
+ * GPFS removes any hints that may have been issued against
+ * this open file handle:
+ *
+ * - The hint status of the file is restored ot what it
+ * would have been immediately after being opened, but
+ * does not affect the contents of the GPFS file
+ * cache. Cancelling an earlier hint that resulted in
+ * data being removed from the GPFS file cache does
+ * not bring that data back int othe cache; data
+ * re-enters the cache only pon access by the
+ * application or by user-driven or automatic
+ * prefetching.
+ * - Only the GPFS_MULTIPLE_ACCESS_RANGE hint has a
+ * state that might be removed by the
+ * GPFS_CANCEL_HINTS directive.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 03. June 2002
+ * Modifications:
+ */
+ static void
+gpfs_cancel_hints(int handle)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsCancelHints_t cancel;
+ } cancel_hints;
+
+ cancel_hints.hdr.totalLength = sizeof(cancel_hints);
+ cancel_hints.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ cancel_hints.hdr.fcntlReserved = 0;
+ cancel_hints.cancel.structLen = sizeof(gpfsCancelHints_t);
+ cancel_hints.cancel.structType = GPFS_CANCEL_HINTS;
+
+ if (gpfs_fcntl(handle, &cancel_hints) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl cancel hints directive failed. errno=%d errorOffset=%d\n",
+ errno, cancel_hints.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_start_data_shipping
+ * Purpose: Initiates data shipping mode.
+ *
+ * Once all participating threads have issued this directive
+ * for a file, GPFS enters a mode where it logically
+ * partitions the blocks of the file among a group of agent
+ * nodes. The agents are those nodes on which one or more
+ * threads have issued the GPFS_DATA_SHIP_START directive.
+ * Each thread that has issued a GPFS_DATA_SHIP_START
+ * directive and the associated agent nodes are referred to
+ * as the data shipping collective.
+ *
+ * The second parameter is the total number of open
+ * instances on all nodes that will be operating on the
+ * file. Must be called for every such instance with the
+ * same value of NUM_INSTS.
+ *
+ * NUM_INSTS - The number of open file instances, on all
+ * nodes, collaborating to operate on the file
+ * Return: Nothing
+ * Programmer: Bill Wendling, 28. May 2002
+ * Modifications:
+ */
+ static void
+gpfs_start_data_shipping(int handle, int num_insts)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsDataShipStart_t start;
+ } ds_start;
+
+ ds_start.hdr.totalLength = sizeof(ds_start);
+ ds_start.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ ds_start.hdr.fcntlReserved = 0;
+ ds_start.start.structLen = sizeof(gpfsDataShipStart_t);
+ ds_start.start.structType = GPFS_DATA_SHIP_START;
+ ds_start.start.numInstances = num_insts;
+ ds_start.start.reserved = 0;
+
+ if (gpfs_fcntl(handle, &ds_start) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl DS start directive failed. errno=%d errorOffset=%d\n",
+ errno, ds_start.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_start_data_ship_map
+ * Purpose: Indicates which agent nodes are to be used for data
+ * shipping. GPFS recognizes which agent nodes to use for
+ * data shipping.
+ *
+ * PARTITION_SIZE - The number of contiguous bytes per
+ * server. This value must be a
+ * multiple of the number of bytes in a
+ * single file system block
+ * AGENT_COUNT - The number of entries in the
+ * agentNodeNumber array
+ * AGENT_NODE_NUM - The data ship agent node numbers as
+ * listed in the SDT or the global ODM
+ *
+ * Return: Nothing
+ * Programmer: Bill Wendling, 10. Jul 2002
+ * Modifications:
+ */
+ static void
+gpfs_start_data_ship_map(int handle, int partition_size, int agent_count,
+ int *agent_node_num)
+{
+ int i;
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsDataShipMap_t map;
+ } ds_map;
+
+ ds_map.hdr.totalLength = sizeof(ds_map);
+ ds_map.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ ds_map.hdr.fcntlReserved = 0;
+ ds_map.map.structLen = sizeof(gpfsDataShipMap_t);
+ ds_map.map.structType = GPFS_DATA_SHIP_MAP;
+ ds_map.map.partitionSize = partition_size;
+ ds_map.map.agentCount = agent_count;
+
+ for (i = 0; i < agent_count; ++i)
+ ds_map.map.agentNodeNumber[i] = agent_node_num[i];
+
+ if (gpfs_fcntl(handle, &ds_map) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl DS map directive failed. errno=%d errorOffset=%d\n",
+ errno, ds_map.hdr.errorOffset);
+ exit(EXIT_FAILURE);
+ }
+}
+
+/*
+ * Function: gpfs_stop_data_shipping
+ * Purpose: Takes a file out of the data shipping mode.
+ *
+ * - GPFS waits for all threads that issued the
+ * GPFS_DATA_SHIP_START directive to issue this directive,
+ * then flushes the dirty file data to disk.
+ *
+ * - While a gpfs_cntl() call is blocked for other threads,
+ * the call can be interrupted by any signal. If a signal
+ * is delivered to any of the waiting calls, all waiting
+ * calls on every node will be interrupted and will return
+ * EINTR. GPFS will not cancel data shipping mode if such
+ * a signal occurs. It is the responsibility of the
+ * application to mask off any signals that might normally
+ * occur while waiting for another node in the data
+ * shipping collective. Several libraries use SIGALRM; the
+ * thread that makes the gpfs_fcntl() call should use
+ * sigthreadmask to mask off delivery of this signal while
+ * inside the call.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 28. May 2002
+ * Modifications:
+ */
+ static void
+gpfs_stop_data_shipping(int handle)
+{
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsDataShipStop_t stop;
+ } ds_stop;
+
+ ds_stop.hdr.totalLength = sizeof(ds_stop);
+ ds_stop.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ ds_stop.hdr.fcntlReserved = 0;
+ ds_stop.stop.structLen = sizeof(ds_stop.stop);
+ ds_stop.stop.structType = GPFS_DATA_SHIP_STOP;
+
+ if (gpfs_fcntl(handle, &ds_stop) != 0)
+ fprintf(stderr,
+ "gpfs_fcntl DS stop directive failed. errno=%d errorOffset=%d\n",
+ errno, ds_stop.hdr.errorOffset);
+}
+
+/*
+ * Function: gpfs_invalidate_file_cache
+ * Purpose: Invalidate all cached data held on behalf of a file on
+ * this node.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 03. June 2002
+ * Modifications:
+ */
+ static void
+gpfs_invalidate_file_cache(const char *filename)
+{
+ int handle;
+ struct {
+ gpfsFcntlHeader_t hdr;
+ gpfsClearFileCache_t inv;
+ } inv_cache_hint;
+
+ /* Open the file. If the open fails, the file cannot be cached. */
+ handle = open(filename, O_RDONLY, 0);
+
+ if (handle == -1)
+ return;
+
+ /* Issue the invalidate hint */
+ inv_cache_hint.hdr.totalLength = sizeof(inv_cache_hint);
+ inv_cache_hint.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
+ inv_cache_hint.hdr.fcntlReserved = 0;
+ inv_cache_hint.inv.structLen = sizeof(gpfsClearFileCache_t);
+ inv_cache_hint.inv.structType = GPFS_CLEAR_FILE_CACHE;
+
+ if (gpfs_fcntl(handle, &inv_cache_hint) != 0) {
+ fprintf(stderr,
+ "gpfs_fcntl clear cache hint failed for file '%s'.",
+ filename);
+ fprintf(stderr, " errno=%d errorOffset=%d\n",
+ errno, inv_cache_hint.hdr.errorOffset);
+ exit(1);
+ }
+
+ /* Close the file */
+ if (close(handle) == -1) {
+ fprintf(stderr,
+ "could not close file '%s' after flushing file cache, ",
+ filename);
+ fprintf(stderr, "errno=%d\n", errno);
+ exit(1);
+ }
+}
+
+#else
+
+/* turn the stubs off since some compilers are warning they are not used */
+#if 0
+/* H5_HAVE_GPFS isn't defined...stub functions */
+
+ static void
+gpfs_access_range(int UNUSED handle, off_t UNUSED start, off_t UNUSED length,
+ int UNUSED is_write)
+{
+ return;
+}
+
+ static void
+gpfs_free_range(int UNUSED handle, off_t UNUSED start, off_t UNUSED length)
+{
+ return;
+}
+
+ static void
+gpfs_clear_file_cache(int UNUSED handle)
+{
+ return;
+}
+
+ static void
+gpfs_cancel_hints(int UNUSED handle)
+{
+ return;
+}
+
+ static void
+gpfs_start_data_shipping(int UNUSED handle, int UNUSED num_insts)
+{
+ return;
+}
+
+ static void
+gpfs_stop_data_shipping(int UNUSED handle)
+{
+ return;
+}
+
+ static void
+gpfs_start_data_ship_map(int UNUSED handle, int UNUSED partition_size,
+ int UNUSED agent_count, int UNUSED *agent_node_num)
+{
+ return;
+}
+
+ static void
+gpfs_invalidate_file_cache(const char UNUSED *filename)
+{
+ return;
+}
+
+#endif /* 0 */
+
+#endif /* H5_HAVE_GPFS */
+
+
diff --git a/perform/sio_perf.c b/perform/sio_perf.c
new file mode 100644
index 0000000..52e80fc
--- /dev/null
+++ b/perform/sio_perf.c
@@ -0,0 +1,1450 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Serial HDF5 Performance Testing Code
+ * --------------------------------------
+ *
+ * Portable code to test performance on the different platforms we support.
+ * This is what the report should look like:
+ *
+ * nprocs = Max#Procs
+ * IO API = POSIXIO
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ *
+ * IO API = HDF5
+ * # Files = 1, # of dsets = 1000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ * # Files = 1, # of dsets = 3000, Elements per dset = 37000
+ * Write Results = x MB/s
+ * Read Results = x MB/s
+ *
+ * . . .
+ *
+ *
+ * . . .
+ *
+ */
+
+/* system header files */
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+
+/* our header files */
+#include "sio_perf.h"
+
+/* useful macros */
+#define TAB_SPACE 4
+
+#define ONE_KB 1024
+#define ONE_MB (ONE_KB * ONE_KB)
+#define ONE_GB (ONE_MB * ONE_KB)
+
+#define SIO_POSIX 0x1
+#define SIO_HDF5 0x4
+
+/* report 0.0 in case t is zero too */
+#define MB_PER_SEC(bytes,t) (((t)==0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t)))
+
+#ifndef TRUE
+#define TRUE 1
+#endif /* TRUE */
+#ifndef FALSE
+#define FALSE (!TRUE)
+#endif /* FALSE */
+
+/* global variables */
+FILE *output; /* output file */
+int sio_debug_level = 0;/* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Maximal & then some
+ */
+
+/* local variables */
+static const char *progname = "h5perf_serial";
+
+/*
+ * Command-line options: The user can specify short or long-named
+ * parameters. The long-named ones can be partially spelled. When
+ * adding more, make sure that they don't clash with each other.
+ */
+
+/*
+ * It seems that only the options that accept additional information
+ * such as dataset size (-e) require the colon next to it.
+ */
+#if 1
+static const char *s_opts = "a:A:B:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:v:wx:X:";
+#else
+static const char *s_opts = "a:A:bB:c:Cd:D:e:F:ghi:Imno:p:P:r:stT:wx:X:";
+#endif /* 1 */
+static struct long_options l_opts[] = {
+ { "align", require_arg, 'a' },
+ { "alig", require_arg, 'a' },
+ { "ali", require_arg, 'a' },
+ { "al", require_arg, 'a' },
+ { "api", require_arg, 'A' },
+ { "ap", require_arg, 'A' },
+#if 0
+ /* a sighting of the elusive binary option */
+ { "binary", no_arg, 'b' },
+ { "binar", no_arg, 'b' },
+ { "bina", no_arg, 'b' },
+ { "bin", no_arg, 'b' },
+ { "bi", no_arg, 'b' },
+#endif /* 0 */
+ { "block-size", require_arg, 'B' },
+ { "block-siz", require_arg, 'B' },
+ { "block-si", require_arg, 'B' },
+ { "block-s", require_arg, 'B' },
+ { "block-", require_arg, 'B' },
+ { "block", require_arg, 'B' },
+ { "bloc", require_arg, 'B' },
+ { "blo", require_arg, 'B' },
+ { "bl", require_arg, 'B' },
+ { "chunk", no_arg, 'c' },
+ { "chun", no_arg, 'c' },
+ { "chu", no_arg, 'c' },
+ { "ch", no_arg, 'c' },
+ { "collective", no_arg, 'C' },
+ { "collectiv", no_arg, 'C' },
+ { "collecti", no_arg, 'C' },
+ { "collect", no_arg, 'C' },
+ { "collec", no_arg, 'C' },
+ { "colle", no_arg, 'C' },
+ { "coll", no_arg, 'C' },
+ { "col", no_arg, 'C' },
+ { "co", no_arg, 'C' },
+ { "debug", require_arg, 'D' },
+ { "debu", require_arg, 'D' },
+ { "deb", require_arg, 'D' },
+ { "de", require_arg, 'D' },
+ { "file-driver", require_arg, 'v' },
+ { "file-drive", require_arg, 'v' },
+ { "file-driv", require_arg, 'v' },
+ { "file-dri", require_arg, 'v' },
+ { "file-dr", require_arg, 'v' },
+ { "file-d", require_arg, 'v' },
+ { "file-", require_arg, 'v' },
+ { "file", require_arg, 'v' },
+ { "fil", require_arg, 'v' },
+ { "fi", require_arg, 'v' },
+ { "geometry", no_arg, 'g' },
+ { "geometr", no_arg, 'g' },
+ { "geomet", no_arg, 'g' },
+ { "geome", no_arg, 'g' },
+ { "geom", no_arg, 'g' },
+ { "geo", no_arg, 'g' },
+ { "ge", no_arg, 'g' },
+ { "help", no_arg, 'h' },
+ { "hel", no_arg, 'h' },
+ { "he", no_arg, 'h' },
+ { "interleaved", require_arg, 'I' },
+ { "interleave", require_arg, 'I' },
+ { "interleav", require_arg, 'I' },
+ { "interlea", require_arg, 'I' },
+ { "interle", require_arg, 'I' },
+ { "interl", require_arg, 'I' },
+ { "inter", require_arg, 'I' },
+ { "inte", require_arg, 'I' },
+ { "int", require_arg, 'I' },
+ { "in", require_arg, 'I' },
+ { "max-num-processes", require_arg, 'P' },
+ { "max-num-processe", require_arg, 'P' },
+ { "max-num-process", require_arg, 'P' },
+ { "max-num-proces", require_arg, 'P' },
+ { "max-num-proce", require_arg, 'P' },
+ { "max-num-proc", require_arg, 'P' },
+ { "max-num-pro", require_arg, 'P' },
+ { "max-num-pr", require_arg, 'P' },
+ { "max-num-p", require_arg, 'P' },
+ { "min-num-processes", require_arg, 'p' },
+ { "min-num-processe", require_arg, 'p' },
+ { "min-num-process", require_arg, 'p' },
+ { "min-num-proces", require_arg, 'p' },
+ { "min-num-proce", require_arg, 'p' },
+ { "min-num-proc", require_arg, 'p' },
+ { "min-num-pro", require_arg, 'p' },
+ { "min-num-pr", require_arg, 'p' },
+ { "min-num-p", require_arg, 'p' },
+ { "max-xfer-size", require_arg, 'X' },
+ { "max-xfer-siz", require_arg, 'X' },
+ { "max-xfer-si", require_arg, 'X' },
+ { "max-xfer-s", require_arg, 'X' },
+ { "max-xfer", require_arg, 'X' },
+ { "max-xfe", require_arg, 'X' },
+ { "max-xf", require_arg, 'X' },
+ { "max-x", require_arg, 'X' },
+ { "min-xfer-size", require_arg, 'x' },
+ { "min-xfer-siz", require_arg, 'x' },
+ { "min-xfer-si", require_arg, 'x' },
+ { "min-xfer-s", require_arg, 'x' },
+ { "min-xfer", require_arg, 'x' },
+ { "min-xfe", require_arg, 'x' },
+ { "min-xf", require_arg, 'x' },
+ { "min-x", require_arg, 'x' },
+ { "mpi-posix", no_arg, 'm' },
+ { "mpi-posi", no_arg, 'm' },
+ { "mpi-pos", no_arg, 'm' },
+ { "mpi-po", no_arg, 'm' },
+ { "mpi-p", no_arg, 'm' },
+ { "mpi-", no_arg, 'm' },
+ { "mpi", no_arg, 'm' },
+ { "mp", no_arg, 'm' },
+ { "num-bytes", require_arg, 'e' },
+ { "num-byte", require_arg, 'e' },
+ { "num-byt", require_arg, 'e' },
+ { "num-by", require_arg, 'e' },
+ { "num-b", require_arg, 'e' },
+ { "num-dsets", require_arg, 'd' },
+ { "num-dset", require_arg, 'd' },
+ { "num-dse", require_arg, 'd' },
+ { "num-ds", require_arg, 'd' },
+ { "num-d", require_arg, 'd' },
+ { "num-files", require_arg, 'F' },
+ { "num-file", require_arg, 'F' },
+ { "num-fil", require_arg, 'F' },
+ { "num-fi", require_arg, 'F' },
+ { "num-f", require_arg, 'F' },
+ { "num-iterations", require_arg, 'i' },
+ { "num-iteration", require_arg, 'i' },
+ { "num-iteratio", require_arg, 'i' },
+ { "num-iterati", require_arg, 'i' },
+ { "num-iterat", require_arg, 'i' },
+ { "num-itera", require_arg, 'i' },
+ { "num-iter", require_arg, 'i' },
+ { "num-ite", require_arg, 'i' },
+ { "num-it", require_arg, 'i' },
+ { "num-i", require_arg, 'i' },
+ { "order", require_arg, 'r' },
+ { "orde", require_arg, 'r' },
+ { "ord", require_arg, 'r' },
+ { "or", require_arg, 'r' },
+ { "output", require_arg, 'o' },
+ { "outpu", require_arg, 'o' },
+ { "outp", require_arg, 'o' },
+ { "out", require_arg, 'o' },
+ { "ou", require_arg, 'o' },
+ { "extendable", no_arg, 't' },
+ { "extendabl", no_arg, 't' },
+ { "extendab", no_arg, 't' },
+ { "extenda", no_arg, 't' },
+ { "extend", no_arg, 't' },
+ { "exten", no_arg, 't' },
+ { "exte", no_arg, 't' },
+ { "ext", no_arg, 't' },
+ { "ex", no_arg, 't' },
+ { "threshold", require_arg, 'T' },
+ { "threshol", require_arg, 'T' },
+ { "thresho", require_arg, 'T' },
+ { "thresh", require_arg, 'T' },
+ { "thres", require_arg, 'T' },
+ { "thre", require_arg, 'T' },
+ { "thr", require_arg, 'T' },
+ { "th", require_arg, 'T' },
+ { "write-only", require_arg, 'w' },
+ { "write-onl", require_arg, 'w' },
+ { "write-on", require_arg, 'w' },
+ { "write-o", require_arg, 'w' },
+ { "write", require_arg, 'w' },
+ { "writ", require_arg, 'w' },
+ { "wri", require_arg, 'w' },
+ { "wr", require_arg, 'w' },
+ { NULL, 0, '\0' }
+};
+
+struct options {
+ long io_types; /* bitmask of which I/O types to test */
+ const char *output_file; /* file to print report to */
+ long num_dsets; /* number of datasets */
+ long num_files; /* number of files */
+ off_t num_bpp; /* number of bytes per proc per dset */
+ int num_iters; /* number of iterations */
+ off_t dset_size[MAX_DIMS]; /* Dataset size */
+ size_t buf_size[MAX_DIMS]; /* Buffer size */
+ size_t chk_size[MAX_DIMS]; /* Chunk size */
+ int order[MAX_DIMS]; /* Dimension access order */
+ int dset_rank; /* Rank */
+ int buf_rank; /* Rank */
+ int order_rank; /* Rank */
+ int chk_rank; /* Rank */
+ int print_times; /* print times as well as throughputs */
+ int print_raw; /* print raw data throughput info */
+ off_t h5_alignment; /* alignment in HDF5 file */
+ off_t h5_threshold; /* threshold for alignment in HDF5 file */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ int h5_extendable; /* Perform the write tests only */
+ unsigned h5_use_mpi_posix; /* Use MPI-posix VFD for HDF5 I/O (instead of MPI-I/O VFD) */
+ int verify; /* Verify data correctness */
+ vfdtype vfd; /* File driver */
+
+};
+
+typedef struct _minmax {
+ double min;
+ double max;
+ double sum;
+ int num;
+} minmax;
+
+/* local functions */
+static off_t parse_size_directive(const char *size);
+static struct options *parse_command_line(int argc, char *argv[]);
+static void run_test_loop(struct options *options);
+static int run_test(iotype iot, parameters parms, struct options *opts);
+static void output_all_info(minmax *mm, int count, int indent_level);
+static void get_minmax(minmax *mm, double val);
+static minmax accumulate_minmax_stuff(minmax *mm, int count);
+static void output_results(const struct options *options, const char *name,
+ minmax *table, int table_size, off_t data_size);
+static void output_report(const char *fmt, ...);
+static void print_indent(register int indent);
+static void usage(const char *prog);
+static void report_parameters(struct options *opts);
+
+/*
+ * Function: main
+ * Purpose: Start things up.
+ * Return: EXIT_SUCCESS or EXIT_FAILURE
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ */
+int
+main(int argc, char **argv)
+{
+ int ret;
+ int exit_value = EXIT_SUCCESS;
+ struct options *opts = NULL;
+
+ output = stdout;
+
+ opts = parse_command_line(argc, argv);
+
+ if (!opts) {
+ exit_value = EXIT_FAILURE;
+ goto finish;
+ }
+
+ if (opts->output_file) {
+ if ((output = fopen(opts->output_file, "w")) == NULL) {
+ fprintf(stderr, "%s: cannot open output file\n", progname);
+ perror(opts->output_file);
+ goto finish;
+ }
+ }
+
+ report_parameters(opts);
+
+ run_test_loop(opts);
+
+finish:
+ free(opts);
+ return exit_value;
+}
+
+/*
+ * Function: run_test_loop
+ * Purpose: Run the I/O tests. Write the results to OUTPUT.
+ *
+ * - The slowest changing part of the test is the number of
+ * processors to use. For each loop iteration, we divide that
+ * number by 2 and rerun the test.
+ *
+ * - The second slowest is what type of IO API to perform. We have
+ * three choices: POSIXIO, and HDF5.
+ *
+ * - Then we change the size of the buffer. This information is
+ * inferred from the number of datasets to create and the number
+ * of integers to put into each dataset. The backend code figures
+ * this out.
+ *
+ * Return: Nothing
+ * Programmer: Bill Wendling, 30. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static void
+run_test_loop(struct options *opts)
+{
+ parameters parms;
+ int i;
+ int doing_sio; /* if this process is doing SIO */
+ size_t buf_bytes;
+ /* load options into parameter structure */
+ parms.num_files = opts->num_files;
+ parms.num_dsets = opts->num_dsets;
+ parms.num_iters = opts->num_iters;
+ parms.rank = opts->dset_rank;
+ parms.h5_align = opts->h5_alignment;
+ parms.h5_thresh = opts->h5_threshold;
+ parms.h5_use_chunks = opts->h5_use_chunks;
+ parms.h5_extendable = opts->h5_extendable;
+ parms.h5_write_only = opts->h5_write_only;
+ parms.h5_use_mpi_posix = opts->h5_use_mpi_posix;
+ parms.verify = opts->verify;
+ parms.vfd = opts->vfd;
+
+ /* load multidimensional options */
+ parms.num_bytes = 1;
+ buf_bytes = 1;
+ for (i=0; i<parms.rank; i++){
+ parms.buf_size[i] = opts->buf_size[i];
+ parms.dset_size[i] = opts->dset_size[i];
+ parms.chk_size[i] = opts->chk_size[i];
+ parms.order[i] = opts->order[i];
+ parms.num_bytes *= opts->dset_size[i];
+ buf_bytes *= opts->buf_size[i];
+ }
+
+ /* print size information */
+ output_report("Transfer Buffer Size (bytes): %d\n", buf_bytes);
+ output_report("File Size(MB): %.2f\n",((double)parms.num_bytes) / ONE_MB);
+
+ print_indent(0);
+ if (opts->io_types & SIO_POSIX)
+ run_test(POSIXIO, parms, opts);
+
+ print_indent(0);
+ if (opts->io_types & SIO_HDF5)
+ run_test(HDF5, parms, opts);
+}
+
+/*
+ * Function: run_test
+ * Purpose: Inner loop call to actually run the I/O test.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+static int
+run_test(iotype iot, parameters parms, struct options *opts)
+{
+ results res;
+ register int i, ret_value = SUCCESS;
+ int comm_size;
+ off_t raw_size;
+ minmax *write_sys_mm_table=NULL;
+ minmax *write_mm_table=NULL;
+ minmax *write_gross_mm_table=NULL;
+ minmax *write_raw_mm_table=NULL;
+ minmax *read_sys_mm_table=NULL;
+ minmax *read_mm_table=NULL;
+ minmax *read_gross_mm_table=NULL;
+ minmax *read_raw_mm_table=NULL;
+ minmax write_sys_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax write_raw_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_sys_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_gross_mm = {0.0, 0.0, 0.0, 0};
+ minmax read_raw_mm = {0.0, 0.0, 0.0, 0};
+
+ raw_size = (off_t)parms.num_bytes;
+ parms.io_type = iot;
+ print_indent(2);
+ output_report("IO API = ");
+
+ switch (iot) {
+ case POSIXIO:
+ output_report("POSIX\n");
+ break;
+ case HDF5:
+ output_report("HDF5\n");
+ break;
+ }
+
+ /* allocate space for tables minmax and that it is sufficient */
+ /* to initialize all elements to zeros by calloc. */
+ write_sys_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ write_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ write_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ write_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+
+ if (!parms.h5_write_only) {
+ read_sys_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ read_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ read_gross_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ read_raw_mm_table = calloc((size_t)parms.num_iters , sizeof(minmax));
+ }
+
+ /* Do IO iteration times, collecting statistics each time */
+ for (i = 0; i < parms.num_iters; ++i) {
+ double t;
+ res = do_sio(parms);
+
+ /* gather all of the "sys write" times */
+ t = get_time(res.timers, HDF5_MPI_WRITE);
+ get_minmax(&write_sys_mm, t);
+
+ write_sys_mm_table[i] = write_sys_mm;
+
+ /* gather all of the "write" times */
+ t = get_time(res.timers, HDF5_FINE_WRITE_FIXED_DIMS);
+ get_minmax(&write_mm, t);
+
+ write_mm_table[i] = write_mm;
+
+ /* gather all of the "write" times from open to close */
+ t = get_time(res.timers, HDF5_GROSS_WRITE_FIXED_DIMS);
+ get_minmax(&write_gross_mm, t);
+
+ write_gross_mm_table[i] = write_gross_mm;
+
+ /* gather all of the raw "write" times */
+ t = get_time(res.timers, HDF5_RAW_WRITE_FIXED_DIMS);
+ get_minmax(&write_raw_mm, t);
+
+ write_raw_mm_table[i] = write_raw_mm;
+
+ if (!parms.h5_write_only) {
+ /* gather all of the "mpi read" times */
+ t = get_time(res.timers, HDF5_MPI_READ);
+ get_minmax(&read_sys_mm, t);
+
+ read_sys_mm_table[i] = read_sys_mm;
+
+ /* gather all of the "read" times */
+ t = get_time(res.timers, HDF5_FINE_READ_FIXED_DIMS);
+ get_minmax(&read_mm, t);
+
+ read_mm_table[i] = read_mm;
+
+ /* gather all of the "read" times from open to close */
+ t = get_time(res.timers, HDF5_GROSS_READ_FIXED_DIMS);
+ get_minmax(&read_gross_mm, t);
+
+ read_gross_mm_table[i] = read_gross_mm;
+
+ /* gather all of the raw "read" times */
+ t = get_time(res.timers, HDF5_RAW_READ_FIXED_DIMS);
+ get_minmax(&read_raw_mm, t);
+
+ read_raw_mm_table[i] = read_gross_mm;
+ }
+ sio_time_destroy(res.timers);
+ }
+
+ /*
+ * Show various statistics
+ */
+ /* Write statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Write details:\n");
+ output_all_info(write_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts,"Raw Data Write",write_raw_mm_table,parms.num_iters,raw_size);
+ } /* end if */
+
+ /* show sys write statics */
+#if 0
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Write details:\n");
+ output_all_info(write_sys_mm_table, parms.num_iters, 4);
+ }
+#endif
+ /* We don't currently output the MPI write results */
+
+ /* accumulate and output the max, min, and average "write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write details:\n");
+ output_all_info(write_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts,"Write",write_mm_table,parms.num_iters,raw_size);
+
+ /* accumulate and output the max, min, and average "gross write" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Write Open-Close details:\n");
+ output_all_info(write_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts,"Write Open-Close",write_gross_mm_table,parms.num_iters,raw_size);
+
+ if (!parms.h5_write_only) {
+ /* Read statistics */
+ /* Print the raw data throughput if desired */
+ if (opts->print_raw) {
+ /* accumulate and output the max, min, and average "raw read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Raw Data Read details:\n");
+ output_all_info(read_raw_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Raw Data Read", read_raw_mm_table,
+ parms.num_iters, raw_size);
+ } /* end if */
+
+ /* show mpi read statics */
+#if 0
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("MPI Read details:\n");
+ output_all_info(read_sys_mm_table, parms.num_iters, 4);
+ }
+#endif
+ /* We don't currently output the MPI read results */
+
+ /* accumulate and output the max, min, and average "read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read details:\n");
+ output_all_info(read_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read", read_mm_table, parms.num_iters, raw_size);
+
+ /* accumulate and output the max, min, and average "gross read" times */
+ if (sio_debug_level >= 3) {
+ /* output all of the times for all iterations */
+ print_indent(3);
+ output_report("Read Open-Close details:\n");
+ output_all_info(read_gross_mm_table, parms.num_iters, 4);
+ }
+
+ output_results(opts, "Read Open-Close", read_gross_mm_table,
+ parms.num_iters, raw_size);
+ }
+
+ /* clean up our mess */
+ free(write_sys_mm_table);
+ free(write_mm_table);
+ free(write_gross_mm_table);
+ free(write_raw_mm_table);
+
+ if (!parms.h5_write_only) {
+ free(read_sys_mm_table);
+ free(read_mm_table);
+ free(read_gross_mm_table);
+ free(read_raw_mm_table);
+ }
+
+ return ret_value;
+}
+
+/*
+ * Function: output_all_info
+ * Purpose:
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. January 2002
+ * Modifications:
+ */
+static void
+output_all_info(minmax *mm, int count, int indent_level)
+{
+ int i;
+
+ for (i = 0; i < count; ++i) {
+ print_indent(indent_level);
+ output_report("Iteration %d:\n", i + 1);
+ print_indent(indent_level + 1);
+ output_report("Minimum Time: %.2fs\n", mm[i].min);
+ print_indent(indent_level + 1);
+ output_report("Maximum Time: %.2fs\n", mm[i].max);
+ }
+}
+
+/*
+ * Function: get_minmax
+ * Purpose: Gather all the min, max and total of val.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Use MPI_Allreduce to do it. -akc, 2002/01/11
+ */
+
+static void
+get_minmax(minmax *mm, double val)
+{
+ mm->max = val;
+ mm->min = val;
+ mm->sum = val;
+}
+
+/*
+ * Function: accumulate_minmax_stuff
+ * Purpose: Accumulate the minimum, maximum, and average of the times
+ * across all processes.
+ * Return: TOTAL_MM - the total of all of these.
+ * Programmer: Bill Wendling, 21. December 2001
+ * Modifications:
+ * Changed to use seconds instead of MB/s - QAK, 5/9/02
+ */
+static minmax
+accumulate_minmax_stuff(minmax *mm, int count)
+{
+ int i;
+ minmax total_mm;
+
+ total_mm.sum = 0.0;
+ total_mm.max = -DBL_MAX;
+ total_mm.min = DBL_MAX;
+ total_mm.num = count;
+
+ for (i = 0; i < count; ++i) {
+ double m = mm[i].max;
+
+ total_mm.sum += m;
+
+ if (m < total_mm.min)
+ total_mm.min = m;
+
+ if (m > total_mm.max)
+ total_mm.max = m;
+ }
+
+ return total_mm;
+}
+
+
+/*
+ * Function: output_results
+ * Purpose: Print information about the time & bandwidth for a given
+ * minmax & # of iterations.
+ * Return: Nothing
+ * Programmer: Quincey Koziol, 9. May 2002
+ * Modifications:
+ */
+static void
+output_results(const struct options *opts, const char *name, minmax *table,
+ int table_size,off_t data_size)
+{
+ minmax total_mm;
+
+ total_mm = accumulate_minmax_stuff(table, table_size);
+
+ print_indent(3);
+ output_report("%s (%d iteration(s)):\n", name,table_size);
+
+ /* Note: The maximum throughput uses the minimum amount of time & vice versa */
+
+ print_indent(4);
+ output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min));
+ if(opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.min);
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Average Throughput: %6.2f MB/s",
+ MB_PER_SEC(data_size,total_mm.sum / total_mm.num));
+ if(opts->print_times)
+ output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num));
+ else
+ output_report("\n");
+
+ print_indent(4);
+ output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max));
+ if(opts->print_times)
+ output_report(" (%7.3f s)\n", total_mm.max);
+ else
+ output_report("\n");
+}
+
+/*
+ * Function: output_report
+ * Purpose: Print a line of the report. Only do so if I'm the 0 process.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 19. December 2001
+ * Modifications:
+ */
+static void
+output_report(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vfprintf(output, fmt, ap);
+ va_end(ap);
+}
+
+/*
+ * Function: print_indent
+ * Purpose: Print spaces to indent a new line of text for pretty printing
+ * things.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 29. October 2001
+ * Modifications:
+ */
+static void
+print_indent(register int indent)
+{
+ indent *= TAB_SPACE;
+
+ for (; indent > 0; --indent)
+ fputc(' ', output);
+}
+
+static void
+recover_size_and_print(long_long val, const char *end)
+{
+ if (val >= ONE_KB && (val % ONE_KB) == 0) {
+ if (val >= ONE_MB && (val % ONE_MB) == 0) {
+ if (val >= ONE_GB && (val % ONE_GB) == 0)
+ HDfprintf(output, "%HdGB%s", val / ONE_GB, end);
+ else
+ HDfprintf(output, "%HdMB%s", val / ONE_MB, end);
+ } else {
+ HDfprintf(output, "%HdKB%s", val / ONE_KB, end);
+ }
+ } else {
+ HDfprintf(output, "%Hd%s", val, end);
+ }
+}
+
+static void
+print_io_api(long io_types)
+{
+ if (io_types & SIO_POSIX)
+ HDfprintf(output, "posix ");
+ if (io_types & SIO_HDF5)
+ HDfprintf(output, "hdf5 ");
+ HDfprintf(output, "\n");
+}
+
+static void
+report_parameters(struct options *opts)
+{
+ int i, rank;
+ rank = opts->dset_rank;
+
+ print_version("HDF5 Library"); /* print library version */
+ HDfprintf(output, "==== Parameters ====\n");
+
+ HDfprintf(output, "IO API=");
+ print_io_api(opts->io_types);
+
+ HDfprintf(output, "Number of iterations=%Hd\n",
+ (long_long)opts->num_iters);
+
+ //HDfprintf(output, "Size of dataset(s)=");
+ //recover_size_and_print((long_long)(opts->num_bpp), "\n");
+
+ HDfprintf(output, "Dataset size=");
+
+ for (i=0; i<rank; i++)
+ recover_size_and_print((long_long)opts->dset_size[i], " ");
+ HDfprintf(output, "\n");
+
+
+ HDfprintf(output, "Transfer buffer size=");
+ for (i=0; i<rank; i++)
+ recover_size_and_print((long_long)opts->buf_size[i], " ");
+ HDfprintf(output, "\n");
+
+ HDfprintf(output, "Dimension access order=");
+ for (i=0; i<rank; i++)
+ recover_size_and_print((long_long)opts->order[i], " ");
+ HDfprintf(output, "\n");
+
+ if (opts->io_types & SIO_HDF5) {
+
+ HDfprintf(output, "HDF5 data storage method=");
+
+ if (opts->h5_use_chunks){
+
+ HDfprintf(output, "Chunked\n");
+ HDfprintf(output, "HDF5 chunk size=");
+ for (i=0; i<rank; i++)
+ recover_size_and_print((long_long)opts->chk_size[i], " ");
+ HDfprintf(output, "\n");
+
+ HDfprintf(output, "HDF5 dataset dimensions=");
+ if (opts->h5_extendable) {
+ HDfprintf(output, "Extendable\n");
+ }
+ else {
+ HDfprintf(output, "Fixed\n");
+ }
+ }
+ else {
+ HDfprintf(output, "Contiguous\n");
+ }
+
+ HDfprintf(output, "HDF5 file driver=");
+ if (opts->vfd==sec2) {
+ HDfprintf(output, "sec2\n");
+ } else if (opts->vfd==stdio) {
+ HDfprintf(output, "stdio\n");
+ } else if (opts->vfd==core) {
+ HDfprintf(output, "core\n");
+ } else if (opts->vfd==split) {
+ HDfprintf(output, "split\n");
+ } else if (opts->vfd==multi) {
+ HDfprintf(output, "multi\n");
+ } else if (opts->vfd==family) {
+ HDfprintf(output, "family\n");
+ } else if (opts->vfd==direct) {
+ HDfprintf(output, "direct\n");
+ }
+ }
+ HDfprintf(output, "==== End of Parameters ====\n");
+ HDfprintf(output, "\n");
+}
+
+/*
+ * Function: parse_command_line
+ * Purpose: Parse the command line options and return a STRUCT OPTIONS
+ * structure which will need to be freed by the calling function.
+ * Return: Pointer to an OPTIONS structure
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static struct options *
+parse_command_line(int argc, char *argv[])
+{
+ register int opt;
+ struct options *cl_opts;
+ int i, default_rank, actual_rank, ranks[4];
+ cl_opts = (struct options *)malloc(sizeof(struct options));
+
+ cl_opts->output_file = NULL;
+ cl_opts->io_types = 0; /* will set default after parsing options */
+ cl_opts->num_iters = 1;
+
+ default_rank = 2;
+
+ cl_opts->dset_rank = 0;
+ cl_opts->buf_rank = 0;
+ cl_opts->chk_rank = 0;
+ cl_opts->order_rank = 0;
+
+ for (i=0; i<MAX_DIMS; i++){
+ cl_opts->buf_size[i]=(i+1)*10;
+ cl_opts->dset_size[i]=(i+1)*100;
+ cl_opts->chk_size[i]=(i+1)*10;
+ cl_opts->order[i]=i+1;
+ }
+
+ cl_opts->vfd = sec2;
+
+ cl_opts->print_times = FALSE; /* Printing times is off by default */
+ cl_opts->print_raw = FALSE; /* Printing raw data throughput is off by default */
+ cl_opts->h5_alignment = 1; /* No alignment for HDF5 objects by default */
+ cl_opts->h5_threshold = 1; /* No threshold for aligning HDF5 objects by default */
+ cl_opts->h5_use_chunks = FALSE; /* Don't chunk the HDF5 dataset by default */
+ cl_opts->h5_write_only = FALSE; /* Do both read and write by default */
+ cl_opts->h5_extendable = FALSE; /* Use extendable dataset */
+ cl_opts->h5_use_mpi_posix = FALSE; /* Don't use MPI-posix VFD for HDF5 I/O by default */
+ cl_opts->verify = FALSE; /* No Verify data correctness by default */
+
+ while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) {
+ switch ((char)opt) {
+ case 'a':
+ cl_opts->h5_alignment = parse_size_directive(opt_arg);
+ break;
+ case 'A':
+ {
+ const char *end = opt_arg;
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (!strcasecmp(buf, "hdf5")) {
+ cl_opts->io_types |= SIO_HDF5;
+ } else if (!strcasecmp(buf, "posix")) {
+ cl_opts->io_types |= SIO_POSIX;
+ } else {
+ fprintf(stderr, "sio_perf: invalid --api option %s\n",
+ buf);
+ exit(EXIT_FAILURE);
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+#if 0
+ case 'b':
+ /* the future "binary" option */
+ break;
+#endif /* 0 */
+ case 'c':
+ /* Turn on chunked HDF5 dataset creation */
+ cl_opts->h5_use_chunks = 1;
+ {
+ const char *end = opt_arg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->chk_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->chk_rank = j;
+ }
+
+ break;
+
+
+ case 'D':
+ {
+ const char *end = opt_arg;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ if (strlen(buf) > 1 || isdigit(buf[0])) {
+ size_t j;
+
+ for (j = 0; j < 10 && buf[j] != '\0'; ++j)
+ if (!isdigit(buf[j])) {
+ fprintf(stderr, "sio_perf: invalid --debug option %s\n",
+ buf);
+ exit(EXIT_FAILURE);
+ }
+
+ sio_debug_level = atoi(buf);
+
+ if (sio_debug_level > 4)
+ sio_debug_level = 4;
+ else if (sio_debug_level < 0)
+ sio_debug_level = 0;
+ } else {
+ switch (*buf) {
+ case 'r':
+ /* Turn on raw data throughput info */
+ cl_opts->print_raw = TRUE;
+ break;
+ case 't':
+ /* Turn on time printing */
+ cl_opts->print_times = TRUE;
+ break;
+ case 'v':
+ /* Turn on verify data correctness*/
+ cl_opts->verify = TRUE;
+ break;
+ default:
+ fprintf(stderr, "sio_perf: invalid --debug option %s\n", buf);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ }
+
+ break;
+ case 'e':
+ {
+ const char *end = opt_arg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->dset_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->dset_rank = j;
+ }
+
+ break;
+
+ case 'i':
+ cl_opts->num_iters = atoi(opt_arg);
+ break;
+ case 'm':
+ /* Turn on MPI-posix VFL driver for HDF5 I/O */
+ cl_opts->h5_use_mpi_posix = TRUE;
+ break;
+ case 'o':
+ cl_opts->output_file = opt_arg;
+ break;
+ case 'T':
+ cl_opts->h5_threshold = parse_size_directive(opt_arg);
+ break;
+ case 'v':
+ if (!strcasecmp(opt_arg, "sec2")) {
+ cl_opts->vfd=sec2;
+ } else if (!strcasecmp(opt_arg, "stdio")) {
+ cl_opts->vfd=stdio;
+ } else if (!strcasecmp(opt_arg, "core")) {
+ cl_opts->vfd=core;
+ } else if (!strcasecmp(opt_arg, "split")) {
+ cl_opts->vfd=split;
+ } else if (!strcasecmp(opt_arg, "multi")) {
+ cl_opts->vfd=multi;
+ } else if (!strcasecmp(opt_arg, "family")) {
+ cl_opts->vfd=family;
+ } else if (!strcasecmp(opt_arg, "direct")) {
+ cl_opts->vfd=direct;
+ } else {
+ fprintf(stderr, "sio_perf: invalid --api option %s\n",
+ opt_arg);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'w':
+ cl_opts->h5_write_only = TRUE;
+ break;
+ case 't':
+ cl_opts->h5_extendable = TRUE;
+ break;
+ case 'x':
+ {
+ const char *end = opt_arg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ cl_opts->buf_size[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+ cl_opts->buf_rank = j;
+ }
+
+ break;
+
+ case 'r':
+ {
+ const char *end = opt_arg;
+ int j = 0;
+
+ while (end && *end != '\0') {
+ char buf[10];
+ int i;
+
+ memset(buf, '\0', sizeof(buf));
+
+ for (i = 0; *end != '\0' && *end != ','; ++end)
+ if (isalnum(*end) && i < 10)
+ buf[i++] = *end;
+
+ //cl_opts->order[j] = atoi(buf);
+ cl_opts->order[j] = parse_size_directive(buf);
+
+ j++;
+
+ if (*end == '\0')
+ break;
+
+ end++;
+ }
+
+ cl_opts->order_rank = j;
+ }
+
+ break;
+
+ case 'h':
+ case '?':
+ default:
+ usage(progname);
+ free(cl_opts);
+ return NULL;
+ }
+ }
+
+ /* perform rank consistency analysis */
+ actual_rank = 0;
+
+ ranks[0] = cl_opts->dset_rank;
+ ranks[1] = cl_opts->buf_rank;
+ ranks[2] = cl_opts->order_rank;
+ ranks[3] = cl_opts->chk_rank;
+
+ for (i=0; i<4; i++) {
+ if (ranks[i]>0) {
+ if (!actual_rank) {
+ actual_rank = ranks[i];
+ }
+ else {
+ if (actual_rank != ranks[i])
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ if (!actual_rank)
+ actual_rank = default_rank;
+
+ cl_opts->dset_rank = actual_rank;
+ cl_opts->buf_rank = actual_rank;
+ cl_opts->order_rank = actual_rank;
+ cl_opts->chk_rank = actual_rank;
+
+
+ /* set default if none specified yet */
+ if (!cl_opts->io_types)
+ cl_opts->io_types = SIO_HDF5 | SIO_POSIX; /* run all API */
+
+ /* verify parameters sanity. Adjust if needed. */
+ /* cap xfer_size with bytes per process */
+ if (cl_opts->num_iters <= 0)
+ cl_opts->num_iters = 1;
+
+ return cl_opts;
+}
+
+/*
+ * Function: parse_size_directive
+ * Purpose: Parse the size directive passed on the commandline. The size
+ * directive is an integer followed by a size indicator:
+ *
+ * K, k - Kilobyte
+ * M, m - Megabyte
+ * G, g - Gigabyte
+ *
+ * Return: The size as a off_t because this is related to file size.
+ * If an unknown size indicator is used, then the program will
+ * exit with EXIT_FAILURE as the return value.
+ * Programmer: Bill Wendling, 18. December 2001
+ * Modifications:
+ */
+
+static off_t
+parse_size_directive(const char *size)
+{
+ off_t s;
+ char *endptr;
+
+ s = strtol(size, &endptr, 10);
+
+ if (endptr && *endptr) {
+ while (*endptr != '\0' && (*endptr == ' ' || *endptr == '\t'))
+ ++endptr;
+
+ switch (*endptr) {
+ case 'K':
+ case 'k':
+ s *= ONE_KB;
+ break;
+ case 'M':
+ case 'm':
+ s *= ONE_MB;
+ break;
+ case 'G':
+ case 'g':
+ s *= ONE_GB;
+ break;
+ default:
+ fprintf(stderr, "Illegal size specifier '%c'\n", *endptr);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ return s;
+}
+
+/*
+ * Function: usage
+ * Purpose: Print a usage message and then exit.
+ * Return: Nothing
+ * Programmer: Bill Wendling, 31. October 2001
+ * Modifications:
+ * Added 2D testing (Christian Chilan, 10. August 2005)
+ */
+static void
+usage(const char *prog)
+{
+
+
+ print_version(prog);
+ printf("usage: %s [OPTIONS]\n", prog);
+ printf(" OPTIONS\n");
+ printf(" -h, --help Print a usage message and exit\n");
+ printf(" -a S, --align=S Alignment of objects in HDF5 file [default: 1]\n");
+ printf(" -A AL, --api=AL Which APIs to test [default: all of them]\n");
+#if 0
+ printf(" -b, --binary The elusive binary option\n");
+#endif /* 0 */
+ printf(" -B S, --block-size=S Block size within transfer buffer\n");
+ printf(" (see below for description)\n");
+ printf(" [default: half the number of bytes per processor per dataset]\n");
+ printf(" -c, --chunk Create HDF5 datasets chunked [default: off]\n");
+ printf(" -C, --collective Use collective I/O for MPI and HDF5 APIs\n");
+ printf(" [default: off (i.e. independent I/O)]\n");
+ printf(" -d N, --num-dsets=N Number of datasets per file [default:1]\n");
+ printf(" -D DL, --debug=DL Indicate the debugging level\n");
+ printf(" [default: no debugging]\n");
+ printf(" -e S, --num-bytes=S Number of bytes per process per dataset\n");
+ printf(" [default: 256K for 1D, 8K for 2D]\n");
+ printf(" -F N, --num-files=N Number of files [default: 1]\n");
+ printf(" -g, --geometry Use 2D geometry [default: 1D]\n");
+ printf(" -i N, --num-iterations=N Number of iterations to perform [default: 1]\n");
+ printf(" -I, --interleaved Interleaved block I/O (see below for example)\n");
+ printf(" [default: Contiguous block I/O]\n");
+ printf(" -m, --mpi-posix Use MPI-posix driver for HDF5 I/O\n");
+ printf(" [default: use MPI-I/O driver]\n");
+ printf(" -o F, --output=F Output raw data into file F [default: none]\n");
+ printf(" -p N, --min-num-processes=N Minimum number of processes to use [default: 1]\n");
+ printf(" -P N, --max-num-processes=N Maximum number of processes to use\n");
+ printf(" [default: all MPI_COMM_WORLD processes ]\n");
+ printf(" -T S, --threshold=S Threshold for alignment of objects in HDF5 file\n");
+ printf(" [default: 1]\n");
+ printf(" -w, --write-only Perform write tests not the read tests\n");
+ printf(" -x S, --min-xfer-size=S Minimum transfer buffer size\n");
+ printf(" [default: half the number of bytes per processor per dataset]\n");
+ printf(" -X S, --max-xfer-size=S Maximum transfer buffer size\n");
+ printf(" [default: the number of bytes per processor per dataset]\n");
+ printf("\n");
+ printf(" F - is a filename.\n");
+ printf(" N - is an integer >=0.\n");
+ printf(" S - is a size specifier, an integer >=0 followed by a size indicator:\n");
+ printf(" K - Kilobyte (%d)\n", ONE_KB);
+ printf(" M - Megabyte (%d)\n", ONE_MB);
+ printf(" G - Gigabyte (%d)\n", ONE_GB);
+ printf("\n");
+ printf(" Example: '37M' is 37 megabytes or %d bytes\n", 37*ONE_MB);
+ printf("\n");
+ printf(" AL - is an API list. Valid values are:\n");
+ printf(" phdf5 - Parallel HDF5\n");
+ printf(" mpiio - MPI-I/O\n");
+ printf(" posix - POSIX\n");
+ printf("\n");
+ printf(" Example: --api=mpiio,phdf5\n");
+ printf("\n");
+ printf(" Block size vs. Transfer buffer size:\n");
+ printf(" The transfer buffer size is the size of a buffer in memory, which is\n");
+ printf(" broken into 'block size' pieces and written to the file. The pattern\n");
+ printf(" of the blocks in the file is described below in the 'Interleaved vs.\n");
+ printf(" Contiguous blocks' example.\n");
+ printf("\n");
+ printf(" If the collective I/O option is given, the blocks in each transfer buffer\n");
+ printf(" are written at once with an MPI derived type, for the MPI-I/O and PHDF5\n");
+ printf(" APIs.\n");
+ printf("\n");
+ printf(" Interleaved vs. Contiguous blocks:\n");
+ printf(" When contiguous blocks are written to a dataset, the dataset is divided\n");
+ printf(" into '# processes' regions and each process writes data to its own region.\n");
+ printf(" When interleaved blocks are written to a dataset, space for the first\n");
+ printf(" block of the first process is allocated in the dataset, then space is\n");
+ printf(" allocated for the first block of the second process, etc. until space is\n");
+ printf(" allocated for the first block of each process, then space is allocated for\n");
+ printf(" the second block of the first process, the second block of the second\n");
+ printf(" process, etc.\n");
+ printf("\n");
+ printf(" For example, with a 4 process run, 1MB bytes-per-process, 256KB transfer\n");
+ printf(" buffer size, and 64KB block size,\n");
+ printf(" 16 contiguous blocks per process are written to the file like so:\n");
+ printf(" 1111111111111111222222222222222233333333333333334444444444444444\n");
+ printf(" 16 interleaved blocks per process are written to the file like so:\n");
+ printf(" 1234123412341234123412341234123412341234123412341234123412341234\n");
+ printf(" If collective I/O is turned on, all of the four blocks per transfer\n");
+ printf(" buffer will be written in one collective I/O call.\n");
+ printf("\n");
+ printf(" DL - is a list of debugging flags. Valid values are:\n");
+ printf(" 1 - Minimal\n");
+ printf(" 2 - Not quite everything\n");
+ printf(" 3 - Everything\n");
+ printf(" 4 - The kitchen sink\n");
+ printf(" r - Raw data I/O throughput information\n");
+ printf(" t - Times as well as throughputs\n");
+ printf(" v - Verify data correctness\n");
+ printf("\n");
+ printf(" Example: --debug=2,r,t\n");
+ printf("\n");
+ printf(" Environment variables:\n");
+ printf(" HDF5_NOCLEANUP Do not remove data files if set [default remove]\n");
+ printf(" HDF5_MPI_INFO MPI INFO object key=value separated by ;\n");
+ printf(" HDF5_PARAPREFIX Paralllel data files prefix\n");
+ fflush(stdout);
+}
+
diff --git a/perform/sio_perf.h b/perform/sio_perf.h
new file mode 100644
index 0000000..b038661
--- /dev/null
+++ b/perform/sio_perf.h
@@ -0,0 +1,105 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef SIO_PERF_H__
+#define SIO_PERF_H__
+
+#include "sio_timer.h"
+#ifndef STANDALONE
+#include "H5private.h"
+#include "h5test.h"
+#include "h5tools_utils.h"
+#else
+#include "sio_standalone.h"
+#endif
+
+/* setup the dataset no fill option if this is v1.5 or more */
+#if H5_VERS_MAJOR > 1 || H5_VERS_MINOR > 4
+#define H5_HAVE_NOFILL 1
+#endif
+
+#define MAX_DIMS 32
+
+typedef enum iotype_ {
+ POSIXIO,
+ HDF5
+ /*NUM_TYPES*/
+} iotype;
+
+typedef enum vfdtype_ {
+ sec2,
+ stdio,
+ core,
+ split,
+ multi,
+ family,
+ direct
+ /*NUM_TYPES*/
+} vfdtype;
+
+typedef struct parameters_ {
+ iotype io_type; /* The type of IO test to perform */
+ vfdtype vfd;
+ long num_files; /* Number of files to create */
+ long num_dsets; /* Number of datasets to create */
+ off_t num_bytes; /* Number of bytes in each dset */
+ int num_iters; /* Number of times to loop doing the IO */
+ int rank; /* Rank of dataset */
+ off_t dset_size[MAX_DIMS]; /* Dataset size */
+ size_t buf_size[MAX_DIMS]; /* Buffer size */
+ size_t chk_size[MAX_DIMS]; /* Chunk size */
+ int order[MAX_DIMS]; /* Buffer size */
+ hsize_t h5_align; /* HDF5 object alignment */
+ hsize_t h5_thresh; /* HDF5 object alignment threshold */
+ int h5_use_chunks; /* Make HDF5 dataset chunked */
+ int h5_extendable; /* Make HDF5 dataset chunked */
+ int h5_write_only; /* Perform the write tests only */
+ unsigned h5_use_mpi_posix; /* VFD for HDF5 I/O */
+ int verify; /* Verify data correctness */
+} parameters;
+
+typedef struct results_ {
+ herr_t ret_code;
+ sio_time *timers;
+} results;
+
+#ifndef SUCCESS
+#define SUCCESS 0
+#endif /* !SUCCESS */
+
+#ifndef FAIL
+#define FAIL -1
+#endif /* !FAIL */
+
+extern FILE *output; /* output file */
+extern sio_time *timer_g; /* timer: global for stub functions */
+extern int sio_debug_level; /* The debug level:
+ * 0 - Off
+ * 1 - Minimal
+ * 2 - Some more
+ * 3 - Maximal
+ * 4 - Even More Debugging (timer stuff)
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+extern results do_sio(parameters param);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PIO_PERF_H__ */
diff --git a/perform/sio_standalone.c b/perform/sio_standalone.c
new file mode 100644
index 0000000..8a93541
--- /dev/null
+++ b/perform/sio_standalone.c
@@ -0,0 +1,286 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+
+/* This file contains the definition of functions required to build h5perf in
+ * STANDALONE mode.
+ * Created: Christian Chilan, 2005/5/18.
+ */
+
+#include "sio_perf.h"
+
+
+/** From h5tools_utils.c **/
+
+/* global variables */
+int nCols = 80;
+
+/* ``get_option'' variables */
+int opt_err = 1; /*get_option prints errors if this is on */
+int opt_ind = 1; /*token pointer */
+const char *opt_arg; /*flag argument (or value) */
+
+
+int
+get_option(int argc, const char **argv, const char *opts, const struct long_options *l_opts)
+{
+ static int sp = 1; /* character index in current token */
+ int opt_opt = '?'; /* option character passed back to user */
+
+ if (sp == 1) {
+ /* check for more flag-like tokens */
+ if (opt_ind >= argc || argv[opt_ind][0] != '-' || argv[opt_ind][1] == '\0') {
+ return EOF;
+ } else if (HDstrcmp(argv[opt_ind], "--") == 0) {
+ opt_ind++;
+ return EOF;
+ }
+ }
+
+ if (sp == 1 && argv[opt_ind][0] == '-' && argv[opt_ind][1] == '-') {
+ /* long command line option */
+ const char *arg = &argv[opt_ind][2];
+ int i;
+
+ for (i = 0; l_opts && l_opts[i].name; i++) {
+ size_t len = HDstrlen(l_opts[i].name);
+
+ if (HDstrncmp(arg, l_opts[i].name, len) == 0) {
+ /* we've found a matching long command line flag */
+ opt_opt = l_opts[i].shortval;
+
+ if (l_opts[i].has_arg != no_arg) {
+ if (arg[len] == '=') {
+ opt_arg = &arg[len + 1];
+ } else if (opt_ind < (argc - 1) && argv[opt_ind + 1][0] != '-') {
+ opt_arg = argv[++opt_ind];
+ } else if (l_opts[i].has_arg == require_arg) {
+ if (opt_err)
+ HDfprintf(stderr,
+ "%s: option required for \"--%s\" flag\n",
+ argv[0], arg);
+
+ opt_opt = '?';
+ }
+ } else {
+ if (arg[len] == '=') {
+ if (opt_err)
+ HDfprintf(stderr,
+ "%s: no option required for \"%s\" flag\n",
+ argv[0], arg);
+
+ opt_opt = '?';
+ }
+
+ opt_arg = NULL;
+ }
+
+ break;
+ }
+ }
+
+ if (l_opts[i].name == NULL) {
+ /* exhausted all of the l_opts we have and still didn't match */
+ if (opt_err)
+ HDfprintf(stderr, "%s: unknown option \"%s\"\n", argv[0], arg);
+
+ opt_opt = '?';
+ }
+
+ opt_ind++;
+ sp = 1;
+ } else {
+ register char *cp; /* pointer into current token */
+
+ /* short command line option */
+ opt_opt = argv[opt_ind][sp];
+
+ if (opt_opt == ':' || (cp = strchr(opts, opt_opt)) == 0) {
+
+ if (opt_err)
+ HDfprintf(stderr, "%s: unknown option \"%c\"\n",
+ argv[0], opt_opt);
+
+ /* if no chars left in this token, move to next token */
+ if (argv[opt_ind][++sp] == '\0') {
+ opt_ind++;
+ sp = 1;
+ }
+
+ return '?';
+ }
+
+ if (*++cp == ':') {
+ /* if a value is expected, get it */
+ if (argv[opt_ind][sp + 1] != '\0') {
+ /* flag value is rest of current token */
+ opt_arg = &argv[opt_ind++][sp + 1];
+ } else if (++opt_ind >= argc) {
+ if (opt_err)
+ HDfprintf(stderr,
+ "%s: value expected for option \"%c\"\n",
+ argv[0], opt_opt);
+
+ opt_opt = '?';
+ } else {
+ /* flag value is next token */
+ opt_arg = argv[opt_ind++];
+ }
+
+ sp = 1;
+ } else {
+ /* set up to look at next char in token, next time */
+ if (argv[opt_ind][++sp] == '\0') {
+ /* no more in current token, so setup next token */
+ opt_ind++;
+ sp = 1;
+ }
+
+ opt_arg = NULL;
+ }
+ }
+
+ /* return the current flag character found */
+ return opt_opt;
+}
+
+
+void
+print_version(const char *progname)
+{
+ printf("%s: Version %u.%u.%u%s%s\n",
+ progname, H5_VERS_MAJOR, H5_VERS_MINOR, H5_VERS_RELEASE,
+ H5_VERS_SUBRELEASE[0] ? "-" : "", H5_VERS_SUBRELEASE);
+}
+
+
+
+/** From h5test.c **/
+
+#ifdef H5_HAVE_PARALLEL
+MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */
+#endif
+
+#if 0
+int
+h5_set_info_object(void)
+{
+ char *envp; /* environment pointer */
+ int ret_value=0;
+
+ /* handle any MPI INFO hints via $HDF5_MPI_INFO */
+ if ((envp = getenv("HDF5_MPI_INFO")) != NULL){
+ char *next, *valp;
+
+
+ valp = envp = next = HDstrdup(envp);
+
+ /* create an INFO object if not created yet */
+ if (h5_io_info_g == MPI_INFO_NULL)
+ MPI_Info_create(&h5_io_info_g);
+
+ do {
+ size_t len;
+ char *key_val, *endp, *namep;
+
+ if (*valp == ';')
+ valp++;
+
+ /* copy key/value pair into temporary buffer */
+ len = strcspn(valp, ";");
+ next = &valp[len];
+ key_val = calloc(1, len + 1);
+
+ /* increment the next pointer past the terminating semicolon */
+ if (*next == ';')
+ ++next;
+
+ namep = HDstrncpy(key_val, valp, len);
+
+ /* pass up any beginning whitespaces */
+ while (*namep && (*namep == ' ' || *namep == '\t'))
+ namep++;
+
+ /* eat up any ending white spaces */
+ endp = &namep[strlen(namep) - 1];
+
+ while (endp && (*endp == ' ' || *endp == '\t'))
+ *endp-- = '\0';
+
+ /* find the '=' */
+
+ valp = HDstrchr(namep, '=');
+
+ if (valp != NULL) { /* it's a valid key/value pairing */
+ char *tmp_val = valp + 1;
+
+ /* change '=' to \0, move valp down one */
+ *valp-- = '\0';
+
+ /* eat up ending whitespace on the "key" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp-- = '\0';
+
+ valp = tmp_val;
+
+ /* eat up beginning whitespace on the "value" part */
+ while (*valp == ' ' || *valp == '\t')
+ *valp++ = '\0';
+
+ /* actually set the darned thing */
+ if (MPI_SUCCESS != MPI_Info_set(h5_io_info_g, namep, valp)) {
+ printf("MPI_Info_set failed\n");
+ ret_value = -1;
+ }
+ }
+
+ valp = next;
+ HDfree(key_val);
+ } while (next && *next);
+
+ HDfree(envp);
+ }
+
+ return ret_value;
+}
+
+
+void
+h5_dump_info_object(MPI_Info info)
+{
+ char key[MPI_MAX_INFO_KEY+1];
+ char value[MPI_MAX_INFO_VAL+1];
+ int flag;
+ int i, nkeys;
+
+ printf("Dumping MPI Info Object(%d) (up to %d bytes per item):\n", (int)info,
+ MPI_MAX_INFO_VAL);
+ if (info==MPI_INFO_NULL){
+ printf("object is MPI_INFO_NULL\n");
+ }
+ else {
+ MPI_Info_get_nkeys(info, &nkeys);
+ printf("object has %d items\n", nkeys);
+ for (i=0; i<nkeys; i++){
+ MPI_Info_get_nthkey(info, i, key);
+ MPI_Info_get(info, key, MPI_MAX_INFO_VAL, value, &flag);
+ printf("%s=%s\n", key, value);
+ }
+
+ }
+}
+
+#endif
+
diff --git a/perform/sio_standalone.h b/perform/sio_standalone.h
new file mode 100644
index 0000000..1f83f61
--- /dev/null
+++ b/perform/sio_standalone.h
@@ -0,0 +1,544 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+#ifndef SIO_STANDALONE_H__
+#define SIO_PERF_H__
+
+/* Header file for building h5perf by standalone mode.
+ * Created: Christian Chilan, 2005/5/18.
+ */
+
+/** From H5private.h **/
+
+#include "H5public.h" /* Include Public Definitions */
+
+
+/*
+ * Include ANSI-C header files.
+ */
+#ifdef H5_STDC_HEADERS
+# include <assert.h>
+# include <ctype.h>
+# include <errno.h>
+# include <fcntl.h>
+# include <float.h>
+# include <limits.h>
+# include <math.h>
+# include <signal.h>
+# include <stdarg.h>
+# include <stdio.h>
+# include <stdlib.h>
+# include <string.h>
+#endif
+
+/* maximum of two, three, or four values */
+#undef MAX
+#define MAX(a,b) (((a)>(b)) ? (a) : (b))
+#define MAX2(a,b) MAX(a,b)
+#define MAX3(a,b,c) MAX(a,MAX(b,c))
+#define MAX4(a,b,c,d) MAX(MAX(a,b),MAX(c,d))
+
+/*
+ * A macro to portably increment enumerated types.
+ */
+#ifndef H5_INC_ENUM
+# define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1))
+#endif
+
+/*
+ * Redefine all the POSIX functions. We should never see a POSIX
+ * function (or any other non-HDF5 function) in the source!
+ */
+#define HDabort() abort()
+#define HDabs(X) abs(X)
+#define HDaccess(F,M) access(F, M)
+#define HDacos(X) acos(X)
+#ifdef H5_HAVE_ALARM
+#define HDalarm(N) alarm(N)
+#else /* H5_HAVE_ALARM */
+#define HDalarm(N) (0)
+#endif /* H5_HAVE_ALARM */
+#define HDasctime(T) asctime(T)
+#define HDasin(X) asin(X)
+#define HDassert(X) assert(X)
+#define HDatan(X) atan(X)
+#define HDatan2(X,Y) atan2(X,Y)
+#define HDatexit(F) atexit(F)
+#define HDatof(S) atof(S)
+#define HDatoi(S) atoi(S)
+#define HDatol(S) atol(S)
+#define HDBSDgettimeofday(S,P) BSDgettimeofday(S,P)
+#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
+#define HDcalloc(N,Z) calloc(N,Z)
+#define HDceil(X) ceil(X)
+#define HDcfgetispeed(T) cfgetispeed(T)
+#define HDcfgetospeed(T) cfgetospeed(T)
+#define HDcfsetispeed(T,S) cfsetispeed(T,S)
+#define HDcfsetospeed(T,S) cfsetospeed(T,S)
+#define HDchdir(S) chdir(S)
+#define HDchmod(S,M) chmod(S,M)
+#define HDchown(S,O,G) chown(S,O,G)
+#define HDclearerr(F) clearerr(F)
+#define HDclock() clock()
+#define HDclose(F) close(F)
+#define HDclosedir(D) closedir(D)
+#define HDcos(X) cos(X)
+#define HDcosh(X) cosh(X)
+#define HDcreat(S,M) creat(S,M)
+#define HDctermid(S) ctermid(S)
+#define HDctime(T) ctime(T)
+#define HDcuserid(S) cuserid(S)
+#ifdef H5_HAVE_DIFFTIME
+#define HDdifftime(X,Y) difftime(X,Y)
+#else
+#define HDdifftime(X,Y) ((double)(X)-(double)(Y))
+#endif
+#define HDdiv(X,Y) div(X,Y)
+#define HDdup(F) dup(F)
+#define HDdup2(F,I) dup2(F,I)
+/* execl() variable arguments */
+/* execle() variable arguments */
+/* execlp() variable arguments */
+#define HDexecv(S,AV) execv(S,AV)
+#define HDexecve(S,AV,E) execve(S,AV,E)
+#define HDexecvp(S,AV) execvp(S,AV)
+#define HDexit(N) exit(N)
+#if defined __MWERKS__
+#include <abort_exit.h>
+#define HD_exit(N) __exit(N)
+#else /* __MWERKS __ */
+#define HD_exit(N) _exit(N)
+#endif /* __MWERKS __ */
+#define HDexp(X) exp(X)
+#define HDfabs(X) fabs(X)
+/* use ABS() because fabsf() fabsl() are not common yet. */
+#define HDfabsf(X) ABS(X)
+#define HDfabsl(X) ABS(X)
+#define HDfclose(F) fclose(F)
+/* fcntl() variable arguments */
+#define HDfdopen(N,S) fdopen(N,S)
+#define HDfeof(F) feof(F)
+#define HDferror(F) ferror(F)
+#define HDfflush(F) fflush(F)
+#define HDfgetc(F) fgetc(F)
+#define HDfgetpos(F,P) fgetpos(F,P)
+#define HDfgets(S,N,F) fgets(S,N,F)
+#ifdef _WIN32
+#define HDfileno(F) _fileno(F)
+#else /* _WIN32 */
+#define HDfileno(F) fileno(F)
+#endif /* _WIN32 */
+#define HDfloor(X) floor(X)
+#define HDfmod(X,Y) fmod(X,Y)
+#define HDfopen(S,M) fopen(S,M)
+#define HDfork() fork()
+#define HDfpathconf(F,N) fpathconf(F,N)
+H5_DLL int HDfprintf (FILE *stream, const char *fmt, ...);
+#define HDfputc(C,F) fputc(C,F)
+#define HDfputs(S,F) fputs(S,F)
+#define HDfread(M,Z,N,F) fread(M,Z,N,F)
+#define HDfree(M) free(M)
+#define HDfreopen(S,M,F) freopen(S,M,F)
+#define HDfrexp(X,N) frexp(X,N)
+/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */
+#ifdef H5_HAVE_FREXPF
+#define HDfrexpf(X,N) frexpf(X,N)
+#else /* H5_HAVE_FREXPF */
+#define HDfrexpf(X,N) frexp(X,N)
+#endif /* H5_HAVE_FREXPF */
+#ifdef H5_HAVE_FREXPL
+#define HDfrexpl(X,N) frexpl(X,N)
+#else /* H5_HAVE_FREXPL */
+#define HDfrexpl(X,N) frexp(X,N)
+#endif /* H5_HAVE_FREXPL */
+/* fscanf() variable arguments */
+#ifdef H5_HAVE_FSEEKO
+ #define HDfseek(F,O,W) fseeko(F,O,W)
+#else
+ #define HDfseek(F,O,W) fseek(F,O,W)
+#endif
+#define HDfsetpos(F,P) fsetpos(F,P)
+/* definitions related to the file stat utilities.
+ * Windows have its own function names.
+ * For Unix, if off_t is not 64bit big, try use the pseudo-standard
+ * xxx64 versions if available.
+ */
+#ifdef _WIN32
+ #ifdef __MWERKS__
+ #define HDfstat(F,B) fstat(F,B)
+ #define HDstat(S,B) stat(S,B)
+ typedef struct stat h5_stat_t;
+ typedef off_t h5_stat_size_t;
+ #else /*MSVC*/
+ #define HDfstat(F,B) _fstati64(F,B)
+ #define HDstat(S,B) _stati64(S,B)
+ typedef struct _stati64 h5_stat_t;
+ typedef __int64 h5_stat_size_t;
+ #endif
+#elif H5_SIZEOF_OFF_T!=8 && H5_SIZEOF_OFF64_T==8 && defined(H5_HAVE_STAT64)
+ #define HDfstat(F,B) fstat64(F,B)
+ #define HDstat(S,B) stat64(S,B)
+ typedef struct stat64 h5_stat_t;
+ typedef off64_t h5_stat_size_t;
+#else
+ #define HDfstat(F,B) fstat(F,B)
+ #define HDstat(S,B) stat(S,B)
+ typedef struct stat h5_stat_t;
+ typedef off_t h5_stat_size_t;
+#endif
+
+#define HDftell(F) ftell(F)
+#define HDftruncate(F,L) ftruncate(F,L)
+#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
+#define HDgetc(F) getc(F)
+#define HDgetchar() getchar()
+#define HDgetcwd(S,Z) getcwd(S,Z)
+#define HDgetegid() getegid()
+#define HDgetenv(S) getenv(S)
+#define HDgeteuid() geteuid()
+#define HDgetgid() getgid()
+#define HDgetgrgid(G) getgrgid(G)
+#define HDgetgrnam(S) getgrnam(S)
+#define HDgetgroups(Z,G) getgroups(Z,G)
+#define HDgetlogin() getlogin()
+#define HDgetpgrp() getpgrp()
+#define HDgetpid() getpid()
+#define HDgetppid() getppid()
+#define HDgetpwnam(S) getpwnam(S)
+#define HDgetpwuid(U) getpwuid(U)
+#define HDgetrusage(X,S) getrusage(X,S)
+#define HDgets(S) gets(S)
+#define HDgettimeofday(S,P) gettimeofday(S,P)
+#define HDgetuid() getuid()
+#define HDgmtime(T) gmtime(T)
+#define HDisalnum(C) isalnum((int)(C)) /*cast for solaris warning*/
+#define HDisalpha(C) isalpha((int)(C)) /*cast for solaris warning*/
+#define HDisatty(F) isatty(F)
+#define HDiscntrl(C) iscntrl((int)(C)) /*cast for solaris warning*/
+#define HDisdigit(C) isdigit((int)(C)) /*cast for solaris warning*/
+#define HDisgraph(C) isgraph((int)(C)) /*cast for solaris warning*/
+#define HDislower(C) islower((int)(C)) /*cast for solaris warning*/
+#define HDisprint(C) isprint((int)(C)) /*cast for solaris warning*/
+#define HDispunct(C) ispunct((int)(C)) /*cast for solaris warning*/
+#define HDisspace(C) isspace((int)(C)) /*cast for solaris warning*/
+#define HDisupper(C) isupper((int)(C)) /*cast for solaris warning*/
+#define HDisxdigit(C) isxdigit((int)(C)) /*cast for solaris warning*/
+#define HDkill(P,S) kill(P,S)
+#define HDlabs(X) labs(X)
+#define HDldexp(X,N) ldexp(X,N)
+#define HDldiv(X,Y) ldiv(X,Y)
+#define HDlink(OLD,NEW) link(OLD,NEW)
+#define HDlocaleconv() localeconv()
+#define HDlocaltime(T) localtime(T)
+#define HDlog(X) log(X)
+#define HDlog10(X) log10(X)
+#define HDlongjmp(J,N) longjmp(J,N)
+#ifdef _WIN32
+ #ifdef __MWERKS__
+ #define HDlseek(F,O,W) lseek(F,O,W)
+ #else /*MSVS */
+ #define HDlseek(F,O,W) _lseeki64(F,O,W)
+ #endif
+#else
+ #ifdef H5_HAVE_FSEEK64
+ #define HDlseek(F,O,W) lseek64(F,O,W)
+ #else
+ #define HDlseek(F,O,W) lseek(F,O,W)
+ #endif
+#endif
+#define HDmalloc(Z) malloc(Z)
+#define HDposix_memalign(P,A,Z) posix_memalign(P,A,Z)
+#define HDmblen(S,N) mblen(S,N)
+#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z)
+#define HDmbtowc(P,S,Z) mbtowc(P,S,Z)
+#define HDmemchr(S,C,Z) memchr(S,C,Z)
+#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
+/*
+ * The (char*) casts are required for the DEC when optimizations are turned
+ * on and the source and/or destination are not aligned.
+ */
+#define HDmemcpy(X,Y,Z) memcpy((char*)(X),(const char*)(Y),Z)
+#define HDmemmove(X,Y,Z) memmove((char*)(X),(const char*)(Y),Z)
+/*
+ * The (void*) cast just avoids a compiler warning in _WIN32
+ */
+#ifdef _WIN32
+#define HDmemset(X,C,Z) memset((void*)(X),C,Z)
+#else /* _WIN32 */
+#define HDmemset(X,C,Z) memset(X,C,Z)
+#endif /* _WIN32 */
+#ifdef _WIN32
+#define HDmkdir(S,M) _mkdir(S)
+#else /* _WIN32 */
+#define HDmkdir(S,M) mkdir(S,M)
+#endif /* _WIN32 */
+#define HDmkfifo(S,M) mkfifo(S,M)
+#define HDmktime(T) mktime(T)
+#define HDmodf(X,Y) modf(X,Y)
+#ifdef _O_BINARY
+#define HDopen(S,F,M) open(S,F|_O_BINARY,M)
+#else
+#define HDopen(S,F,M) open(S,F,M)
+#endif
+#define HDopendir(S) opendir(S)
+#define HDpathconf(S,N) pathconf(S,N)
+#define HDpause() pause()
+#define HDperror(S) perror(S)
+#define HDpipe(F) pipe(F)
+#define HDpow(X,Y) pow(X,Y)
+/* printf() variable arguments */
+#define HDputc(C,F) putc(C,F)
+#define HDputchar(C) putchar(C)
+#define HDputs(S) puts(S)
+#define HDqsort(M,N,Z,F) qsort(M,N,Z,F)
+#define HDraise(N) raise(N)
+
+#ifdef H5_HAVE_RAND_R
+#define HDrandom() HDrand()
+H5_DLL int HDrand(void);
+#elif H5_HAVE_RANDOM
+#define HDrand() random()
+#define HDrandom() random()
+#else
+#define HDrand() rand()
+#define HDrandom() rand()
+#endif
+
+#define HDread(F,M,Z) read(F,M,Z)
+#define HDreaddir(D) readdir(D)
+#define HDrealloc(M,Z) realloc(M,Z)
+#ifdef H5_VMS
+#ifdef __cplusplus
+extern "C" {
+#endif
+int HDremove_all(const char * fname);
+#ifdef __cplusplus
+}
+#endif
+#define HDremove(S) HDremove_all(S)
+#else
+#define HDremove(S) remove(S)
+#endif /*H5_VMS*/
+#define HDrename(OLD,NEW) rename(OLD,NEW)
+#define HDrewind(F) rewind(F)
+#define HDrewinddir(D) rewinddir(D)
+#define HDrmdir(S) rmdir(S)
+/* scanf() variable arguments */
+#define HDsetbuf(F,S) setbuf(F,S)
+#define HDsetgid(G) setgid(G)
+#define HDsetjmp(J) setjmp(J)
+#define HDsetlocale(N,S) setlocale(N,S)
+#define HDsetpgid(P,PG) setpgid(P,PG)
+#define HDsetsid() setsid()
+#define HDsetuid(U) setuid(U)
+/* Windows does not permit setting the buffer size to values
+ less than 2. */
+#ifndef _WIN32
+#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z)
+#else
+#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,(Z>1?Z:2))
+#endif
+#define HDsigaction(N,A) sigaction(N,A)
+#define HDsigaddset(S,N) sigaddset(S,N)
+#define HDsigdelset(S,N) sigdelset(S,N)
+#define HDsigemptyset(S) sigemptyset(S)
+#define HDsigfillset(S) sigfillset(S)
+#define HDsigismember(S,N) sigismember(S,N)
+#define HDsiglongjmp(J,N) siglongjmp(J,N)
+#define HDsignal(N,F) signal(N,F)
+#define HDsigpending(S) sigpending(S)
+#define HDsigprocmask(H,S,O) sigprocmask(H,S,O)
+#define HDsigsetjmp(J,N) sigsetjmp(J,N)
+#define HDsigsuspend(S) sigsuspend(S)
+#define HDsin(X) sin(X)
+#define HDsinh(X) sinh(X)
+#define HDsleep(N) sleep(N)
+#ifdef _WIN32
+#define HDsnprintf _snprintf /*varargs*/
+#else
+#define HDsnprintf snprintf /*varargs*/
+#endif
+/* sprintf() variable arguments */
+#define HDsqrt(X) sqrt(X)
+#ifdef H5_HAVE_RAND_R
+H5_DLL void HDsrand(unsigned int seed);
+#define HDsrandom(S) HDsrand(S)
+#elif H5_HAVE_RANDOM
+#define HDsrand(S) srandom(S)
+#define HDsrandom(S) srandom(S)
+#else
+#define HDsrand(S) srand(S)
+#define HDsrandom(S) srand(S)
+#endif
+/* sscanf() variable arguments */
+
+#define HDstrcat(X,Y) strcat(X,Y)
+#define HDstrchr(S,C) strchr(S,C)
+#define HDstrcmp(X,Y) strcmp(X,Y)
+#define HDstrcoll(X,Y) strcoll(X,Y)
+#define HDstrcpy(X,Y) strcpy(X,Y)
+#define HDstrcspn(X,Y) strcspn(X,Y)
+#define HDstrerror(N) strerror(N)
+#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
+#define HDstrlen(S) strlen(S)
+#define HDstrncat(X,Y,Z) strncat(X,Y,Z)
+#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z)
+#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z)
+#define HDstrpbrk(X,Y) strpbrk(X,Y)
+#define HDstrrchr(S,C) strrchr(S,C)
+#define HDstrspn(X,Y) strspn(X,Y)
+#define HDstrstr(X,Y) strstr(X,Y)
+#define HDstrtod(S,R) strtod(S,R)
+#define HDstrtok(X,Y) strtok(X,Y)
+#define HDstrtol(S,R,N) strtol(S,R,N)
+H5_DLL int64_t HDstrtoll (const char *s, const char **rest, int base);
+#define HDstrtoul(S,R,N) strtoul(S,R,N)
+#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
+#define HDsysconf(N) sysconf(N)
+#define HDsystem(S) system(S)
+#define HDtan(X) tan(X)
+#define HDtanh(X) tanh(X)
+#define HDtcdrain(F) tcdrain(F)
+#define HDtcflow(F,A) tcflow(F,A)
+#define HDtcflush(F,N) tcflush(F,N)
+#define HDtcgetattr(F,T) tcgetattr(F,T)
+#define HDtcgetpgrp(F) tcgetpgrp(F)
+#define HDtcsendbreak(F,N) tcsendbreak(F,N)
+#define HDtcsetattr(F,O,T) tcsetattr(F,O,T)
+#define HDtcsetpgrp(F,N) tcsetpgrp(F,N)
+#define HDtime(T) time(T)
+#define HDtimes(T) times(T)
+#define HDtmpfile() tmpfile()
+#define HDtmpnam(S) tmpnam(S)
+#define HDtolower(C) tolower(C)
+#define HDtoupper(C) toupper(C)
+#define HDttyname(F) ttyname(F)
+#define HDtzset() tzset()
+#define HDumask(N) umask(N)
+#define HDuname(S) uname(S)
+#define HDungetc(C,F) ungetc(C,F)
+#ifdef _WIN32
+#define HDunlink(S) _unlink(S)
+#else
+#define HDunlink(S) unlink(S)
+#endif
+#define HDutime(S,T) utime(S,T)
+#define HDva_arg(A,T) va_arg(A,T)
+#define HDva_end(A) va_end(A)
+#define HDva_start(A,P) va_start(A,P)
+#define HDvasprintf(RET,FMT,A) vasprintf(RET,FMT,A)
+#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
+#define HDvprintf(FMT,A) vprintf(FMT,A)
+#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
+#ifdef _WIN32
+# define HDvsnprintf(S,N,FMT,A) _vsnprintf(S,N,FMT,A)
+#else
+# define HDvsnprintf(S,N,FMT,A) vsnprintf(S,N,FMT,A)
+#endif
+#define HDwait(W) wait(W)
+#define HDwaitpid(P,W,O) waitpid(P,W,O)
+#define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
+#define HDwctomb(S,C) wctomb(S,C)
+
+#if defined (__MWERKS__)
+/* workaround for a bug in the Metrowerks version 6.0 header file for write
+ which is not defined as const void*
+ */
+#define HDwrite(F,M,Z) write(F,(void*)M,Z)
+#else
+#define HDwrite(F,M,Z) write(F,M,Z)
+#endif
+
+/*
+ * And now for a couple non-Posix functions... Watch out for systems that
+ * define these in terms of macros.
+ */
+#ifdef _WIN32
+#define HDstrdup(S) _strdup(S)
+#else /* _WIN32 */
+
+#if !defined strdup && !defined H5_HAVE_STRDUP
+extern char *strdup(const char *s);
+#endif
+
+#define HDstrdup(S) strdup(S)
+
+#endif /* _WIN32 */
+
+/*
+ * HDF Boolean type.
+ */
+#ifndef FALSE
+# define FALSE 0
+#endif
+#ifndef TRUE
+# define TRUE 1
+#endif
+
+/*
+ * Although `long long' is part of the revised ANSI-C some compilers don't
+ * support it yet. We define `long_long' as the longest integral integer type
+ * supported by the compiler, usually 64 bits. It must be legal to qualify
+ * `long_long' with `unsigned'.
+ */
+#if H5_SIZEOF_LONG_LONG>0
+# define long_long long long
+#elif H5_SIZEOF___INT64>0
+# define long_long __int64 /*Win32*/
+# undef H5_SIZEOF_LONG_LONG
+# define H5_SIZEOF_LONG_LONG H5_SIZEOF___INT64
+#else
+# define long_long long int
+# undef H5_SIZEOF_LONG_LONG
+# define H5_SIZEOF_LONG_LONG H5_SIZEOF_LONG
+#endif
+
+/** From h5test.h **/
+
+#ifdef H5_HAVE_PARALLEL
+extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */
+#endif
+
+#ifdef H5_HAVE_PARALLEL
+H5TEST_DLL int h5_set_info_object(void);
+H5TEST_DLL void h5_dump_info_object(MPI_Info info);
+#endif
+
+
+
+/** From h5tools_utils.h **/
+
+extern int opt_err; /* getoption prints errors if this is on */
+extern int opt_ind; /* token pointer */
+extern const char *opt_arg; /* flag argument (or value) */
+
+
+enum {
+ no_arg = 0, /* doesn't take an argument */
+ require_arg, /* requires an argument */
+ optional_arg /* argument is optional */
+};
+
+
+typedef struct long_options {
+ const char *name; /* name of the long option */
+ int has_arg; /* whether we should look for an arg */
+ char shortval; /* the shortname equivalent of long arg
+ * this gets returned from get_option */
+} long_options;
+
+extern int get_option(int argc, const char **argv, const char *opt,
+ const struct long_options *l_opt);
+#endif