Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 67 additions & 10 deletions BITGROOM/config/cmake/binex/example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ foreach (example ${dyn_examples})
endforeach ()

if (H5PL_BUILD_TESTING)
# h5repack test input generator. Target name is plugin-suffixed because the
# BITROUND and BITGROOM trees share the same CMake project and source file
# basename (issue #240).
add_executable (h5repack_floats_bitgroom ${PROJECT_SOURCE_DIR}/h5repack_floats.c)
target_include_directories(h5repack_floats_bitgroom PRIVATE ${H5PL_HDF5_INCLUDE_DIRS})
TARGET_C_PROPERTIES (h5repack_floats_bitgroom ${LIB_TYPE})
target_link_libraries (h5repack_floats_bitgroom PRIVATE ${H5PL_HDF5_LINK_LIBS})
if (NOT WIN32)
target_link_libraries (h5repack_floats_bitgroom PRIVATE ${CMAKE_DL_LIBS})
endif ()

macro (ADD_H5_TEST testname)
add_test (
NAME ${testname}-clearall
Expand Down Expand Up @@ -121,21 +132,47 @@ if (H5PL_BUILD_TESTING)
NAME H5BITGROOM_UD-${testname}-clearall-objects
COMMAND ${CMAKE_COMMAND}
-E remove
${resultfile}
out-${testname}.${resultfile}
${testname}.${resultfile}.out
${testname}.${resultfile}.out.err
${resultfile}-${testname}.out
${resultfile}-${testname}.out.err
${resultfile}-${testname}-data.out
${resultfile}-${testname}-data.out.err
)
if (NOT "${last_test}" STREQUAL "")
set_tests_properties (H5BITGROOM_UD-${testname}-clearall-objects PROPERTIES DEPENDS ${last_test})
endif ()
set (last_test "H5BITGROOM_UD-${testname}-clearall-objects")
if (WIN32)
set (${TESTLIBDIR} "${HDF5_TOOLS_DIR}")
set (TESTLIBDIR "${HDF5_TOOLS_DIR}")
else ()
set (${TESTLIBDIR} "${HDF5_LIBRARY_PATH}")
set (TESTLIBDIR "${HDF5_LIBRARY_PATH}")
endif ()
# Generate the float-data input file for h5repack. The BitGroom filter's
# set_local() callback removes the filter from the pipeline on non-float
# datasets, so the input must contain float data for the test to actually
# exercise the filter (issue #240). Routed through runTest.cmake so
# PATH/DYLD_LIBRARY_PATH/LD_LIBRARY_PATH are set up for the helper to find
# the HDF5 runtime library on every platform (Windows in particular has
# no rpath equivalent and reports STATUS_DLL_NOT_FOUND if the HDF5 DLL is
# not on PATH).
add_test (
NAME H5BITGROOM_UD-${testname}-gen-input
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=$<TARGET_FILE:h5repack_floats_bitgroom>"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-D "TEST_EXPECT=0"
-D "TEST_OUTPUT=h5repack_floats_bitgroom.out"
-D "TEST_SKIP_COMPARE=1"
-D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR}"
-P "${H5PL_RESOURCES_DIR}/runTest.cmake"
)
set_tests_properties (H5BITGROOM_UD-${testname}-gen-input PROPERTIES
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
DEPENDS H5BITGROOM_UD-${testname}-clearall-objects)
set (last_test "H5BITGROOM_UD-${testname}-gen-input")
if (HDF5_BUILD_TOOLS OR HDF5_PROVIDES_TOOLS)
add_test (
NAME H5BITGROOM_UD-${testname}
Expand All @@ -150,7 +187,7 @@ if (H5PL_BUILD_TESTING)
-D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR}"
-P "${H5PL_RESOURCES_DIR}/runTest.cmake"
)
set_tests_properties (H5BITGROOM_UD-${testname} PROPERTIES DEPENDS H5BITGROOM_UD-${testname}-clearall-objects)
set_tests_properties (H5BITGROOM_UD-${testname} PROPERTIES DEPENDS H5BITGROOM_UD-${testname}-gen-input)
add_test (
NAME H5BITGROOM_UD-h5dump-${testname}
COMMAND "${CMAKE_COMMAND}"
Expand All @@ -167,23 +204,43 @@ if (H5PL_BUILD_TESTING)
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
DEPENDS H5BITGROOM_UD-${testname})
set (last_test "H5BITGROOM_UD-h5dump-${testname}")
# Verify that the filter actually modifies the dataset values: dump the
# data (no -pH) and compare against a captured reference of the
# quantized output. BitGroom's encoding is bit-deterministic across
# platforms (its inner loop is pure integer bit ops, with the bit-zero
# count derived once per call from NSD via ceil() of a constant
# expression), so the captured reference is portable.
add_test (
NAME H5BITGROOM_UD-h5dump-data-${testname}
COMMAND "${CMAKE_COMMAND}"
-D "TEST_PROGRAM=${H5PL_HDF5_DUMP_EXECUTABLE}"
-D "TEST_ARGS:STRING=out-${testname}.${resultfile}"
-D "TEST_FOLDER=${PROJECT_BINARY_DIR}"
-D "TEST_OUTPUT=${resultfile}-${testname}-data.out"
-D "TEST_EXPECT=${resultcode}"
-D "TEST_REFERENCE=${resultfile}-${testname}-data.ddl"
-D "TEST_LIBRARY_DIRECTORY=${TESTLIBDIR}"
-P "${H5PL_RESOURCES_DIR}/runTest.cmake"
)
set_tests_properties (H5BITGROOM_UD-h5dump-data-${testname} PROPERTIES
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
DEPENDS H5BITGROOM_UD-h5dump-${testname})
set (last_test "H5BITGROOM_UD-h5dump-data-${testname}")
endif ()
endmacro ()

