summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-08-15 00:16:11 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-08-15 00:16:11 (GMT)
commit62c296f1eb69255c5140a675270b11b5b265a220 (patch)
tree704a648065d1b20586457843958606b1ff37bb0f /examples
parent5a61eb24af840b45105f71da4ea4edc7062e24d9 (diff)
downloadhdf5-62c296f1eb69255c5140a675270b11b5b265a220.zip
hdf5-62c296f1eb69255c5140a675270b11b5b265a220.tar.gz
hdf5-62c296f1eb69255c5140a675270b11b5b265a220.tar.bz2
Brings monotonic timer changes from develop
Diffstat (limited to 'examples')
-rw-r--r--examples/CMakeLists.txt1
-rw-r--r--examples/Makefile.am21
-rw-r--r--examples/h5_debug_trace.c144
-rw-r--r--examples/run-c-ex.sh.in5
4 files changed, 161 insertions, 10 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 8383ba2..bc9a445 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -29,6 +29,7 @@ set (examples
h5_extlink
h5_elink_unix2win
h5_shared_mesg
+ h5_debug_trace
h5_vds
h5_vds-exc
h5_vds-exclim
diff --git a/examples/Makefile.am b/examples/Makefile.am
index 12ec52a..adc86ed 100644
--- a/examples/Makefile.am
+++ b/examples/Makefile.am
@@ -35,22 +35,23 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \
h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \
h5_crtatt h5_crtgrp h5_crtdat \
h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \
- h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \
- h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \
+ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_debug_trace \
+ h5_vds h5_vds-exc h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \
h5_vds-percival-unlim h5_vds-percival-unlim-maxmin
TEST_SCRIPT=testh5cc.sh
TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES)
# Install files
# List all file that should be installed in examples directory
-INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \
- h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c \
- h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
- h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \
- h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \
- h5_ref2reg.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \
- h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \
- h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
+INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c h5_compound.c \
+ h5_crtgrpd.c h5_subset.c h5_cmprss.c h5_rdwt.c h5_crtgrpar.c h5_extend.c \
+ h5_crtatt.c h5_crtgrp.c h5_crtdat.c \
+ h5_group.c h5_select.c h5_attribute.c h5_mount.c h5_drivers.c \
+ h5_reference.c h5_ref2reg.c \
+ h5_extlink.c h5_elink_unix2win.c h5_shared_mesg.c h5_debug_trace.c \
+ ph5example.c \
+ h5_vds.c h5_vds-exc.c h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c \
+ h5_vds-percival.c h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c
diff --git a/examples/h5_debug_trace.c b/examples/h5_debug_trace.c
new file mode 100644
index 0000000..5da55ed
--- /dev/null
+++ b/examples/h5_debug_trace.c
@@ -0,0 +1,144 @@
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ * Copyright by The HDF Group. *
+ * Copyright by the Board of Trustees of the University of Illinois. *
+ * All rights reserved. *
+ * *
+ * This file is part of HDF5. The full HDF5 copyright notice, including *
+ * terms governing use, modification, and redistribution, is contained in *
+ * the files COPYING and Copyright.html. COPYING can be found at the root *
+ * of the source code distribution tree; Copyright.html can be found at the *
+ * root level of an installed copy of the electronic HDF5 document set and *
+ * is linked from the top-level documents page. It can also be found at *
+ * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
+ * access to either file, you may request a copy from help@hdfgroup.org. *
+ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* This example demonstrates debug trace output.
+ *
+ * Debug/trace/performance output is not tested as a regular part of our
+ * testing so this program gives a quick check that it's all working.
+ *
+ * Preconditions:
+ *
+ * You need to set an environment variable named HDF5_DEBUG to have a value
+ * of "+all trace ttimes". In the bash shell, you'd use:
+ *
+ * export HDF5_DEBUG="+all trace ttimes"
+ *
+ * When you are done with this test program, you can set the variable back
+ * to "-all" to suppress trace output.
+ *
+ * Usage:
+ *
+ * Compile and run the test program, then inspect the output. You should see
+ * trace information for each HDF5 function call that increase over time.
+ * Each time stamp is in seconds and designated with an '@' sign. The
+ * elapsed time for the function call is given in seconds in the [dt= ]
+ * part.
+ *
+ * You will also get summary output for the shuffle filter performance and
+ * data type conversion performance. These will include the elapsed time
+ * (always) and the system and user times (if available on your system). On
+ * fast machines, these numbers may be 0.0. Adjust the loop variables in
+ * the program as needed to generate reasonable output.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "hdf5.h"
+
+#define BUF_SIZE 1048576
+#define N_LOOPS 64
+
+#define TESTFILE "h5_debug_trace_out.h5"
+
+int
+main(int argc, char **argv)
+{
+ int i, j;
+ int *data;
+
+ hid_t fid;
+ hid_t pid;
+ hid_t did;
+ hid_t sid;
+
+ hsize_t dims[1] = { BUF_SIZE };
+ hsize_t chunk_sizes[1] = { 1024 };
+
+ herr_t err;
+
+ /*************************************************************************/
+
+ /* Warn the user about trace deluge to come */
+
+ printf("Testing debug/trace/performance data generation\n");
+ printf("\n");
+ printf("This test should generate a large amount of trace data\n");
+ printf("\n");
+ printf("*** BEGIN TRACE OUTPUT ***\n");
+ printf("\n");
+ fflush(stdout);
+
+ /* This will emit H5Tconvert() performance information */
+
+ for(i = 0; i < N_LOOPS; i++) {
+
+ /* The buffer has to be large enough to hold the conversion output */
+ data = (int *)malloc(BUF_SIZE * sizeof(double));
+
+ for(j = 0; j < BUF_SIZE; j++) {
+ data[j] = j;
+ }
+
+ err = H5Tconvert(H5T_NATIVE_INT, H5T_NATIVE_DOUBLE, BUF_SIZE, data,
+ NULL, H5P_DEFAULT);
+
+ if(err < 0) {
+ fprintf(stderr, "ERROR: Conversion failed\n");
+ free(data);
+ return err;
+ }
+
+ free(data);
+
+ }
+
+
+ /* This will emit H5Z performance information */
+
+ data = (int *)malloc(BUF_SIZE * sizeof(int));
+
+ for(i = 0; i < BUF_SIZE; i++) {
+ data[i] = i;
+ }
+
+ fid = H5Fcreate(TESTFILE, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ pid = H5Pcreate(H5P_DATASET_CREATE);
+ err = H5Pset_chunk(pid, 1, chunk_sizes);
+ err = H5Pset_shuffle(pid);
+
+ sid = H5Screate_simple(1, dims, dims);
+ did = H5Dcreate2(fid, "somedata", H5T_NATIVE_INT, sid, H5P_DEFAULT, pid, H5P_DEFAULT);
+ err = H5Dwrite(did, H5T_NATIVE_INT, sid, sid, H5P_DEFAULT, data);
+
+ H5Sclose(sid);
+ H5Dclose(did);
+ H5Pclose(pid);
+ H5Fclose(fid);
+
+ free(data);
+
+ /* Finished */
+ fflush(stdout);
+ printf("\n");
+ printf("*** END TRACE OUTPUT ***\n");
+ printf("\n");
+
+ remove(TESTFILE);
+
+ return 0;
+}
+
diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in
index b5ec561..1990ad9 100644
--- a/examples/run-c-ex.sh.in
+++ b/examples/run-c-ex.sh.in
@@ -145,6 +145,11 @@ then
rm h5_extlink &&\
RunTest h5_elink_unix2win &&\
rm h5_elink_unix2win &&\
+ OLD_DEBUG_STRING=$HDF5_DEBUG &&\
+ export HDF5_DEBUG="+all +trace +ttimes" &&\
+ RunTest h5_debug_trace &&\
+ HDF5_DEBUG=$OLD_DEBUG_STRING &&\
+ rm h5_debug_trace &&\
RunTest h5_shared_mesg &&\
rm h5_shared_mesg &&\
RunTest h5_vds-eiger &&\