diff options
24 files changed, 172 insertions, 2439 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 62d09b2..ab10311 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -24,7 +24,7 @@ The official HDF5 releases can be obtained from: Changes from release to release and new features in the HDF5-1.10.x release series can be found at: - https://portal.hdfgroup.org/display/HDF5/HDF5+Application+Developer%27s+Guide + https://portal.hdfgroup.org/display/HDF5/Release+Specific+Information If you have any questions or comments, please send them to the HDF Help Desk: @@ -36,7 +36,7 @@ CONTENTS - New Features - Support for new platforms and languages -- Bug Fixes since HDF5-1.10.8 +- Bug Fixes since HDF5-1.10.9 - Supported Platforms - Tested Configuration Features Summary - More Tested Platforms @@ -188,12 +188,32 @@ New Features Tools: ------ - - + - Building h5perf/h5perf_serial in "standalone mode" has been removed + + Building h5perf separately from the library was added circa 2008 + in HDF5 1.6.8. It's unclear what purpose this serves and the current + implementation is currently broken. The existing files require + H5private.h and the symbols we use to determine how the copied + platform-independence scheme should be used come from H5pubconf.h, + which may not match the compiler being used to build standalone h5perf. + + Due to the maintenance overhead and lack of a clear use case, support + for building h5perf and h5perf_serial separately from the HDF5 library + has been removed. + + (DER - 2023/03/20) + + - The perf tool has been removed + + The small `perf` tool didn't really do anything special and the name + conflicts with gnu's perf tool. + + (DER - 2023/03/20, GitHub #1787) High-Level APIs: ---------------- - - + - C Packet Table API: diff --git a/tools/src/h5perf/CMakeLists.txt b/tools/src/h5perf/CMakeLists.txt index 78838d5..9fd9366 100644 --- a/tools/src/h5perf/CMakeLists.txt +++ b/tools/src/h5perf/CMakeLists.txt @@ -30,34 +30,6 @@ endif () # h5perf # -------------------------------------------------------------------- if (H5_HAVE_PARALLEL) - if (UNIX) - #-- Adding test for perf - only on unix systems - set (perf_SOURCES - ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/perf.c - ) - add_executable (perf ${perf_SOURCES}) - target_include_directories (perf PRIVATE "${HDF5_TEST_SRC_DIR};${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - if (BUILD_STATIC_LIBS) - TARGET_C_PROPERTIES (perf STATIC) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") - else () - TARGET_C_PROPERTIES (perf SHARED) - target_link_libraries (perf PRIVATE ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") - endif () - set_target_properties (perf PROPERTIES FOLDER perform) - set_global_variable (HDF5_UTILS_TO_EXPORT "${HDF5_UTILS_TO_EXPORT};perf") - - set (H5_DEP_EXECUTABLES perf) - - #----------------------------------------------------------------------------- - # Add Target to clang-format - #----------------------------------------------------------------------------- - if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_TOOLS_SRC_H5PERF_perf_FORMAT perf) - endif () - endif () - - #-- Adding test for h5perf set (h5perf_SOURCES ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_perf.c ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/pio_engine.c diff --git a/tools/src/h5perf/Makefile.am b/tools/src/h5perf/Makefile.am index 6b470eb..09ac26b 100644 --- a/tools/src/h5perf/Makefile.am +++ b/tools/src/h5perf/Makefile.am @@ -22,7 +22,7 @@ AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib # bin_PROGRAMS will be installed. if BUILD_PARALLEL_CONDITIONAL - bin_PROGRAMS=h5perf_serial perf h5perf + bin_PROGRAMS=h5perf_serial h5perf else bin_PROGRAMS=h5perf_serial endif @@ -46,7 +46,7 @@ endif # List them in the order they should be run. # Parallel test programs. if BUILD_PARALLEL_CONDITIONAL - TEST_PROG_PARA=h5perf perf + TEST_PROG_PARA=h5perf endif h5perf_SOURCES=pio_perf.c pio_engine.c @@ -57,6 +57,5 @@ h5perf_serial_SOURCES=sio_perf.c sio_engine.c LDADD=$(LIBHDF5) h5perf_LDADD=$(LIBH5TOOLS) $(LIBHDF5) h5perf_serial_LDADD=$(LIBH5TOOLS) $(LIBHDF5) -perf_LDADD=$(LIBHDF5) include $(top_srcdir)/config/conclude.am diff --git a/tools/src/h5perf/perf.c b/tools/src/h5perf/perf.c deleted file mode 100644 index 16f3285..0000000 --- a/tools/src/h5perf/perf.c +++ /dev/null @@ -1,802 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Author: Albert Cheng of NCSA, May 1, 2001. - * This is derived from code given to me by Robert Ross. - * - * NOTE: This code assumes that all command line arguments make it out to all - * the processes that make up the parallel job, which isn't always the case. - * So if it doesn't work on some platform, that might be why. - */ - -#include "hdf5.h" -#include "H5private.h" - -#ifdef H5_HAVE_PARALLEL - -#ifdef H5_STDC_HEADERS -#include <errno.h> -#include <fcntl.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <time.h> -#endif - -#ifdef H5_HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif - -#if defined(H5_TIME_WITH_SYS_TIME) -#include <sys/time.h> -#include <time.h> -#elif defined(H5_HAVE_SYS_TIME_H) -#include <sys/time.h> -#else -#include <time.h> -#endif - -#ifdef H5_HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif - -#ifdef H5_HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include <mpi.h> -#ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */ -#include <mpio.h> -#endif - -/* Macro definitions */ -/* Verify: - * if val is false (0), print mesg and if fatal is true (non-zero), die. - */ -#define H5FATAL 1 -#define VRFY(val, mesg, fatal) \ - do { \ - if (!val) { \ - printf("Proc %d: ", mynod); \ - printf("*** Assertion failed (%s) at line %4d in %s\n", mesg, (int)__LINE__, __FILE__); \ - if (fatal) { \ - fflush(stdout); \ - goto die_jar_jar_die; \ - } \ - } \ - } while (0) -#define RANK 1 -#define MAX_PATH 1024 - -hsize_t dims[RANK]; /* dataset dim sizes */ -hsize_t block[RANK], stride[RANK], count[RANK]; -hsize_t start[RANK]; -hid_t fid; /* HDF5 file ID */ -hid_t acc_tpl; /* File access templates */ -hid_t sid; /* Dataspace ID */ -hid_t file_dataspace; /* File dataspace ID */ -hid_t mem_dataspace; /* memory dataspace ID */ -hid_t dataset; /* Dataset ID */ -hsize_t opt_alignment = 1; -hsize_t opt_threshold = 1; -int opt_split_vfd = 0; -char *meta_ext, *raw_ext; /* holds the meta and raw file extension if */ - /* opt_split_vfd is set */ - -/* DEFAULT VALUES FOR OPTIONS */ -int64_t opt_block = 1048576 * 16; -int opt_iter = 1; -int opt_stripe = -1; -int opt_correct = 0; -int amode = O_RDWR | O_CREAT; -char opt_file[256] = "perftest.out"; -char opt_pvfstab[256] = "notset"; -int opt_pvfstab_set = 0; - -const char *FILENAME[] = {opt_file, NULL}; - -/* function prototypes */ -static int parse_args(int argc, char **argv); - -#ifndef H5_HAVE_UNISTD_H -/* globals needed for getopt */ -extern char *optarg; -#endif - -#ifndef HDF5_PARAPREFIX -#define HDF5_PARAPREFIX "" -#endif -char *paraprefix = NULL; /* for command line option para-prefix */ -MPI_Info h5_io_info_g = MPI_INFO_NULL; /* MPI INFO object for IO */ - -static char *h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, - size_t size, hbool_t nest_printf, hbool_t subst_for_superblock); - -int -main(int argc, char **argv) -{ - char *buf, *tmp, *buf2 = NULL, *tmp2 = NULL, *check; - int i, j, mynod = 0, nprocs = 1, my_correct = 1, correct, myerrno; - double stim, etim; - double write_tim = 0; - double read_tim = 0; - double read_bw, write_bw; - double max_read_tim, max_write_tim; - double min_read_tim, min_write_tim; - double ave_read_tim, ave_write_tim; - int64_t iter_jump = 0; - char filename[MAX_PATH]; - herr_t ret; /* Generic return value */ - - /* startup MPI and determine the rank of this process */ - MPI_Init(&argc, &argv); - MPI_Comm_size(MPI_COMM_WORLD, &nprocs); - MPI_Comm_rank(MPI_COMM_WORLD, &mynod); - - /* parse the command line arguments */ - parse_args(argc, argv); - - if (mynod == 0) - printf("# Using hdf5-io calls.\n"); - -#ifdef H5_HAVE_UNISTD_H - /* Kind of a weird hack- if the location of the pvfstab file was - * specified on the command line, then spit out this location into - * the appropriate environment variable. - */ - if (opt_pvfstab_set) { - if ((setenv("PVFSTAB_FILE", opt_pvfstab, 1)) < 0) { - perror("setenv"); - goto die_jar_jar_die; - } - } -#endif - - /* this is how much of the file data is covered on each iteration of - * the test. used to help determine the seek offset on each - * iteration */ - iter_jump = nprocs * opt_block; - - /* setup a buffer of data to write */ - if (!(tmp = (char *)malloc((size_t)opt_block + 256))) { - perror("malloc"); - goto die_jar_jar_die; - } - buf = tmp + 128 - (((long)tmp) % 128); /* align buffer */ - - if (opt_correct) { - /* do the same buffer setup for verifiable data */ - if (!(tmp2 = (char *)malloc((size_t)opt_block + 256))) { - perror("malloc2"); - goto die_jar_jar_die; - } - buf2 = tmp + 128 - (((long)tmp) % 128); - } - - /* setup file access template with parallel IO access. */ - if (opt_split_vfd) { - hid_t mpio_pl; - - mpio_pl = H5Pcreate(H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(mpio_pl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment * opt_threshold != 1) { - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } - - /* setup file access template */ - acc_tpl = H5Pcreate(H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_split(acc_tpl, meta_ext, mpio_pl, raw_ext, mpio_pl); - VRFY((ret >= 0), "H5Pset_fapl_split succeeded", H5FATAL); - ret = H5Pclose(mpio_pl); - VRFY((ret >= 0), "H5Pclose mpio_pl succeeded", H5FATAL); - } - else { - /* setup file access template */ - acc_tpl = H5Pcreate(H5P_FILE_ACCESS); - VRFY((acc_tpl >= 0), "", H5FATAL); - ret = H5Pset_fapl_mpio(acc_tpl, MPI_COMM_WORLD, MPI_INFO_NULL); - VRFY((ret >= 0), "", H5FATAL); - - /* set optional allocation alignment */ - if (opt_alignment * opt_threshold != 1) { - ret = H5Pset_alignment(acc_tpl, opt_threshold, opt_alignment); - VRFY((ret >= 0), "H5Pset_alignment succeeded", !H5FATAL); - } - } - - h5_fixname_real(FILENAME[0], acc_tpl, NULL, filename, sizeof filename, FALSE, FALSE); - - /* create the parallel file */ - fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); - VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL); - - /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ - dims[0] = (hsize_t)opt_iter * (hsize_t)nprocs * (hsize_t)opt_block; - sid = H5Screate_simple(RANK, dims, NULL); - VRFY((sid >= 0), "H5Screate_simple succeeded", H5FATAL); - dataset = H5Dcreate2(fid, "Dataset1", H5T_NATIVE_CHAR, sid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - VRFY((dataset >= 0), "H5Dcreate2 succeeded", H5FATAL); - - /* create the memory dataspace and the file dataspace */ - dims[0] = (hsize_t)opt_block; - mem_dataspace = H5Screate_simple(RANK, dims, NULL); - VRFY((mem_dataspace >= 0), "", H5FATAL); - file_dataspace = H5Dget_space(dataset); - VRFY((file_dataspace >= 0), "H5Dget_space succeeded", H5FATAL); - - /* now each process writes a block of opt_block chars in round robbin - * fashion until the whole dataset is covered. - */ - for (j = 0; j < opt_iter; j++) { - /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); - stride[0] = block[0] = (hsize_t)opt_block; - count[0] = 1; - ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - - if (opt_correct) /* fill in buffer for iteration */ { - for (i = mynod + j, check = buf; i < opt_block; i++, check++) - *check = (char)i; - } - - /* discover the starting time of the operation */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); - - /* write data */ - ret = H5Dwrite(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); - VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - /* discover the ending time of the operation */ - etim = MPI_Wtime(); - - write_tim += (etim - stim); - - /* we are done with this "write" iteration */ - } - - /* close dataset and file */ - ret = H5Dclose(dataset); - VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret = H5Fclose(fid); - VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - - /* wait for everyone to synchronize at this point */ - MPI_Barrier(MPI_COMM_WORLD); - - /* reopen the file for reading */ - fid = H5Fopen(filename, H5F_ACC_RDONLY, acc_tpl); - VRFY((fid >= 0), "", H5FATAL); - - /* open the dataset */ - dataset = H5Dopen2(fid, "Dataset1", H5P_DEFAULT); - VRFY((dataset >= 0), "H5Dopen succeeded", H5FATAL); - - /* we can re-use the same mem_dataspace and file_dataspace - * the H5Dwrite used since the dimension size is the same. - */ - - /* we are going to repeat the read the same pattern the write used */ - for (j = 0; j < opt_iter; j++) { - /* setup a file dataspace selection */ - start[0] = (hsize_t)((j * iter_jump) + (mynod * opt_block)); - stride[0] = block[0] = (hsize_t)opt_block; - count[0] = 1; - ret = H5Sselect_hyperslab(file_dataspace, H5S_SELECT_SET, start, stride, count, block); - VRFY((ret >= 0), "H5Sset_hyperslab succeeded", H5FATAL); - /* seek to the appropriate spot give the current iteration and - * rank within the MPI processes */ - - /* discover the start time */ - MPI_Barrier(MPI_COMM_WORLD); - stim = MPI_Wtime(); - - /* read in the file data */ - if (!opt_correct) { - ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf); - } - else { - ret = H5Dread(dataset, H5T_NATIVE_CHAR, mem_dataspace, file_dataspace, H5P_DEFAULT, buf2); - } - myerrno = errno; - - /* discover the end time */ - etim = MPI_Wtime(); - read_tim += (etim - stim); - VRFY((ret >= 0), "H5Dwrite dataset1 succeeded", !H5FATAL); - - if (ret < 0) - HDfprintf(stderr, "node %d, read error, loc = %" PRId64 ": %s\n", mynod, mynod * opt_block, - strerror(myerrno)); - - /* if the user wanted to check correctness, compare the write - * buffer to the read buffer */ - if (opt_correct && memcmp(buf, buf2, (size_t)opt_block)) { - HDfprintf(stderr, "node %d, correctness test failed\n", mynod); - my_correct = 0; - MPI_Allreduce(&my_correct, &correct, 1, MPI_INT, MPI_MIN, MPI_COMM_WORLD); - } - - /* we are done with this read iteration */ - } - - /* close dataset and file */ - ret = H5Dclose(dataset); - VRFY((ret >= 0), "H5Dclose succeeded", H5FATAL); - ret = H5Fclose(fid); - VRFY((ret >= 0), "H5Fclose succeeded", H5FATAL); - ret = H5Pclose(acc_tpl); - VRFY((ret >= 0), "H5Pclose succeeded", H5FATAL); - - /* compute the read and write times */ - MPI_Allreduce(&read_tim, &max_read_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &min_read_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - MPI_Allreduce(&read_tim, &ave_read_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - - /* calculate the average from the sum */ - ave_read_tim = ave_read_tim / nprocs; - - MPI_Allreduce(&write_tim, &max_write_tim, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &min_write_tim, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD); - MPI_Allreduce(&write_tim, &ave_write_tim, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD); - - /* calculate the average from the sum */ - ave_write_tim = ave_write_tim / nprocs; - - /* print out the results on one node */ - if (mynod == 0) { - read_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_read_tim * 1000000.0); - write_bw = (double)((int64_t)(opt_block * nprocs * opt_iter)) / (max_write_tim * 1000000.0); - - printf("nr_procs = %d, nr_iter = %d, blk_sz = %ld\n", nprocs, opt_iter, (long)opt_block); - - printf("# total_size = %ld\n", (long)(opt_block * nprocs * opt_iter)); - - printf("# Write: min_time = %f, max_time = %f, mean_time = %f\n", min_write_tim, max_write_tim, - ave_write_tim); - printf("# Read: min_time = %f, max_time = %f, mean_time = %f\n", min_read_tim, max_read_tim, - ave_read_tim); - - printf("Write bandwidth = %f Mbytes/sec\n", write_bw); - printf("Read bandwidth = %f Mbytes/sec\n", read_bw); - - if (opt_correct) { - printf("Correctness test %s.\n", correct ? "passed" : "failed"); - } - } - -die_jar_jar_die: - -#ifdef H5_HAVE_UNISTD - /* Clear the environment variable if it was set earlier */ - if (opt_pvfstab_set) { - unsetenv("PVFSTAB_FILE"); - } -#endif - - free(tmp); - if (opt_correct) - free(tmp2); - - MPI_Finalize(); - - return (0); -} - -static int -parse_args(int argc, char **argv) -{ - int c; - - while ((c = getopt(argc, argv, "s:b:i:f:p:a:2:c")) != EOF) { - switch (c) { - case 's': /* stripe */ - opt_stripe = atoi(optarg); - break; - case 'b': /* block size */ - opt_block = atoi(optarg); - break; - case 'i': /* iterations */ - opt_iter = atoi(optarg); - break; - case 'f': /* filename */ - strncpy(opt_file, optarg, 255); - FILENAME[0] = opt_file; - break; - case 'p': /* pvfstab file */ - strncpy(opt_pvfstab, optarg, 255); - opt_pvfstab_set = 1; - break; - case 'a': /* aligned allocation. - * syntax: -a<alignment>/<threshold> - * e.g., -a4096/512 allocate at 4096 bytes - * boundary if request size >= 512. - */ - { - char *p; - - opt_alignment = (hsize_t)HDatoi(optarg); - if (NULL != (p = (char *)HDstrchr(optarg, '/'))) - opt_threshold = (hsize_t)HDatoi(p + 1); - } - HDfprintf(stdout, "alignment/threshold=%" PRIuHSIZE "/%" PRIuHSIZE "\n", opt_alignment, - opt_threshold); - break; - case '2': /* use 2-files, i.e., split file driver */ - opt_split_vfd = 1; - /* get meta and raw file extension. */ - /* syntax is <raw_ext>,<meta_ext> */ - meta_ext = raw_ext = optarg; - while (*raw_ext != '\0') { - if (*raw_ext == ',') { - *raw_ext = '\0'; - raw_ext++; - break; - } - raw_ext++; - } - printf("split-file-vfd used: %s,%s\n", meta_ext, raw_ext); - break; - case 'c': /* correctness */ - opt_correct = 1; - break; - case '?': /* unknown */ - default: - break; - } - } - - return (0); -} -/*------------------------------------------------------------------------- - * Function: getenv_all - * - * Purpose: Used to get the environment that the root MPI task has. - * name specifies which environment variable to look for - * val is the string to which the value of that environment - * variable will be copied. - * - * NOTE: The pointer returned by this function is only - * valid until the next call to getenv_all and the data - * stored there must be copied somewhere else before any - * further calls to getenv_all take place. - * - * Return: pointer to a string containing the value of the environment variable - * NULL if the variable doesn't exist in task 'root's environment. - * - * Programmer: Leon Arber - * 4/4/05 - * - * Modifications: - * Use original getenv if MPI is not initialized. This happens - * one uses the PHDF5 library to build a serial nature code. - * Albert 2006/04/07 - * - *------------------------------------------------------------------------- - */ -char * -getenv_all(MPI_Comm comm, int root, const char *name) -{ - int mpi_size, mpi_rank, mpi_initialized, mpi_finalized; - int len; - static char *env = NULL; - - HDassert(name); - - MPI_Initialized(&mpi_initialized); - MPI_Finalized(&mpi_finalized); - - if (mpi_initialized && !mpi_finalized) { - MPI_Comm_rank(comm, &mpi_rank); - MPI_Comm_size(comm, &mpi_size); - HDassert(root < mpi_size); - - /* The root task does the getenv call - * and sends the result to the other tasks */ - if (mpi_rank == root) { - env = HDgetenv(name); - if (env) { - len = (int)HDstrlen(env); - MPI_Bcast(&len, 1, MPI_INT, root, comm); - MPI_Bcast(env, len, MPI_CHAR, root, comm); - } - else { - /* len -1 indicates that the variable was not in the environment */ - len = -1; - MPI_Bcast(&len, 1, MPI_INT, root, comm); - } - } - else { - MPI_Bcast(&len, 1, MPI_INT, root, comm); - if (len >= 0) { - if (env == NULL) - env = (char *)HDmalloc((size_t)len + 1); - else if (HDstrlen(env) < (size_t)len) - env = (char *)HDrealloc(env, (size_t)len + 1); - - MPI_Bcast(env, len, MPI_CHAR, root, comm); - env[len] = '\0'; - } - else { - if (env) - HDfree(env); - env = NULL; - } - } -#ifndef NDEBUG - MPI_Barrier(comm); -#endif - } - else { - /* use original getenv */ - if (env) - HDfree(env); - env = HDgetenv(name); - } /* end if */ - - return env; -} - -/*------------------------------------------------------------------------- - * Function: h5_fixname_real - * - * Purpose: Create a file name from a file base name like `test' and - * return it through the FULLNAME (at most SIZE characters - * counting the null terminator). The full name is created by - * prepending the contents of HDF5_PREFIX (separated from the - * base name by a slash) and appending a file extension based on - * the driver supplied, resulting in something like - * `ufs:/u/matzke/test.h5'. - * - * Return: Success: The FULLNAME pointer. - * - * Failure: NULL if BASENAME or FULLNAME is the null - * pointer or if FULLNAME isn't large enough for - * the result. - * - * Programmer: Robb Matzke - * Thursday, November 19, 1998 - * - *------------------------------------------------------------------------- - */ -static char * -h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, char *fullname, size_t size, - hbool_t nest_printf, hbool_t subst_for_superblock) -{ - const char *prefix = NULL; - const char *env = NULL; /* HDF5_DRIVER environment variable */ - char *ptr, last = '\0'; - const char *suffix = _suffix; - size_t i, j; - hid_t driver = -1; - int isppdriver = 0; /* if the driver is MPI parallel */ - - if (!base_name || !fullname || size < 1) - return NULL; - - HDmemset(fullname, 0, size); - - /* figure out the suffix */ - if (H5P_DEFAULT != fapl) { - if ((driver = H5Pget_driver(fapl)) < 0) - return NULL; - - if (suffix) { - if (H5FD_FAMILY == driver) { - if (subst_for_superblock) - suffix = "00000.h5"; - else - suffix = nest_printf ? "%%05d.h5" : "%05d.h5"; - } - else if (H5FD_MULTI == driver) { - - /* Get the environment variable, if it exists, in case - * we are using the split driver since both of those - * use the multi VFD under the hood. - */ - env = HDgetenv("HDF5_DRIVER"); -#ifdef HDF5_DRIVER - /* Use the environment variable, then the compile-time constant */ - if (!env) - env = HDF5_DRIVER; -#endif - if (env && !HDstrcmp(env, "split")) { - /* split VFD */ - if (subst_for_superblock) - suffix = "-m.h5"; - else - suffix = NULL; - } - else { - /* multi VFD */ - if (subst_for_superblock) - suffix = "-s.h5"; - else - suffix = NULL; - } - } - } - } - - /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX - * could be of value -1 if it is not defined. - */ - isppdriver = H5P_DEFAULT != fapl && (H5FD_MPIO == driver); - - /* Check what prefix to use for test files. Process HDF5_PARAPREFIX and - * HDF5_PREFIX. - * Use different ones depending on parallel or serial driver used. - * (The #ifdef is needed to prevent compile failure in case MPI is not - * configured.) - */ - if (isppdriver) { - /* - * For parallel: - * First use command line option, then the environment - * variable, then try the constant - */ - static int explained = 0; - - prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); - - if (!prefix && !explained) { - /* print hint by process 0 once. */ - int mpi_rank; - - MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); - - if (mpi_rank == 0) - HDprintf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. e.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); - - explained = TRUE; -#ifdef HDF5_PARAPREFIX - prefix = HDF5_PARAPREFIX; -#endif /* HDF5_PARAPREFIX */ - } - } - else { - /* - * For serial: - * First use the environment variable, then try the constant - */ - prefix = HDgetenv("HDF5_PREFIX"); - -#ifdef HDF5_PREFIX - if (!prefix) - prefix = HDF5_PREFIX; -#endif /* HDF5_PREFIX */ - } - - /* Prepend the prefix value to the base name */ - if (prefix && *prefix) { - if (isppdriver) { - /* This is a parallel system */ - char *subdir; - - if (!HDstrcmp(prefix, HDF5_PARAPREFIX)) { - /* - * If the prefix specifies the HDF5_PARAPREFIX directory, then - * default to using the "/tmp/$USER" or "/tmp/$LOGIN" - * directory instead. - */ - char *user, *login; - - user = HDgetenv("USER"); - login = HDgetenv("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]; - } - } - - if (!fullname[0]) { - /* We didn't append the prefix yet */ - HDstrncpy(fullname, prefix, size); - fullname[size - 1] = '\0'; - } - - if (HDstrlen(fullname) + HDstrlen(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 (HDmkdir(fullname, (mode_t)0755) < 0 && errno != EEXIST) - /* - * We couldn't make the "/tmp/${USER,LOGIN}" - * subdirectory. Default to PREFIX's original - * prefix value. - */ - HDstrcpy(fullname, prefix); - - HDstrcat(fullname, "/"); - HDstrcat(fullname, base_name); - } - else { - /* Buffer is too small */ - return NULL; - } - } - else { - if (HDsnprintf(fullname, size, "%s/%s", prefix, base_name) == (int)size) - /* Buffer is too small */ - return NULL; - } - } - else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; - } - else { - HDstrcpy(fullname, base_name); - } - - /* Append a suffix */ - if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) - return NULL; - - HDstrcat(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; -} - -/* - * Local variables: - * c-indent-level: 3 - * c-basic-offset: 3 - * tab-width: 3 - * End: - */ - -#else /* H5_HAVE_PARALLEL */ -/* dummy program since H5_HAVE_PARALLEL is not configured in */ -int -main(int H5_ATTR_UNUSED argc, char H5_ATTR_UNUSED **argv) -{ - printf("No parallel performance because parallel is not configured in\n"); - return (0); -} -#endif /* H5_HAVE_PARALLEL */ diff --git a/tools/src/h5perf/pio_engine.c b/tools/src/h5perf/pio_engine.c index 83bf299..1c30f06 100644 --- a/tools/src/h5perf/pio_engine.c +++ b/tools/src/h5perf/pio_engine.c @@ -16,12 +16,10 @@ #include "hdf5.h" -#ifdef H5_STDC_HEADERS #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#endif #ifdef H5_HAVE_UNISTD_H #include <sys/types.h> @@ -148,7 +146,7 @@ do_pio(parameters param) file_descr fd; iotype iot; - char fname[FILENAME_MAX]; + char *fname = NULL; long nf; long ndsets; off_t nbytes; /*number of bytes per dataset */ @@ -170,6 +168,9 @@ do_pio(parameters param) /* IO type */ iot = param.io_type; + if (NULL == (fname = HDcalloc(FILENAME_MAX, sizeof(char)))) + GOTOERROR(FAIL); + switch (iot) { case MPIO: fd.mpifd = MPI_FILE_NULL; @@ -236,7 +237,7 @@ do_pio(parameters param) } if ((snbytes % pio_mpi_nprocs_g) != 0) { HDfprintf(stderr, - "Dataset size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "Dataset size (%lld) must be a multiple of the " "number of processes (%d)\n", (long long)snbytes, pio_mpi_nprocs_g); GOTOERROR(FAIL); @@ -245,7 +246,7 @@ do_pio(parameters param) if (!param.dim2d) { if (((size_t)(snbytes / pio_mpi_nprocs_g) % buf_size) != 0) { HDfprintf(stderr, - "Dataset size/process (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "Dataset size/process (%lld) must be a multiple of the " "transfer buffer size (%zu)\n", (long long)(snbytes / pio_mpi_nprocs_g), buf_size); GOTOERROR(FAIL); @@ -254,7 +255,7 @@ do_pio(parameters param) else { if (((size_t)snbytes % buf_size) != 0) { HDfprintf(stderr, - "Dataset side size (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "Dataset side size (%lld) must be a multiple of the " "transfer buffer size (%zu)\n", (long long)snbytes, buf_size); GOTOERROR(FAIL); @@ -284,8 +285,8 @@ do_pio(parameters param) /* Open file for write */ char base_name[256]; - HDsprintf(base_name, "#pio_tmp_%lu", nf); - pio_create_filename(iot, base_name, fname, sizeof(fname)); + HDsnprintf(base_name, sizeof(base_name), "#pio_tmp_%lu", nf); + pio_create_filename(iot, base_name, fname, FILENAME_MAX); if (pio_debug_level > 0) HDfprintf(output, "rank %d: data filename=%s\n", pio_mpi_rank_g, fname); @@ -367,8 +368,8 @@ done: } /* release generic resources */ - if (buffer) - HDfree(buffer); + HDfree(buffer); + HDfree(fname); res.ret_code = ret_code; return res; } @@ -422,7 +423,7 @@ pio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si /* 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; + char *user, *login, *subdir; user = HDgetenv("USER"); login = HDgetenv("LOGIN"); @@ -504,18 +505,18 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby void *buffer) { int ret_code = SUCCESS; - int rc; /*routine return code */ + int rc; /* Return code */ long ndset; size_t blk_size; /* The block size to subdivide the xfer buffer into */ off_t nbytes_xfer; /* Total number of bytes transferred so far */ size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ char dname[64]; - off_t dset_offset = 0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes = 0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ + off_t dset_offset = 0; /* Dataset offset in a file */ + off_t bytes_begin[2] = {0, 0}; /* First elmt this process transfer */ + off_t bytes_count; /* Number of elmts this process transfer */ + off_t snbytes = 0; /* Size of a side of the dataset square */ + unsigned char *buf_p; /* Current buffer pointer */ /* POSIX variables */ off_t file_offset; /* File offset of the next transfer */ @@ -627,15 +628,13 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby if (!parms->dim2d) { HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH - "d\n", + "buf_size=%zu, bytes_begin=%lld, bytes_count=%lld\n", buf_size, (long long)bytes_begin[0], (long long)bytes_count); } else { HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH - "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + "linear buf_size=%zu, bytes_begin=(%lld,%lld), bytes_count=%lld\n", buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], (long long)bytes_count); } @@ -900,7 +899,7 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby } /* end if */ } /* end else */ - HDsprintf(dname, "Dataset_%ld", ndset); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset); h5ds_id = H5DCREATE(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, h5dcpl); if (h5ds_id < 0) { @@ -1185,7 +1184,7 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby /* Set the file view */ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type, - (char *)"native", h5_io_info_g); + "native", h5_io_info_g); VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); /* Perform write */ @@ -1321,7 +1320,7 @@ do_write(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nby else { /* Set the file view */ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type, - (char *)"native", h5_io_info_g); + "native", h5_io_info_g); VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); /* Perform write */ @@ -1531,11 +1530,11 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt size_t nbytes_xfer_advance; /* Number of bytes transferred in a single I/O operation */ size_t nbytes_toxfer; /* Number of bytes to transfer a particular time */ char dname[64]; - off_t dset_offset = 0; /*dataset offset in a file */ - off_t bytes_begin[2]; /*first elmt this process transfer */ - off_t bytes_count; /*number of elmts this process transfer */ - off_t snbytes = 0; /*size of a side of the dataset square */ - unsigned char *buf_p; /* Current buffer pointer */ + off_t dset_offset = 0; /* Dataset offset in a file */ + off_t bytes_begin[2] = {0, 0}; /* First elmt this process transfer */ + off_t bytes_count; /* Number of elmts this process transfer */ + off_t snbytes = 0; /* Size of a side of the dataset square */ + unsigned char *buf_p; /* Current buffer pointer */ /* POSIX variables */ off_t file_offset; /* File offset of the next transfer */ @@ -1641,15 +1640,13 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt if (!parms->dim2d) { HDfprintf(output, "Debug(do_write): " - "buf_size=%zu, bytes_begin=%" H5_PRINTF_LL_WIDTH "d, bytes_count=%" H5_PRINTF_LL_WIDTH - "d\n", + "buf_size=%zu, bytes_begin=%lld, bytes_count=%lld\n", buf_size, (long long)bytes_begin[0], (long long)bytes_count); } else { HDfprintf(output, "Debug(do_write): " - "linear buf_size=%zu, bytes_begin=(%" H5_PRINTF_LL_WIDTH "d,%" H5_PRINTF_LL_WIDTH - "d), bytes_count=%" H5_PRINTF_LL_WIDTH "d\n", + "linear buf_size=%zu, bytes_begin=(%lld,%lld), bytes_count=%lld\n", buf_size * blk_size, (long long)bytes_begin[0], (long long)bytes_begin[1], (long long)bytes_count); } @@ -1880,7 +1877,7 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt break; case PHDF5: - HDsprintf(dname, "Dataset_%ld", ndset); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", ndset); h5ds_id = H5DOPEN(fd->h5fd, dname); if (h5ds_id < 0) { HDfprintf(stderr, "HDF5 Dataset open failed\n"); @@ -2155,7 +2152,7 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt /* Set the file view */ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, mpi_blk_type, mpi_file_type, - (char *)"native", h5_io_info_g); + "native", h5_io_info_g); VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); /* Perform collective read */ @@ -2291,7 +2288,7 @@ do_read(results *res, file_descr *fd, parameters *parms, long ndsets, off_t nbyt else { /* Set the file view */ mrc = MPI_File_set_view(fd->mpifd, mpi_offset, MPI_BYTE, mpi_collective_type, - (char *)"native", h5_io_info_g); + "native", h5_io_info_g); VRFY((mrc == MPI_SUCCESS), "MPIO_VIEW"); /* Perform read */ diff --git a/tools/src/h5perf/pio_perf.c b/tools/src/h5perf/pio_perf.c index f997166..e9a3341 100644 --- a/tools/src/h5perf/pio_perf.c +++ b/tools/src/h5perf/pio_perf.c @@ -80,11 +80,6 @@ #define PIO_MPI 0x2 #define PIO_HDF5 0x4 -#ifdef STANDALONE -#define DBL_EPSILON 2.2204460492503131e-16 -#define H5_DBL_ABS_EQUAL(X, Y) (fabs((X) - (Y)) < DBL_EPSILON) -#endif - /* report 0.0 in case t is zero too */ #define MB_PER_SEC(bytes, t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) @@ -199,8 +194,8 @@ static int destroy_comm_world(void); static void output_results(const struct options *options, const char *name, minmax *table, int table_size, off_t data_size); static void output_times(const struct options *options, const char *name, minmax *table, int table_size); -static void output_report(const char *fmt, ...); -static void print_indent(register int indent); +static void output_report(const char *fmt, ...) H5_ATTR_FORMAT(printf, 1, 2); +static void print_indent(int indent); static void usage(const char *prog); static void report_parameters(struct options *opts); static off_t squareo(off_t); @@ -220,10 +215,8 @@ main(int argc, char *argv[]) int exit_value = EXIT_SUCCESS; struct options *opts = NULL; -#ifndef STANDALONE /* Initialize h5tools lib */ h5tools_init(); -#endif output = stdout; @@ -318,7 +311,7 @@ run_test_loop(struct options *opts) { parameters parms; int num_procs; - int doing_pio; /* if this process is doing PIO */ + int doing_pio = 0; /* if this process is doing parallel IO */ parms.num_files = opts->num_files; parms.num_dsets = opts->num_dsets; @@ -336,7 +329,7 @@ run_test_loop(struct options *opts) /* start with max_num_procs and decrement it by half for each loop. */ /* if performance needs restart, fewer processes may be needed. */ for (num_procs = opts->max_num_procs; num_procs >= opts->min_num_procs; num_procs >>= 1) { - register size_t buf_size; + size_t buf_size; parms.num_procs = num_procs; @@ -346,7 +339,7 @@ run_test_loop(struct options *opts) /* only processes doing PIO will run the tests */ if (doing_pio) { - output_report("Number of processors = %ld\n", parms.num_procs); + output_report("Number of processors = %d\n", parms.num_procs); /* multiply the xfer buffer size by 2 for each loop iteration */ for (buf_size = opts->min_xfer_size; buf_size <= opts->max_xfer_size; buf_size <<= 1) { @@ -411,34 +404,34 @@ run_test_loop(struct options *opts) 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_mpi_mm_table = NULL; - minmax *write_mm_table = NULL; - minmax *write_gross_mm_table = NULL; - minmax *write_raw_mm_table = NULL; - minmax *read_mpi_mm_table = NULL; - minmax *read_mm_table = NULL; - minmax *read_gross_mm_table = NULL; - minmax *read_raw_mm_table = NULL; - minmax *read_open_mm_table = NULL; - minmax *read_close_mm_table = NULL; - minmax *write_open_mm_table = NULL; - minmax *write_close_mm_table = NULL; - minmax write_mpi_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_mpi_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}; - minmax read_open_mm = {0.0, 0.0, 0.0, 0}; - minmax read_close_mm = {0.0, 0.0, 0.0, 0}; - minmax write_open_mm = {0.0, 0.0, 0.0, 0}; - minmax write_close_mm = {0.0, 0.0, 0.0, 0}; + results res; + int i, ret_value = SUCCESS; + int comm_size; + off_t raw_size; + minmax *write_mpi_mm_table = NULL; + minmax *write_mm_table = NULL; + minmax *write_gross_mm_table = NULL; + minmax *write_raw_mm_table = NULL; + minmax *read_mpi_mm_table = NULL; + minmax *read_mm_table = NULL; + minmax *read_gross_mm_table = NULL; + minmax *read_raw_mm_table = NULL; + minmax *read_open_mm_table = NULL; + minmax *read_close_mm_table = NULL; + minmax *write_open_mm_table = NULL; + minmax *write_close_mm_table = NULL; + minmax write_mpi_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_mpi_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}; + minmax read_open_mm = {0.0, 0.0, 0.0, 0}; + minmax read_close_mm = {0.0, 0.0, 0.0, 0}; + minmax write_open_mm = {0.0, 0.0, 0.0, 0}; + minmax write_close_mm = {0.0, 0.0, 0.0, 0}; raw_size = parms.num_files * (off_t)parms.num_dsets * (off_t)parms.num_bytes; parms.io_type = iot; @@ -904,7 +897,7 @@ accumulate_minmax_stuff(minmax *mm, int count) int i; minmax total_mm; - total_mm.sum = 0.0f; + total_mm.sum = 0.0; total_mm.max = -DBL_MAX; total_mm.min = DBL_MAX; total_mm.num = count; @@ -1059,14 +1052,14 @@ output_times(const struct options *opts, const char *name, minmax *table, int ta /* Note: The maximum throughput uses the minimum amount of time & vice versa */ print_indent(4); - output_report("Minimum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.min)); + output_report("Minimum Accumulated Time using %ld file(s): %7.5f s\n", opts->num_files, (total_mm.min)); print_indent(4); - output_report("Average Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, + output_report("Average Accumulated Time using %ld file(s): %7.5f s\n", opts->num_files, (total_mm.sum / total_mm.num)); print_indent(4); - output_report("Maximum Accumulated Time using %d file(s): %7.5f s\n", opts->num_files, (total_mm.max)); + output_report("Maximum Accumulated Time using %ld file(s): %7.5f s\n", opts->num_files, (total_mm.max)); } /* @@ -1087,7 +1080,9 @@ output_report(const char *fmt, ...) va_list ap; HDva_start(ap, fmt); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(output, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDva_end(ap); } } @@ -1098,10 +1093,9 @@ output_report(const char *fmt, ...) * things. * Return: Nothing * Programmer: Bill Wendling, 29. October 2001 - * Modifications: */ static void -print_indent(register int indent) +print_indent(int indent) { int myrank; @@ -1122,25 +1116,25 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "GB%s", val / ONE_GB, end); else HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "MB%s", val / ONE_MB, end); } else { HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "KB%s", val / ONE_KB, end); } } else { HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "%s", val, end); } @@ -1278,7 +1272,7 @@ report_parameters(struct options *opts) static struct options * parse_command_line(int argc, const char *const *argv) { - register int opt; + int opt; struct options *cl_opts; cl_opts = (struct options *)malloc(sizeof(struct options)); diff --git a/tools/src/h5perf/pio_perf.h b/tools/src/h5perf/pio_perf.h index b12996f..05f8d5b 100644 --- a/tools/src/h5perf/pio_perf.h +++ b/tools/src/h5perf/pio_perf.h @@ -13,15 +13,10 @@ #ifndef PIO_PERF_H #define PIO_PERF_H -#ifndef STANDALONE #include "io_timer.h" #include "H5private.h" #include "h5tools.h" #include "h5tools_utils.h" -#else -#include "io_timer.h" -#include "pio_standalone.h" -#endif #ifdef H5_HAVE_PARALLEL extern MPI_Info h5_io_info_g; /* MPI INFO object for IO */ diff --git a/tools/src/h5perf/sio_engine.c b/tools/src/h5perf/sio_engine.c index 4b39545..a1b52b9 100644 --- a/tools/src/h5perf/sio_engine.c +++ b/tools/src/h5perf/sio_engine.c @@ -16,12 +16,10 @@ #include "hdf5.h" -#ifdef H5_STDC_HEADERS #include <errno.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> -#endif #ifdef H5_HAVE_UNISTD_H #include <sys/types.h> @@ -52,7 +50,7 @@ /* verify: if val is false (0), print mesg. */ #define VRFY(val, mesg) \ do { \ - if (!val) { \ + if (!(val)) { \ ERRMSG(mesg); \ GOTOERROR(FAIL); \ } \ @@ -181,7 +179,7 @@ do_sio(parameters param, results *res) if ((param.dset_size[i] % param.buf_size[i]) != 0) { HDfprintf(stderr, - "Dataset size[%d] (%" H5_PRINTF_LL_WIDTH "d) must be a multiple of the " + "Dataset size[%d] (%lld) must be a multiple of the " "transfer buffer size[%d] (%zu)\n", param.rank, (long long)param.dset_size[i], param.rank, param.buf_size[i]); GOTOERROR(FAIL); @@ -205,7 +203,7 @@ do_sio(parameters param, results *res) /* Open file for write */ HDstrcpy(base_name, "#sio_tmp"); - sio_create_filename(iot, base_name, fname, sizeof(fname), ¶m); + sio_create_filename(iot, base_name, fname, FILENAME_MAX, ¶m); if (sio_debug_level > 0) HDfprintf(output, "data filename=%s\n", fname); @@ -331,7 +329,7 @@ sio_create_filename(iotype iot, const char *base_name, char *fullname, size_t si /* If the prefix specifies the HDF5_PREFIX directory, then * default to using the "/tmp/$USER" or "/tmp/$LOGIN" * directory instead. */ - register char *user, *login, *subdir; + char *user, *login, *subdir; user = HDgetenv("USER"); login = HDgetenv("LOGIN"); @@ -524,7 +522,7 @@ do_write(results *res, file_descr *fd, parameters *parms, void *buffer) } /* end if */ } /* end if */ - HDsprintf(dname, "Dataset_%ld", (unsigned long)parms->num_bytes); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", (unsigned long)parms->num_bytes); h5ds_id = H5Dcreate2(fd->h5fd, dname, ELMT_H5_TYPE, h5dset_space_id, H5P_DEFAULT, h5dcpl, H5P_DEFAULT); @@ -853,7 +851,7 @@ do_read(results *res, file_descr *fd, parameters *parms, void *buffer) break; case HDF5: - HDsprintf(dname, "Dataset_%ld", (long)parms->num_bytes); + HDsnprintf(dname, sizeof(dname), "Dataset_%ld", (long)parms->num_bytes); h5ds_id = H5Dopen2(fd->h5fd, dname, H5P_DEFAULT); if (h5ds_id < 0) { HDfprintf(stderr, "HDF5 Dataset open failed\n"); @@ -1183,7 +1181,7 @@ set_vfd(parameters *param) return -1; for (mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; mt++) { memb_fapl[mt] = H5P_DEFAULT; - HDsprintf(sv->arr[mt], "%%s-%c.h5", multi_letters[mt]); + HDsnprintf(sv->arr[mt], 1024, "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv->arr[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } @@ -1281,7 +1279,7 @@ do_cleanupfile(iotype iot, char *filename) int j; hid_t driver; - temp_sz = (2048) * sizeof(char); + temp_sz = (4096 + sizeof("-?.h5")) * sizeof(char); if (NULL == (temp = HDcalloc(1, temp_sz))) goto done; @@ -1300,7 +1298,9 @@ do_cleanupfile(iotype iot, char *filename) if (driver == H5FD_FAMILY) { for (j = 0; /*void*/; j++) { + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDsnprintf(temp, temp_sz, filename, j); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") if (HDaccess(temp, F_OK) < 0) break; diff --git a/tools/src/h5perf/sio_perf.c b/tools/src/h5perf/sio_perf.c index 227ee4e..cc6a1c0 100644 --- a/tools/src/h5perf/sio_perf.c +++ b/tools/src/h5perf/sio_perf.c @@ -172,8 +172,8 @@ static void get_minmax(minmax *mm, double val); static void accumulate_minmax_stuff(const minmax *mm, int count, minmax *total_mm); 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 output_report(const char *fmt, ...) H5_ATTR_FORMAT(printf, 1, 2); +static void print_indent(int indent); static void usage(const char *prog); static void report_parameters(struct options *opts); @@ -190,10 +190,8 @@ main(int argc, char *argv[]) int exit_value = EXIT_SUCCESS; struct options *opts = NULL; -#ifndef STANDALONE /* Initialize h5tools lib */ h5tools_init(); -#endif output = stdout; @@ -299,25 +297,25 @@ run_test_loop(struct options *opts) static int run_test(iotype iot, parameters parms, struct options *opts) { - results res; - register int i, ret_value = SUCCESS; - 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}; + results res; + int i, ret_value = SUCCESS; + 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; @@ -647,7 +645,9 @@ output_report(const char *fmt, ...) va_list ap; HDva_start(ap, fmt); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(output, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDva_end(ap); } @@ -657,10 +657,9 @@ output_report(const char *fmt, ...) * things. * Return: Nothing * Programmer: Bill Wendling, 29. October 2001 - * Modifications: */ static void -print_indent(register int indent) +print_indent(int indent) { indent *= TAB_SPACE; @@ -675,25 +674,25 @@ recover_size_and_print(long long val, const char *end) if (val >= ONE_MB && (val % ONE_MB) == 0) { if (val >= ONE_GB && (val % ONE_GB) == 0) HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "GB%s", val / ONE_GB, end); else HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "MB%s", val / ONE_MB, end); } else { HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "KB%s", val / ONE_KB, end); } } else { HDfprintf(output, - "%" H5_PRINTF_LL_WIDTH "d" + "%lld" "%s", val, end); } diff --git a/tools/src/h5perf/sio_perf.h b/tools/src/h5perf/sio_perf.h index cb4af1f..a417bdb 100644 --- a/tools/src/h5perf/sio_perf.h +++ b/tools/src/h5perf/sio_perf.h @@ -13,15 +13,10 @@ #ifndef SIO_PERF_H #define SIO_PERF_H -#ifndef STANDALONE #include "io_timer.h" #include "H5private.h" #include "h5tools.h" #include "h5tools_utils.h" -#else -#include "io_timer.h" -#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 diff --git a/tools/test/perform/CMakeLists.txt b/tools/test/perform/CMakeLists.txt index eed545b..268acbb 100644 --- a/tools/test/perform/CMakeLists.txt +++ b/tools/test/perform/CMakeLists.txt @@ -1,39 +1,9 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_TOOLS_TEST_PERFORM C) -# -------------------------------------------------------------------- -# Add the executables -# -------------------------------------------------------------------- - -if (HDF5_BUILD_PERFORM_STANDALONE) - #-- Adding test for h5perf_serial_alone - io_timer.c includes - set (h5perf_serial_alone_SOURCES - ${HDF5_TOOLS_DIR}/lib/io_timer.c - ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_perf.c - ${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR}/sio_engine.c - ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/sio_standalone.c - ) - add_executable (h5perf_serial_alone ${h5perf_serial_alone_SOURCES}) - target_include_directories (h5perf_serial_alone PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_TOOLS_SRC_H5PERF_SOURCE_DIR};${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>") - if (NOT BUILD_SHARED_LIBS) - TARGET_C_PROPERTIES (h5perf_serial_alone STATIC) - target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_LIB_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") - else () - TARGET_C_PROPERTIES (h5perf_serial_alone SHARED) - target_link_libraries (h5perf_serial_alone PRIVATE ${HDF5_LIBSH_TARGET} "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_LIBRARIES}>") - endif () - set_target_properties (h5perf_serial_alone PROPERTIES FOLDER perform) - set_property (TARGET h5perf_serial_alone APPEND PROPERTY COMPILE_DEFINITIONS STANDALONE) - - #----------------------------------------------------------------------------- - # Add Target to clang-format - #----------------------------------------------------------------------------- - if (HDF5_ENABLE_FORMATTERS) - clang_format (HDF5_TOOLS_TEST_PERFORM_h5perf_serial_alone_FORMAT h5perf_serial_alone) - endif () -endif () - -#-- Adding test for chunk +#----------------------------------------------------------------------------- +# chunk +#----------------------------------------------------------------------------- set (chunk_SOURCES ${HDF5_TOOLS_TEST_PERFORM_SOURCE_DIR}/chunk.c ) diff --git a/tools/test/perform/CMakeTests.cmake b/tools/test/perform/CMakeTests.cmake index 17f4b48..ac6080b 100644 --- a/tools/test/perform/CMakeTests.cmake +++ b/tools/test/perform/CMakeTests.cmake @@ -29,6 +29,8 @@ if (HDF5_TEST_SERIAL) COMMAND ${CMAKE_COMMAND} -E remove chunk.h5 + direct_write.h5 + unix.raw iopipe.h5 iopipe.raw x-diag-rd.dat @@ -36,20 +38,6 @@ if (HDF5_TEST_SERIAL) x-rowmaj-rd.dat x-rowmaj-wr.dat x-gnuplot - h5perf_serial.txt - h5perf_serial.txt.err - chunk.txt - chunk.txt.err - iopipe.txt - iopipe.txt.err - overhead.txt - overhead.txt.err - perf_meta.txt - perf_meta.txt.err - zip_perf-h.txt - zip_perf-h.txt.err - zip_perf.txt - zip_perf.txt.err ) if (HDF5_ENABLE_USING_MEMCHECKER) @@ -72,10 +60,6 @@ if (HDF5_TEST_SERIAL) DEPENDS "PERFORM_h5perform-clearall-objects" ) - if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME PERFORM_h5perf_serial_alone COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:h5perf_serial_alone>) - endif () - if (HDF5_ENABLE_USING_MEMCHECKER) add_test (NAME PERFORM_chunk COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:chunk>) else () @@ -192,13 +176,6 @@ if (HDF5_TEST_SERIAL) endif () if (H5_HAVE_PARALLEL AND HDF5_TEST_PARALLEL) - if (UNIX) - add_test (NAME MPI_TEST_PERFORM_perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:perf> ${MPIEXEC_POSTFLAGS}) - endif () - add_test (NAME MPI_TEST_PERFORM_h5perf COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:h5perf> ${MPIEXEC_POSTFLAGS}) - if (HDF5_BUILD_PERFORM_STANDALONE) - add_test (NAME MPI_TEST_PERFORM_h5perf_alone COMMAND ${MPIEXEC_EXECUTABLE} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_PREFLAGS} $<TARGET_FILE:h5perf_alone> ${MPIEXEC_POSTFLAGS}) - endif () endif () diff --git a/tools/test/perform/build_h5perf_alone.sh b/tools/test/perform/build_h5perf_alone.sh deleted file mode 100644 index 0cbb119..0000000 --- a/tools/test/perform/build_h5perf_alone.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -x -# -# Copyright by The HDF Group. -# 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 COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Name: build_h5perf_alone.sh -# -# Puporse: Build the h5perf tool by standalone mode. -# -# Created: Albert Cheng, 2005/09/18 -# -# Modification: -# - -# Default to use h5pcc to build h5perf unless $H5CC is defined. -# -h5pcc=${H5CC:-h5pcc} -$h5pcc -DSTANDALONE pio_perf.c pio_engine.c pio_timer.c -o h5perf diff --git a/tools/test/perform/build_h5perf_serial_alone.sh b/tools/test/perform/build_h5perf_serial_alone.sh deleted file mode 100644 index 06909d0..0000000 --- a/tools/test/perform/build_h5perf_serial_alone.sh +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh -x -# -# Copyright by The HDF Group. -# 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 COPYING file, which can be found at the root of the source code -# distribution tree, or in https://www.hdfgroup.org/licenses. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# -# Name: build_h5perf_serial_alone.sh -# -# Puporse: Build the h5perf_serial tool by standalone mode. -# -# Created: Christian Chilan, 2008/09/02 -# -# Modification: -# - -# Default to use h5cc to build h5perf_serial unless $H5CC is defined. -# -h5cc=${H5CC:-h5cc} -$h5cc -DSTANDALONE sio_perf.c sio_engine.c sio_timer.c -o h5perf_serial diff --git a/tools/test/perform/chunk.c b/tools/test/perform/chunk.c index e4a25ab..27ada87 100644 --- a/tools/test/perform/chunk.c +++ b/tools/test/perform/chunk.c @@ -20,15 +20,12 @@ */ /* See H5private.h for how to include headers */ -#undef NDEBUG #include "hdf5.h" -#ifdef H5_STDC_HEADERS #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#endif /* Solaris Studio defines attribute, but for the attributes we need */ #if !defined(H5_HAVE_ATTRIBUTE) || defined __cplusplus || defined(__SUNPRO_C) diff --git a/tools/test/perform/direct_write_perf.c b/tools/test/perform/direct_write_perf.c index f142d0a..0d94cf5 100644 --- a/tools/test/perform/direct_write_perf.c +++ b/tools/test/perform/direct_write_perf.c @@ -22,31 +22,27 @@ #if !defined(WIN32) && !defined(__MINGW32__) -#include <math.h> - -#ifdef H5_STDC_HEADERS #include <errno.h> #include <fcntl.h> +#include <math.h> #include <stdio.h> #include <stdlib.h> -#endif - -#ifdef H5_HAVE_UNISTD_H -#include <sys/types.h> -#include <unistd.h> -#endif +#include <time.h> #ifdef H5_HAVE_SYS_STAT_H #include <sys/stat.h> #endif -#if defined(H5_TIME_WITH_SYS_TIME) +#ifdef H5_HAVE_SYS_TIME_H #include <sys/time.h> -#include <time.h> -#elif defined(H5_HAVE_SYS_TIME_H) -#include <sys/time.h> -#else -#include <time.h> +#endif + +#ifdef H5_HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif + +#ifdef H5_HAVE_UNISTD_H +#include <unistd.h> #endif const char *FILENAME[] = {"direct_write", "unix.raw", NULL}; @@ -54,8 +50,7 @@ const char *FILENAME[] = {"direct_write", "unix.raw", NULL}; /* * Print the current location on the standard output stream. */ -#define FUNC __func__ -#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, FUNC); +#define AT() printf(" at %s:%d in %s()...\n", __FILE__, __LINE__, __func__); #define H5_FAILED() \ { \ puts("*FAILED*"); \ @@ -659,7 +654,7 @@ main(void) hid_t fapl = H5P_DEFAULT; int i; - sprintf(filename, "%s.h5", FILENAME[0]); + snprintf(filename, sizeof(filename), "%s.h5", FILENAME[0]); create_file(fapl); test_direct_write_uncompressed_data(fapl); diff --git a/tools/test/perform/iopipe.c b/tools/test/perform/iopipe.c index 8e09308..b8ce4c0 100644 --- a/tools/test/perform/iopipe.c +++ b/tools/test/perform/iopipe.c @@ -94,7 +94,6 @@ print_stats(const char *prefix, static void synchronize(void) { -#ifdef H5_HAVE_SYSTEM #if defined(H5_HAVE_WIN32_API) && !defined(__CYGWIN__) _flushall(); #else @@ -106,7 +105,6 @@ synchronize(void) status = HDsystem("df >/dev/null"); HDassert(status >= 0); #endif -#endif } /*------------------------------------------------------------------------- diff --git a/tools/test/perform/overhead.c b/tools/test/perform/overhead.c index 5a4c533..eb57408 100644 --- a/tools/test/perform/overhead.c +++ b/tools/test/perform/overhead.c @@ -22,17 +22,11 @@ #include "hdf5.h" #include "H5private.h" -#ifdef H5_STDC_HEADERS #include <ctype.h> #include <fcntl.h> #include <stdlib.h> #include <sys/stat.h> #include <string.h> -#endif - -#ifdef H5_HAVE_IO_H -#include <io.h> -#endif #ifdef H5_HAVE_UNISTD_H #include <sys/types.h> diff --git a/tools/test/perform/perf_meta.c b/tools/test/perform/perf_meta.c index f60f82f..94fe849 100644 --- a/tools/test/perform/perf_meta.c +++ b/tools/test/perform/perf_meta.c @@ -303,7 +303,7 @@ create_dsets(hid_t file) * Create a dataset using the default dataset creation properties. */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error; @@ -365,14 +365,14 @@ create_attrs_1(void) * Create all(user specifies the number) attributes for each dataset */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); open_t.start = retrieve_time(); if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); for (j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -467,7 +467,7 @@ create_attrs_2(void) * Create all(user specifies the number) attributes for each new dataset */ for (i = 0; i < NUM_DSETS; i++) { - HDsprintf(dset_name, "dataset %d", i); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", i); create_t.start = retrieve_time(); if ((dataset = H5Dcreate2(file, dset_name, H5T_NATIVE_DOUBLE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -475,7 +475,7 @@ create_attrs_2(void) perf(&create_t, create_t.start, retrieve_time()); for (j = 0; j < NUM_ATTRS; j++) { - HDsprintf(attr_name, "all attrs for each dset %d", j); + HDsnprintf(attr_name, sizeof(attr_name), "all attrs for each dset %d", j); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) @@ -578,14 +578,14 @@ create_attrs_3(void) for (i = 0; i < loop_num; i++) { for (j = 0; j < NUM_DSETS; j++) { - HDsprintf(dset_name, "dataset %d", j); + HDsnprintf(dset_name, sizeof(dset_name), "dataset %d", j); open_t.start = retrieve_time(); if ((dataset = H5Dopen2(file, dset_name, H5P_DEFAULT)) < 0) goto error; perf(&open_t, open_t.start, retrieve_time()); for (k = 0; k < BATCH_ATTRS; k++) { - HDsprintf(attr_name, "some attrs for each dset %d %d", i, k); + HDsnprintf(attr_name, sizeof(attr_name), "some attrs for each dset %d %d", i, k); attr_t.start = retrieve_time(); if ((attr = H5Acreate2(dataset, attr_name, H5T_NATIVE_DOUBLE, small_space, H5P_DEFAULT, H5P_DEFAULT)) < 0) diff --git a/tools/test/perform/pio_standalone.c b/tools/test/perform/pio_standalone.c deleted file mode 100644 index b4680a4..0000000 --- a/tools/test/perform/pio_standalone.c +++ /dev/null @@ -1,159 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * 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 "pio_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 *const *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); -} diff --git a/tools/test/perform/pio_standalone.h b/tools/test/perform/pio_standalone.h deleted file mode 100644 index 093247c..0000000 --- a/tools/test/perform/pio_standalone.h +++ /dev/null @@ -1,493 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef PIO_STANDALONE_H -#define PIO_STANDALONE_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 - -/* - * 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) -#ifdef H5_HAVE_WIN32_API -#define HDaccess(F, M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F, M) access(F, M) -#ifndef F_OK -#define F_OK 00 -#define W_OK 02 -#define R_OK 04 -#endif -#endif /* H5_HAVE_WIN32_API */ -#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 HDasprintf asprintf /*varargs*/ -#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 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) -#define HD_exit(N) _exit(N) -#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 H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) -#else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) -#endif /* H5_HAVE_WIN32_API */ -#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) -#define HDfprintf fprintf -#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 H5_HAVE_WIN32_API -#define HDfstat(F, B) _fstati64(F, B) -#define HDlstat(S, B) _lstati64(S, B) -#define HDstat(S, B) _stati64(S, B) -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; -#define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) -#define HDfstat(F, B) fstat64(F, B) -#define HDlstat(S, B) lstat64(S, B) -#define HDstat(S, B) stat64(S, B) -typedef struct stat64 h5_stat_t; -typedef off64_t h5_stat_size_t; -#define HDoff_t off64_t -#else -#define HDfstat(F, B) fstat(F, B) -#define HDlstat(S, B) lstat(S, B) -#define HDstat(S, B) stat(S, B) -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; -#define HDoff_t off_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) -#ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() -#else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() -#endif /* H5_HAVE_WIN32_API */ -#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) -/* Don't define a macro for gets() - it was removed in C11 */ -#ifdef H5_HAVE_WIN32_API -H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) -#else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S, P) gettimeofday(S, P) -#endif /* H5_HAVE_WIN32_API */ -#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 H5_HAVE_WIN32_API -#define HDlseek(F, O, W) _lseeki64(F, O, W) -#else -#ifdef H5_HAVE_LSEEK64 -#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 H5_HAVE_VISUAL_STUDIO - */ -#ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X, C, Z) memset((void *)(X), C, Z) -#else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X, C, Z) memset(X, C, Z) -#endif /* H5_HAVE_VISUAL_STUDIO */ -#ifdef H5_HAVE_WIN32_API -#define HDmkdir(S, M) _mkdir(S) -#else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S, M) mkdir(S, M) -#endif /* H5_HAVE_WIN32_API */ -#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 HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#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) -#define HDremove(S) remove(S) -#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 H5_HAVE_WIN32_API -#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 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) -#define HDsnprintf snprintf /*varargs*/ -#define HDsprintf sprintf /*varargs*/ -#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 - -#ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A, B) _stricmp(A, B) -#else -#define HDstrcasecmp(X, Y) strcasecmp(X, Y) -#endif -#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) -#ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S, R, N) _strtoui64(S, R, N) -#else -#define HDstrtoull(S, R, N) strtoull(S, R, N) -#endif -#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 H5_HAVE_WIN32_API -#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) -#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) -#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) -#define HDwrite(F, M, Z) write(F, M, Z) - -/* - * And now for a couple non-Posix functions... Watch out for systems that - * define these in terms of macros. - */ -#ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) -#else /* H5_HAVE_WIN32_API */ - -#if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); -#endif - -#define HDstrdup(S) strdup(S) - -#endif /* H5_HAVE_WIN32_API */ - -/* - * HDF Boolean type. - */ -#ifndef FALSE -#define FALSE false -#endif -#ifndef TRUE -#define TRUE true -#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 h5_arg_level { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ -}; - -struct long_options { - const char *name; /* Name of the long option */ - enum h5_arg_level has_arg; /* Whether we should look for an arg */ - char shortval; /* The shortname equivalent of long arg - * this gets returned from get_option - */ -}; - -extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt); - -extern int nCols; /*max number of columns for outputting */ - -/* Definitions of useful routines */ -extern void print_version(const char *progname); - -#endif diff --git a/tools/test/perform/sio_standalone.c b/tools/test/perform/sio_standalone.c deleted file mode 100644 index 21a2fb5..0000000 --- a/tools/test/perform/sio_standalone.c +++ /dev/null @@ -1,159 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * 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 *const *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); -} diff --git a/tools/test/perform/sio_standalone.h b/tools/test/perform/sio_standalone.h deleted file mode 100644 index b46af62..0000000 --- a/tools/test/perform/sio_standalone.h +++ /dev/null @@ -1,508 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://www.hdfgroup.org/licenses. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef SIO_STANDALONE_H -#define SIO_STANDALONE_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)) - -#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON) -#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON) -#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON) - -#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M)) -#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M)) -#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M)) - -/* - * 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) -#ifdef H5_HAVE_WIN32_API -#define HDaccess(F, M) _access(F, M) -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#else /* H5_HAVE_WIN32_API */ -#define HDaccess(F, M) access(F, M) -#ifndef F_OK -#define F_OK 00 -#define W_OK 02 -#define R_OK 04 -#endif -#endif /* H5_HAVE_WIN32_API */ -#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 HDasprintf asprintf /*varargs*/ -#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 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) -#define HD_exit(N) _exit(N) -#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 H5_HAVE_WIN32_API -#define HDfileno(F) _fileno(F) -#else /* H5_HAVE_WIN32_API */ -#define HDfileno(F) fileno(F) -#endif /* H5_HAVE_WIN32_API */ -#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) -#define HDfprintf fprintf -#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 H5_HAVE_WIN32_API -#define HDfstat(F, B) _fstati64(F, B) -#define HDlstat(S, B) _lstati64(S, B) -#define HDstat(S, B) _stati64(S, B) -typedef struct _stati64 h5_stat_t; -typedef __int64 h5_stat_size_t; -#define HDoff_t __int64 -#elif H5_SIZEOF_OFF_T != 8 && H5_SIZEOF_OFF64_T == 8 && defined(H5_HAVE_STAT64) -#define HDfstat(F, B) fstat64(F, B) -#define HDlstat(S, B) lstat64(S, B) -#define HDstat(S, B) stat64(S, B) -typedef struct stat64 h5_stat_t; -typedef off64_t h5_stat_size_t; -#define HDoff_t off64_t -#else -#define HDfstat(F, B) fstat(F, B) -#define HDlstat(S, B) lstat(S, B) -#define HDstat(S, B) stat(S, B) -typedef struct stat h5_stat_t; -typedef off_t h5_stat_size_t; -#define HDoff_t off_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) -#ifdef H5_HAVE_WIN32_API -#define HDgetlogin() Wgetlogin() -#else /* H5_HAVE_WIN32_API */ -#define HDgetlogin() getlogin() -#endif /* H5_HAVE_WIN32_API */ -#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) -/* Don't define a macro for gets() - it was removed in C11 */ -#ifdef H5_HAVE_WIN32_API -H5_DLL int Wgettimeofday(struct timeval *tv, struct timezone *tz); -#define HDgettimeofday(V, Z) Wgettimeofday(V, Z) -#else /* H5_HAVE_WIN32_API */ -#define HDgettimeofday(S, P) gettimeofday(S, P) -#endif /* H5_HAVE_WIN32_API */ -#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 H5_HAVE_WIN32_API -#define HDlseek(F, O, W) _lseeki64(F, O, W) -#else -#ifdef H5_HAVE_LSEEK64 -#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 H5_HAVE_VISUAL_STUDIO - */ -#ifdef H5_HAVE_VISUAL_STUDIO -#define HDmemset(X, C, Z) memset((void *)(X), C, Z) -#else /* H5_HAVE_VISUAL_STUDIO */ -#define HDmemset(X, C, Z) memset(X, C, Z) -#endif /* H5_HAVE_VISUAL_STUDIO */ -#ifdef H5_HAVE_WIN32_API -#define HDmkdir(S, M) _mkdir(S) -#else /* H5_HAVE_WIN32_API */ -#define HDmkdir(S, M) mkdir(S, M) -#endif /* H5_HAVE_WIN32_API */ -#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 HDprintf(...) HDfprintf(stdout, __VA_ARGS__) -#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) -#define HDremove(S) remove(S) -#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 H5_HAVE_WIN32_API -#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 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) -#define HDsnprintf snprintf /*varargs*/ -#define HDsprintf sprintf /*varargs*/ -#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 - -#ifdef H5_HAVE_WIN32_API -#define HDstrcasecmp(A, B) _stricmp(A, B) -#else -#define HDstrcasecmp(X, Y) strcasecmp(X, Y) -#endif -#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) -#ifdef H5_HAVE_WIN32_API -#define HDstrtoull(S, R, N) _strtoui64(S, R, N) -#else -#define HDstrtoull(S, R, N) strtoull(S, R, N) -#endif -#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 H5_HAVE_WIN32_API -#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) -#define HDvsnprintf(S, N, FMT, A) vsnprintf(S, N, FMT, A) -#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) -#define HDwrite(F, M, Z) write(F, M, Z) - -/* - * And now for a couple non-Posix functions... Watch out for systems that - * define these in terms of macros. - */ -#ifdef H5_HAVE_WIN32_API -#define HDstrdup(S) _strdup(S) -#else /* H5_HAVE_WIN32_API */ - -#if !defined strdup && !defined H5_HAVE_STRDUP -extern char *strdup(const char *s); -#endif - -#define HDstrdup(S) strdup(S) - -#endif /* H5_HAVE_WIN32_API */ - -/* - * HDF Boolean type. - */ -#ifndef FALSE -#define FALSE false -#endif -#ifndef TRUE -#define TRUE true -#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 h5_arg_level { - no_arg = 0, /* doesn't take an argument */ - require_arg, /* requires an argument */ - optional_arg /* argument is optional */ -}; - -struct long_options { - const char *name; /* Name of the long option */ - enum h5_arg_level has_arg; /* Whether we should look for an arg */ - char shortval; /* The shortname equivalent of long arg - * this gets returned from get_option - */ -}; - -extern int get_option(int argc, const char *const *argv, const char *opt, const struct long_options *l_opt); - -extern int nCols; /*max number of columns for outputting */ - -/* Definitions of useful routines */ -extern void print_version(const char *progname); - -#endif diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index 7820582..3cfe2cc 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -86,7 +86,9 @@ error(const char *fmt, ...) va_start(ap, fmt); HDfprintf(stderr, "%s: error: ", prog); + H5_GCC_CLANG_DIAG_OFF("format-nonliteral") HDvfprintf(stderr, fmt, ap); + H5_GCC_CLANG_DIAG_ON("format-nonliteral") HDfprintf(stderr, "\n"); va_end(ap); HDexit(EXIT_FAILURE); @@ -335,8 +337,8 @@ parse_size_directive(const char *size) static void fill_with_random_data(Bytef *src, uLongf src_len) { - register unsigned u; - h5_stat_t stat_buf; + unsigned u; + h5_stat_t stat_buf; if (HDstat("/dev/urandom", &stat_buf) == 0) { uLongf len = src_len; @@ -385,7 +387,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, unsigned long Bytef *src; for (src_len = min_buf_size; src_len <= max_buf_size; src_len <<= 1) { - register unsigned long i, iters; + unsigned long i, iters; iters = file_size / src_len; src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); |