# --------------------------------------------------------------------
# Copy all the HDF5 files from the source directory into the test directory
# --------------------------------------------------------------------
set (LIST_HDF5_TEST_FILES
h5repack_layout.h5
)
set (LIST_OTHER_TEST_FILES
h5ex_d_bitgroom.ddl
h5ex_d_bitgroom.tst
h5repack_layout.h5-ud_convert.ddl
ud_convert.h5repack_layout.h5.tst
h5repack_floats.h5-ud_convert.ddl
h5repack_floats.h5-ud_convert-data.ddl
ud_convert.h5repack_floats.h5.tst
)

foreach (h5_file ${LIST_HDF5_TEST_FILES} ${LIST_OTHER_TEST_FILES})
foreach (h5_file ${LIST_OTHER_TEST_FILES})
HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "example_files")
endforeach ()
add_custom_target(example_files ALL COMMENT "Copying files needed by example tests" DEPENDS ${example_files_list})
Expand All @@ -192,7 +249,7 @@ if (H5PL_BUILD_TESTING)

if (NOT DISABLE_H5PL_ENCODER)
#UD BITGROOM
ADD_H5_UD_TEST (ud_convert 0 h5repack_layout.h5 --enable-error-stack -v -f UD=32022,0,5,3,4,0,0,0 -l CHUNK=4x8)
ADD_H5_UD_TEST (ud_convert 0 h5repack_floats.h5 --enable-error-stack -v -f UD=32022,0,5,3,4,0,0,0 -l CHUNK=4x8)
endif ()

endif ()
87 changes: 87 additions & 0 deletions BITGROOM/config/cmake/binex/example/h5repack_floats.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of the HDF5 BitGroom filter plugin source. The full *
* copyright notice, including terms governing use, modification, and *
* redistribution, is contained in the file COPYING, which can be found at *
* the root of the source code distribution tree. If you do not have access *
* to this file, you may request a copy from help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

/*
* Generates an HDF5 file with a chunked dataset of IEEE 32-bit floats and no
* filters applied. Used as input for the h5repack BitGroom test so the
* filter's set_local() callback retains the filter in the pipeline (the
* callback removes itself on non-float data). See issue #240.
*/

#include "hdf5.h"
#include <stdio.h>

#define FILENAME "h5repack_floats.h5"
#define DATASET "data"
#define DIM0 32
#define DIM1 64
#define CHUNK0 4
#define CHUNK1 8

int
main(void)
{
hid_t file_id = H5I_INVALID_HID;
hid_t space_id = H5I_INVALID_HID;
hid_t dcpl_id = H5I_INVALID_HID;
hid_t dset_id = H5I_INVALID_HID;
hsize_t dims[2] = {DIM0, DIM1};
hsize_t chunk[2] = {CHUNK0, CHUNK1};
float wdata[DIM0][DIM1];
int i, j;
int ret_value = 1;

/* Non-integer floats: the 0.137f multiplier ensures every value carries
* non-trivial mantissa bits, so quantization by BitGroom is visible
* across the entire dataset rather than only on values that exceed the
* retained mantissa width. */
for (i = 0; i < DIM0; i++)
for (j = 0; j < DIM1; j++)
wdata[i][j] = ((float)(i * j) - (float)j) * 0.137f;

file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
if (file_id < 0)
goto done;

space_id = H5Screate_simple(2, dims, NULL);
if (space_id < 0)
goto done;

dcpl_id = H5Pcreate(H5P_DATASET_CREATE);
if (dcpl_id < 0)
goto done;
if (H5Pset_chunk(dcpl_id, 2, chunk) < 0)
goto done;

dset_id = H5Dcreate(file_id, DATASET, H5T_IEEE_F32LE, space_id, H5P_DEFAULT, dcpl_id, H5P_DEFAULT);
if (dset_id < 0)
goto done;

if (H5Dwrite(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, (void *)wdata) < 0)
goto done;

ret_value = 0;

done:
if (dset_id >= 0)
H5Dclose(dset_id);
if (dcpl_id >= 0)
H5Pclose(dcpl_id);
if (space_id >= 0)
H5Sclose(space_id);
if (file_id >= 0)
H5Fclose(file_id);

if (ret_value != 0)
fprintf(stderr, "h5repack_floats: failed to create %s\n", FILENAME);

return ret_value;
}
Loading
Loading