From 94e0a476bed94beb3bc1712ee7fd0594b5de3d02 Mon Sep 17 00:00:00 2001 From: Peter Lindstrom Date: Fri, 19 Oct 2018 16:04:15 -0700 Subject: [PATCH 001/194] Fix incorrect handling of parallel decompression --- utils/zfp.c | 53 ++++++++--------------------------------------------- 1 file changed, 8 insertions(+), 45 deletions(-) diff --git a/utils/zfp.c b/utils/zfp.c index d4f4cf6f5..e8bc3de1f 100644 --- a/utils/zfp.c +++ b/utils/zfp.c @@ -275,8 +275,6 @@ int main(int argc, char* argv[]) usage(); if (!strcmp(argv[i], "serial")) exec = zfp_exec_serial; - else if (!strcmp(argv[i], "cuda")) - exec = zfp_exec_cuda; else if (sscanf(argv[i], "omp=%u,%u", &threads, &chunk_size) == 2) exec = zfp_exec_omp; else if (sscanf(argv[i], "omp=%u", &threads) == 1) { @@ -288,6 +286,8 @@ int main(int argc, char* argv[]) threads = 0; chunk_size = 0; } + else if (!strcmp(argv[i], "cuda")) + exec = zfp_exec_cuda; else usage(); break; @@ -448,6 +448,12 @@ int main(int argc, char* argv[]) /* specify execution policy */ switch (exec) { + case zfp_exec_cuda: + if (!zfp_stream_set_execution(zfp, exec)) { + fprintf(stderr, "cuda execution not available\n"); + return EXIT_FAILURE; + } + break; case zfp_exec_omp: if (!zfp_stream_set_execution(zfp, exec) || !zfp_stream_set_omp_threads(zfp, threads) || @@ -487,30 +493,6 @@ int main(int argc, char* argv[]) } zfp_stream_set_bit_stream(zfp, stream); - /* specify execution policy */ - switch (exec) { - case zfp_exec_omp: - if (!zfp_stream_set_execution(zfp, exec) || - !zfp_stream_set_omp_threads(zfp, threads) || - !zfp_stream_set_omp_chunk_size(zfp, chunk_size)) { - fprintf(stderr, "OpenMP execution not available\n"); - return EXIT_FAILURE; - } - break; - case zfp_exec_cuda: - if (!zfp_stream_set_execution(zfp, exec)) { - fprintf(stderr, "cuda execution not available\n"); - return EXIT_FAILURE; - } - case zfp_exec_serial: - default: - if (!zfp_stream_set_execution(zfp, exec)) { - fprintf(stderr, "serial execution not available\n"); - return EXIT_FAILURE; - } - break; - } - /* optionally write header */ if (header && !zfp_write_header(zfp, field, ZFP_HEADER_FULL)) { fprintf(stderr, "cannot write header\n"); @@ -566,25 +548,6 @@ int main(int argc, char* argv[]) nw = MAX(field->nw, 1u); } - /* specify execution policy */ - switch (exec) { - case zfp_exec_omp: - fprintf(stderr, "OpenMP decompression not available\n"); - return EXIT_FAILURE; - case zfp_exec_cuda: - if (!zfp_stream_set_execution(zfp, exec)) { - fprintf(stderr, "cuda execution not available\n"); - return EXIT_FAILURE; - } - case zfp_exec_serial: - default: - if (!zfp_stream_set_execution(zfp, exec)) { - fprintf(stderr, "serial execution not available\n"); - return EXIT_FAILURE; - } - break; - } - /* allocate memory for decompressed data */ rawsize = typesize * count; fo = malloc(rawsize); From d1584219613b9d0553cf538c93c2306b800e952f Mon Sep 17 00:00:00 2001 From: lindstro Date: Wed, 24 Oct 2018 03:38:56 -0700 Subject: [PATCH 002/194] Remove dead code in (de)compress.c --- src/template/compress.c | 19 ------------------- src/template/decompress.c | 19 ------------------- 2 files changed, 38 deletions(-) diff --git a/src/template/compress.c b/src/template/compress.c index 6a4b370c8..037157675 100644 --- a/src/template/compress.c +++ b/src/template/compress.c @@ -14,24 +14,6 @@ _t2(compress, Scalar, 1)(zfp_stream* stream, const zfp_field* field) _t2(zfp_encode_partial_block_strided, Scalar, 1)(stream, data, nx - x, 1); } -#if 0 -/* compress 1d strided array */ -static void -_t2(compress_strided, Scalar, 1)(zfp_stream* stream, const zfp_field* field) -{ - const Scalar* data = (const Scalar*)field->data; - uint nx = field->nx; - uint mx = nx & ~3u; - int sx = field->sx ? field->sx : 1; - uint x; - - /* compress array one block of 4 values at a time */ - for (x = 0; x < mx; x += 4, data += 4 * sx) - _t2(zfp_encode_block_strided, Scalar, 1)(stream, data, sx); - if (x < nx) - _t2(zfp_encode_partial_block_strided, Scalar, 1)(stream, data, nx - x, sx); -} -#else /* compress 1d strided array */ static void _t2(compress_strided, Scalar, 1)(zfp_stream* stream, const zfp_field* field) @@ -50,7 +32,6 @@ _t2(compress_strided, Scalar, 1)(zfp_stream* stream, const zfp_field* field) _t2(zfp_encode_block_strided, Scalar, 1)(stream, p, sx); } } -#endif /* compress 2d strided array */ static void diff --git a/src/template/decompress.c b/src/template/decompress.c index db7bb512f..58c28132a 100644 --- a/src/template/decompress.c +++ b/src/template/decompress.c @@ -14,24 +14,6 @@ _t2(decompress, Scalar, 1)(zfp_stream* stream, zfp_field* field) _t2(zfp_decode_partial_block_strided, Scalar, 1)(stream, data, nx - x, 1); } -#if 0 -/* decompress 1d strided array */ -static void -_t2(decompress_strided, Scalar, 1)(zfp_stream* stream, zfp_field* field) -{ - Scalar* data = (Scalar*)field->data; - uint nx = field->nx; - uint mx = nx & ~3u; - int sx = field->sx ? field->sx : 1; - uint x; - - /* decompress array one block of 4 values at a time */ - for (x = 0; x < mx; x += 4, data += 4 * sx) - _t2(zfp_decode_block_strided, Scalar, 1)(stream, data, sx); - if (x < nx) - _t2(zfp_decode_partial_block_strided, Scalar, 1)(stream, data, nx - x, sx); -} -#else /* decompress 1d strided array */ static void _t2(decompress_strided, Scalar, 1)(zfp_stream* stream, zfp_field* field) @@ -50,7 +32,6 @@ _t2(decompress_strided, Scalar, 1)(zfp_stream* stream, zfp_field* field) _t2(zfp_decode_block_strided, Scalar, 1)(stream, p, sx); } } -#endif /* decompress 2d strided array */ static void From 7728d98dc8a6fd77e265415e4086d2034ea80e20 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 25 Oct 2018 08:57:33 -0700 Subject: [PATCH 003/194] Fix broken decompression with header in zfp utility --- utils/zfp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/zfp.c b/utils/zfp.c index e8bc3de1f..3d42e9b8c 100644 --- a/utils/zfp.c +++ b/utils/zfp.c @@ -306,7 +306,7 @@ int main(int argc, char* argv[]) count = (size_t)nx * (size_t)ny * (size_t)nz * (size_t)nw; /* make sure one of the array dimensions is not zero */ - if (!count) { + if (!count && dims) { fprintf(stderr, "array size must be nonzero\n"); return EXIT_FAILURE; } @@ -546,6 +546,7 @@ int main(int argc, char* argv[]) ny = MAX(field->ny, 1u); nz = MAX(field->nz, 1u); nw = MAX(field->nw, 1u); + count = (size_t)nx * (size_t)ny * (size_t)nz * (size_t)nw; } /* allocate memory for decompressed data */ From 7e0bef05d665cc368b07871025ecc8eb3fc9655c Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 3 Oct 2018 12:18:25 -0700 Subject: [PATCH 004/194] Add code coverage through Travis CI build + README badge --- .travis.yml | 12 ++++++++++++ README.md | 2 ++ codecov.yml | 8 ++++++++ travis.sh | 29 ++++++++++++++++++++--------- 4 files changed, 42 insertions(+), 9 deletions(-) create mode 100644 codecov.yml diff --git a/.travis.yml b/.travis.yml index 49e1eb0a2..4ea63a31b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,6 +6,16 @@ env: matrix: include: + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: ubuntu-toolchain-r-test + packages: gcc-6 + env: + - COVERAGE=ON + - os: linux dist: trusty compiler: clang-3.6 @@ -131,3 +141,5 @@ matrix: script: - ./travis.sh +after_success: + - if [[ -n "${COVERAGE}" ]]; then bash <(curl -s https://codecov.io/bash); fi diff --git a/README.md b/README.md index c2aa80dec..b84e777c8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ ZFP === +[![codecov](https://codecov.io/gh/LLNL/zfp/branch/develop/graph/badge.svg)](https://codecov.io/gh/LLNL/zfp) + INTRODUCTION ------------ diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..cc6db5f50 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,8 @@ +coverage: + ignore: + - docs/* + - examples/* + - src/cuda_zfp/* + - src/template/cuda* + - tests/* + - utils/* diff --git a/travis.sh b/travis.sh index 2314e0376..e09bf904d 100755 --- a/travis.sh +++ b/travis.sh @@ -4,14 +4,25 @@ set -e mkdir build cd build -# build/test without OpenMP, with CFP -cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON -cmake --build . -ctest -V -C "Debug" +if [ -n "${COVERAGE}" ]; then -rm -rf ./* + # build + cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DZFP_WITH_OPENMP=ON -DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage; + cmake --build . ; + ctest -V -C "Debug"; -# build/test with OpenMP, with CFP custom namespace -cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -cmake --build . -ctest -V -C "Debug" +else + + # build/test without OpenMP, with CFP + cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON; + cmake --build . ; + ctest -V -C "Debug"; + + rm -rf ./* ; + + # build/test with OpenMP, with CFP custom namespace + cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2; + cmake --build . ; + ctest -V -C "Debug"; + +fi From cb7bc4bfa2bd57490dab71eed0b1ad1845b92f77 Mon Sep 17 00:00:00 2001 From: "Mohamed A. Bamakhrama" Date: Thu, 11 Oct 2018 13:13:05 +0200 Subject: [PATCH 005/194] Fix CUDA include flags When compiling using CUDA, the inclusion to zfp.h was missing. This patch fixes that by using cuda_include_directories() --- src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4119245c0..b25b18159 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,6 +3,7 @@ if(ZFP_WITH_CUDA) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC" ) add_subdirectory(cuda_zfp) + cuda_include_directories(${PROJECT_SOURCE_DIR}/include) cuda_wrap_srcs(zfp OBJ zfp_cuda_backend_obj cuda_zfp/cuZFP.cu) SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_PREVIOUS}) add_definitions(-DZFP_WITH_CUDA) From 75a679ec18ab0293798ea210c8895d0308487045 Mon Sep 17 00:00:00 2001 From: Mohamed Bamakhrama Date: Fri, 16 Nov 2018 14:16:23 +0100 Subject: [PATCH 006/194] Fixed two typos in zfp_add_test in tests/src/endtoend/CMakeLists.txt --- tests/src/endtoend/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 820ba55fa..54ae9e18a 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -16,7 +16,7 @@ function(zfp_add_test dims type bits) cmocka zfp hash${bits}Lib genSmoothRandNumsLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) - target_link_libraries(${serial_test_name} m) + target_link_libraries(${omp_test_name} m) endif() add_test(NAME ${omp_test_name} COMMAND ${omp_test_name}) set_property(TEST ${omp_test_name} PROPERTY RUN_SERIAL TRUE) @@ -30,7 +30,7 @@ function(zfp_add_test dims type bits) target_link_libraries(${cuda_test_name} cmocka zfp hash${bits}Lib genSmoothRandNumsLib) if(HAVE_LIBM_MATH) - target_link_libraries(${serial_test_name} m) + target_link_libraries(${cuda_test_name} m) endif() add_test(NAME ${cuda_test_name} COMMAND ${cuda_test_name}) set_property(TEST ${cuda_test_name} PROPERTY RUN_SERIAL TRUE) From 4c94570217eb0ca3e31f2253c2d4b58ccaf4aa33 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 7 Dec 2018 17:32:46 -0800 Subject: [PATCH 007/194] Remove lib RT dependency (clock_gettime -> clock()) in endtoend test timings for linux --- tests/src/endtoend/zfpEndtoendBase.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 08788d819..5d94939e6 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -64,9 +64,7 @@ struct setupVars { UInt decompressedChecksum; // timer -#if defined(__linux__) - struct timespec timeStart, timeEnd; -#elif defined(_WIN32) +#if defined(__linux__) || defined(_WIN32) clock_t timeStart, timeEnd; #elif defined(__MACH__) uint64_t timeStart, timeEnd; @@ -465,9 +463,7 @@ startTimer(void **state) struct setupVars *bundle = *state; // set up timer -#if defined(__linux__) - clock_gettime(CLOCK_REALTIME, &(bundle->timeStart)); -#elif defined(_WIN32) +#if defined(__linux__) || defined(_WIN32) bundle->timeStart = clock(); #elif defined(__MACH__) bundle->timeStart = mach_absolute_time(); @@ -483,10 +479,7 @@ stopTimer(void **state) double time; // stop timer, compute elapsed time -#if defined(__linux__) - clock_gettime(CLOCK_REALTIME, &(bundle->timeEnd)); - time = ((bundle->timeEnd.tv_sec) - (bundle->timeStart.tv_sec)) + ((bundle->timeEnd.tv_nsec) - (bundle->timeStart.tv_nsec)) / 1E9; -#elif defined(_WIN32) +#if defined(__linux__) || defined(_WIN32) bundle->timeEnd = clock(); time = (double)((bundle->timeEnd) - (bundle->timeStart)) / CLOCKS_PER_SEC; #elif defined(__MACH__) From ba1a464c6b219829a0fc8c996ac75265adf55f46 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 30 Dec 2018 09:06:56 -0800 Subject: [PATCH 008/194] Improve error messages when missing command-line options --- utils/zfp.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/utils/zfp.c b/utils/zfp.c index 3d42e9b8c..705f01490 100644 --- a/utils/zfp.c +++ b/utils/zfp.c @@ -317,22 +317,40 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - /* make sure we know floating-point type */ - if ((inpath || !header) && !typesize) { - fprintf(stderr, "must specify scalar type via -f, -d, or -t or header via -h\n"); - return EXIT_FAILURE; + /* make sure we (will) know scalar type */ + if (!typesize) { + if (inpath) { + fprintf(stderr, "must specify scalar type via -f, -d, or -t to compress\n"); + return EXIT_FAILURE; + } + else if (!header) { + fprintf(stderr, "must specify scalar type via -f, -d, or -t or header via -h to decompress\n"); + return EXIT_FAILURE; + } } - /* make sure we know array dimensions */ - if ((inpath || !header) && !dims) { - fprintf(stderr, "must specify array dimensions via -1, -2, or -3 or header via -h\n"); - return EXIT_FAILURE; + /* make sure we (will) know array dimensions */ + if (!dims) { + if (inpath) { + fprintf(stderr, "must specify array dimensions via -1, -2, -3, or -4 to compress\n"); + return EXIT_FAILURE; + } + else if (!header) { + fprintf(stderr, "must specify array dimensions via -1, -2, -3, or -4 or header via -h to decompress\n"); + return EXIT_FAILURE; + } } - /* make sure we know (de)compression mode and parameters */ - if ((inpath || !header) && !mode) { - fprintf(stderr, "must specify compression parameters via -a, -c, -p, or -r or header via -h\n"); - return EXIT_FAILURE; + /* make sure we (will) know (de)compression mode and parameters */ + if (!mode) { + if (inpath) { + fprintf(stderr, "must specify compression parameters via -a, -c, -p, or -r to compress\n"); + return EXIT_FAILURE; + } + else if (!header) { + fprintf(stderr, "must specify compression parameters via -a, -c, -p, or -r or header via -h to decompress\n"); + return EXIT_FAILURE; + } } /* make sure we have input file for stats */ From 96eb6b6c3b499409b6056eb66e27e732bea9ad5c Mon Sep 17 00:00:00 2001 From: "Mohamed A. Bamakhrama" Date: Fri, 14 Dec 2018 10:25:41 +0100 Subject: [PATCH 009/194] Use https:// instead of git:// for cryptomilk In many companies, the git:// protocol is blocked by corporate firewall. To circumvent that, use https:// instead of git:// --- tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index e164e44a1..54e336cc2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -10,7 +10,7 @@ list(APPEND CMOCKA_ARGS "-DWITH_STATIC_LIB=ON;-DCMAKE_C_COMPILER=${CMAKE_C_COMPI include(ExternalProject) ExternalProject_Add( cmocka_cloned - GIT_REPOSITORY git://git.cryptomilk.org/projects/cmocka.git + GIT_REPOSITORY https://git.cryptomilk.org/projects/cmocka.git GIT_TAG cmocka-1.1.0 SOURCE_DIR "${CMAKE_BINARY_DIR}/cmocka-src" BINARY_DIR "${CMAKE_BINARY_DIR}/cmocka-build" From 776d89a2a28a5ea9d86a68573fc265e6546b40ea Mon Sep 17 00:00:00 2001 From: "Mohamed A. Bamakhrama" Date: Fri, 14 Dec 2018 10:18:26 +0100 Subject: [PATCH 010/194] Fix endtoend tests on Cygwin CMake no longer defines WIN32 on Cygwin. This means that endtoend tests are failing now on Cygwin. To fix that, we have two options: 1) Check if "__CYGWIN__" is defined 2) Use "__unix__" instead of "__linux__". The Unix macro seems to be defined on Cygwin --- tests/src/endtoend/zfpEndtoendBase.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 5d94939e6..f9f8b6277 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -8,7 +8,7 @@ #include #include -#if defined(__linux__) || defined(_WIN32) +#if defined(__unix__) || defined(_WIN32) #include #elif defined(__MACH__) #include @@ -64,7 +64,7 @@ struct setupVars { UInt decompressedChecksum; // timer -#if defined(__linux__) || defined(_WIN32) +#if defined(__unix__) || defined(_WIN32) clock_t timeStart, timeEnd; #elif defined(__MACH__) uint64_t timeStart, timeEnd; @@ -463,7 +463,7 @@ startTimer(void **state) struct setupVars *bundle = *state; // set up timer -#if defined(__linux__) || defined(_WIN32) +#if defined(__unix__) || defined(_WIN32) bundle->timeStart = clock(); #elif defined(__MACH__) bundle->timeStart = mach_absolute_time(); @@ -479,7 +479,7 @@ stopTimer(void **state) double time; // stop timer, compute elapsed time -#if defined(__linux__) || defined(_WIN32) +#if defined(__unix__) || defined(_WIN32) bundle->timeEnd = clock(); time = (double)((bundle->timeEnd) - (bundle->timeStart)) / CLOCKS_PER_SEC; #elif defined(__MACH__) From 44bb08e2e29162f410517fbce7a0d5fdd1d90130 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 11 Jan 2019 10:52:08 -0500 Subject: [PATCH 011/194] warnings: mark conditionally used parameters in bitstream src with new macro unused_ --- src/inline/bitstream.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/inline/bitstream.c b/src/inline/bitstream.c index 6e9662925..aa58b73fd 100644 --- a/src/inline/bitstream.c +++ b/src/inline/bitstream.c @@ -107,6 +107,9 @@ The following assumptions and restrictions apply: #define inline_ #endif +/* satisfy compiler when args unused */ +#define unused_(x) ((void)(x)) + /* bit stream word/buffer type; granularity of stream I/O operations */ #ifdef BIT_STREAM_WORD_TYPE /* may be 8-, 16-, 32-, or 64-bit unsigned integer type */ @@ -187,6 +190,7 @@ stream_stride_block(const bitstream* s) #ifdef BIT_STREAM_STRIDED return s->mask + 1; #else + unused_(s); return 1; #endif } @@ -198,6 +202,7 @@ stream_stride_delta(const bitstream* s) #ifdef BIT_STREAM_STRIDED return s->delta / (s->mask + 1); #else + unused_(s); return 0; #endif } @@ -448,3 +453,5 @@ stream_clone(const bitstream* s) *c = *s; return c; } + +#undef unused_ From 57abe08b092d7ebe03032c42f279e49c5ab907d6 Mon Sep 17 00:00:00 2001 From: LennartNoordsij Date: Fri, 14 Dec 2018 13:21:11 +0100 Subject: [PATCH 012/194] Unroll deposit bit plane loop Setting the bound static prevents Warp divergence and speeds up the writing. CUDA 8 supports specifying the unrolling factor which is done in other functions of the CUDA implementation as well. --- src/cuda_zfp/decode.cuh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cuda_zfp/decode.cuh b/src/cuda_zfp/decode.cuh index 656cf0b36..d3d087723 100644 --- a/src/cuda_zfp/decode.cuh +++ b/src/cuda_zfp/decode.cuh @@ -127,8 +127,12 @@ void decode_ints(BlockReader &reader, uint &max_bits, UInt *data) for (; n < (Size - 1) && bits && (bits--, !reader.read_bit()); n++); // deposit bit plane +#if (CUDART_VERSION < 8000) #pragma unroll - for (int i = 0; x; i++, x >>= 1) +#else + #pragma unroll Size +#endif + for (int i = 0; i < Size; i++, x >>= 1) { data[i] += (UInt)(x & 1u) << k; } From e1f58b0cfaa4f3450bee87307911113ea8541997 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 13 Feb 2019 11:01:14 -0500 Subject: [PATCH 013/194] Travis CI builds now report to the zfp cdash instance --- CTestConfig.cmake | 13 +++++++++++++ cmake/travis.cmake | 47 ++++++++++++++++++++++++++++++++++++++++++++++ travis.sh | 21 +++++---------------- 3 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 CTestConfig.cmake create mode 100644 cmake/travis.cmake diff --git a/CTestConfig.cmake b/CTestConfig.cmake new file mode 100644 index 000000000..cbb9abccd --- /dev/null +++ b/CTestConfig.cmake @@ -0,0 +1,13 @@ +## This file should be placed in the root directory of your project. +## Then modify the CMakeLists.txt file in the root directory of your +## project to incorporate the testing dashboard. +## # The following are required to uses Dart and the Cdash dashboard +## ENABLE_TESTING() +## INCLUDE(CTest) +set(CTEST_PROJECT_NAME "ZFP") +set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") + +set(CTEST_DROP_METHOD "https") +set(CTEST_DROP_SITE "open.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=zfp") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/cmake/travis.cmake b/cmake/travis.cmake new file mode 100644 index 000000000..a148e9248 --- /dev/null +++ b/cmake/travis.cmake @@ -0,0 +1,47 @@ + +set(CTEST_SOURCE_DIRECTORY "$ENV{TRAVIS_BUILD_DIR}") +set(CTEST_BINARY_DIRECTORY "$ENV{TRAVIS_BUILD_DIR}/build") + +# We need to set this otherwise we yet 255 as our return code! +set(CTEST_COMMAND ctest) +include(${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake) +set(CTEST_SITE "travis") +set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +set(CTEST_BUILD_NAME "$ENV{TRAVIS_BRANCH}-#$ENV{TRAVIS_JOB_NUMBER}") +set(cfg_options + -DCMAKE_C_STANDARD=${C_STANDARD} + -DCMAKE_CXX_STANDARD=${CXX_STANDARD} + -DBUILD_CFP=${BUILD_CFP} + -DZFP_WITH_OPENMP=${BUILD_OPENMP} + -DZFP_WITH_CUDA=${BUILD_CUDA} + ) + +if(CFP_NAMESPACE) + list(APPEND cfg_options + -DCFP_NAMESPACE=${CFP_NAMESPACE} + ) +endif() + +if(WITH_COVERAGE) + list(APPEND cfg_options + -DCMAKE_C_FLAGS=-coverage + -DCMAKE_CXX_FLAGS=-coverage + ) +endif() + +ctest_start(Experimental TRACK Travis) +ctest_configure(OPTIONS "${cfg_options}") +ctest_submit(PARTS Update Notes Configure) +ctest_build(FLAGS -j1) +ctest_submit(PARTS Build) +ctest_test(RETURN_VALUE rv) +ctest_submit(PARTS Test) + +if(WITH_COVERAGE) + ctest_coverage() + ctest_submit(PARTS Coverage) +endif() + +if(NOT rv EQUAL 0) + message(FATAL_ERROR "Test failures occurred.") +endif() diff --git a/travis.sh b/travis.sh index e09bf904d..3f60f2b30 100755 --- a/travis.sh +++ b/travis.sh @@ -4,25 +4,14 @@ set -e mkdir build cd build -if [ -n "${COVERAGE}" ]; then +if [ -n "${COVERAGE}" ]; then # build - cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DZFP_WITH_OPENMP=ON -DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage; - cmake --build . ; - ctest -V -C "Debug"; - + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake else - # build/test without OpenMP, with CFP - cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON; - cmake --build . ; - ctest -V -C "Debug"; - - rm -rf ./* ; - - # build/test with OpenMP, with CFP custom namespace - cmake .. -DCMAKE_C_STANDARD=${C_STANDARD:-99} -DCMAKE_CXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2; - cmake --build . ; - ctest -V -C "Debug"; + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # build/test with CFP custom namespace + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -S $TRAVIS_BUILD_DIR/cmake/travis.cmake fi From d405a4edeae0895b303e3ded01ccf86ad4c5ff42 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 13 Feb 2019 17:19:27 -0500 Subject: [PATCH 014/194] travis submissions include variant components This allow a single travis builder to have multiple variants such as +openmp submitted to cdash. --- cmake/travis.cmake | 23 ++++++++++++++++++++--- travis.sh | 6 ++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/cmake/travis.cmake b/cmake/travis.cmake index a148e9248..41c28c40e 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -2,7 +2,6 @@ set(CTEST_SOURCE_DIRECTORY "$ENV{TRAVIS_BUILD_DIR}") set(CTEST_BINARY_DIRECTORY "$ENV{TRAVIS_BUILD_DIR}/build") -# We need to set this otherwise we yet 255 as our return code! set(CTEST_COMMAND ctest) include(${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake) set(CTEST_SITE "travis") @@ -16,10 +15,21 @@ set(cfg_options -DZFP_WITH_CUDA=${BUILD_CUDA} ) +# Add the variants to the testers name so that we can report multiple +# times from the same CI builder +if(BUILD_OPENMP) + set(CTEST_SITE "${CTEST_SITE}_openmp") +endif() + +if(BUILD_CUDA) + set(CTEST_SITE "${CTEST_SITE}_cuda") +endif() + if(CFP_NAMESPACE) list(APPEND cfg_options -DCFP_NAMESPACE=${CFP_NAMESPACE} - ) + ) + set(TEST_SITE "${CTEST_SITE}_namespace") endif() if(WITH_COVERAGE) @@ -27,6 +37,13 @@ if(WITH_COVERAGE) -DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage ) + set(CTEST_SITE "${CTEST_SITE}_coverage") +endif() + +if(ENDTOEND_TESTS_ONLY) + list(APPEND cfg_options + -DZFP_ENDTOEND_TESTS_ONLY=1 + ) endif() ctest_start(Experimental TRACK Travis) @@ -34,7 +51,7 @@ ctest_configure(OPTIONS "${cfg_options}") ctest_submit(PARTS Update Notes Configure) ctest_build(FLAGS -j1) ctest_submit(PARTS Build) -ctest_test(RETURN_VALUE rv) +ctest_test(PARALLEL_LEVEL 6 RETURN_VALUE rv) ctest_submit(PARTS Test) if(WITH_COVERAGE) diff --git a/travis.sh b/travis.sh index 3f60f2b30..9ed05a04b 100755 --- a/travis.sh +++ b/travis.sh @@ -12,6 +12,8 @@ else # build/test without OpenMP, with CFP ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake - # build/test with CFP custom namespace - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + rm -rf ./* ; + + # build/test with OpenMP, with CFP custom namespace + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake fi From 9fcc11b1ac8edec4a935965218ae62c61eadd4f1 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 15 Feb 2019 17:44:28 -0800 Subject: [PATCH 015/194] Consolidate CI builds to {openmp off, cfp on} and {openmp on} --- appveyor.yml | 13 ++++++------- travis.sh | 8 ++++---- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 2cfbb139a..98d9d523d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -74,9 +74,9 @@ build_script: - mkdir build - cd build - # build/test without OpenMP, with CFP - - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON .. - - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON .. + # build/test without OpenMP, with CFP (and custom namespace) + - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. + - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. - if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%" - if not "%COMPILER%"=="msvc" cmake --build . @@ -85,14 +85,13 @@ build_script: - rm -rf ./* - # build/test with OpenMP, with CFP custom namespace - - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_ENDTOEND_TESTS_ONLY=1 -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. - - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_ENDTOEND_TESTS_ONLY=1 -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. + # build/test with OpenMP + - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_WITH_OPENMP=ON -DZFP_ENDTOEND_TESTS_ONLY=1 .. + - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_WITH_OPENMP=ON -DZFP_ENDTOEND_TESTS_ONLY=1 .. - if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%" - if not "%COMPILER%"=="msvc" cmake --build . # only run tests not run in previous build, due to appveyor time limit (1 hour) - ctest -V -C "%BUILD_TYPE%" -R ".*Omp.*" - - ctest -V -C "%BUILD_TYPE%" -R "testCfpNamespace" diff --git a/travis.sh b/travis.sh index 9ed05a04b..0be50e776 100755 --- a/travis.sh +++ b/travis.sh @@ -9,11 +9,11 @@ if [ -n "${COVERAGE}" ]; then # build ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake else - # build/test without OpenMP, with CFP - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # build/test without OpenMP, with CFP (and custom namespace) + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake rm -rf ./* ; - # build/test with OpenMP, with CFP custom namespace - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # build/test with OpenMP + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake fi From ae82c7eb36ca5d4672e446ed608a16a11d729422 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 15 Feb 2019 17:45:53 -0800 Subject: [PATCH 016/194] travis: only attempt openmp build if it's available --- tests/ci-utils/CMakeLists.txt | 10 ++++++++++ travis.sh | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/ci-utils/CMakeLists.txt diff --git a/tests/ci-utils/CMakeLists.txt b/tests/ci-utils/CMakeLists.txt new file mode 100644 index 000000000..834d434a7 --- /dev/null +++ b/tests/ci-utils/CMakeLists.txt @@ -0,0 +1,10 @@ +# This empty project is used to determine if OpenMP is available on CI machines +# without compiling any ZFP code. + +if(WIN32) + cmake_minimum_required(VERSION 3.4) +else() + cmake_minimum_required(VERSION 3.1) +endif() + +find_package(OpenMP COMPONENTS C REQUIRED) diff --git a/travis.sh b/travis.sh index 0be50e776..2b756a75b 100755 --- a/travis.sh +++ b/travis.sh @@ -14,6 +14,11 @@ else rm -rf ./* ; - # build/test with OpenMP - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # if OpenMP available, start a 2nd build with it + if cmake ../tests/ci-utils/ ; then + rm -rf ./* ; + + # build/test with OpenMP + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + fi fi From d9764a240c78e5c3512fb18ea6cc3895d0bc3ca6 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 15 Feb 2019 19:07:01 -0800 Subject: [PATCH 017/194] Change CDash testsite naming with cfp --- cmake/travis.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 41c28c40e..71255f038 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -25,11 +25,15 @@ if(BUILD_CUDA) set(CTEST_SITE "${CTEST_SITE}_cuda") endif() -if(CFP_NAMESPACE) - list(APPEND cfg_options - -DCFP_NAMESPACE=${CFP_NAMESPACE} - ) - set(TEST_SITE "${CTEST_SITE}_namespace") +if(BUILD_CFP) + set(CTEST_SITE "${CTEST_SITE}_cfp") + + if(CFP_NAMESPACE) + list(APPEND cfg_options + -DCFP_NAMESPACE=${CFP_NAMESPACE} + ) + set(CTEST_SITE "${CTEST_SITE}namespace") + endif() endif() if(WITH_COVERAGE) From 20a3e10c5b6a1740fbe84a75a633f59a142c9357 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 14 Feb 2019 10:12:54 -0800 Subject: [PATCH 018/194] generalize hash strided array functions to handle all dimensionalities --- tests/utils/hash32.c | 43 ++++++------------------------------- tests/utils/hash32.h | 8 +------ tests/utils/hash64.c | 50 ++++++-------------------------------------- tests/utils/hash64.h | 8 +------ 4 files changed, 14 insertions(+), 95 deletions(-) diff --git a/tests/utils/hash32.c b/tests/utils/hash32.c index 8cad29516..2beb0e601 100644 --- a/tests/utils/hash32.c +++ b/tests/utils/hash32.c @@ -14,48 +14,17 @@ hashArray(const uint32* arr, size_t nx, int sx) return hashFinish(h); } +// unused n[] entries are 0 uint32 -hash2dStridedArray(const uint32* arr, size_t nx, size_t ny, int sx, int sy) -{ - uint32 h = 0; - - size_t i, j; - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { - hashValue(*arr, &h); - } - } - - return hashFinish(h); -} - -uint32 -hash3dStridedArray(const uint32* arr, size_t nx, size_t ny, size_t nz, int sx, int sy, int sz) -{ - uint32 h = 0; - - size_t i, j, k; - for (k = 0; k < nz; arr += (sz - ny*sy), k++) { - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { - hashValue(*arr, &h); - } - } - } - - return hashFinish(h); -} - -uint32 -hash4dStridedArray(const uint32* arr, size_t nx, size_t ny, size_t nz, size_t nw, int sx, int sy, int sz, int sw) +hashStridedArray(const uint32* arr, size_t n[4], int s[4]) { uint32 h = 0; size_t i, j, k, l; - for (l = 0; l < nw; arr += (sw - nz*sz), l++) { - for (k = 0; k < nz; arr += (sz - ny*sy), k++) { - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { + for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { + for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { + for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { + for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { hashValue(*arr, &h); } } diff --git a/tests/utils/hash32.h b/tests/utils/hash32.h index a8717d0f6..43b6fadb2 100644 --- a/tests/utils/hash32.h +++ b/tests/utils/hash32.h @@ -10,13 +10,7 @@ uint32 hashArray(const uint32* arr, size_t nx, int sx); uint32 -hash2dStridedArray(const uint32* arr, size_t nx, size_t ny, int sx, int sy); - -uint32 -hash3dStridedArray(const uint32* arr, size_t nx, size_t ny, size_t nz, int sx, int sy, int sz); - -uint32 -hash4dStridedArray(const uint32* arr, size_t nx, size_t ny, size_t nz, size_t nw, int sx, int sy, int sz, int sw); +hashStridedArray(const uint32* arr, size_t n[4], int s[4]); uint32 hash2dStridedBlock(const uint32* arr, int sx, int sy); diff --git a/tests/utils/hash64.c b/tests/utils/hash64.c index 3e67bb9c8..5c18900b5 100644 --- a/tests/utils/hash64.c +++ b/tests/utils/hash64.c @@ -18,56 +18,18 @@ hashArray(const uint64* arr, size_t nx, int sx) return result1 + (result2 << 32); } +// unused n[] entries are 0 uint64 -hash2dStridedArray(const uint64* arr, size_t nx, size_t ny, int sx, int sy) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - size_t i, j; - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { - hashValue64(*arr, &h1, &h2); - } - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} - -uint64 -hash3dStridedArray(const uint64* arr, size_t nx, size_t ny, size_t nz, int sx, int sy, int sz) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - size_t i, j, k; - for (k = 0; k < nz; arr += (sz - ny*sy), k++) { - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { - hashValue64(*arr, &h1, &h2); - } - } - } - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} - -uint64 -hash4dStridedArray(const uint64* arr, size_t nx, size_t ny, size_t nz, size_t nw, int sx, int sy, int sz, int sw) +hashStridedArray(const uint64* arr, size_t n[4], int s[4]) { uint32 h1 = 0; uint32 h2 = 0; size_t i, j, k, l; - for (l = 0; l < nw; arr += (sw - nz*sz), l++) { - for (k = 0; k < nz; arr += (sz - ny*sy), k++) { - for (j = 0; j < ny; arr += (sy - nx*sx), j++) { - for (i = 0; i < nx; arr += sx, i++) { + for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { + for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { + for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { + for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { hashValue64(*arr, &h1, &h2); } } diff --git a/tests/utils/hash64.h b/tests/utils/hash64.h index 97a350702..dc90995c1 100644 --- a/tests/utils/hash64.h +++ b/tests/utils/hash64.h @@ -10,13 +10,7 @@ uint64 hashArray(const uint64* arr, size_t nx, int sx); uint64 -hash2dStridedArray(const uint64* arr, size_t nx, size_t ny, int sx, int sy); - -uint64 -hash3dStridedArray(const uint64* arr, size_t nx, size_t ny, size_t nz, int sx, int sy, int sz); - -uint64 -hash4dStridedArray(const uint64* arr, size_t nx, size_t ny, size_t nz, size_t nw, int sx, int sy, int sz, int sw); +hashStridedArray(const uint64* arr, size_t n[4], int s[4]); uint64 hash2dStridedBlock(const uint64* arr, int sx, int sy); From b888aad270e391bd8a90ddf88961071745d12771 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 14 Feb 2019 15:16:43 -0800 Subject: [PATCH 019/194] update decode, endtoend tests to call new generalized strided hash function --- tests/src/decode/zfpDecodeBlockStridedBase.c | 8 +- tests/src/endtoend/zfpEndtoendBase.c | 168 +++++++++---------- 2 files changed, 79 insertions(+), 97 deletions(-) diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index af1ec6dc2..9d317d87e 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -224,7 +224,7 @@ teardown(void **state) } UInt -hashStridedArray(Scalar* dataArr) +hashStridedEntries(Scalar* dataArr) { UInt checksum = 0; switch (DIMS) { @@ -487,7 +487,7 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashStridedArray(bundle->dataArr), CHECKSUM_ORIGINAL_DATA_BLOCK); + assert_int_equal(hashStridedEntries(bundle->dataArr), CHECKSUM_ORIGINAL_DATA_BLOCK); } static void @@ -532,7 +532,7 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_ArrayChecksu decodeBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedArray(bundle->decodedDataArr), CHECKSUM_DECODED_BLOCK); + assert_int_equal(hashStridedEntries(bundle->decodedDataArr), CHECKSUM_DECODED_BLOCK); } static void @@ -591,5 +591,5 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_Array decodePartialBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedArray(bundle->decodedDataArr), CHECKSUM_DECODED_PARTIAL_BLOCK); + assert_int_equal(hashStridedEntries(bundle->decodedDataArr), CHECKSUM_DECODED_PARTIAL_BLOCK); } diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index f9f8b6277..43eedbf01 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -36,7 +36,7 @@ struct setupVars { // randomly generated array // this entire dataset eventually gets compressed // its data gets copied and possibly rearranged, into compressedArr - size_t randomGenArrSideLen; + size_t randomGenArrSideLen[4]; size_t totalRandomGenArrLen; Scalar* randomGenArr; @@ -82,19 +82,19 @@ setupRandomData(void** state) #ifdef FL_PT_DATA case zfp_type_float: - generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, DIMS, (float**)&bundle->randomGenArr, &bundle->randomGenArrSideLen, &bundle->totalRandomGenArrLen); + generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, DIMS, (float**)&bundle->randomGenArr, &bundle->randomGenArrSideLen[0], &bundle->totalRandomGenArrLen); break; case zfp_type_double: - generateSmoothRandDoubles(MIN_TOTAL_ELEMENTS, DIMS, (double**)&bundle->randomGenArr, &bundle->randomGenArrSideLen, &bundle->totalRandomGenArrLen); + generateSmoothRandDoubles(MIN_TOTAL_ELEMENTS, DIMS, (double**)&bundle->randomGenArr, &bundle->randomGenArrSideLen[0], &bundle->totalRandomGenArrLen); break; #else case zfp_type_int32: - generateSmoothRandInts32(MIN_TOTAL_ELEMENTS, DIMS, 32 - 2, (int32**)&bundle->randomGenArr, &bundle->randomGenArrSideLen, &bundle->totalRandomGenArrLen); + generateSmoothRandInts32(MIN_TOTAL_ELEMENTS, DIMS, 32 - 2, (int32**)&bundle->randomGenArr, &bundle->randomGenArrSideLen[0], &bundle->totalRandomGenArrLen); break; case zfp_type_int64: - generateSmoothRandInts64(MIN_TOTAL_ELEMENTS, DIMS, 64 - 2, (int64**)&bundle->randomGenArr, &bundle->randomGenArrSideLen, &bundle->totalRandomGenArrLen); + generateSmoothRandInts64(MIN_TOTAL_ELEMENTS, DIMS, 64 - 2, (int64**)&bundle->randomGenArr, &bundle->randomGenArrSideLen[0], &bundle->totalRandomGenArrLen); break; #endif @@ -104,6 +104,12 @@ setupRandomData(void** state) } assert_non_null(bundle->randomGenArr); + // set remaining indices (square for now) + int i; + for (i = 1; i < 4; i++) { + bundle->randomGenArrSideLen[i] = (i < DIMS) ? bundle->randomGenArrSideLen[0] : 0; + } + *state = bundle; return 0; @@ -141,7 +147,7 @@ interleaveArray(Scalar* inputArr, Scalar* outputArr, size_t inputLen) } static void -permuteArray(Scalar* inputArr, Scalar* outputArr, size_t sideLen) +permuteSquareArray(Scalar* inputArr, Scalar* outputArr, size_t sideLen) { size_t i, j, k, l; @@ -188,7 +194,7 @@ permuteArray(Scalar* inputArr, Scalar* outputArr, size_t sideLen) case 1: default: - fail_msg("Unexpected DIMS value in permuteArray()"); + fail_msg("Unexpected DIMS value in permuteSquareArray()"); break; } } @@ -214,21 +220,26 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ assert_non_null(bundle->decompressedArr); // identify strides and produce compressedArr + uint nx = (uint)bundle->randomGenArrSideLen[0]; + uint ny = (uint)bundle->randomGenArrSideLen[1]; + uint nz = (uint)bundle->randomGenArrSideLen[2]; + uint nw = (uint)bundle->randomGenArrSideLen[3]; int sx = 0, sy = 0, sz = 0, sw = 0; + switch(bundle->stride) { case REVERSED: if (DIMS == 4) { sx = -1; - sy = sx * (int)bundle->randomGenArrSideLen; - sz = sy * (int)bundle->randomGenArrSideLen; - sw = sz * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; + sz = sy * (int)ny; + sw = sz * (int)nz; } else if (DIMS == 3) { sx = -1; - sy = sx * (int)bundle->randomGenArrSideLen; - sz = sy * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; + sz = sy * (int)ny; } else if (DIMS == 2) { sx = -1; - sy = sx * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; } else { sx = -1; } @@ -242,16 +253,16 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ case INTERLEAVED: if (DIMS == 4) { sx = 2; - sy = sx * (int)bundle->randomGenArrSideLen; - sz = sy * (int)bundle->randomGenArrSideLen; - sw = sz * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; + sz = sy * (int)ny; + sw = sz * (int)nz; } else if (DIMS == 3) { sx = 2; - sy = sx * (int)bundle->randomGenArrSideLen; - sz = sy * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; + sz = sy * (int)ny; } else if (DIMS == 2) { sx = 2; - sy = sx * (int)bundle->randomGenArrSideLen; + sy = sx * (int)nx; } else { sx = 2; } @@ -260,19 +271,19 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ case PERMUTED: if (DIMS == 4) { - sx = (int)intPow(bundle->randomGenArrSideLen, 3); - sy = (int)intPow(bundle->randomGenArrSideLen, 2); - sz = (int)bundle->randomGenArrSideLen; + sx = (int)(nx * ny * nz); + sy = (int)(nx * ny); + sz = (int)nx; sw = 1; } else if (DIMS == 3) { - sx = (int)intPow(bundle->randomGenArrSideLen, 2); - sy = (int)bundle->randomGenArrSideLen; + sx = (int)(nx * ny); + sy = (int)nx; sz = 1; } else if (DIMS == 2) { - sx = (int)bundle->randomGenArrSideLen; + sx = (int)nx; sy = 1; } - permuteArray(bundle->randomGenArr, bundle->compressedArr, bundle->randomGenArrSideLen); + permuteSquareArray(bundle->randomGenArr, bundle->compressedArr, nx); break; case AS_IS: @@ -285,37 +296,37 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_type type = ZFP_TYPE; zfp_field* field; zfp_field* decompressField; - uint sideLen = (uint)bundle->randomGenArrSideLen; + switch(DIMS) { case 1: - field = zfp_field_1d(bundle->compressedArr, type, sideLen); + field = zfp_field_1d(bundle->compressedArr, type, nx); zfp_field_set_stride_1d(field, sx); - decompressField = zfp_field_1d(bundle->decompressedArr, type, sideLen); + decompressField = zfp_field_1d(bundle->decompressedArr, type, nx); zfp_field_set_stride_1d(decompressField, sx); break; case 2: - field = zfp_field_2d(bundle->compressedArr, type, sideLen, sideLen); + field = zfp_field_2d(bundle->compressedArr, type, nx, ny); zfp_field_set_stride_2d(field, sx, sy); - decompressField = zfp_field_2d(bundle->decompressedArr, type, sideLen, sideLen); + decompressField = zfp_field_2d(bundle->decompressedArr, type, nx, ny); zfp_field_set_stride_2d(decompressField, sx, sy); break; case 3: - field = zfp_field_3d(bundle->compressedArr, type, sideLen, sideLen, sideLen); + field = zfp_field_3d(bundle->compressedArr, type, nx, ny, nz); zfp_field_set_stride_3d(field, sx, sy, sz); - decompressField = zfp_field_3d(bundle->decompressedArr, type, sideLen, sideLen, sideLen); + decompressField = zfp_field_3d(bundle->decompressedArr, type, nx, ny, nz); zfp_field_set_stride_3d(decompressField, sx, sy, sz); break; case 4: - field = zfp_field_4d(bundle->compressedArr, type, sideLen, sideLen, sideLen, sideLen); + field = zfp_field_4d(bundle->compressedArr, type, nx, ny, nz, nw); zfp_field_set_stride_4d(field, sx, sy, sz, sw); - decompressField = zfp_field_4d(bundle->decompressedArr, type, sideLen, sideLen, sideLen, sideLen); + decompressField = zfp_field_4d(bundle->decompressedArr, type, nx, ny, nz, nw); zfp_field_set_stride_4d(decompressField, sx, sy, sz, sw); break; } @@ -658,31 +669,15 @@ assertZfpCompressDecompressChecksumMatches(void **state) // hash decompressedArr const UInt* arr = (const UInt*)bundle->decompressedArr; - size_t rSideLen = bundle->randomGenArrSideLen; - int strides[4]; + int strides[4] = {0, 0, 0, 0}; + zfp_field_stride(field, strides); + size_t* n = bundle->randomGenArrSideLen; UInt checksum = 0; switch(bundle->stride) { case REVERSED: - zfp_field_stride(field, strides); // arr already points to last element (so strided traverse is legal) - switch(DIMS) { - case 4: - checksum = hash4dStridedArray(arr, rSideLen, rSideLen, rSideLen, rSideLen, strides[0], strides[1], strides[2], strides[3]); - break; - - case 3: - checksum = hash3dStridedArray(arr, rSideLen, rSideLen, rSideLen, strides[0], strides[1], strides[2]); - break; - - case 2: - checksum = hash2dStridedArray(arr, rSideLen, rSideLen, strides[0], strides[1]); - break; - - case 1: - checksum = hashArray(arr, rSideLen, strides[0]); - break; - } + checksum = hashStridedArray(arr, bundle->randomGenArrSideLen, strides); break; case INTERLEAVED: @@ -690,24 +685,7 @@ assertZfpCompressDecompressChecksumMatches(void **state) break; case PERMUTED: - zfp_field_stride(field, strides); - switch(DIMS) { - case 4: - checksum = hash4dStridedArray(arr, rSideLen, rSideLen, rSideLen, rSideLen, strides[0], strides[1], strides[2], strides[3]); - break; - - case 3: - checksum = hash3dStridedArray(arr, rSideLen, rSideLen, rSideLen, strides[0], strides[1], strides[2]); - break; - - case 2: - checksum = hash2dStridedArray(arr, rSideLen, rSideLen, strides[0], strides[1]); - break; - - case 1: - default: - break; - } + checksum = hashStridedArray(arr, bundle->randomGenArrSideLen, strides); break; case AS_IS: @@ -834,9 +812,25 @@ _catFunc3(given_, DESCRIPTOR, Array_when_ZfpCompressFixedRate_expect_CompressedB assert_int_not_equal(compressedBytes, 0); size_t compressedBits = compressedBytes * 8; + // compute padded lengths (multiples of block-side-len, 4) + size_t paddedNx = (bundle->randomGenArrSideLen[0] + 3) & ~0x3; + size_t paddedNy = (bundle->randomGenArrSideLen[1] + 3) & ~0x3; + size_t paddedNz = (bundle->randomGenArrSideLen[2] + 3) & ~0x3; + size_t paddedNw = (bundle->randomGenArrSideLen[3] + 3) & ~0x3; + + size_t paddedArrayLen = 1; + switch (DIMS) { + case 4: + paddedArrayLen *= paddedNw; + case 3: + paddedArrayLen *= paddedNz; + case 2: + paddedArrayLen *= paddedNy; + case 1: + paddedArrayLen *= paddedNx; + } + // expect bitrate to scale wrt padded array length - size_t paddedArraySideLen = (bundle->randomGenArrSideLen + 3) & ~0x3; - size_t paddedArrayLen = intPow(paddedArraySideLen, DIMS); size_t expectedTotalBits = bundle->rateParam * paddedArrayLen; // account for zfp_compress() ending with stream_flush() expectedTotalBits = (expectedTotalBits + stream_word_bits - 1) & ~(stream_word_bits - 1); @@ -866,31 +860,19 @@ _catFunc3(given_, DESCRIPTOR, Array_when_ZfpCompressFixedAccuracy_expect_Compres assert_int_equal(compressedBytes, zfp_decompress(stream, bundle->decompressField)); int strides[4]; - int sx, sy, sz, sw; - if (!zfp_field_stride(field, strides)) { - // contiguous - sx = 1; - sy = 1; - sz = 1; - sw = 1; - } else { - sx = strides[0]; - sy = strides[1]; - sz = strides[2]; - sw = strides[3]; - } + zfp_field_stride(field, strides); // apply strides ptrdiff_t offset = 0; - size_t sideLen = bundle->randomGenArrSideLen; + size_t* n = bundle->randomGenArrSideLen; float maxDiffF = 0; double maxDiffD = 0; size_t i, j, k, l; - for (l = (DIMS >= 4) ? sideLen : 1; l--; offset += sw - sideLen*sz) { - for (k = (DIMS >= 3) ? sideLen : 1; k--; offset += sz - sideLen*sy) { - for (j = (DIMS >= 2) ? sideLen : 1; j--; offset += sy - sideLen*sx) { - for (i = sideLen; i--; offset += sx) { + for (l = (n[3] ? n[3] : 1); l--; offset += strides[3] - n[2]*strides[2]) { + for (k = (n[2] ? n[2] : 1); k--; offset += strides[2] - n[1]*strides[1]) { + for (j = (n[1] ? n[1] : 1); j--; offset += strides[1] - n[0]*strides[0]) { + for (i = (n[0] ? n[0] : 1); i--; offset += strides[0]) { float absDiffF; double absDiffD; From b90a31309ac74bb77d470d7b205114b82c4c87d8 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 14 Feb 2019 15:35:12 -0800 Subject: [PATCH 020/194] remove hashStridedBlock() functions from hash libs --- tests/src/decode/zfpDecodeBlockStridedBase.c | 30 ++++------ tests/src/encode/zfpEncodeBlockStridedBase.c | 21 +++---- tests/utils/hash32.c | 51 ---------------- tests/utils/hash32.h | 9 --- tests/utils/hash64.c | 63 -------------------- tests/utils/hash64.h | 9 --- 6 files changed, 18 insertions(+), 165 deletions(-) diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index 9d317d87e..654f1a746 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -224,25 +224,17 @@ teardown(void **state) } UInt -hashStridedEntries(Scalar* dataArr) +hashStridedBlock(Scalar* dataArr) { - UInt checksum = 0; - switch (DIMS) { - case 1: - checksum = hashArray((const UInt*)dataArr, BLOCK_SIZE, SX); - break; - case 2: - checksum = hash2dStridedBlock((const UInt*)dataArr, SX, SY); - break; - case 3: - checksum = hash3dStridedBlock((const UInt*)dataArr, SX, SY, SZ); - break; - case 4: - checksum = hash4dStridedBlock((const UInt*)dataArr, SX, SY, SZ, SW); - break; + size_t n[4]; + int i; + for (i = 0; i < 4; i++) { + n[i] = (i < DIMS) ? BLOCK_SIDE_LEN : 0; } - return checksum; + int s[4] = {SX, SY, SZ, SW}; + + return hashStridedArray((const UInt*)dataArr, n, s); } uint @@ -487,7 +479,7 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashStridedEntries(bundle->dataArr), CHECKSUM_ORIGINAL_DATA_BLOCK); + assert_int_equal(hashStridedBlock(bundle->dataArr), CHECKSUM_ORIGINAL_DATA_BLOCK); } static void @@ -532,7 +524,7 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_ArrayChecksu decodeBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedEntries(bundle->decodedDataArr), CHECKSUM_DECODED_BLOCK); + assert_int_equal(hashStridedBlock(bundle->decodedDataArr), CHECKSUM_DECODED_BLOCK); } static void @@ -591,5 +583,5 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_Array decodePartialBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedEntries(bundle->decodedDataArr), CHECKSUM_DECODED_PARTIAL_BLOCK); + assert_int_equal(hashStridedBlock(bundle->decodedDataArr), CHECKSUM_DECODED_PARTIAL_BLOCK); } diff --git a/tests/src/encode/zfpEncodeBlockStridedBase.c b/tests/src/encode/zfpEncodeBlockStridedBase.c index c7be05fe1..25babc8e7 100644 --- a/tests/src/encode/zfpEncodeBlockStridedBase.c +++ b/tests/src/encode/zfpEncodeBlockStridedBase.c @@ -254,22 +254,15 @@ when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - UInt checksum; - switch (DIMS) { - case 1: - checksum = hashArray((const UInt*)bundle->dataArr, BLOCK_SIDE_LEN, SX); - break; - case 2: - checksum = hash2dStridedBlock((const UInt*)bundle->dataArr, SX, SY); - break; - case 3: - checksum = hash3dStridedBlock((const UInt*)bundle->dataArr, SX, SY, SZ); - break; - case 4: - checksum = hash4dStridedBlock((const UInt*)bundle->dataArr, SX, SY, SZ, SW); - break; + size_t n[4]; + int i; + for (i = 0; i < 4; i++) { + n[i] = (i < DIMS) ? BLOCK_SIDE_LEN : 0; } + int s[4] = {SX, SY, SZ, SW}; + + UInt checksum = hashStridedArray((const UInt*)bundle->dataArr, n, s); assert_int_equal(checksum, CHECKSUM_ORIGINAL_DATA_BLOCK); } diff --git a/tests/utils/hash32.c b/tests/utils/hash32.c index 2beb0e601..c448f1480 100644 --- a/tests/utils/hash32.c +++ b/tests/utils/hash32.c @@ -33,54 +33,3 @@ hashStridedArray(const uint32* arr, size_t n[4], int s[4]) return hashFinish(h); } - -uint32 -hash2dStridedBlock(const uint32* arr, int sx, int sy) -{ - uint32 h = 0; - - uint x, y; - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue(*arr, &h); - } - } - - return hashFinish(h); -} - -uint32 -hash3dStridedBlock(const uint32* arr, int sx, int sy, int sz) -{ - uint32 h = 0; - - uint x, y, z; - for (z = 0; z < 4; arr += (sz - 4*sy), z++) { - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue(*arr, &h); - } - } - } - - return hashFinish(h); -} - -uint32 -hash4dStridedBlock(const uint32* arr, int sx, int sy, int sz, int sw) -{ - uint32 h = 0; - - uint x, y, z, w; - for (w = 0; w < 4; arr += (sw - 4*sz), w++) { - for (z = 0; z < 4; arr += (sz - 4*sy), z++) { - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue(*arr, &h); - } - } - } - } - - return hashFinish(h); -} diff --git a/tests/utils/hash32.h b/tests/utils/hash32.h index 43b6fadb2..0dcd076da 100644 --- a/tests/utils/hash32.h +++ b/tests/utils/hash32.h @@ -12,13 +12,4 @@ hashArray(const uint32* arr, size_t nx, int sx); uint32 hashStridedArray(const uint32* arr, size_t n[4], int s[4]); -uint32 -hash2dStridedBlock(const uint32* arr, int sx, int sy); - -uint32 -hash3dStridedBlock(const uint32* arr, int sx, int sy, int sz); - -uint32 -hash4dStridedBlock(const uint32* arr, int sx, int sy, int sz, int sw); - #endif diff --git a/tests/utils/hash64.c b/tests/utils/hash64.c index 5c18900b5..62beb66cc 100644 --- a/tests/utils/hash64.c +++ b/tests/utils/hash64.c @@ -40,66 +40,3 @@ hashStridedArray(const uint64* arr, size_t n[4], int s[4]) return result1 + (result2 << 32); } - -uint64 -hash2dStridedBlock(const uint64* arr, int sx, int sy) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - uint x, y; - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue64(*arr, &h1, &h2); - } - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} - -uint64 -hash3dStridedBlock(const uint64* arr, int sx, int sy, int sz) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - uint x, y, z; - for (z = 0; z < 4; arr += (sz - 4*sy), z++) { - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue64(*arr, &h1, &h2); - } - } - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} - -uint64 -hash4dStridedBlock(const uint64* arr, int sx, int sy, int sz, int sw) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - uint x, y, z, w; - for (w = 0; w < 4; arr += (sw - 4*sz), w++) { - for (z = 0; z < 4; arr += (sz - 4*sy), z++) { - for (y = 0; y < 4; arr += (sy - 4*sx), y++) { - for (x = 0; x < 4; arr += sx, x++) { - hashValue64(*arr, &h1, &h2); - } - } - } - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} diff --git a/tests/utils/hash64.h b/tests/utils/hash64.h index dc90995c1..5184c7986 100644 --- a/tests/utils/hash64.h +++ b/tests/utils/hash64.h @@ -12,13 +12,4 @@ hashArray(const uint64* arr, size_t nx, int sx); uint64 hashStridedArray(const uint64* arr, size_t n[4], int s[4]); -uint64 -hash2dStridedBlock(const uint64* arr, int sx, int sy); - -uint64 -hash3dStridedBlock(const uint64* arr, int sx, int sy, int sz); - -uint64 -hash4dStridedBlock(const uint64* arr, int sx, int sy, int sz, int sw); - #endif From 3ecd284ccbcffc587687370cf556cd2bc04883aa Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sun, 17 Feb 2019 17:23:16 -0800 Subject: [PATCH 021/194] extract testing timer into utils/zfpTimer as a library --- tests/src/endtoend/CMakeLists.txt | 6 +-- tests/src/endtoend/zfpEndtoendBase.c | 68 ++++++---------------------- tests/utils/CMakeLists.txt | 3 ++ tests/utils/zfpTimer.c | 56 +++++++++++++++++++++++ tests/utils/zfpTimer.h | 24 ++++++++++ 5 files changed, 101 insertions(+), 56 deletions(-) create mode 100644 tests/utils/zfpTimer.c create mode 100644 tests/utils/zfpTimer.h diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 54ae9e18a..b506adb9b 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_test dims type bits) set(serial_test_name testZfpSerial${dims}d${type}) add_executable(${serial_test_name} ${serial_test_name}.c) target_link_libraries(${serial_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${serial_test_name} m) endif() @@ -13,7 +13,7 @@ function(zfp_add_test dims type bits) add_executable(${omp_test_name} ${omp_test_name}.c) target_compile_options(${omp_test_name} PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries(${omp_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) target_link_libraries(${omp_test_name} m) @@ -28,7 +28,7 @@ function(zfp_add_test dims type bits) set(cuda_test_name testZfpCuda${dims}d${type}) add_executable(${cuda_test_name} ${cuda_test_name}.c) target_link_libraries(${cuda_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${cuda_test_name} m) endif() diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 43eedbf01..74321633f 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -8,14 +8,9 @@ #include #include -#if defined(__unix__) || defined(_WIN32) - #include -#elif defined(__MACH__) - #include -#endif - #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" +#include "utils/zfpTimer.h" #ifdef FL_PT_DATA #define MIN_TOTAL_ELEMENTS 1000000 @@ -63,12 +58,7 @@ struct setupVars { uint64 compressedChecksum; UInt decompressedChecksum; - // timer -#if defined(__unix__) || defined(_WIN32) - clock_t timeStart, timeEnd; -#elif defined(__MACH__) - uint64_t timeStart, timeEnd; -#endif + zfp_timer* timer; }; // run this once per (datatype, DIM) combination for performance @@ -434,6 +424,9 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ bundle->field = field; bundle->decompressField = decompressField; bundle->stream = stream; + + bundle->timer = zfp_timer_alloc(); + *state = bundle; return 0; @@ -458,6 +451,8 @@ teardown(void **state) free(bundle->decompressedArr); free(bundle->compressedArr); + zfp_timer_free(bundle->timer); + return 0; } @@ -468,43 +463,6 @@ when_seededRandomSmoothDataGenerated_expect_ChecksumMatches(void **state) assert_int_equal(hashArray((const UInt*)bundle->randomGenArr, bundle->totalRandomGenArrLen, 1), CHECKSUM_ORIGINAL_DATA_ARRAY); } -static void -startTimer(void **state) -{ - struct setupVars *bundle = *state; - - // set up timer -#if defined(__unix__) || defined(_WIN32) - bundle->timeStart = clock(); -#elif defined(__MACH__) - bundle->timeStart = mach_absolute_time(); -#else - fail_msg("Unknown platform (none of linux, win, osx)"); -#endif -} - -static double -stopTimer(void **state) -{ - struct setupVars *bundle = *state; - double time; - - // stop timer, compute elapsed time -#if defined(__unix__) || defined(_WIN32) - bundle->timeEnd = clock(); - time = (double)((bundle->timeEnd) - (bundle->timeStart)) / CLOCKS_PER_SEC; -#elif defined(__MACH__) - bundle->timeEnd = mach_absolute_time(); - - mach_timebase_info_data_t tb = {0}; - mach_timebase_info(&tb); - double timebase = tb.numer / tb.denom; - time = ((bundle->timeEnd) - (bundle->timeStart)) * timebase * (1E-9); -#endif - - return time; -} - static void assertZfpCompressBitstreamChecksumMatches(void **state) { @@ -514,9 +472,11 @@ assertZfpCompressBitstreamChecksumMatches(void **state) bitstream* s = zfp_stream_bit_stream(stream); // perform compression and time it - startTimer(state); + if (zfp_timer_start(bundle->timer)) { + fail_msg("Unknown platform (none of linux, win, osx)"); + } size_t result = zfp_compress(stream, field); - double time = stopTimer(state); + double time = zfp_timer_stop(bundle->timer); printf("\t\tCompress time (s): %lf\n", time); assert_int_not_equal(result, 0); @@ -661,9 +621,11 @@ assertZfpCompressDecompressChecksumMatches(void **state) // zfp_decompress() will write to bundle->decompressedArr // assert bitstream ends in same location - startTimer(state); + if (zfp_timer_start(bundle->timer)) { + fail_msg("Unknown platform (none of linux, win, osx)"); + } size_t result = zfp_decompress(stream, bundle->decompressField); - double time = stopTimer(state); + double time = zfp_timer_stop(bundle->timer); printf("\t\tDecompress time (s): %lf\n", time); assert_int_equal(compressedBytes, result); diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index e279eb8ee..e337a375f 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -25,6 +25,9 @@ add_library(fixedpoint96Lib fixedpoint96.c fixedpoint96.h) add_library(genSmoothRandNumsLib genSmoothRandNums.c genSmoothRandNums.h) target_link_libraries(genSmoothRandNumsLib PRIVATE rand64Lib fixedpoint96Lib) +# timer +add_library(zfpTimerLib zfpTimer.c zfpTimer.h) + if(HAVE_LIBM_MATH) target_link_libraries(rand32Lib PRIVATE m) target_link_libraries(rand64Lib PRIVATE m) diff --git a/tests/utils/zfpTimer.c b/tests/utils/zfpTimer.c new file mode 100644 index 000000000..1acfc5964 --- /dev/null +++ b/tests/utils/zfpTimer.c @@ -0,0 +1,56 @@ +#include "zfpTimer.h" +#include + +struct zfp_timer { +#if defined(__unix__) || defined(_WIN32) + clock_t timeStart, timeEnd; +#elif defined(__MACH__) + uint64_t timeStart, timeEnd; +#endif +}; + +zfp_timer* +zfp_timer_alloc() +{ + return malloc(sizeof(zfp_timer)); +} + +void +zfp_timer_free(zfp_timer* timer) { + free(timer); +} + +int +zfp_timer_start(zfp_timer* timer) +{ +#if defined(__unix__) || defined(_WIN32) + timer->timeStart = clock(); +#elif defined(__MACH__) + timer->timeStart = mach_absolute_time(); +#else + return 1; +#endif + return 0; +} + +double +zfp_timer_stop(zfp_timer* timer) +{ + double time; + + // stop timer, compute elapsed time +#if defined(__unix__) || defined(_WIN32) + timer->timeEnd = clock(); + time = (double)((timer->timeEnd) - (timer->timeStart)) / CLOCKS_PER_SEC; +#elif defined(__MACH__) + timer->timeEnd = mach_absolute_time(); + + mach_timebase_info_data_t tb = {0}; + mach_timebase_info(&tb); + double timebase = tb.numer / tb.denom; + time = ((timer->timeEnd) - (timer->timeStart)) * timebase * (1E-9); +#endif + + return time; +} + diff --git a/tests/utils/zfpTimer.h b/tests/utils/zfpTimer.h new file mode 100644 index 000000000..71c425ff7 --- /dev/null +++ b/tests/utils/zfpTimer.h @@ -0,0 +1,24 @@ +#ifndef ZFP_TIMER_H +#define ZFP_TIMER_H + +#if defined(__unix__) || defined(_WIN32) + #include +#elif defined(__MACH__) + #include +#endif + +typedef struct zfp_timer zfp_timer; + +zfp_timer* +zfp_timer_alloc(); + +void +zfp_timer_free(zfp_timer* timer); + +int +zfp_timer_start(zfp_timer* timer); + +double +zfp_timer_stop(zfp_timer* timer); + +#endif From 15e589efe387cd4aa36d6f0d9c9b4d72c76a62e6 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sat, 16 Feb 2019 14:54:16 -0800 Subject: [PATCH 022/194] Create tests/ checksums API (raw checksum macros replaced with static arrays so checksums can coexist) --- tests/array/testArrayBase.cpp | 10 +- tests/array/utils/gtestBaseFixture.h | 16 --- tests/cfp/testCfpArray_source.c | 24 ++--- tests/constants/1dDouble.h | 32 ------ tests/constants/1dFloat.h | 32 ------ tests/constants/1dInt32.h | 25 ----- tests/constants/1dInt64.h | 25 ----- tests/constants/2dDouble.h | 32 ------ tests/constants/2dFloat.h | 32 ------ tests/constants/2dInt32.h | 25 ----- tests/constants/2dInt64.h | 25 ----- tests/constants/3dDouble.h | 32 ------ tests/constants/3dFloat.h | 32 ------ tests/constants/3dInt32.h | 25 ----- tests/constants/3dInt64.h | 25 ----- tests/constants/4dDouble.h | 32 ------ tests/constants/4dFloat.h | 32 ------ tests/constants/4dInt32.h | 25 ----- tests/constants/4dInt64.h | 25 ----- tests/constants/checksums/1dDouble.h | 26 +++++ tests/constants/checksums/1dFloat.h | 26 +++++ tests/constants/checksums/1dInt32.h | 20 ++++ tests/constants/checksums/1dInt64.h | 20 ++++ tests/constants/checksums/2dDouble.h | 26 +++++ tests/constants/checksums/2dFloat.h | 26 +++++ tests/constants/checksums/2dInt32.h | 20 ++++ tests/constants/checksums/2dInt64.h | 20 ++++ tests/constants/checksums/3dDouble.h | 26 +++++ tests/constants/checksums/3dFloat.h | 26 +++++ tests/constants/checksums/3dInt32.h | 20 ++++ tests/constants/checksums/3dInt64.h | 20 ++++ tests/constants/checksums/4dDouble.h | 26 +++++ tests/constants/checksums/4dFloat.h | 26 +++++ tests/constants/checksums/4dInt32.h | 20 ++++ tests/constants/checksums/4dInt64.h | 20 ++++ tests/constants/checksums/checksums.h | 108 +++++++++++++++++++ tests/src/decode/zfpDecodeBlockBase.c | 9 +- tests/src/decode/zfpDecodeBlockStridedBase.c | 14 ++- tests/src/encode/zfpEncodeBlockBase.c | 9 +- tests/src/encode/zfpEncodeBlockStridedBase.c | 11 +- tests/src/endtoend/zfpEndtoendBase.c | 68 ++---------- 41 files changed, 532 insertions(+), 561 deletions(-) create mode 100644 tests/constants/checksums/1dDouble.h create mode 100644 tests/constants/checksums/1dFloat.h create mode 100644 tests/constants/checksums/1dInt32.h create mode 100644 tests/constants/checksums/1dInt64.h create mode 100644 tests/constants/checksums/2dDouble.h create mode 100644 tests/constants/checksums/2dFloat.h create mode 100644 tests/constants/checksums/2dInt32.h create mode 100644 tests/constants/checksums/2dInt64.h create mode 100644 tests/constants/checksums/3dDouble.h create mode 100644 tests/constants/checksums/3dFloat.h create mode 100644 tests/constants/checksums/3dInt32.h create mode 100644 tests/constants/checksums/3dInt64.h create mode 100644 tests/constants/checksums/4dDouble.h create mode 100644 tests/constants/checksums/4dFloat.h create mode 100644 tests/constants/checksums/4dInt32.h create mode 100644 tests/constants/checksums/4dInt64.h create mode 100644 tests/constants/checksums/checksums.h diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 609049543..e90eac786 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -1,3 +1,5 @@ +#include "constants/checksums/checksums.h" + TEST_F(TEST_FIXTURE, when_constructorCalled_then_rateSetWithWriteRandomAccess) { double rate = ZFP_RATE_PARAM_BITS; @@ -62,7 +64,7 @@ TEST_F(TEST_FIXTURE, when_setRate_then_compressionRateChanged) TEST_F(TEST_FIXTURE, when_generateRandomData_then_checksumMatches) { - EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, CHECKSUM_ORIGINAL_DATA_ARRAY, hashArray((UINT*)inputDataArr, inputDataTotalLen, 1)); + EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, getChecksumOriginalDataArray(DIMS, ZFP_TYPE), hashArray((UINT*)inputDataArr, inputDataTotalLen, 1)); } #if DIMS == 1 @@ -82,7 +84,7 @@ TEST_P(TEST_FIXTURE, given_dataset_when_set_then_underlyingBitstreamChecksumMatc ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, getRate()); #endif - uint64 expectedChecksum = getExpectedBitstreamChecksum(); + uint64 expectedChecksum = getChecksumCompressedBitstream(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, GetParam()); uint64 checksum = hashBitstream((uint64*)arr.compressed_data(), arr.compressed_size()); EXPECT_PRED_FORMAT2(ExpectNeqPrintHexPred, expectedChecksum, checksum); @@ -105,7 +107,7 @@ TEST_P(TEST_FIXTURE, given_setArray_when_get_then_decompressedValsReturned) SCALAR* decompressedArr = new SCALAR[inputDataTotalLen]; arr.get(decompressedArr); - uint64 expectedChecksum = getExpectedDecompressedChecksum(); + uint64 expectedChecksum = getChecksumDecompressedArray(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, GetParam()); uint64 checksum = hashArray((UINT*)decompressedArr, inputDataTotalLen, 1); EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); @@ -151,7 +153,7 @@ TEST_P(TEST_FIXTURE, when_configureCompressedArrayFromDefaultConstructor_then_bi arr.set_rate(getRate()); arr.set(inputDataArr); - uint64 expectedChecksum = getExpectedBitstreamChecksum(); + uint64 expectedChecksum = getChecksumCompressedBitstream(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, GetParam()); uint64 checksum = hashBitstream((uint64*)arr.compressed_data(), arr.compressed_size()); EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); } diff --git a/tests/array/utils/gtestBaseFixture.h b/tests/array/utils/gtestBaseFixture.h index 17188ce08..042a91de8 100644 --- a/tests/array/utils/gtestBaseFixture.h +++ b/tests/array/utils/gtestBaseFixture.h @@ -4,21 +4,5 @@ class ArrayNdTestFixture : public ::testing::TestWithParam { protected: - virtual void SetUp() { - bitstreamChecksums_[0] = CHECKSUM_FR_8_COMPRESSED_BITSTREAM; - bitstreamChecksums_[1] = CHECKSUM_FR_16_COMPRESSED_BITSTREAM; - bitstreamChecksums_[2] = CHECKSUM_FR_32_COMPRESSED_BITSTREAM; - - decompressedChecksums_[0] = CHECKSUM_FR_8_DECOMPRESSED_ARRAY; - decompressedChecksums_[1] = CHECKSUM_FR_16_DECOMPRESSED_ARRAY; - decompressedChecksums_[2] = CHECKSUM_FR_32_DECOMPRESSED_ARRAY; - } - double getRate() { return 1u << (GetParam() + 3); } - - uint64 getExpectedBitstreamChecksum() { return bitstreamChecksums_[GetParam()]; } - - uint64 getExpectedDecompressedChecksum() { return decompressedChecksums_[GetParam()]; } - - uint64 bitstreamChecksums_[3], decompressedChecksums_[3]; }; diff --git a/tests/cfp/testCfpArray_source.c b/tests/cfp/testCfpArray_source.c index b86af63c0..2a23f5392 100644 --- a/tests/cfp/testCfpArray_source.c +++ b/tests/cfp/testCfpArray_source.c @@ -11,6 +11,7 @@ #include "cfparrays.h" #include "zfp.h" +#include "constants/checksums/checksums.h" #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" @@ -33,9 +34,6 @@ struct setupVars { int paramNum; double rate; size_t csize; - - uint64 compressedChecksums[3]; - UInt decompressedChecksums[3]; }; // run this once per (datatype, DIM) combination for performance @@ -190,16 +188,6 @@ loadFixedRateVars(void **state, int paramNum) bundle->rate = (double)(1u << (bundle->paramNum + 3)); printf("\t\tFixed rate: %lf\n", bundle->rate); - bundle->compressedChecksums[0] = CHECKSUM_FR_8_COMPRESSED_BITSTREAM; - bundle->compressedChecksums[1] = CHECKSUM_FR_16_COMPRESSED_BITSTREAM; - bundle->compressedChecksums[2] = CHECKSUM_FR_32_COMPRESSED_BITSTREAM; - - bundle->decompressedChecksums[0] = CHECKSUM_FR_8_DECOMPRESSED_ARRAY; - bundle->decompressedChecksums[1] = CHECKSUM_FR_16_DECOMPRESSED_ARRAY; - bundle->decompressedChecksums[2] = CHECKSUM_FR_32_DECOMPRESSED_ARRAY; - - memset(bundle->decompressedArr, 0, sizeof(Scalar) * bundle->totalDataLen); - *state = bundle; return setupCfpArrLarge(state); @@ -237,7 +225,9 @@ static void when_seededRandomSmoothDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashArray((const UInt*)bundle->dataArr, bundle->totalDataLen, 1), CHECKSUM_ORIGINAL_DATA_ARRAY); + UInt checksum = hashArray((const UInt*)bundle->dataArr, bundle->totalDataLen, 1); + uint64 expectedChecksum = getChecksumOriginalDataArray(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -415,7 +405,7 @@ _catFunc3(given_, CFP_ARRAY_TYPE, _when_setArray_expect_compressedStreamChecksum size_t compressedSize = CFP_NAMESPACE.SUB_NAMESPACE.compressed_size(cfpArr); uint64 checksum = hashBitstream((uint64*)compressedPtr, compressedSize); - uint64 expectedChecksum = bundle->compressedChecksums[bundle->paramNum]; + uint64 expectedChecksum = getChecksumCompressedBitstream(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, bundle->paramNum); assert_int_equal(checksum, expectedChecksum); } @@ -428,7 +418,7 @@ _catFunc3(given_, CFP_ARRAY_TYPE, _when_getArray_expect_decompressedArrChecksumM CFP_NAMESPACE.SUB_NAMESPACE.set_array(cfpArr, bundle->dataArr); CFP_NAMESPACE.SUB_NAMESPACE.get_array(cfpArr, bundle->decompressedArr); - uint64 checksum = hashArray((UInt*)bundle->decompressedArr, bundle->totalDataLen, 1); - uint64 expectedChecksum = bundle->decompressedChecksums[bundle->paramNum]; + UInt checksum = hashArray((UInt*)bundle->decompressedArr, bundle->totalDataLen, 1); + uint64 expectedChecksum = getChecksumDecompressedArray(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, bundle->paramNum); assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/constants/1dDouble.h b/tests/constants/1dDouble.h index 54bee1c62..d7b579ff0 100644 --- a/tests/constants/1dDouble.h +++ b/tests/constants/1dDouble.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_double #define DIM_INT_STR 1dDouble - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xb519ca1b83e2b23f -#define CHECKSUM_ENCODED_BLOCK 0xd1a4b883363919a6 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x7e0c5012d3011a34 - -#define CHECKSUM_DECODED_BLOCK 0xf034a06e00000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x907a60b70d3a1692 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x49d66cd3c1044484 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xd19e1bd58ae7b771 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xd1de17cee7c8de3b -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x89204000682034e7 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xe823070a00000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x174e113400000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xa8c3e7eef220a0e4 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x713fc507f37f624d -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xa9c0457b722fce7c -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0xb6569815387d0248 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xeecbcbd400000000 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x5763edcdef7122e3 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x84a661bb59df99b6 - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0x492797c144b2f5aa -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x5f530b841d8ad3b2 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0x8aaa2c3635420ca1 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x33931390025a6c7 -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0x1245fb8d26d1004b -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x495d680180ba02ab diff --git a/tests/constants/1dFloat.h b/tests/constants/1dFloat.h index d4b8d0f29..5d3882170 100644 --- a/tests/constants/1dFloat.h +++ b/tests/constants/1dFloat.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_float #define DIM_INT_STR 1dFloat - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xa35730c2 -#define CHECKSUM_ENCODED_BLOCK 0x40bdf65ac73b115c -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xb4fe1804c2e28f46 - -#define CHECKSUM_DECODED_BLOCK 0xe7f64d14 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x6bc01e0 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x81123c83 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x6698eeddef2c576f -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xd2f86ca7a1a270e6 -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x5b428a8dde9cc0c1 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x7582fd98 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xa6e9b884 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x81123c83 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x4271157f4d1561e4 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x450fcb1330dab01a -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0xae3f40d6903e54eb -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xc298af05 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xfe1c110c -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x81123c83 - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0xe8cef6c8c8ac1e62 -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x83fe1bf6d49a1b6e -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0xe7ab29faf14866d1 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0xaef278e8 -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0x60361242 -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x67e8c596 diff --git a/tests/constants/1dInt32.h b/tests/constants/1dInt32.h index 3f4c9a033..7e003ddd0 100644 --- a/tests/constants/1dInt32.h +++ b/tests/constants/1dInt32.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 1dInt32 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xf3e7c054 -#define CHECKSUM_ENCODED_BLOCK 0xc9d92bd5bdfd2c41 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x2b7ac04c5f2c27f9 - -#define CHECKSUM_DECODED_BLOCK 0x4b38a824 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xfbfb6da8 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x224cbf63 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xd31e1d4f3028cea -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x2d76d29099fb22ec -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xb90d9da736a534a9 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xae502d39 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xdf369702 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x8e2310b0 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x804c71c729a559cf -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xbe1ef33c903369a4 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x8c1e4b2bdfca4bca -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xff2890c -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x35a6f08e -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x8e2310b0 diff --git a/tests/constants/1dInt64.h b/tests/constants/1dInt64.h index d615a7007..088cd0374 100644 --- a/tests/constants/1dInt64.h +++ b/tests/constants/1dInt64.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 1dInt64 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x10decbfab896db77 -#define CHECKSUM_ENCODED_BLOCK 0x103c2fc57809b590 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x5a808f85fa746948 - -#define CHECKSUM_DECODED_BLOCK 0x321e0ab000000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x1e0e4631271d520e - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x261f22581146db18 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xd31e1d4f3028cea -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x2d76d29099fb22ec -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x2fa06f3672c34330 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xae502d3900000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xdf36970200000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xc64d5c7c923c2a4e - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x804c71c729a559cf -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xdf50079b903369a4 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x9de253002800ea54 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xff2890c00000000 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xea935b1000000000 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xebb9a3b522e681e diff --git a/tests/constants/2dDouble.h b/tests/constants/2dDouble.h index 3e00866b9..59e8b9088 100644 --- a/tests/constants/2dDouble.h +++ b/tests/constants/2dDouble.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_double #define DIM_INT_STR 2dDouble - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x1c772c230f3ccbb4 -#define CHECKSUM_ENCODED_BLOCK 0xc0a1814da6ce303b -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xf47a9d0740fd12f1 - -#define CHECKSUM_DECODED_BLOCK 0x7ac02ede00000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x12ef3cd64903bcca - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x856a073a7252dd4 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xe4efc0e6e0c4937f -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x26ab1ab12b69d8e7 -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xd7605316605ae257 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x8e010bbc00000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xa296ec5400000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x626c78e0852013ee - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x10288c2054631266 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xb1d8865622fe6fc0 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x816b6359b90eaba1 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xd5495117b8fe1c02 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x9437836903fc33a1 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x124ac89d7f6e6511 - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0x7cb428be5481bd7b -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0xf94462ab31afa215 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0x8beb41214f9ee0d6 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x2229f480c522c420 -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0x25f62aac2713f851 -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x94fd382138403fb1 diff --git a/tests/constants/2dFloat.h b/tests/constants/2dFloat.h index faa461148..cc3e51e53 100644 --- a/tests/constants/2dFloat.h +++ b/tests/constants/2dFloat.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_float #define DIM_INT_STR 2dFloat - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xd61ebeeb -#define CHECKSUM_ENCODED_BLOCK 0xda4c301a8e0f8cee -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x584942f81bec40fb - -#define CHECKSUM_DECODED_BLOCK 0xd183b619 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x713809a7 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xe4bfe4e - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x8417e3e4287f38b5 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xf5356ab8f5b59e8a -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xa537f64220d1fc1d -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x9b77e022 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x541a3433 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xe4bfe4e - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0xd183e05b7c3be5eb -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x254679da05758c1a -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x72cd5c52aa46c2da -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0x5198a34b -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xb9126f4 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xe4bfe4e - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0x211f16ea5922b678 -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0xf2a1526474d8ee29 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0x53ed9feb9ca6dd1a -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x2e0e3c8b -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0xb6a7efcb -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x18bad4a1 diff --git a/tests/constants/2dInt32.h b/tests/constants/2dInt32.h index 8520242fb..9ed8f01da 100644 --- a/tests/constants/2dInt32.h +++ b/tests/constants/2dInt32.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 2dInt32 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x94aada73 -#define CHECKSUM_ENCODED_BLOCK 0x1264830f387e560 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xf09d2faf2ba66c16 - -#define CHECKSUM_DECODED_BLOCK 0x3ece4105 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xbb514638 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xbafc4f7c - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x2a2ecc3532b9e47c -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xa68050a6f03bbeac -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x298cca6049cda102 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xa0b51de9 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x8d1227ea -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xb331c139 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x419666be07f8fd5b -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x1bb735117e4b84c0 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x45e684a399d342bf -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xc955273b -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xb2cff311 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xb331c139 diff --git a/tests/constants/2dInt64.h b/tests/constants/2dInt64.h index d8a3bf662..b967abb23 100644 --- a/tests/constants/2dInt64.h +++ b/tests/constants/2dInt64.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 2dInt64 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x60569371027435a7 -#define CHECKSUM_ENCODED_BLOCK 0x74905e21b1d68ae2 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xc83e2f319f07372e - -#define CHECKSUM_DECODED_BLOCK 0x8cdc228000000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x6bd17a493be325d1 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xf57fe1822b2a33c8 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x2a2ecc3532b9e47c -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xa68050a6f03bbeac -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x7abe90820ae730a -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xa0b51de900000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x8d1227ea00000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x4384aefdd310e015 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x419666be07f8fd5b -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xd9cd09fd7e4b84c0 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x8bed6d7ee10836ae -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xc955273b00000000 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x74b2370100000000 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xe0b475056c768219 diff --git a/tests/constants/3dDouble.h b/tests/constants/3dDouble.h index 69143d12a..ef0ef0dec 100644 --- a/tests/constants/3dDouble.h +++ b/tests/constants/3dDouble.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_double #define DIM_INT_STR 3dDouble - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x5f9e82c4fef6f593 -#define CHECKSUM_ENCODED_BLOCK 0x20a6c761afd4380b -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x9a658e0fe05b9657 - -#define CHECKSUM_DECODED_BLOCK 0x4f653444ff3fdbe4 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x7e8c64faafedcb18 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xb29ddfb4a7719b6a - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x6b5b0dab297c9d33 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xe933645e8cf7a7c9 -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xc3d061d1944a8106 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x1e497b1f00000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xdce089f900000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x3817c78441377d10 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0xd3b75ae8488a556d -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x8d8d80142436d812 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x64e50911ed54c0ef -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xf4bd2afd74af921 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x9103ee0106602bb1 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xcd7da85356f9db40 - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0xca9d4c2be9c2a15b -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x8f79006fd9e45619 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0x5c056eecba4d5349 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x8eaf0fa126b3de89 -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0xb0dd4ed6a7196f47 -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x3262044561f9cceb diff --git a/tests/constants/3dFloat.h b/tests/constants/3dFloat.h index fd2a7cbef..90b10fcc4 100644 --- a/tests/constants/3dFloat.h +++ b/tests/constants/3dFloat.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_float #define DIM_INT_STR 3dFloat - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x54572f34 -#define CHECKSUM_ENCODED_BLOCK 0x6ad38b388f18d118 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x256107e3209389ee - -#define CHECKSUM_DECODED_BLOCK 0xd822c66d -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xc3e0b4fb - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xdbe7e231 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xe3b79c04a6174576 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xb666d473ca7d7e1c -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xb0c2a41ec2111183 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x6ea0403c -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xc2408604 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x97a819ae - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x5ec963fda5ed8273 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xa72b103d6027cbef -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x4e2c7e0bf502c3a1 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xb0695ba7 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xcdd7c8b6 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x97a819ae - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0xdb9351a2125e34e4 -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x2fd5a60cdd2227e -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0x73829fdec12a0374 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x3518c38f -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0x4f0985dd -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0xcb6afbd diff --git a/tests/constants/3dInt32.h b/tests/constants/3dInt32.h index 22ff25111..4a962de78 100644 --- a/tests/constants/3dInt32.h +++ b/tests/constants/3dInt32.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 3dInt32 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xab8e83e9 -#define CHECKSUM_ENCODED_BLOCK 0xda55ac5950c74c2 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xb85a3bd936a5c392 - -#define CHECKSUM_DECODED_BLOCK 0xdbb57cfa -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x205d2fad - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xad7ade47 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xc92ee0e3f6e6aa91 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x21b0a7777c2c5b2d -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xfe72d7ca4ce4cd2b -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xd2482c01 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x9436e0c7 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xea428b3e - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x32942f0afdb349c2 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x3a036901bbfdee14 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x8a8ae9c57224ef8e -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xb3d2ff2c -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xb9258768 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xea428b3e diff --git a/tests/constants/3dInt64.h b/tests/constants/3dInt64.h index 40ba77124..18bd3dc35 100644 --- a/tests/constants/3dInt64.h +++ b/tests/constants/3dInt64.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 3dInt64 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xcc5133515849571c -#define CHECKSUM_ENCODED_BLOCK 0x6c0ff959c2207d41 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xd6b771a93e2404f4 - -#define CHECKSUM_DECODED_BLOCK 0x4b9f52d500000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xc78c8cca00000000 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xee34e487f557278f - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0xc92ee0e3f6e6aa91 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x21b0a7777c2c5b2d -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xa8b1239155fdd8ab -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xd2482c0100000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x9436e0c700000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xc723b42e1e4f2274 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x32942f0afdb349c2 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x84e238f16919a151 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x4e6417e960207269 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xb3d2ff2c00000000 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x879bc89700000000 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xc348c52175d9ec77 diff --git a/tests/constants/4dDouble.h b/tests/constants/4dDouble.h index 3b636ceb3..864a46049 100644 --- a/tests/constants/4dDouble.h +++ b/tests/constants/4dDouble.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_double #define DIM_INT_STR 4dDouble - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x61f9b8c3ddcbe9b -#define CHECKSUM_ENCODED_BLOCK 0x3bd0d8f2da9e9acf -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x1dbd79f0a52ec95b - -#define CHECKSUM_DECODED_BLOCK 0xbf4272427fcd2646 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xdf41e51abd93ea8a - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0xe1c8a968261e4559 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x7a0d035888f5d7e3 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xc0f286466ade809e -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xbfd8f5f591cb0f2d -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0x9940d71100000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0xaead20c8a88f2622 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x4de9a84f4ab886fa - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0x94219b32ec93e2a9 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x464485425bf411aa -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x8ca875e7386e2cea -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xa1ca18c21794908b -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x7abae3fe33d0ce6a -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x6a44d79a5a33d47d - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0xc0b867f744b71cc0 -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x6a1908a569eb1a99 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0xb920196fca3513eb -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0xb8f1525cd842fbd5 -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0xb14abd4386fddb81 -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x249da35a6e8ca411 diff --git a/tests/constants/4dFloat.h b/tests/constants/4dFloat.h index 506e46bbd..29d8f5c62 100644 --- a/tests/constants/4dFloat.h +++ b/tests/constants/4dFloat.h @@ -3,35 +3,3 @@ #define FL_PT_DATA #define ZFP_TYPE zfp_type_float #define DIM_INT_STR 4dFloat - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x8c5867f7 -#define CHECKSUM_ENCODED_BLOCK 0x26580b0af77ece38 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0xb47c6e115d00b400 - -#define CHECKSUM_DECODED_BLOCK 0xda2b72f9 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xfc12ceb2 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x725f89ff - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x59e13fe363db5c6f -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0x23d6299eeaa79a9e -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0x69ff59c816afd8bd -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xb444287b -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x52fe0450 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0xd916b61 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0xeaae9de596da1479 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xf0e8cdfbb12d5bdb -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x669314f4f9637698 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0xf29a4049 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x8bc47f0d -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0xd916b61 - -#define CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM 0xc22cce8aa431fffb -#define CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM 0x4b0af02b26351468 -#define CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM 0xedc915189e4764f2 -#define CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY 0x83f41e -#define CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY 0x425b2a0d -#define CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY 0x3ca6456a diff --git a/tests/constants/4dInt32.h b/tests/constants/4dInt32.h index c732c8a85..23754ef07 100644 --- a/tests/constants/4dInt32.h +++ b/tests/constants/4dInt32.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 4dInt32 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0x8b21ff0 -#define CHECKSUM_ENCODED_BLOCK 0xf89b3fdf64ff5b5b -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x8d094f52b8fd6250 - -#define CHECKSUM_DECODED_BLOCK 0xcaa8e882 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0x86320cb4 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x89f6c535 - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x38d58bf8bf7f5b07 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xb9f8a476db61b946 -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xb44975c2cdae2907 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xbd347efd -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x6f0e9866 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x539b74c9 - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0xabd0b79d9c135337 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0xe331fda805ba7319 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0xc934178cb9e06ff5 -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0x5a8a7db4 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0xec560874 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x539b74c9 diff --git a/tests/constants/4dInt64.h b/tests/constants/4dInt64.h index ab3a54b5a..6af78053d 100644 --- a/tests/constants/4dInt64.h +++ b/tests/constants/4dInt64.h @@ -2,28 +2,3 @@ #define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 4dInt64 - -// single block -#define CHECKSUM_ORIGINAL_DATA_BLOCK 0xc9f0cadc2b040375 -#define CHECKSUM_ENCODED_BLOCK 0xbe695ffaef2d6055 -#define CHECKSUM_ENCODED_PARTIAL_BLOCK 0x3bf1627a5fd514a7 - -#define CHECKSUM_DECODED_BLOCK 0x83e0508600000000 -#define CHECKSUM_DECODED_PARTIAL_BLOCK 0xa194665700000000 - -// entire array -#define CHECKSUM_ORIGINAL_DATA_ARRAY 0x3c7a84c24a0d97db - -#define CHECKSUM_FP_8_COMPRESSED_BITSTREAM 0x38d58bf8bf7f5b07 -#define CHECKSUM_FP_16_COMPRESSED_BITSTREAM 0xb9f8a476db61b946 -#define CHECKSUM_FP_32_COMPRESSED_BITSTREAM 0xf1324a2092943e33 -#define CHECKSUM_FP_8_DECOMPRESSED_ARRAY 0xbd347efd00000000 -#define CHECKSUM_FP_16_DECOMPRESSED_ARRAY 0x6f0e986600000000 -#define CHECKSUM_FP_32_DECOMPRESSED_ARRAY 0x6b2d4650a70cb4be - -#define CHECKSUM_FR_8_COMPRESSED_BITSTREAM 0xabd0b79d9c135337 -#define CHECKSUM_FR_16_COMPRESSED_BITSTREAM 0x4269d84b05ba7319 -#define CHECKSUM_FR_32_COMPRESSED_BITSTREAM 0x3009aef996d98fa -#define CHECKSUM_FR_8_DECOMPRESSED_ARRAY 0x5a8a7db400000000 -#define CHECKSUM_FR_16_DECOMPRESSED_ARRAY 0x73c78b5d00000000 -#define CHECKSUM_FR_32_DECOMPRESSED_ARRAY 0x230d83c5490fa7dd diff --git a/tests/constants/checksums/1dDouble.h b/tests/constants/checksums/1dDouble.h new file mode 100644 index 000000000..20189ddb4 --- /dev/null +++ b/tests/constants/checksums/1dDouble.h @@ -0,0 +1,26 @@ +static const uint64 _1dDoubleChecksums[24] = { +UINT64C(0xb519ca1b83e2b23f), +UINT64C(0xd1a4b883363919a6), +UINT64C(0x7e0c5012d3011a34), +UINT64C(0xf034a06e00000000), +UINT64C(0x907a60b70d3a1692), +UINT64C(0x49d66cd3c1044484), +UINT64C(0x713fc507f37f624d), +UINT64C(0xa9c0457b722fce7c), +UINT64C(0xb6569815387d0248), +UINT64C(0xeecbcbd400000000), +UINT64C(0x5763edcdef7122e3), +UINT64C(0x84a661bb59df99b6), +UINT64C(0xd19e1bd58ae7b771), +UINT64C(0xd1de17cee7c8de3b), +UINT64C(0x89204000682034e7), +UINT64C(0xe823070a00000000), +UINT64C(0x174e113400000000), +UINT64C(0xa8c3e7eef220a0e4), +UINT64C(0x492797c144b2f5aa), +UINT64C(0x5f530b841d8ad3b2), +UINT64C(0x8aaa2c3635420ca1), +UINT64C(0x033931390025a6c7), +UINT64C(0x1245fb8d26d1004b), +UINT64C(0x495d680180ba02ab), +}; diff --git a/tests/constants/checksums/1dFloat.h b/tests/constants/checksums/1dFloat.h new file mode 100644 index 000000000..00c5add67 --- /dev/null +++ b/tests/constants/checksums/1dFloat.h @@ -0,0 +1,26 @@ +static const uint64 _1dFloatChecksums[24] = { +UINT64C(0xa35730c2), +UINT64C(0x40bdf65ac73b115c), +UINT64C(0xb4fe1804c2e28f46), +UINT64C(0xe7f64d14), +UINT64C(0x06bc01e0), +UINT64C(0x81123c83), +UINT64C(0x4271157f4d1561e4), +UINT64C(0x450fcb1330dab01a), +UINT64C(0xae3f40d6903e54eb), +UINT64C(0xc298af05), +UINT64C(0xfe1c110c), +UINT64C(0x81123c83), +UINT64C(0x6698eeddef2c576f), +UINT64C(0xd2f86ca7a1a270e6), +UINT64C(0x5b428a8dde9cc0c1), +UINT64C(0x7582fd98), +UINT64C(0xa6e9b884), +UINT64C(0x81123c83), +UINT64C(0xe8cef6c8c8ac1e62), +UINT64C(0x83fe1bf6d49a1b6e), +UINT64C(0xe7ab29faf14866d1), +UINT64C(0xaef278e8), +UINT64C(0x60361242), +UINT64C(0x67e8c596), +}; diff --git a/tests/constants/checksums/1dInt32.h b/tests/constants/checksums/1dInt32.h new file mode 100644 index 000000000..007be8e99 --- /dev/null +++ b/tests/constants/checksums/1dInt32.h @@ -0,0 +1,20 @@ +static const uint64 _1dInt32Checksums[18] = { +UINT64C(0xf3e7c054), +UINT64C(0xc9d92bd5bdfd2c41), +UINT64C(0x2b7ac04c5f2c27f9), +UINT64C(0x4b38a824), +UINT64C(0xfbfb6da8), +UINT64C(0x224cbf63), +UINT64C(0x804c71c729a559cf), +UINT64C(0xbe1ef33c903369a4), +UINT64C(0x8c1e4b2bdfca4bca), +UINT64C(0x0ff2890c), +UINT64C(0x35a6f08e), +UINT64C(0x8e2310b0), +UINT64C(0x0d31e1d4f3028cea), +UINT64C(0x2d76d29099fb22ec), +UINT64C(0xb90d9da736a534a9), +UINT64C(0xae502d39), +UINT64C(0xdf369702), +UINT64C(0x8e2310b0), +}; diff --git a/tests/constants/checksums/1dInt64.h b/tests/constants/checksums/1dInt64.h new file mode 100644 index 000000000..f4296d7cc --- /dev/null +++ b/tests/constants/checksums/1dInt64.h @@ -0,0 +1,20 @@ +static const uint64 _1dInt64Checksums[18] = { +UINT64C(0x10decbfab896db77), +UINT64C(0x103c2fc57809b590), +UINT64C(0x5a808f85fa746948), +UINT64C(0x321e0ab000000000), +UINT64C(0x1e0e4631271d520e), +UINT64C(0x261f22581146db18), +UINT64C(0x804c71c729a559cf), +UINT64C(0xdf50079b903369a4), +UINT64C(0x9de253002800ea54), +UINT64C(0x0ff2890c00000000), +UINT64C(0xea935b1000000000), +UINT64C(0x0ebb9a3b522e681e), +UINT64C(0x0d31e1d4f3028cea), +UINT64C(0x2d76d29099fb22ec), +UINT64C(0x2fa06f3672c34330), +UINT64C(0xae502d3900000000), +UINT64C(0xdf36970200000000), +UINT64C(0xc64d5c7c923c2a4e), +}; diff --git a/tests/constants/checksums/2dDouble.h b/tests/constants/checksums/2dDouble.h new file mode 100644 index 000000000..953cdb5ba --- /dev/null +++ b/tests/constants/checksums/2dDouble.h @@ -0,0 +1,26 @@ +static const uint64 _2dDoubleChecksums[24] = { +UINT64C(0x1c772c230f3ccbb4), +UINT64C(0xc0a1814da6ce303b), +UINT64C(0xf47a9d0740fd12f1), +UINT64C(0x7ac02ede00000000), +UINT64C(0x12ef3cd64903bcca), +UINT64C(0x856a073a7252dd4), +UINT64C(0x10288c2054631266), +UINT64C(0xb1d8865622fe6fc0), +UINT64C(0x816b6359b90eaba1), +UINT64C(0xd5495117b8fe1c02), +UINT64C(0x9437836903fc33a1), +UINT64C(0x124ac89d7f6e6511), +UINT64C(0xe4efc0e6e0c4937f), +UINT64C(0x26ab1ab12b69d8e7), +UINT64C(0xd7605316605ae257), +UINT64C(0x8e010bbc00000000), +UINT64C(0xa296ec5400000000), +UINT64C(0x626c78e0852013ee), +UINT64C(0x7cb428be5481bd7b), +UINT64C(0xf94462ab31afa215), +UINT64C(0x8beb41214f9ee0d6), +UINT64C(0x2229f480c522c420), +UINT64C(0x25f62aac2713f851), +UINT64C(0x94fd382138403fb1), +}; diff --git a/tests/constants/checksums/2dFloat.h b/tests/constants/checksums/2dFloat.h new file mode 100644 index 000000000..7b4121c7b --- /dev/null +++ b/tests/constants/checksums/2dFloat.h @@ -0,0 +1,26 @@ +static const uint64 _2dFloatChecksums[24] = { +UINT64C(0xd61ebeeb), +UINT64C(0xda4c301a8e0f8cee), +UINT64C(0x584942f81bec40fb), +UINT64C(0xd183b619), +UINT64C(0x713809a7), +UINT64C(0xe4bfe4e), +UINT64C(0xd183e05b7c3be5eb), +UINT64C(0x254679da05758c1a), +UINT64C(0x72cd5c52aa46c2da), +UINT64C(0x5198a34b), +UINT64C(0xb9126f4), +UINT64C(0xe4bfe4e), +UINT64C(0x8417e3e4287f38b5), +UINT64C(0xf5356ab8f5b59e8a), +UINT64C(0xa537f64220d1fc1d), +UINT64C(0x9b77e022), +UINT64C(0x541a3433), +UINT64C(0xe4bfe4e), +UINT64C(0x211f16ea5922b678), +UINT64C(0xf2a1526474d8ee29), +UINT64C(0x53ed9feb9ca6dd1a), +UINT64C(0x2e0e3c8b), +UINT64C(0xb6a7efcb), +UINT64C(0x18bad4a1), +}; diff --git a/tests/constants/checksums/2dInt32.h b/tests/constants/checksums/2dInt32.h new file mode 100644 index 000000000..87a9d2936 --- /dev/null +++ b/tests/constants/checksums/2dInt32.h @@ -0,0 +1,20 @@ +static const uint64 _2dInt32Checksums[18] = { +UINT64C(0x94aada73), +UINT64C(0x1264830f387e560), +UINT64C(0xf09d2faf2ba66c16), +UINT64C(0x3ece4105), +UINT64C(0xbb514638), +UINT64C(0xbafc4f7c), +UINT64C(0x419666be07f8fd5b), +UINT64C(0x1bb735117e4b84c0), +UINT64C(0x45e684a399d342bf), +UINT64C(0xc955273b), +UINT64C(0xb2cff311), +UINT64C(0xb331c139), +UINT64C(0x2a2ecc3532b9e47c), +UINT64C(0xa68050a6f03bbeac), +UINT64C(0x298cca6049cda102), +UINT64C(0xa0b51de9), +UINT64C(0x8d1227ea), +UINT64C(0xb331c139), +}; diff --git a/tests/constants/checksums/2dInt64.h b/tests/constants/checksums/2dInt64.h new file mode 100644 index 000000000..c03e91770 --- /dev/null +++ b/tests/constants/checksums/2dInt64.h @@ -0,0 +1,20 @@ +static const uint64 _2dInt64Checksums[18] = { +UINT64C(0x60569371027435a7), +UINT64C(0x74905e21b1d68ae2), +UINT64C(0xc83e2f319f07372e), +UINT64C(0x8cdc228000000000), +UINT64C(0x6bd17a493be325d1), +UINT64C(0xf57fe1822b2a33c8), +UINT64C(0x419666be07f8fd5b), +UINT64C(0xd9cd09fd7e4b84c0), +UINT64C(0x8bed6d7ee10836ae), +UINT64C(0xc955273b00000000), +UINT64C(0x74b2370100000000), +UINT64C(0xe0b475056c768219), +UINT64C(0x2a2ecc3532b9e47c), +UINT64C(0xa68050a6f03bbeac), +UINT64C(0x7abe90820ae730a), +UINT64C(0xa0b51de900000000), +UINT64C(0x8d1227ea00000000), +UINT64C(0x4384aefdd310e015), +}; diff --git a/tests/constants/checksums/3dDouble.h b/tests/constants/checksums/3dDouble.h new file mode 100644 index 000000000..288d29466 --- /dev/null +++ b/tests/constants/checksums/3dDouble.h @@ -0,0 +1,26 @@ +static const uint64 _3dDoubleChecksums[24] = { +UINT64C(0x5f9e82c4fef6f593), +UINT64C(0x20a6c761afd4380b), +UINT64C(0x9a658e0fe05b9657), +UINT64C(0x4f653444ff3fdbe4), +UINT64C(0x7e8c64faafedcb18), +UINT64C(0xb29ddfb4a7719b6a), +UINT64C(0xd3b75ae8488a556d), +UINT64C(0x8d8d80142436d812), +UINT64C(0x64e50911ed54c0ef), +UINT64C(0xf4bd2afd74af921), +UINT64C(0x9103ee0106602bb1), +UINT64C(0xcd7da85356f9db40), +UINT64C(0x6b5b0dab297c9d33), +UINT64C(0xe933645e8cf7a7c9), +UINT64C(0xc3d061d1944a8106), +UINT64C(0x1e497b1f00000000), +UINT64C(0xdce089f900000000), +UINT64C(0x3817c78441377d10), +UINT64C(0xca9d4c2be9c2a15b), +UINT64C(0x8f79006fd9e45619), +UINT64C(0x5c056eecba4d5349), +UINT64C(0x8eaf0fa126b3de89), +UINT64C(0xb0dd4ed6a7196f47), +UINT64C(0x3262044561f9cceb), +}; diff --git a/tests/constants/checksums/3dFloat.h b/tests/constants/checksums/3dFloat.h new file mode 100644 index 000000000..cf05bcd2f --- /dev/null +++ b/tests/constants/checksums/3dFloat.h @@ -0,0 +1,26 @@ +static const uint64 _3dFloatChecksums[24] = { +UINT64C(0x54572f34), +UINT64C(0x6ad38b388f18d118), +UINT64C(0x256107e3209389ee), +UINT64C(0xd822c66d), +UINT64C(0xc3e0b4fb), +UINT64C(0xdbe7e231), +UINT64C(0x5ec963fda5ed8273), +UINT64C(0xa72b103d6027cbef), +UINT64C(0x4e2c7e0bf502c3a1), +UINT64C(0xb0695ba7), +UINT64C(0xcdd7c8b6), +UINT64C(0x97a819ae), +UINT64C(0xe3b79c04a6174576), +UINT64C(0xb666d473ca7d7e1c), +UINT64C(0xb0c2a41ec2111183), +UINT64C(0x6ea0403c), +UINT64C(0xc2408604), +UINT64C(0x97a819ae), +UINT64C(0xdb9351a2125e34e4), +UINT64C(0x2fd5a60cdd2227e), +UINT64C(0x73829fdec12a0374), +UINT64C(0x3518c38f), +UINT64C(0x4f0985dd), +UINT64C(0xcb6afbd), +}; diff --git a/tests/constants/checksums/3dInt32.h b/tests/constants/checksums/3dInt32.h new file mode 100644 index 000000000..bf324195d --- /dev/null +++ b/tests/constants/checksums/3dInt32.h @@ -0,0 +1,20 @@ +static const uint64 _3dInt32Checksums[18] = { +UINT64C(0xab8e83e9), +UINT64C(0xda55ac5950c74c2), +UINT64C(0xb85a3bd936a5c392), +UINT64C(0xdbb57cfa), +UINT64C(0x205d2fad), +UINT64C(0xad7ade47), +UINT64C(0x32942f0afdb349c2), +UINT64C(0x3a036901bbfdee14), +UINT64C(0x8a8ae9c57224ef8e), +UINT64C(0xb3d2ff2c), +UINT64C(0xb9258768), +UINT64C(0xea428b3e), +UINT64C(0xc92ee0e3f6e6aa91), +UINT64C(0x21b0a7777c2c5b2d), +UINT64C(0xfe72d7ca4ce4cd2b), +UINT64C(0xd2482c01), +UINT64C(0x9436e0c7), +UINT64C(0xea428b3e), +}; diff --git a/tests/constants/checksums/3dInt64.h b/tests/constants/checksums/3dInt64.h new file mode 100644 index 000000000..8462a4bca --- /dev/null +++ b/tests/constants/checksums/3dInt64.h @@ -0,0 +1,20 @@ +static const uint64 _3dInt64Checksums[18] = { +UINT64C(0xcc5133515849571c), +UINT64C(0x6c0ff959c2207d41), +UINT64C(0xd6b771a93e2404f4), +UINT64C(0x4b9f52d500000000), +UINT64C(0xc78c8cca00000000), +UINT64C(0xee34e487f557278f), +UINT64C(0x32942f0afdb349c2), +UINT64C(0x84e238f16919a151), +UINT64C(0x4e6417e960207269), +UINT64C(0xb3d2ff2c00000000), +UINT64C(0x879bc89700000000), +UINT64C(0xc348c52175d9ec77), +UINT64C(0xc92ee0e3f6e6aa91), +UINT64C(0x21b0a7777c2c5b2d), +UINT64C(0xa8b1239155fdd8ab), +UINT64C(0xd2482c0100000000), +UINT64C(0x9436e0c700000000), +UINT64C(0xc723b42e1e4f2274), +}; diff --git a/tests/constants/checksums/4dDouble.h b/tests/constants/checksums/4dDouble.h new file mode 100644 index 000000000..9de5d4be6 --- /dev/null +++ b/tests/constants/checksums/4dDouble.h @@ -0,0 +1,26 @@ +static const uint64 _4dDoubleChecksums[24] = { +UINT64C(0x61f9b8c3ddcbe9b), +UINT64C(0x3bd0d8f2da9e9acf), +UINT64C(0x1dbd79f0a52ec95b), +UINT64C(0xbf4272427fcd2646), +UINT64C(0xdf41e51abd93ea8a), +UINT64C(0xe1c8a968261e4559), +UINT64C(0x94219b32ec93e2a9), +UINT64C(0x464485425bf411aa), +UINT64C(0x8ca875e7386e2cea), +UINT64C(0xa1ca18c21794908b), +UINT64C(0x7abae3fe33d0ce6a), +UINT64C(0x6a44d79a5a33d47d), +UINT64C(0x7a0d035888f5d7e3), +UINT64C(0xc0f286466ade809e), +UINT64C(0xbfd8f5f591cb0f2d), +UINT64C(0x9940d71100000000), +UINT64C(0xaead20c8a88f2622), +UINT64C(0x4de9a84f4ab886fa), +UINT64C(0xc0b867f744b71cc0), +UINT64C(0x6a1908a569eb1a99), +UINT64C(0xb920196fca3513eb), +UINT64C(0xb8f1525cd842fbd5), +UINT64C(0xb14abd4386fddb81), +UINT64C(0x249da35a6e8ca411), +}; diff --git a/tests/constants/checksums/4dFloat.h b/tests/constants/checksums/4dFloat.h new file mode 100644 index 000000000..da08009e2 --- /dev/null +++ b/tests/constants/checksums/4dFloat.h @@ -0,0 +1,26 @@ +static const uint64 _4dFloatChecksums[24] = { +UINT64C(0x8c5867f7), +UINT64C(0x26580b0af77ece38), +UINT64C(0xb47c6e115d00b400), +UINT64C(0xda2b72f9), +UINT64C(0xfc12ceb2), +UINT64C(0x725f89ff), +UINT64C(0xeaae9de596da1479), +UINT64C(0xf0e8cdfbb12d5bdb), +UINT64C(0x669314f4f9637698), +UINT64C(0xf29a4049), +UINT64C(0x8bc47f0d), +UINT64C(0xd916b61), +UINT64C(0x59e13fe363db5c6f), +UINT64C(0x23d6299eeaa79a9e), +UINT64C(0x69ff59c816afd8bd), +UINT64C(0xb444287b), +UINT64C(0x52fe0450), +UINT64C(0xd916b61), +UINT64C(0xc22cce8aa431fffb), +UINT64C(0x4b0af02b26351468), +UINT64C(0xedc915189e4764f2), +UINT64C(0x83f41e), +UINT64C(0x425b2a0d), +UINT64C(0x3ca6456a), +}; diff --git a/tests/constants/checksums/4dInt32.h b/tests/constants/checksums/4dInt32.h new file mode 100644 index 000000000..a0689111f --- /dev/null +++ b/tests/constants/checksums/4dInt32.h @@ -0,0 +1,20 @@ +static const uint64 _4dInt32Checksums[18] = { +UINT64C(0x8b21ff0), +UINT64C(0xf89b3fdf64ff5b5b), +UINT64C(0x8d094f52b8fd6250), +UINT64C(0xcaa8e882), +UINT64C(0x86320cb4), +UINT64C(0x89f6c535), +UINT64C(0xabd0b79d9c135337), +UINT64C(0xe331fda805ba7319), +UINT64C(0xc934178cb9e06ff5), +UINT64C(0x5a8a7db4), +UINT64C(0xec560874), +UINT64C(0x539b74c9), +UINT64C(0x38d58bf8bf7f5b07), +UINT64C(0xb9f8a476db61b946), +UINT64C(0xb44975c2cdae2907), +UINT64C(0xbd347efd), +UINT64C(0x6f0e9866), +UINT64C(0x539b74c9), +}; diff --git a/tests/constants/checksums/4dInt64.h b/tests/constants/checksums/4dInt64.h new file mode 100644 index 000000000..16d6bfb7f --- /dev/null +++ b/tests/constants/checksums/4dInt64.h @@ -0,0 +1,20 @@ +static const uint64 _4dInt64Checksums[18] = { +UINT64C(0xc9f0cadc2b040375), +UINT64C(0xbe695ffaef2d6055), +UINT64C(0x3bf1627a5fd514a7), +UINT64C(0x83e0508600000000), +UINT64C(0xa194665700000000), +UINT64C(0x3c7a84c24a0d97db), +UINT64C(0xabd0b79d9c135337), +UINT64C(0x4269d84b05ba7319), +UINT64C(0x3009aef996d98fa), +UINT64C(0x5a8a7db400000000), +UINT64C(0x73c78b5d00000000), +UINT64C(0x230d83c5490fa7dd), +UINT64C(0x38d58bf8bf7f5b07), +UINT64C(0xb9f8a476db61b946), +UINT64C(0xf1324a2092943e33), +UINT64C(0xbd347efd00000000), +UINT64C(0x6f0e986600000000), +UINT64C(0x6b2d4650a70cb4be), +}; diff --git a/tests/constants/checksums/checksums.h b/tests/constants/checksums/checksums.h new file mode 100644 index 000000000..23c762b57 --- /dev/null +++ b/tests/constants/checksums/checksums.h @@ -0,0 +1,108 @@ +#include "zfp/types.h" + +#include "constants/checksums/1dInt32.h" +#include "constants/checksums/1dInt64.h" +#include "constants/checksums/1dFloat.h" +#include "constants/checksums/1dDouble.h" +#include "constants/checksums/2dInt32.h" +#include "constants/checksums/2dInt64.h" +#include "constants/checksums/2dFloat.h" +#include "constants/checksums/2dDouble.h" +#include "constants/checksums/3dInt32.h" +#include "constants/checksums/3dInt64.h" +#include "constants/checksums/3dFloat.h" +#include "constants/checksums/3dDouble.h" +#include "constants/checksums/4dInt32.h" +#include "constants/checksums/4dInt64.h" +#include "constants/checksums/4dFloat.h" +#include "constants/checksums/4dDouble.h" + +// [dimensionality][zfp_type] +static const uint64* checksums[4][4] = { + { + _1dInt32Checksums, + _1dInt64Checksums, + _1dFloatChecksums, + _1dDoubleChecksums, + }, + { + _2dInt32Checksums, + _2dInt64Checksums, + _2dFloatChecksums, + _2dDoubleChecksums, + }, + { + _3dInt32Checksums, + _3dInt64Checksums, + _3dFloatChecksums, + _3dDoubleChecksums, + }, + { + _4dInt32Checksums, + _4dInt64Checksums, + _4dFloatChecksums, + _4dDoubleChecksums, + }, +}; + +static const uint64* +getChecksumPtr(int dims, zfp_type type) +{ + return checksums[dims - 1][type - zfp_type_int32]; +} + +uint64 +getChecksumOriginalDataBlock(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[0]; +} + +uint64 +getChecksumEncodedBlock(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[1]; +} + +uint64 +getChecksumEncodedPartialBlock(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[2]; +} + +uint64 +getChecksumDecodedBlock(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[3]; +} + +uint64 +getChecksumDecodedPartialBlock(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[4]; +} + +uint64 +getChecksumOriginalDataArray(int dims, zfp_type type) +{ + return getChecksumPtr(dims, type)[5]; +} + +static size_t +getZfpModeOffset(zfp_mode mode) +{ + return 6 + 6 * (mode - zfp_mode_fixed_rate); +} + +uint64 +getChecksumCompressedBitstream(int dims, zfp_type type, zfp_mode mode, int compressParamNum) +{ + size_t offset = getZfpModeOffset(mode) + compressParamNum; + return getChecksumPtr(dims, type)[offset]; +} + +uint64 +getChecksumDecompressedArray(int dims, zfp_type type, zfp_mode mode, int compressParamNum) +{ + size_t offset = getZfpModeOffset(mode) + 3 + compressParamNum; + return getChecksumPtr(dims, type)[offset]; +} diff --git a/tests/src/decode/zfpDecodeBlockBase.c b/tests/src/decode/zfpDecodeBlockBase.c index 066f5f5a7..5381861a2 100644 --- a/tests/src/decode/zfpDecodeBlockBase.c +++ b/tests/src/decode/zfpDecodeBlockBase.c @@ -4,6 +4,8 @@ #include #include + +#include "constants/checksums/checksums.h" #include "utils/testMacros.h" struct setupVars { @@ -89,7 +91,9 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1), CHECKSUM_ORIGINAL_DATA_BLOCK); + UInt checksum = hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); + uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -125,5 +129,6 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ArrayChecksumMatche UInt checksum = hashArray((const UInt*)decodedDataArr, BLOCK_SIZE, 1); free(decodedDataArr); - assert_int_equal(checksum, CHECKSUM_DECODED_BLOCK); + uint64 expectedChecksum = getChecksumDecodedBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index 654f1a746..20d466b22 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -4,6 +4,8 @@ #include #include + +#include "constants/checksums/checksums.h" #include "utils/testMacros.h" #define SX 2 @@ -479,7 +481,9 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashStridedBlock(bundle->dataArr), CHECKSUM_ORIGINAL_DATA_BLOCK); + UInt checksum = hashStridedBlock(bundle->dataArr); + uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -524,7 +528,9 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_ArrayChecksu decodeBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedBlock(bundle->decodedDataArr), CHECKSUM_DECODED_BLOCK); + UInt checksum = hashStridedBlock(bundle->decodedDataArr); + uint64 expectedChecksum = getChecksumDecodedBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -583,5 +589,7 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_Array decodePartialBlockStrided(stream, bundle->decodedDataArr); - assert_int_equal(hashStridedBlock(bundle->decodedDataArr), CHECKSUM_DECODED_PARTIAL_BLOCK); + UInt checksum = hashStridedBlock(bundle->decodedDataArr); + uint64 expectedChecksum = getChecksumDecodedPartialBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index 84074322f..500fdd743 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -4,6 +4,8 @@ #include #include + +#include "constants/checksums/checksums.h" #include "utils/testMacros.h" struct setupVars { @@ -89,7 +91,9 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1), CHECKSUM_ORIGINAL_DATA_BLOCK); + UInt checksum = hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); + uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -116,5 +120,6 @@ _catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_BitstreamChecksumMa zfp_stream_flush(stream); uint64 checksum = hashBitstream(stream_data(s), stream_size(s)); - assert_int_equal(checksum, CHECKSUM_ENCODED_BLOCK); + uint64 expectedChecksum = getChecksumEncodedBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/encode/zfpEncodeBlockStridedBase.c b/tests/src/encode/zfpEncodeBlockStridedBase.c index 25babc8e7..901162b80 100644 --- a/tests/src/encode/zfpEncodeBlockStridedBase.c +++ b/tests/src/encode/zfpEncodeBlockStridedBase.c @@ -4,6 +4,8 @@ #include #include + +#include "constants/checksums/checksums.h" #include "utils/testMacros.h" #define SX 2 @@ -263,7 +265,8 @@ when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) int s[4] = {SX, SY, SZ, SW}; UInt checksum = hashStridedArray((const UInt*)bundle->dataArr, n, s); - assert_int_equal(checksum, CHECKSUM_ORIGINAL_DATA_BLOCK); + uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -321,7 +324,8 @@ _catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlockStrided_expect_BitstreamChe zfp_stream_flush(stream); uint64 checksum = hashBitstream(stream_data(s), stream_size(s)); - assert_int_equal(checksum, CHECKSUM_ENCODED_BLOCK); + uint64 expectedChecksum = getChecksumEncodedBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -452,5 +456,6 @@ _catFunc3(given_, DIM_INT_STR, Block_when_EncodePartialBlockStrided_expect_Bitst zfp_stream_flush(stream); uint64 checksum = hashBitstream(stream_data(s), stream_size(s)); - assert_int_equal(checksum, CHECKSUM_ENCODED_PARTIAL_BLOCK); + uint64 expectedChecksum = getChecksumEncodedPartialBlock(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 74321633f..786da6933 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -8,6 +8,7 @@ #include #include +#include "constants/checksums/checksums.h" #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" #include "utils/zfpTimer.h" @@ -55,9 +56,6 @@ struct setupVars { stride_config stride; - uint64 compressedChecksum; - UInt decompressedChecksum; - zfp_timer* timer; }; @@ -334,7 +332,7 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_stream_set_bit_stream(stream, s); zfp_stream_rewind(stream); - // grab checksums for this compressParamNum + // set compression mode for this compressParamNum if (compressParamNum > 2 || compressParamNum < 0) { fail_msg("Unknown compressParamNum during setupChosenZfpMode()"); } @@ -346,23 +344,6 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_stream_set_precision(stream, bundle->precParam); printf("\t\tFixed precision param: %u\n", bundle->precParam); - switch(compressParamNum) { - case 0: - bundle->compressedChecksum = CHECKSUM_FP_8_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FP_8_DECOMPRESSED_ARRAY; - break; - - case 1: - bundle->compressedChecksum = CHECKSUM_FP_16_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FP_16_DECOMPRESSED_ARRAY; - break; - - case 2: - bundle->compressedChecksum = CHECKSUM_FP_32_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FP_32_DECOMPRESSED_ARRAY; - break; - } - break; case zfp_mode_fixed_rate: @@ -370,23 +351,6 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_stream_set_rate(stream, (double)bundle->rateParam, type, DIMS, 0); printf("\t\tFixed rate param: %lu\n", (unsigned long)bundle->rateParam); - switch(compressParamNum) { - case 0: - bundle->compressedChecksum = CHECKSUM_FR_8_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FR_8_DECOMPRESSED_ARRAY; - break; - - case 1: - bundle->compressedChecksum = CHECKSUM_FR_16_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FR_16_DECOMPRESSED_ARRAY; - break; - - case 2: - bundle->compressedChecksum = CHECKSUM_FR_32_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FR_32_DECOMPRESSED_ARRAY; - break; - } - break; #ifdef FL_PT_DATA @@ -395,23 +359,6 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_stream_set_accuracy(stream, bundle->accParam); printf("\t\tFixed accuracy param: %lf\n", bundle->accParam); - switch(compressParamNum) { - case 0: - bundle->compressedChecksum = CHECKSUM_FA_0p5_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FA_0p5_DECOMPRESSED_ARRAY; - break; - - case 1: - bundle->compressedChecksum = CHECKSUM_FA_0p25_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FA_0p25_DECOMPRESSED_ARRAY; - break; - - case 2: - bundle->compressedChecksum = CHECKSUM_FA_0p0625_COMPRESSED_BITSTREAM; - bundle->decompressedChecksum = CHECKSUM_FA_0p0625_DECOMPRESSED_ARRAY; - break; - } - break; #endif @@ -460,7 +407,9 @@ static void when_seededRandomSmoothDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - assert_int_equal(hashArray((const UInt*)bundle->randomGenArr, bundle->totalRandomGenArrLen, 1), CHECKSUM_ORIGINAL_DATA_ARRAY); + UInt checksum = hashArray((const UInt*)bundle->randomGenArr, bundle->totalRandomGenArrLen, 1); + uint64 expectedChecksum = getChecksumOriginalDataArray(DIMS, ZFP_TYPE); + assert_int_equal(checksum, expectedChecksum); } static void @@ -481,7 +430,8 @@ assertZfpCompressBitstreamChecksumMatches(void **state) assert_int_not_equal(result, 0); uint64 checksum = hashBitstream(stream_data(s), stream_size(s)); - assert_int_equal(checksum, bundle->compressedChecksum); + uint64 expectedChecksum = getChecksumCompressedBitstream(DIMS, ZFP_TYPE, zfp_stream_compression_mode(stream), bundle->compressParamNum); + assert_int_equal(checksum, expectedChecksum); } #ifdef ZFP_TEST_SERIAL @@ -654,7 +604,9 @@ assertZfpCompressDecompressChecksumMatches(void **state) checksum = hashArray(arr, bundle->totalRandomGenArrLen, 1); break; } - assert_int_equal(checksum, bundle->decompressedChecksum); + + uint64 expectedChecksum = getChecksumDecompressedArray(DIMS, ZFP_TYPE, zfp_stream_compression_mode(stream), bundle->compressParamNum); + assert_int_equal(checksum, expectedChecksum); } static void From e9aada103b1854553721bbedc13e5862946fd8f3 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 19 Feb 2019 01:11:48 -0800 Subject: [PATCH 023/194] tests/ checksum API is now a standalone library --- tests/array/CMakeLists.txt | 2 +- tests/array/testArrayBase.cpp | 4 ++- tests/cfp/CMakeLists.txt | 2 +- tests/cfp/testCfpArray_source.c | 2 +- tests/src/decode/CMakeLists.txt | 4 +-- tests/src/decode/zfpDecodeBlockBase.c | 2 +- tests/src/decode/zfpDecodeBlockStridedBase.c | 2 +- tests/src/encode/CMakeLists.txt | 4 +-- tests/src/encode/zfpEncodeBlockBase.c | 2 +- tests/src/encode/zfpEncodeBlockStridedBase.c | 2 +- tests/src/endtoend/CMakeLists.txt | 6 ++-- tests/src/endtoend/zfpEndtoendBase.c | 2 +- tests/utils/CMakeLists.txt | 3 ++ .../checksums.h => utils/zfpChecksums.c} | 21 ++++++++----- tests/utils/zfpChecksums.h | 30 +++++++++++++++++++ 15 files changed, 64 insertions(+), 24 deletions(-) rename tests/{constants/checksums/checksums.h => utils/zfpChecksums.c} (97%) create mode 100644 tests/utils/zfpChecksums.h diff --git a/tests/array/CMakeLists.txt b/tests/array/CMakeLists.txt index d76a6ed40..26ff94a8e 100644 --- a/tests/array/CMakeLists.txt +++ b/tests/array/CMakeLists.txt @@ -3,7 +3,7 @@ function(zfp_add_cpp_tests dims type bits) set(test_name testArray${dims}${type}) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} - gtest gtest_main zfp hash${bits}Lib genSmoothRandNumsLib) + gtest gtest_main zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's references diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index e90eac786..52056014c 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -1,4 +1,6 @@ -#include "constants/checksums/checksums.h" +extern "C" { + #include "utils/zfpChecksums.h" +} TEST_F(TEST_FIXTURE, when_constructorCalled_then_rateSetWithWriteRandomAccess) { diff --git a/tests/cfp/CMakeLists.txt b/tests/cfp/CMakeLists.txt index b8b760ea1..037d2ff50 100644 --- a/tests/cfp/CMakeLists.txt +++ b/tests/cfp/CMakeLists.txt @@ -2,7 +2,7 @@ function(cfp_add_test dims type bits) set(test_name testCfpArray${dims}${type}) add_executable(${test_name} ${test_name}.c) target_link_libraries(${test_name} - cmocka cfp hash${bits}Lib genSmoothRandNumsLib) + cmocka cfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib) add_test(NAME ${test_name} COMMAND ${test_name}) endfunction() diff --git a/tests/cfp/testCfpArray_source.c b/tests/cfp/testCfpArray_source.c index 2a23f5392..e376c99fc 100644 --- a/tests/cfp/testCfpArray_source.c +++ b/tests/cfp/testCfpArray_source.c @@ -11,9 +11,9 @@ #include "cfparrays.h" #include "zfp.h" -#include "constants/checksums/checksums.h" #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" #define SIZE_X 20 #define SIZE_Y 31 diff --git a/tests/src/decode/CMakeLists.txt b/tests/src/decode/CMakeLists.txt index b4f998f4e..4a5b35793 100644 --- a/tests/src/decode/CMakeLists.txt +++ b/tests/src/decode/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_block_tests dims type bits) set(block_test_name testZfpDecodeBlock${dims}d${type}) add_executable(${block_test_name} ${block_test_name}.c) target_link_libraries(${block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib) + cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${block_test_name} m) endif() @@ -11,7 +11,7 @@ function(zfp_add_block_tests dims type bits) set(strided_block_test_name testZfpDecodeBlockStrided${dims}d${type}) add_executable(${strided_block_test_name} ${strided_block_test_name}.c) target_link_libraries(${strided_block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib) + cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${strided_block_test_name} m) endif() diff --git a/tests/src/decode/zfpDecodeBlockBase.c b/tests/src/decode/zfpDecodeBlockBase.c index 5381861a2..68c38acb8 100644 --- a/tests/src/decode/zfpDecodeBlockBase.c +++ b/tests/src/decode/zfpDecodeBlockBase.c @@ -5,8 +5,8 @@ #include -#include "constants/checksums/checksums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" struct setupVars { Scalar* dataArr; diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index 20d466b22..2a436921e 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -5,8 +5,8 @@ #include -#include "constants/checksums/checksums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" #define SX 2 #define SY (3 * BLOCK_SIDE_LEN*SX) diff --git a/tests/src/encode/CMakeLists.txt b/tests/src/encode/CMakeLists.txt index 9e4e53b73..5c71d97f0 100644 --- a/tests/src/encode/CMakeLists.txt +++ b/tests/src/encode/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_block_tests dims type bits) set(block_test_name testZfpEncodeBlock${dims}d${type}) add_executable(${block_test_name} ${block_test_name}.c) target_link_libraries(${block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib) + cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${block_test_name} m) endif() @@ -11,7 +11,7 @@ function(zfp_add_block_tests dims type bits) set(strided_block_test_name testZfpEncodeBlockStrided${dims}d${type}) add_executable(${strided_block_test_name} ${strided_block_test_name}.c) target_link_libraries(${strided_block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib) + cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${strided_block_test_name} m) endif() diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index 500fdd743..4ece61c03 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -5,8 +5,8 @@ #include -#include "constants/checksums/checksums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" struct setupVars { Scalar* dataArr; diff --git a/tests/src/encode/zfpEncodeBlockStridedBase.c b/tests/src/encode/zfpEncodeBlockStridedBase.c index 901162b80..a75cc6f42 100644 --- a/tests/src/encode/zfpEncodeBlockStridedBase.c +++ b/tests/src/encode/zfpEncodeBlockStridedBase.c @@ -5,8 +5,8 @@ #include -#include "constants/checksums/checksums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" #define SX 2 #define SY (3 * BLOCK_SIDE_LEN*SX) diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index b506adb9b..4427503ec 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_test dims type bits) set(serial_test_name testZfpSerial${dims}d${type}) add_executable(${serial_test_name} ${serial_test_name}.c) target_link_libraries(${serial_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${serial_test_name} m) endif() @@ -13,7 +13,7 @@ function(zfp_add_test dims type bits) add_executable(${omp_test_name} ${omp_test_name}.c) target_compile_options(${omp_test_name} PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries(${omp_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) target_link_libraries(${omp_test_name} m) @@ -28,7 +28,7 @@ function(zfp_add_test dims type bits) set(cuda_test_name testZfpCuda${dims}d${type}) add_executable(${cuda_test_name} ${cuda_test_name}.c) target_link_libraries(${cuda_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpTimerLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${cuda_test_name} m) endif() diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 786da6933..a8493f7a2 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -8,9 +8,9 @@ #include #include -#include "constants/checksums/checksums.h" #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" +#include "utils/zfpChecksums.h" #include "utils/zfpTimer.h" #ifdef FL_PT_DATA diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index e337a375f..b4023aa88 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -28,6 +28,9 @@ target_link_libraries(genSmoothRandNumsLib PRIVATE rand64Lib fixedpoint96Lib) # timer add_library(zfpTimerLib zfpTimer.c zfpTimer.h) +# checksums API +add_library(zfpChecksumsLib zfpChecksums.c zfpChecksums.h) + if(HAVE_LIBM_MATH) target_link_libraries(rand32Lib PRIVATE m) target_link_libraries(rand64Lib PRIVATE m) diff --git a/tests/constants/checksums/checksums.h b/tests/utils/zfpChecksums.c similarity index 97% rename from tests/constants/checksums/checksums.h rename to tests/utils/zfpChecksums.c index 23c762b57..a4e9a337b 100644 --- a/tests/constants/checksums/checksums.h +++ b/tests/utils/zfpChecksums.c @@ -1,21 +1,26 @@ #include "zfp/types.h" +#include "zfpChecksums.h" +// raw checksums as static arrays +#include "constants/checksums/1dDouble.h" +#include "constants/checksums/1dFloat.h" #include "constants/checksums/1dInt32.h" #include "constants/checksums/1dInt64.h" -#include "constants/checksums/1dFloat.h" -#include "constants/checksums/1dDouble.h" + +#include "constants/checksums/2dDouble.h" +#include "constants/checksums/2dFloat.h" #include "constants/checksums/2dInt32.h" #include "constants/checksums/2dInt64.h" -#include "constants/checksums/2dFloat.h" -#include "constants/checksums/2dDouble.h" + +#include "constants/checksums/3dDouble.h" +#include "constants/checksums/3dFloat.h" #include "constants/checksums/3dInt32.h" #include "constants/checksums/3dInt64.h" -#include "constants/checksums/3dFloat.h" -#include "constants/checksums/3dDouble.h" + +#include "constants/checksums/4dDouble.h" +#include "constants/checksums/4dFloat.h" #include "constants/checksums/4dInt32.h" #include "constants/checksums/4dInt64.h" -#include "constants/checksums/4dFloat.h" -#include "constants/checksums/4dDouble.h" // [dimensionality][zfp_type] static const uint64* checksums[4][4] = { diff --git a/tests/utils/zfpChecksums.h b/tests/utils/zfpChecksums.h new file mode 100644 index 000000000..1b7f8c360 --- /dev/null +++ b/tests/utils/zfpChecksums.h @@ -0,0 +1,30 @@ +#ifndef ZFP_CHECKSUMS_H +#define ZFP_CHECKSUMS_H + +#include "zfp.h" + +uint64 +getChecksumOriginalDataBlock(int dims, zfp_type type); + +uint64 +getChecksumEncodedBlock(int dims, zfp_type type); + +uint64 +getChecksumEncodedPartialBlock(int dims, zfp_type type); + +uint64 +getChecksumDecodedBlock(int dims, zfp_type type); + +uint64 +getChecksumDecodedPartialBlock(int dims, zfp_type type); + +uint64 +getChecksumOriginalDataArray(int dims, zfp_type type); + +uint64 +getChecksumCompressedBitstream(int dims, zfp_type type, zfp_mode mode, int compressParamNum); + +uint64 +getChecksumDecompressedArray(int dims, zfp_type type, zfp_mode mode, int compressParamNum); + +#endif From 8c3ff4b0eaa3730ef5e7dc95c0e3706fed2cc889 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 19 Feb 2019 12:59:03 -0800 Subject: [PATCH 024/194] refactor tests (decode, encode, endtoend) to break up long functions --- tests/src/decode/zfpDecodeBlockBase.c | 33 +++-- tests/src/decode/zfpDecodeBlockStridedBase.c | 29 +++-- tests/src/encode/zfpEncodeBlockBase.c | 32 +++-- tests/src/encode/zfpEncodeBlockStridedBase.c | 21 +-- tests/src/endtoend/zfpEndtoendBase.c | 130 ++++++++++++------- 5 files changed, 153 insertions(+), 92 deletions(-) diff --git a/tests/src/decode/zfpDecodeBlockBase.c b/tests/src/decode/zfpDecodeBlockBase.c index 68c38acb8..4c3deb502 100644 --- a/tests/src/decode/zfpDecodeBlockBase.c +++ b/tests/src/decode/zfpDecodeBlockBase.c @@ -14,26 +14,26 @@ struct setupVars { zfp_stream* stream; }; -static int -setup(void **state) +static void +populateInitialArray(Scalar** dataArrPtr) { - struct setupVars *bundle = malloc(sizeof(struct setupVars)); - assert_non_null(bundle); - - resetRandGen(); - - bundle->dataArr = malloc(sizeof(Scalar) * BLOCK_SIZE); - assert_non_null(bundle->dataArr); + *dataArrPtr = malloc(sizeof(Scalar) * BLOCK_SIZE); + assert_non_null(*dataArrPtr); int i; for (i = 0; i < BLOCK_SIZE; i++) { #ifdef FL_PT_DATA - bundle->dataArr[i] = nextSignedRandFlPt(); + (*dataArrPtr)[i] = nextSignedRandFlPt(); #else - bundle->dataArr[i] = nextSignedRandInt(); + (*dataArrPtr)[i] = nextSignedRandInt(); #endif } +} + +static void +setupZfpStream(struct setupVars* bundle) +{ zfp_type type = ZFP_TYPE; zfp_field* field; switch(DIMS) { @@ -67,6 +67,17 @@ setup(void **state) bundle->buffer = buffer; bundle->stream = stream; +} + +static int +setup(void **state) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + resetRandGen(); + populateInitialArray(&bundle->dataArr); + setupZfpStream(bundle); *state = bundle; diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index 2a436921e..3df41fdf0 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -154,19 +154,9 @@ initializeStridedArray(Scalar** dataArrPtr, Scalar dummyVal) return arrayLen; } -static int -setup(void **state) +static void +setupZfpStream(struct setupVars* bundle) { - struct setupVars *bundle = malloc(sizeof(struct setupVars)); - assert_non_null(bundle); - - resetRandGen(); - - size_t arrayLen = initializeStridedArray(&bundle->dataArr, DUMMY_VAL); - - bundle->decodedDataArr = calloc(arrayLen, sizeof(Scalar)); - assert_non_null(bundle->decodedDataArr); - zfp_type type = ZFP_TYPE; zfp_field* field; switch(DIMS) { @@ -204,6 +194,21 @@ setup(void **state) bundle->buffer = buffer; bundle->stream = stream; +} + +static int +setup(void **state) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + resetRandGen(); + + size_t arrayLen = initializeStridedArray(&bundle->dataArr, DUMMY_VAL); + bundle->decodedDataArr = calloc(arrayLen, sizeof(Scalar)); + assert_non_null(bundle->decodedDataArr); + + setupZfpStream(bundle); *state = bundle; diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index 4ece61c03..474f89664 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -14,26 +14,25 @@ struct setupVars { zfp_stream* stream; }; -static int -setup(void **state) +static void +populateInitialArray(Scalar** dataArrPtr) { - struct setupVars *bundle = malloc(sizeof(struct setupVars)); - assert_non_null(bundle); - - resetRandGen(); - - bundle->dataArr = malloc(sizeof(Scalar) * BLOCK_SIZE); - assert_non_null(bundle); + *dataArrPtr = malloc(sizeof(Scalar) * BLOCK_SIZE); + assert_non_null(*dataArrPtr); int i; for (i = 0; i < BLOCK_SIZE; i++) { #ifdef FL_PT_DATA - bundle->dataArr[i] = nextSignedRandFlPt(); + (*dataArrPtr)[i] = nextSignedRandFlPt(); #else - bundle->dataArr[i] = nextSignedRandInt(); + (*dataArrPtr)[i] = nextSignedRandInt(); #endif } +} +static void +setupZfpStream(struct setupVars* bundle) +{ zfp_type type = ZFP_TYPE; zfp_field* field; switch(DIMS) { @@ -67,6 +66,17 @@ setup(void **state) bundle->buffer = buffer; bundle->stream = stream; +} + +static int +setup(void **state) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + resetRandGen(); + populateInitialArray(&bundle->dataArr); + setupZfpStream(bundle); *state = bundle; diff --git a/tests/src/encode/zfpEncodeBlockStridedBase.c b/tests/src/encode/zfpEncodeBlockStridedBase.c index a75cc6f42..ef3a62168 100644 --- a/tests/src/encode/zfpEncodeBlockStridedBase.c +++ b/tests/src/encode/zfpEncodeBlockStridedBase.c @@ -141,15 +141,9 @@ initializeStridedArray(Scalar** dataArrPtr, Scalar dummyVal) } -static int -setup(void **state) +static void +setupZfpStream(struct setupVars* bundle) { - struct setupVars *bundle = malloc(sizeof(struct setupVars)); - assert_non_null(bundle); - - resetRandGen(); - initializeStridedArray(&bundle->dataArr, DUMMY_VAL); - zfp_type type = ZFP_TYPE; zfp_field* field; switch(DIMS) { @@ -187,6 +181,17 @@ setup(void **state) bundle->buffer = buffer; bundle->stream = stream; +} + +static int +setup(void **state) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + resetRandGen(); + initializeStridedArray(&bundle->dataArr, DUMMY_VAL); + setupZfpStream(bundle); *state = bundle; diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index a8493f7a2..35af42649 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -187,12 +187,60 @@ permuteSquareArray(Scalar* inputArr, Scalar* outputArr, size_t sideLen) } } -// assumes setupRandomData() already run (having set some setupVars members) -static int -setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_config stride) +static void +setupZfpFields(struct setupVars* bundle, int s[4]) { - struct setupVars *bundle = *state; + uint nx = (uint)bundle->randomGenArrSideLen[0]; + uint ny = (uint)bundle->randomGenArrSideLen[1]; + uint nz = (uint)bundle->randomGenArrSideLen[2]; + uint nw = (uint)bundle->randomGenArrSideLen[3]; + + // setup zfp_fields: source/destination arrays for compression/decompression + zfp_type type = ZFP_TYPE; + zfp_field* field; + zfp_field* decompressField; + + switch(DIMS) { + case 1: + field = zfp_field_1d(bundle->compressedArr, type, nx); + zfp_field_set_stride_1d(field, s[0]); + + decompressField = zfp_field_1d(bundle->decompressedArr, type, nx); + zfp_field_set_stride_1d(decompressField, s[0]); + break; + + case 2: + field = zfp_field_2d(bundle->compressedArr, type, nx, ny); + zfp_field_set_stride_2d(field, s[0], s[1]); + decompressField = zfp_field_2d(bundle->decompressedArr, type, nx, ny); + zfp_field_set_stride_2d(decompressField, s[0], s[1]); + break; + + case 3: + field = zfp_field_3d(bundle->compressedArr, type, nx, ny, nz); + zfp_field_set_stride_3d(field, s[0], s[1], s[2]); + + decompressField = zfp_field_3d(bundle->decompressedArr, type, nx, ny, nz); + zfp_field_set_stride_3d(decompressField, s[0], s[1], s[2]); + break; + + case 4: + field = zfp_field_4d(bundle->compressedArr, type, nx, ny, nz, nw); + zfp_field_set_stride_4d(field, s[0], s[1], s[2], s[3]); + + decompressField = zfp_field_4d(bundle->decompressedArr, type, nx, ny, nz, nw); + zfp_field_set_stride_4d(decompressField, s[0], s[1], s[2], s[3]); + break; + } + + bundle->field = field; + bundle->decompressField = decompressField; +} + +static void +initStridedFields(struct setupVars* bundle, stride_config stride) +{ // apply stride permutations on randomGenArr, into compressedArr, which gets compressed bundle->stride = stride; @@ -280,49 +328,18 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ break; } - // setup zfp_fields: source/destination arrays for compression/decompression - zfp_type type = ZFP_TYPE; - zfp_field* field; - zfp_field* decompressField; - - switch(DIMS) { - case 1: - field = zfp_field_1d(bundle->compressedArr, type, nx); - zfp_field_set_stride_1d(field, sx); - - decompressField = zfp_field_1d(bundle->decompressedArr, type, nx); - zfp_field_set_stride_1d(decompressField, sx); - break; - - case 2: - field = zfp_field_2d(bundle->compressedArr, type, nx, ny); - zfp_field_set_stride_2d(field, sx, sy); - - decompressField = zfp_field_2d(bundle->decompressedArr, type, nx, ny); - zfp_field_set_stride_2d(decompressField, sx, sy); - break; - - case 3: - field = zfp_field_3d(bundle->compressedArr, type, nx, ny, nz); - zfp_field_set_stride_3d(field, sx, sy, sz); - - decompressField = zfp_field_3d(bundle->decompressedArr, type, nx, ny, nz); - zfp_field_set_stride_3d(decompressField, sx, sy, sz); - break; - - case 4: - field = zfp_field_4d(bundle->compressedArr, type, nx, ny, nz, nw); - zfp_field_set_stride_4d(field, sx, sy, sz, sw); - - decompressField = zfp_field_4d(bundle->decompressedArr, type, nx, ny, nz, nw); - zfp_field_set_stride_4d(decompressField, sx, sy, sz, sw); - break; - } + int s[4] = {sx, sy, sz, sw}; + setupZfpFields(bundle, s); +} +static void +setupZfpStream(struct setupVars* bundle) +{ // setup zfp_stream (compression settings) zfp_stream* stream = zfp_stream_open(NULL); + assert_non_null(stream); - size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + size_t bufsizeBytes = zfp_stream_maximum_size(stream, bundle->field); char* buffer = calloc(bufsizeBytes, sizeof(char)); assert_non_null(buffer); @@ -332,6 +349,13 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ zfp_stream_set_bit_stream(stream, s); zfp_stream_rewind(stream); + bundle->stream = stream; + bundle->buffer = buffer; +} + +static void +setupCompressParam(struct setupVars* bundle, zfp_mode zfpMode, int compressParamNum) +{ // set compression mode for this compressParamNum if (compressParamNum > 2 || compressParamNum < 0) { fail_msg("Unknown compressParamNum during setupChosenZfpMode()"); @@ -341,14 +365,14 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ switch(zfpMode) { case zfp_mode_fixed_precision: bundle->precParam = 1u << (bundle->compressParamNum + 3); - zfp_stream_set_precision(stream, bundle->precParam); + zfp_stream_set_precision(bundle->stream, bundle->precParam); printf("\t\tFixed precision param: %u\n", bundle->precParam); break; case zfp_mode_fixed_rate: bundle->rateParam = intPow(2, bundle->compressParamNum + 3); - zfp_stream_set_rate(stream, (double)bundle->rateParam, type, DIMS, 0); + zfp_stream_set_rate(bundle->stream, (double)bundle->rateParam, ZFP_TYPE, DIMS, 0); printf("\t\tFixed rate param: %lu\n", (unsigned long)bundle->rateParam); break; @@ -356,7 +380,7 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ #ifdef FL_PT_DATA case zfp_mode_fixed_accuracy: bundle->accParam = ldexp(1.0, -(1u << bundle->compressParamNum)); - zfp_stream_set_accuracy(stream, bundle->accParam); + zfp_stream_set_accuracy(bundle->stream, bundle->accParam); printf("\t\tFixed accuracy param: %lf\n", bundle->accParam); break; @@ -366,11 +390,17 @@ setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_ fail_msg("Invalid zfp mode during setupChosenZfpMode()"); break; } +} - bundle->buffer = buffer; - bundle->field = field; - bundle->decompressField = decompressField; - bundle->stream = stream; +// assumes setupRandomData() already run (having set some setupVars members) +static int +setupChosenZfpMode(void **state, zfp_mode zfpMode, int compressParamNum, stride_config stride) +{ + struct setupVars *bundle = *state; + + initStridedFields(bundle, stride); + setupZfpStream(bundle); + setupCompressParam(bundle, zfpMode, compressParamNum); bundle->timer = zfp_timer_alloc(); From 2711b712fcb38e2b2812ef5a6a5973b68b2ce7c1 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 19 Feb 2019 15:14:19 -0800 Subject: [PATCH 025/194] add tests/ lib to compute zfp compression parameters --- tests/src/endtoend/CMakeLists.txt | 8 +++++--- tests/src/endtoend/zfpEndtoendBase.c | 9 ++++----- tests/utils/CMakeLists.txt | 4 ++++ tests/utils/zfpCompressionParams.c | 20 ++++++++++++++++++++ tests/utils/zfpCompressionParams.h | 15 +++++++++++++++ 5 files changed, 48 insertions(+), 8 deletions(-) create mode 100644 tests/utils/zfpCompressionParams.c create mode 100644 tests/utils/zfpCompressionParams.h diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 4427503ec..04132843c 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -2,7 +2,8 @@ function(zfp_add_test dims type bits) set(serial_test_name testZfpSerial${dims}d${type}) add_executable(${serial_test_name} ${serial_test_name}.c) target_link_libraries(${serial_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib + zfpCompressionParamsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${serial_test_name} m) endif() @@ -14,7 +15,7 @@ function(zfp_add_test dims type bits) target_compile_options(${omp_test_name} PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries(${omp_test_name} cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib - ${OpenMP_C_LIBRARIES}) + zfpCompressionParamsLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) target_link_libraries(${omp_test_name} m) endif() @@ -28,7 +29,8 @@ function(zfp_add_test dims type bits) set(cuda_test_name testZfpCuda${dims}d${type}) add_executable(${cuda_test_name} ${cuda_test_name}.c) target_link_libraries(${cuda_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib + zfpCompressionParamsLib) if(HAVE_LIBM_MATH) target_link_libraries(${cuda_test_name} m) endif() diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 35af42649..fc3bb5b25 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -11,6 +11,7 @@ #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpCompressionParams.h" #include "utils/zfpTimer.h" #ifdef FL_PT_DATA @@ -19,8 +20,6 @@ #define MIN_TOTAL_ELEMENTS 4096 #endif -#define RATE_TOL (1e-3) - typedef enum { AS_IS = 0, PERMUTED = 1, @@ -364,14 +363,14 @@ setupCompressParam(struct setupVars* bundle, zfp_mode zfpMode, int compressParam switch(zfpMode) { case zfp_mode_fixed_precision: - bundle->precParam = 1u << (bundle->compressParamNum + 3); + bundle->precParam = computeFixedPrecisionParam(bundle->compressParamNum); zfp_stream_set_precision(bundle->stream, bundle->precParam); printf("\t\tFixed precision param: %u\n", bundle->precParam); break; case zfp_mode_fixed_rate: - bundle->rateParam = intPow(2, bundle->compressParamNum + 3); + bundle->rateParam = computeFixedRateParam(bundle->compressParamNum); zfp_stream_set_rate(bundle->stream, (double)bundle->rateParam, ZFP_TYPE, DIMS, 0); printf("\t\tFixed rate param: %lu\n", (unsigned long)bundle->rateParam); @@ -379,7 +378,7 @@ setupCompressParam(struct setupVars* bundle, zfp_mode zfpMode, int compressParam #ifdef FL_PT_DATA case zfp_mode_fixed_accuracy: - bundle->accParam = ldexp(1.0, -(1u << bundle->compressParamNum)); + bundle->accParam = computeFixedAccuracyParam(bundle->compressParamNum); zfp_stream_set_accuracy(bundle->stream, bundle->accParam); printf("\t\tFixed accuracy param: %lf\n", bundle->accParam); diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index b4023aa88..43b6e85f1 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -25,6 +25,9 @@ add_library(fixedpoint96Lib fixedpoint96.c fixedpoint96.h) add_library(genSmoothRandNumsLib genSmoothRandNums.c genSmoothRandNums.h) target_link_libraries(genSmoothRandNumsLib PRIVATE rand64Lib fixedpoint96Lib) +# compute zfp compression parameters +add_library(zfpCompressionParamsLib zfpCompressionParams.c zfpCompressionParams.h) + # timer add_library(zfpTimerLib zfpTimer.c zfpTimer.h) @@ -35,4 +38,5 @@ if(HAVE_LIBM_MATH) target_link_libraries(rand32Lib PRIVATE m) target_link_libraries(rand64Lib PRIVATE m) target_link_libraries(genSmoothRandNumsLib PRIVATE m) + target_link_libraries(zfpCompressionParamsLib PRIVATE m) endif() diff --git a/tests/utils/zfpCompressionParams.c b/tests/utils/zfpCompressionParams.c new file mode 100644 index 000000000..073b5a280 --- /dev/null +++ b/tests/utils/zfpCompressionParams.c @@ -0,0 +1,20 @@ +#include +#include "utils/zfpCompressionParams.h" + +int +computeFixedPrecisionParam(int param) +{ + return 1u << (param + 3); +} + +size_t +computeFixedRateParam(int param) +{ + return (size_t)(1u << (param + 3)); +} + +double +computeFixedAccuracyParam(int param) +{ + return ldexp(1.0, -(1u << param)); +} diff --git a/tests/utils/zfpCompressionParams.h b/tests/utils/zfpCompressionParams.h new file mode 100644 index 000000000..42cead7e5 --- /dev/null +++ b/tests/utils/zfpCompressionParams.h @@ -0,0 +1,15 @@ +#ifndef ZFP_COMPRESSION_PARAMS_H +#define ZFP_COMPRESSION_PARAMS_H + +#include + +int +computeFixedPrecisionParam(int param); + +size_t +computeFixedRateParam(int param); + +double +computeFixedAccuracyParam(int param); + +#endif From cfdea04ca78a86a535e37154bfb2f831b1ddca89 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 19 Feb 2019 17:28:33 -0800 Subject: [PATCH 026/194] extract endtoend tests' strided array operations to its own library --- tests/src/endtoend/CMakeLists.txt | 12 ++-- tests/src/endtoend/zfpEndtoendBase.c | 90 ++------------------------- tests/utils/CMakeLists.txt | 3 + tests/utils/stridedOperations.c | 91 ++++++++++++++++++++++++++++ tests/utils/stridedOperations.h | 27 +++++++++ 5 files changed, 133 insertions(+), 90 deletions(-) create mode 100644 tests/utils/stridedOperations.c create mode 100644 tests/utils/stridedOperations.h diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 04132843c..6c68c9744 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -2,8 +2,8 @@ function(zfp_add_test dims type bits) set(serial_test_name testZfpSerial${dims}d${type}) add_executable(${serial_test_name} ${serial_test_name}.c) target_link_libraries(${serial_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib - zfpCompressionParamsLib zfpTimerLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + zfpChecksumsLib zfpCompressionParamsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${serial_test_name} m) endif() @@ -14,8 +14,8 @@ function(zfp_add_test dims type bits) add_executable(${omp_test_name} ${omp_test_name}.c) target_compile_options(${omp_test_name} PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries(${omp_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib - zfpCompressionParamsLib ${OpenMP_C_LIBRARIES}) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) target_link_libraries(${omp_test_name} m) endif() @@ -29,8 +29,8 @@ function(zfp_add_test dims type bits) set(cuda_test_name testZfpCuda${dims}d${type}) add_executable(${cuda_test_name} ${cuda_test_name}.c) target_link_libraries(${cuda_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib zfpTimerLib - zfpCompressionParamsLib) + cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib) if(HAVE_LIBM_MATH) target_link_libraries(${cuda_test_name} m) endif() diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index fc3bb5b25..27ecda264 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -9,6 +9,7 @@ #include #include "utils/genSmoothRandNums.h" +#include "utils/stridedOperations.h" #include "utils/testMacros.h" #include "utils/zfpChecksums.h" #include "utils/zfpCompressionParams.h" @@ -20,13 +21,6 @@ #define MIN_TOTAL_ELEMENTS 4096 #endif -typedef enum { - AS_IS = 0, - PERMUTED = 1, - INTERLEAVED = 2, - REVERSED = 3, -} stride_config; - struct setupVars { // randomly generated array // this entire dataset eventually gets compressed @@ -112,80 +106,6 @@ teardownRandomData(void** state) return 0; } -// reversed array ([inputLen - 1], [inputLen - 2], ..., [1], [0]) -static void -reverseArray(Scalar* inputArr, Scalar* outputArr, size_t inputLen) -{ - size_t i; - for (i = 0; i < inputLen; i++) { - outputArr[i] = inputArr[inputLen - i - 1]; - } -} - -// interleaved array ([0], [0], [1], [1], [2], ...) -static void -interleaveArray(Scalar* inputArr, Scalar* outputArr, size_t inputLen) -{ - size_t i; - for (i = 0; i < inputLen; i++) { - outputArr[2*i] = inputArr[i]; - outputArr[2*i + 1] = inputArr[i]; - } -} - -static void -permuteSquareArray(Scalar* inputArr, Scalar* outputArr, size_t sideLen) -{ - size_t i, j, k, l; - - switch(DIMS) { - case 4: - // permute ijkl lkji - for (l = 0; l < sideLen; l++) { - for (k = 0; k < sideLen; k++) { - for (j = 0; j < sideLen; j++) { - for (i = 0; i < sideLen; i++) { - size_t index = l*sideLen*sideLen*sideLen + k*sideLen*sideLen + j*sideLen + i; - size_t transposedIndex = i*sideLen*sideLen*sideLen + j*sideLen*sideLen + k*sideLen + l; - outputArr[transposedIndex] = inputArr[index]; - } - } - } - } - break; - - case 3: - // permute ijk to kji - for (k = 0; k < sideLen; k++) { - for (j = 0; j < sideLen; j++) { - for (i = 0; i < sideLen; i++) { - size_t index = k*sideLen*sideLen + j*sideLen + i; - size_t transposedIndex = i*sideLen*sideLen + j*sideLen + k; - outputArr[transposedIndex] = inputArr[index]; - } - } - } - break; - - case 2: - // permute ij to ji - for (j = 0; j < sideLen; j++) { - for (i = 0; i < sideLen; i++) { - size_t index = j*sideLen + i; - size_t transposedIndex = i*sideLen + j; - outputArr[transposedIndex] = inputArr[index]; - } - } - - break; - - case 1: - default: - fail_msg("Unexpected DIMS value in permuteSquareArray()"); - break; - } -} - static void setupZfpFields(struct setupVars* bundle, int s[4]) { @@ -278,7 +198,7 @@ initStridedFields(struct setupVars* bundle, stride_config stride) } else { sx = -1; } - reverseArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen); + reverseArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen, ZFP_TYPE); // adjust pointer to last element, so strided traverse is valid bundle->compressedArr += bundle->totalRandomGenArrLen - 1; @@ -301,7 +221,7 @@ initStridedFields(struct setupVars* bundle, stride_config stride) } else { sx = 2; } - interleaveArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen); + interleaveArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen, ZFP_TYPE); break; case PERMUTED: @@ -318,7 +238,9 @@ initStridedFields(struct setupVars* bundle, stride_config stride) sx = (int)nx; sy = 1; } - permuteSquareArray(bundle->randomGenArr, bundle->compressedArr, nx); + if (permuteSquareArray(bundle->randomGenArr, bundle->compressedArr, nx, DIMS, ZFP_TYPE)) { + fail_msg("Unexpected DIMS value in permuteSquareArray()"); + } break; case AS_IS: diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index 43b6e85f1..dd35f0137 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -25,6 +25,9 @@ add_library(fixedpoint96Lib fixedpoint96.c fixedpoint96.h) add_library(genSmoothRandNumsLib genSmoothRandNums.c genSmoothRandNums.h) target_link_libraries(genSmoothRandNumsLib PRIVATE rand64Lib fixedpoint96Lib) +# strided array operations +add_library(stridedOperationsLib stridedOperations.c stridedOperations.h) + # compute zfp compression parameters add_library(zfpCompressionParamsLib zfpCompressionParams.c zfpCompressionParams.h) diff --git a/tests/utils/stridedOperations.c b/tests/utils/stridedOperations.c new file mode 100644 index 000000000..84adccfd7 --- /dev/null +++ b/tests/utils/stridedOperations.c @@ -0,0 +1,91 @@ +#include +#include "stridedOperations.h" + +// reversed array ([inputArrLen - 1], [inputArrLen - 2], ..., [1], [0]) +void +reverseArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zfpType) +{ + const size_t elementSizeBytes = zfp_type_size(zfpType); + + // move ptr to last element + inputArr += elementSizeBytes * (inputArrLen - 1); + + size_t i; + for (i = 0; i < inputArrLen; i++) { + memcpy(outputArr, inputArr, elementSizeBytes); + + outputArr += elementSizeBytes; + inputArr -= elementSizeBytes; + } +} + +// interleaved array ([0], [0], [1], [1], [2], ...) +void +interleaveArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zfpType) +{ + const size_t elementSizeBytes = zfp_type_size(zfpType); + + size_t i; + for (i = 0; i < inputArrLen; i++) { + memcpy(outputArr, inputArr, elementSizeBytes); + memcpy(outputArr + elementSizeBytes, inputArr, elementSizeBytes); + + inputArr += elementSizeBytes; + outputArr += 2 * elementSizeBytes; + } +} + +int +permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zfp_type zfpType) +{ + const size_t elementSizeBytes = zfp_type_size(zfpType); + + size_t i, j, k, l; + + switch(dims) { + case 4: + // permute ijkl lkji + for (l = 0; l < sideLen; l++) { + for (k = 0; k < sideLen; k++) { + for (j = 0; j < sideLen; j++) { + for (i = 0; i < sideLen; i++) { + size_t index = l*sideLen*sideLen*sideLen + k*sideLen*sideLen + j*sideLen + i; + size_t transposedIndex = i*sideLen*sideLen*sideLen + j*sideLen*sideLen + k*sideLen + l; + memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + } + } + } + } + break; + + case 3: + // permute ijk to kji + for (k = 0; k < sideLen; k++) { + for (j = 0; j < sideLen; j++) { + for (i = 0; i < sideLen; i++) { + size_t index = k*sideLen*sideLen + j*sideLen + i; + size_t transposedIndex = i*sideLen*sideLen + j*sideLen + k; + memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + } + } + } + break; + + case 2: + // permute ij to ji + for (j = 0; j < sideLen; j++) { + for (i = 0; i < sideLen; i++) { + size_t index = j*sideLen + i; + size_t transposedIndex = i*sideLen + j; + memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + } + } + break; + + case 1: + default: + return 1; + } + + return 0; +} diff --git a/tests/utils/stridedOperations.h b/tests/utils/stridedOperations.h new file mode 100644 index 000000000..c2bc91587 --- /dev/null +++ b/tests/utils/stridedOperations.h @@ -0,0 +1,27 @@ +#ifndef STRIDED_OPERATIONS_H +#define STRIDED_OPERATIONS_H + +#include +#include "zfp.h" + +typedef enum { + AS_IS = 0, + PERMUTED = 1, + INTERLEAVED = 2, + REVERSED = 3, +} stride_config; + +// reversed array ([inputLen - 1], [inputLen - 2], ..., [1], [0]) +void +reverseArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zfpType); + +// interleaved array ([0], [0], [1], [1], [2], ...) +void +interleaveArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zfpType); + +// ijkl -> lkji, or for lower dims (ex. ij -> ji) +// returns 0 on success, 1 on failure +int +permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zfp_type zfpType); + +#endif From b95d9443a2c435ccb3d5cbb8d5c62acb7a956851 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 21 Feb 2019 13:07:36 -0800 Subject: [PATCH 027/194] break up strided functions into smaller pieces in endtoend/ tests --- tests/src/endtoend/zfpEndtoendBase.c | 95 ++++++++++++++++++---------- 1 file changed, 62 insertions(+), 33 deletions(-) diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 27ecda264..5ac9c2891 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -30,7 +30,6 @@ struct setupVars { Scalar* randomGenArr; // these arrays/dims may include stride-space - size_t totalEntireDataLen; Scalar* compressedArr; Scalar* decompressedArr; @@ -158,98 +157,128 @@ setupZfpFields(struct setupVars* bundle, int s[4]) } static void -initStridedFields(struct setupVars* bundle, stride_config stride) +allocateFieldArrays(stride_config stride, size_t totalRandomGenArrLen, Scalar** compressedArrPtr, Scalar** decompressedArrPtr) { - // apply stride permutations on randomGenArr, into compressedArr, which gets compressed - bundle->stride = stride; - - bundle->totalEntireDataLen = bundle->totalRandomGenArrLen; + size_t totalEntireDataLen = totalRandomGenArrLen; if (stride == INTERLEAVED) - bundle->totalEntireDataLen *= 2; + totalEntireDataLen *= 2; // allocate arrays which we directly compress or decompress into - bundle->compressedArr = calloc(bundle->totalEntireDataLen, sizeof(Scalar)); - assert_non_null(bundle->compressedArr); + *compressedArrPtr = calloc(totalEntireDataLen, sizeof(Scalar)); + assert_non_null(*compressedArrPtr); + + *decompressedArrPtr = malloc(sizeof(Scalar) * totalEntireDataLen); + assert_non_null(*decompressedArrPtr); +} + +static void +generateStridedRandomArray(stride_config stride, Scalar* randomGenArr, zfp_type type, size_t n[4], int s[4], Scalar** compressedArrPtr, Scalar** decompressedArrPtr) +{ + int dims, i; + for (i = 0; i < 4; i++) { + if (n[i] == 0) { + break; + } + } + dims = i; - bundle->decompressedArr = malloc(sizeof(Scalar) * bundle->totalEntireDataLen); - assert_non_null(bundle->decompressedArr); + size_t totalRandomGenArrLen = 1; + for (i = 0; i < dims; i++) { + totalRandomGenArrLen *= n[i]; + } // identify strides and produce compressedArr - uint nx = (uint)bundle->randomGenArrSideLen[0]; - uint ny = (uint)bundle->randomGenArrSideLen[1]; - uint nz = (uint)bundle->randomGenArrSideLen[2]; - uint nw = (uint)bundle->randomGenArrSideLen[3]; + uint nx = (uint)n[0]; + uint ny = (uint)n[1]; + uint nz = (uint)n[2]; + uint nw = (uint)n[3]; int sx = 0, sy = 0, sz = 0, sw = 0; - switch(bundle->stride) { + switch(stride) { case REVERSED: - if (DIMS == 4) { + if (dims == 4) { sx = -1; sy = sx * (int)nx; sz = sy * (int)ny; sw = sz * (int)nz; - } else if (DIMS == 3) { + } else if (dims == 3) { sx = -1; sy = sx * (int)nx; sz = sy * (int)ny; - } else if (DIMS == 2) { + } else if (dims == 2) { sx = -1; sy = sx * (int)nx; } else { sx = -1; } - reverseArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen, ZFP_TYPE); + reverseArray(randomGenArr, *compressedArrPtr, totalRandomGenArrLen, type); // adjust pointer to last element, so strided traverse is valid - bundle->compressedArr += bundle->totalRandomGenArrLen - 1; - bundle->decompressedArr += bundle->totalRandomGenArrLen - 1; + *compressedArrPtr += totalRandomGenArrLen - 1; + *decompressedArrPtr += totalRandomGenArrLen - 1; break; case INTERLEAVED: - if (DIMS == 4) { + if (dims == 4) { sx = 2; sy = sx * (int)nx; sz = sy * (int)ny; sw = sz * (int)nz; - } else if (DIMS == 3) { + } else if (dims == 3) { sx = 2; sy = sx * (int)nx; sz = sy * (int)ny; - } else if (DIMS == 2) { + } else if (dims == 2) { sx = 2; sy = sx * (int)nx; } else { sx = 2; } - interleaveArray(bundle->randomGenArr, bundle->compressedArr, bundle->totalRandomGenArrLen, ZFP_TYPE); + interleaveArray(randomGenArr, *compressedArrPtr, totalRandomGenArrLen, ZFP_TYPE); break; case PERMUTED: - if (DIMS == 4) { + if (dims == 4) { sx = (int)(nx * ny * nz); sy = (int)(nx * ny); sz = (int)nx; sw = 1; - } else if (DIMS == 3) { + } else if (dims == 3) { sx = (int)(nx * ny); sy = (int)nx; sz = 1; - } else if (DIMS == 2) { + } else if (dims == 2) { sx = (int)nx; sy = 1; } - if (permuteSquareArray(bundle->randomGenArr, bundle->compressedArr, nx, DIMS, ZFP_TYPE)) { - fail_msg("Unexpected DIMS value in permuteSquareArray()"); + if (permuteSquareArray(randomGenArr, *compressedArrPtr, nx, dims, type)) { + fail_msg("Unexpected dims value in permuteSquareArray()"); } break; case AS_IS: // no-op - memcpy(bundle->compressedArr, bundle->randomGenArr, bundle->totalRandomGenArrLen * sizeof(Scalar)); + memcpy(*compressedArrPtr, randomGenArr, totalRandomGenArrLen * sizeof(Scalar)); break; } - int s[4] = {sx, sy, sz, sw}; + s[0] = sx; + s[1] = sy; + s[2] = sz; + s[3] = sw; +} + +static void +initStridedFields(struct setupVars* bundle, stride_config stride) +{ + // apply stride permutations on randomGenArr, into compressedArr, which gets compressed + bundle->stride = stride; + + allocateFieldArrays(stride, bundle->totalRandomGenArrLen, &bundle->compressedArr, &bundle->decompressedArr); + + int s[4]; + generateStridedRandomArray(stride, bundle->randomGenArr, ZFP_TYPE, bundle->randomGenArrSideLen, s, &bundle->compressedArr, &bundle->decompressedArr); + setupZfpFields(bundle, s); } From c5e978af028c6b7730e5fb0ba8e80016fd066ecd Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 21 Feb 2019 17:35:16 -0800 Subject: [PATCH 028/194] extract endtoend/ test functions to compute strides to stridedOperationsLib --- tests/src/endtoend/zfpEndtoendBase.c | 64 ++++------------------------ tests/utils/CMakeLists.txt | 1 + tests/utils/stridedOperations.c | 41 ++++++++++++++++++ tests/utils/stridedOperations.h | 9 ++++ 4 files changed, 59 insertions(+), 56 deletions(-) diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 5ac9c2891..90f90cfc2 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -188,29 +188,10 @@ generateStridedRandomArray(stride_config stride, Scalar* randomGenArr, zfp_type } // identify strides and produce compressedArr - uint nx = (uint)n[0]; - uint ny = (uint)n[1]; - uint nz = (uint)n[2]; - uint nw = (uint)n[3]; - int sx = 0, sy = 0, sz = 0, sw = 0; - switch(stride) { case REVERSED: - if (dims == 4) { - sx = -1; - sy = sx * (int)nx; - sz = sy * (int)ny; - sw = sz * (int)nz; - } else if (dims == 3) { - sx = -1; - sy = sx * (int)nx; - sz = sy * (int)ny; - } else if (dims == 2) { - sx = -1; - sy = sx * (int)nx; - } else { - sx = -1; - } + getReversedStrides(dims, n, s); + reverseArray(randomGenArr, *compressedArrPtr, totalRandomGenArrLen, type); // adjust pointer to last element, so strided traverse is valid @@ -219,39 +200,15 @@ generateStridedRandomArray(stride_config stride, Scalar* randomGenArr, zfp_type break; case INTERLEAVED: - if (dims == 4) { - sx = 2; - sy = sx * (int)nx; - sz = sy * (int)ny; - sw = sz * (int)nz; - } else if (dims == 3) { - sx = 2; - sy = sx * (int)nx; - sz = sy * (int)ny; - } else if (dims == 2) { - sx = 2; - sy = sx * (int)nx; - } else { - sx = 2; - } + getInterleavedStrides(dims, n, s); + interleaveArray(randomGenArr, *compressedArrPtr, totalRandomGenArrLen, ZFP_TYPE); break; case PERMUTED: - if (dims == 4) { - sx = (int)(nx * ny * nz); - sy = (int)(nx * ny); - sz = (int)nx; - sw = 1; - } else if (dims == 3) { - sx = (int)(nx * ny); - sy = (int)nx; - sz = 1; - } else if (dims == 2) { - sx = (int)nx; - sy = 1; - } - if (permuteSquareArray(randomGenArr, *compressedArrPtr, nx, dims, type)) { + getPermutedStrides(dims, n, s); + + if (permuteSquareArray(randomGenArr, *compressedArrPtr, n[0], dims, type)) { fail_msg("Unexpected dims value in permuteSquareArray()"); } break; @@ -261,11 +218,6 @@ generateStridedRandomArray(stride_config stride, Scalar* randomGenArr, zfp_type memcpy(*compressedArrPtr, randomGenArr, totalRandomGenArrLen * sizeof(Scalar)); break; } - - s[0] = sx; - s[1] = sy; - s[2] = sz; - s[3] = sw; } static void @@ -276,7 +228,7 @@ initStridedFields(struct setupVars* bundle, stride_config stride) allocateFieldArrays(stride, bundle->totalRandomGenArrLen, &bundle->compressedArr, &bundle->decompressedArr); - int s[4]; + int s[4] = {0}; generateStridedRandomArray(stride, bundle->randomGenArr, ZFP_TYPE, bundle->randomGenArrSideLen, s, &bundle->compressedArr, &bundle->decompressedArr); setupZfpFields(bundle, s); diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index dd35f0137..f4b588aa7 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -27,6 +27,7 @@ target_link_libraries(genSmoothRandNumsLib PRIVATE rand64Lib fixedpoint96Lib) # strided array operations add_library(stridedOperationsLib stridedOperations.c stridedOperations.h) +target_link_libraries(stridedOperationsLib PRIVATE zfp) # compute zfp compression parameters add_library(zfpCompressionParamsLib zfpCompressionParams.c zfpCompressionParams.h) diff --git a/tests/utils/stridedOperations.c b/tests/utils/stridedOperations.c index 84adccfd7..de76709cb 100644 --- a/tests/utils/stridedOperations.c +++ b/tests/utils/stridedOperations.c @@ -89,3 +89,44 @@ permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zf return 0; } + +static void +completeStrides(int dims, size_t n[4], int s[4]) +{ + int i; + for (i = 1; i < dims; i++) { + s[i] = s[i-1] * (int)n[i-1]; + } +} + +void +getReversedStrides(int dims, size_t n[4], int s[4]) +{ + s[0] = -1; + completeStrides(dims, n, s); +} + +void +getInterleavedStrides(int dims, size_t n[4], int s[4]) +{ + s[0] = 2; + completeStrides(dims, n, s); +} + +void +getPermutedStrides(int dims, size_t n[4], int s[4]) +{ + if (dims == 4) { + s[0] = (int)(n[0] * n[1] * n[2]); + s[1] = (int)(n[0] * n[1]); + s[2] = (int)n[0]; + s[3] = 1; + } else if (dims == 3) { + s[0] = (int)(n[0] * n[1]); + s[1] = (int)n[0]; + s[2] = 1; + } else if (dims == 2) { + s[0] = (int)n[0]; + s[1] = 1; + } +} diff --git a/tests/utils/stridedOperations.h b/tests/utils/stridedOperations.h index c2bc91587..6db03ea27 100644 --- a/tests/utils/stridedOperations.h +++ b/tests/utils/stridedOperations.h @@ -24,4 +24,13 @@ interleaveArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zf int permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zfp_type zfpType); +void +getReversedStrides(int dims, size_t n[4], int s[4]); + +void +getInterleavedStrides(int dims, size_t n[4], int s[4]); + +void +getPermutedStrides(int dims, size_t n[4], int s[4]); + #endif From 0603b9060f43fcf749f05fde1046e6014291c653 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 21 Feb 2019 23:59:27 -0800 Subject: [PATCH 029/194] unify tests/ hashing libs, giving old API functions unique names --- tests/array/CMakeLists.txt | 4 +- tests/array/testArray1d.cpp | 1 - tests/array/testArray1dRefs.cpp | 1 - tests/array/testArray1dViews.cpp | 1 - tests/array/testArray1f.cpp | 1 - tests/array/testArray1fRefs.cpp | 1 - tests/array/testArray1fViews.cpp | 1 - tests/array/testArray2d.cpp | 1 - tests/array/testArray2dRefs.cpp | 1 - tests/array/testArray2dViews.cpp | 1 - tests/array/testArray2f.cpp | 1 - tests/array/testArray2fRefs.cpp | 1 - tests/array/testArray2fViews.cpp | 1 - tests/array/testArray3d.cpp | 1 - tests/array/testArray3dRefs.cpp | 1 - tests/array/testArray3dViews.cpp | 1 - tests/array/testArray3f.cpp | 1 - tests/array/testArray3fRefs.cpp | 1 - tests/array/testArray3fViews.cpp | 1 - tests/array/testArrayBase.cpp | 6 +- tests/array/testArrayRefsBase.cpp | 4 + tests/cfp/CMakeLists.txt | 2 +- tests/cfp/testCfpArray1d.c | 1 - tests/cfp/testCfpArray1f.c | 1 - tests/cfp/testCfpArray2d.c | 1 - tests/cfp/testCfpArray2f.c | 1 - tests/cfp/testCfpArray3d.c | 1 - tests/cfp/testCfpArray3f.c | 1 - tests/cfp/testCfpArray_source.c | 5 +- tests/constants/1dDouble.h | 3 +- tests/constants/1dFloat.h | 3 +- tests/constants/1dInt32.h | 2 +- tests/constants/1dInt64.h | 2 +- tests/constants/2dDouble.h | 3 +- tests/constants/2dFloat.h | 3 +- tests/constants/2dInt32.h | 2 +- tests/constants/2dInt64.h | 2 +- tests/constants/3dDouble.h | 3 +- tests/constants/3dFloat.h | 3 +- tests/constants/3dInt32.h | 2 +- tests/constants/3dInt64.h | 2 +- tests/constants/4dDouble.h | 3 +- tests/constants/4dFloat.h | 3 +- tests/constants/4dInt32.h | 2 +- tests/constants/4dInt64.h | 2 +- tests/constants/doubleConsts.h | 3 + tests/constants/floatConsts.h | 3 + tests/constants/int32Consts.h | 2 + tests/constants/int64Consts.h | 2 + tests/src/decode/CMakeLists.txt | 4 +- tests/src/decode/testZfpDecodeBlock1dDouble.c | 1 - tests/src/decode/testZfpDecodeBlock1dFloat.c | 1 - tests/src/decode/testZfpDecodeBlock1dInt32.c | 1 - tests/src/decode/testZfpDecodeBlock1dInt64.c | 1 - tests/src/decode/testZfpDecodeBlock2dDouble.c | 1 - tests/src/decode/testZfpDecodeBlock2dFloat.c | 1 - tests/src/decode/testZfpDecodeBlock2dInt32.c | 1 - tests/src/decode/testZfpDecodeBlock2dInt64.c | 1 - tests/src/decode/testZfpDecodeBlock3dDouble.c | 1 - tests/src/decode/testZfpDecodeBlock3dFloat.c | 1 - tests/src/decode/testZfpDecodeBlock3dInt32.c | 1 - tests/src/decode/testZfpDecodeBlock3dInt64.c | 1 - tests/src/decode/testZfpDecodeBlock4dDouble.c | 1 - tests/src/decode/testZfpDecodeBlock4dFloat.c | 1 - tests/src/decode/testZfpDecodeBlock4dInt32.c | 1 - tests/src/decode/testZfpDecodeBlock4dInt64.c | 1 - .../testZfpDecodeBlockStrided1dDouble.c | 1 - .../decode/testZfpDecodeBlockStrided1dFloat.c | 1 - .../decode/testZfpDecodeBlockStrided1dInt32.c | 1 - .../decode/testZfpDecodeBlockStrided1dInt64.c | 1 - .../testZfpDecodeBlockStrided2dDouble.c | 1 - .../decode/testZfpDecodeBlockStrided2dFloat.c | 1 - .../decode/testZfpDecodeBlockStrided2dInt32.c | 1 - .../decode/testZfpDecodeBlockStrided2dInt64.c | 1 - .../testZfpDecodeBlockStrided3dDouble.c | 1 - .../decode/testZfpDecodeBlockStrided3dFloat.c | 1 - .../decode/testZfpDecodeBlockStrided3dInt32.c | 1 - .../decode/testZfpDecodeBlockStrided3dInt64.c | 1 - .../testZfpDecodeBlockStrided4dDouble.c | 1 - .../decode/testZfpDecodeBlockStrided4dFloat.c | 1 - .../decode/testZfpDecodeBlockStrided4dInt32.c | 1 - .../decode/testZfpDecodeBlockStrided4dInt64.c | 1 - tests/src/decode/zfpDecodeBlockBase.c | 5 +- tests/src/decode/zfpDecodeBlockStridedBase.c | 3 +- tests/src/encode/CMakeLists.txt | 4 +- tests/src/encode/testZfpEncodeBlock1dDouble.c | 1 - tests/src/encode/testZfpEncodeBlock1dFloat.c | 1 - tests/src/encode/testZfpEncodeBlock1dInt32.c | 1 - tests/src/encode/testZfpEncodeBlock1dInt64.c | 1 - tests/src/encode/testZfpEncodeBlock2dDouble.c | 1 - tests/src/encode/testZfpEncodeBlock2dFloat.c | 1 - tests/src/encode/testZfpEncodeBlock2dInt32.c | 1 - tests/src/encode/testZfpEncodeBlock2dInt64.c | 1 - tests/src/encode/testZfpEncodeBlock3dDouble.c | 1 - tests/src/encode/testZfpEncodeBlock3dFloat.c | 1 - tests/src/encode/testZfpEncodeBlock3dInt32.c | 1 - tests/src/encode/testZfpEncodeBlock3dInt64.c | 1 - tests/src/encode/testZfpEncodeBlock4dDouble.c | 1 - tests/src/encode/testZfpEncodeBlock4dFloat.c | 1 - tests/src/encode/testZfpEncodeBlock4dInt32.c | 1 - tests/src/encode/testZfpEncodeBlock4dInt64.c | 1 - .../testZfpEncodeBlockStrided1dDouble.c | 1 - .../encode/testZfpEncodeBlockStrided1dFloat.c | 1 - .../encode/testZfpEncodeBlockStrided1dInt32.c | 1 - .../encode/testZfpEncodeBlockStrided1dInt64.c | 1 - .../testZfpEncodeBlockStrided2dDouble.c | 1 - .../encode/testZfpEncodeBlockStrided2dFloat.c | 1 - .../encode/testZfpEncodeBlockStrided2dInt32.c | 1 - .../encode/testZfpEncodeBlockStrided2dInt64.c | 1 - .../testZfpEncodeBlockStrided3dDouble.c | 1 - .../encode/testZfpEncodeBlockStrided3dFloat.c | 1 - .../encode/testZfpEncodeBlockStrided3dInt32.c | 1 - .../encode/testZfpEncodeBlockStrided3dInt64.c | 1 - .../testZfpEncodeBlockStrided4dDouble.c | 1 - .../encode/testZfpEncodeBlockStrided4dFloat.c | 1 - .../encode/testZfpEncodeBlockStrided4dInt32.c | 1 - .../encode/testZfpEncodeBlockStrided4dInt64.c | 1 - tests/src/encode/zfpEncodeBlockBase.c | 3 +- tests/src/encode/zfpEncodeBlockStridedBase.c | 3 +- tests/src/endtoend/CMakeLists.txt | 6 +- tests/src/endtoend/testZfpCuda1dDouble.c | 1 - tests/src/endtoend/testZfpCuda1dFloat.c | 1 - tests/src/endtoend/testZfpCuda1dInt32.c | 1 - tests/src/endtoend/testZfpCuda1dInt64.c | 1 - tests/src/endtoend/testZfpCuda2dDouble.c | 1 - tests/src/endtoend/testZfpCuda2dFloat.c | 1 - tests/src/endtoend/testZfpCuda2dInt32.c | 1 - tests/src/endtoend/testZfpCuda2dInt64.c | 1 - tests/src/endtoend/testZfpCuda3dDouble.c | 1 - tests/src/endtoend/testZfpCuda3dFloat.c | 1 - tests/src/endtoend/testZfpCuda3dInt32.c | 1 - tests/src/endtoend/testZfpCuda3dInt64.c | 1 - tests/src/endtoend/testZfpOmp1dDouble.c | 1 - tests/src/endtoend/testZfpOmp1dFloat.c | 1 - tests/src/endtoend/testZfpOmp1dInt32.c | 1 - tests/src/endtoend/testZfpOmp1dInt64.c | 1 - tests/src/endtoend/testZfpOmp2dDouble.c | 1 - tests/src/endtoend/testZfpOmp2dFloat.c | 1 - tests/src/endtoend/testZfpOmp2dInt32.c | 1 - tests/src/endtoend/testZfpOmp2dInt64.c | 1 - tests/src/endtoend/testZfpOmp3dDouble.c | 1 - tests/src/endtoend/testZfpOmp3dFloat.c | 1 - tests/src/endtoend/testZfpOmp3dInt32.c | 1 - tests/src/endtoend/testZfpOmp3dInt64.c | 1 - tests/src/endtoend/testZfpOmp4dDouble.c | 1 - tests/src/endtoend/testZfpOmp4dFloat.c | 1 - tests/src/endtoend/testZfpOmp4dInt32.c | 1 - tests/src/endtoend/testZfpOmp4dInt64.c | 1 - tests/src/endtoend/testZfpSerial1dDouble.c | 1 - tests/src/endtoend/testZfpSerial1dFloat.c | 1 - tests/src/endtoend/testZfpSerial1dInt32.c | 1 - tests/src/endtoend/testZfpSerial1dInt64.c | 1 - tests/src/endtoend/testZfpSerial2dDouble.c | 1 - tests/src/endtoend/testZfpSerial2dFloat.c | 1 - tests/src/endtoend/testZfpSerial2dInt32.c | 1 - tests/src/endtoend/testZfpSerial2dInt64.c | 1 - tests/src/endtoend/testZfpSerial3dDouble.c | 1 - tests/src/endtoend/testZfpSerial3dFloat.c | 1 - tests/src/endtoend/testZfpSerial3dInt32.c | 1 - tests/src/endtoend/testZfpSerial3dInt64.c | 1 - tests/src/endtoend/testZfpSerial4dDouble.c | 1 - tests/src/endtoend/testZfpSerial4dFloat.c | 1 - tests/src/endtoend/testZfpSerial4dInt32.c | 1 - tests/src/endtoend/testZfpSerial4dInt64.c | 1 - tests/src/endtoend/zfpEndtoendBase.c | 11 +-- tests/utils/CMakeLists.txt | 7 +- tests/utils/hash32.c | 35 --------- tests/utils/hash32.h | 15 ---- tests/utils/hash64.c | 42 ---------- tests/utils/hash64.h | 15 ---- tests/utils/testMacros.h | 3 + tests/utils/zfpHash.c | 76 +++++++++++++++++++ tests/utils/zfpHash.h | 23 ++++++ 173 files changed, 166 insertions(+), 292 deletions(-) create mode 100644 tests/constants/doubleConsts.h create mode 100644 tests/constants/floatConsts.h create mode 100644 tests/constants/int32Consts.h create mode 100644 tests/constants/int64Consts.h delete mode 100644 tests/utils/hash32.c delete mode 100644 tests/utils/hash32.h delete mode 100644 tests/utils/hash64.c delete mode 100644 tests/utils/hash64.h create mode 100644 tests/utils/zfpHash.c create mode 100644 tests/utils/zfpHash.h diff --git a/tests/array/CMakeLists.txt b/tests/array/CMakeLists.txt index 26ff94a8e..1430d43c3 100644 --- a/tests/array/CMakeLists.txt +++ b/tests/array/CMakeLists.txt @@ -3,14 +3,14 @@ function(zfp_add_cpp_tests dims type bits) set(test_name testArray${dims}${type}) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} - gtest gtest_main zfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib) + gtest gtest_main zfp zfpHashLib genSmoothRandNumsLib zfpChecksumsLib) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's references set(test_name testArray${dims}${type}Refs) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} - gtest gtest_main zfp hash${bits}Lib rand${bits}Lib) + gtest gtest_main zfp zfpHashLib rand${bits}Lib) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's pointers diff --git a/tests/array/testArray1d.cpp b/tests/array/testArray1d.cpp index ba4b12fda..ff8d2267b 100644 --- a/tests/array/testArray1d.cpp +++ b/tests/array/testArray1d.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/1dDouble.h" - #include "utils/hash64.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray1dRefs.cpp b/tests/array/testArray1dRefs.cpp index 782821bb9..41a13e8bf 100644 --- a/tests/array/testArray1dRefs.cpp +++ b/tests/array/testArray1dRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray1dViews.cpp b/tests/array/testArray1dViews.cpp index 10ff5dad1..61e671e05 100644 --- a/tests/array/testArray1dViews.cpp +++ b/tests/array/testArray1dViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray1f.cpp b/tests/array/testArray1f.cpp index e49160155..04a334a33 100644 --- a/tests/array/testArray1f.cpp +++ b/tests/array/testArray1f.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/1dFloat.h" - #include "utils/hash32.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray1fRefs.cpp b/tests/array/testArray1fRefs.cpp index c82e945e2..517b3718f 100644 --- a/tests/array/testArray1fRefs.cpp +++ b/tests/array/testArray1fRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash32.h" #include "utils/rand32.h" } diff --git a/tests/array/testArray1fViews.cpp b/tests/array/testArray1fViews.cpp index 9eb184040..142c72b72 100644 --- a/tests/array/testArray1fViews.cpp +++ b/tests/array/testArray1fViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash32.h" #include "utils/rand32.h" } diff --git a/tests/array/testArray2d.cpp b/tests/array/testArray2d.cpp index b1b49a123..a6882f78f 100644 --- a/tests/array/testArray2d.cpp +++ b/tests/array/testArray2d.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/2dDouble.h" - #include "utils/hash64.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray2dRefs.cpp b/tests/array/testArray2dRefs.cpp index 4aca15f63..bcfaf2d1e 100644 --- a/tests/array/testArray2dRefs.cpp +++ b/tests/array/testArray2dRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray2dViews.cpp b/tests/array/testArray2dViews.cpp index 3abcfdf4c..e1d40e082 100644 --- a/tests/array/testArray2dViews.cpp +++ b/tests/array/testArray2dViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray2f.cpp b/tests/array/testArray2f.cpp index ff0248665..b2bba1a9f 100644 --- a/tests/array/testArray2f.cpp +++ b/tests/array/testArray2f.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/2dFloat.h" - #include "utils/hash32.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray2fRefs.cpp b/tests/array/testArray2fRefs.cpp index cb17f3cb2..10fb38f4b 100644 --- a/tests/array/testArray2fRefs.cpp +++ b/tests/array/testArray2fRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash32.h" #include "utils/rand32.h" } diff --git a/tests/array/testArray2fViews.cpp b/tests/array/testArray2fViews.cpp index 9a888d39d..e43eb69c9 100644 --- a/tests/array/testArray2fViews.cpp +++ b/tests/array/testArray2fViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash32.h" #include "utils/rand32.h" } diff --git a/tests/array/testArray3d.cpp b/tests/array/testArray3d.cpp index bb435cc21..b58e1a113 100644 --- a/tests/array/testArray3d.cpp +++ b/tests/array/testArray3d.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/3dDouble.h" - #include "utils/hash64.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray3dRefs.cpp b/tests/array/testArray3dRefs.cpp index 6f486aa46..d4a43582b 100644 --- a/tests/array/testArray3dRefs.cpp +++ b/tests/array/testArray3dRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray3dViews.cpp b/tests/array/testArray3dViews.cpp index 580401289..cda31375a 100644 --- a/tests/array/testArray3dViews.cpp +++ b/tests/array/testArray3dViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArray3f.cpp b/tests/array/testArray3f.cpp index 2864f5b32..d38d1d5aa 100644 --- a/tests/array/testArray3f.cpp +++ b/tests/array/testArray3f.cpp @@ -3,7 +3,6 @@ using namespace zfp; extern "C" { #include "constants/3dFloat.h" - #include "utils/hash32.h" } #include "gtest/gtest.h" diff --git a/tests/array/testArray3fRefs.cpp b/tests/array/testArray3fRefs.cpp index d3e16362f..f6afbfed0 100644 --- a/tests/array/testArray3fRefs.cpp +++ b/tests/array/testArray3fRefs.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash32.h" #include "utils/rand32.h" } diff --git a/tests/array/testArray3fViews.cpp b/tests/array/testArray3fViews.cpp index 580401289..cda31375a 100644 --- a/tests/array/testArray3fViews.cpp +++ b/tests/array/testArray3fViews.cpp @@ -2,7 +2,6 @@ using namespace zfp; extern "C" { - #include "utils/hash64.h" #include "utils/rand64.h" } diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 52056014c..413010a4a 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -1,5 +1,7 @@ extern "C" { + #include "utils/testMacros.h" #include "utils/zfpChecksums.h" + #include "utils/zfpHash.h" } TEST_F(TEST_FIXTURE, when_constructorCalled_then_rateSetWithWriteRandomAccess) @@ -66,7 +68,7 @@ TEST_F(TEST_FIXTURE, when_setRate_then_compressionRateChanged) TEST_F(TEST_FIXTURE, when_generateRandomData_then_checksumMatches) { - EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, getChecksumOriginalDataArray(DIMS, ZFP_TYPE), hashArray((UINT*)inputDataArr, inputDataTotalLen, 1)); + EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, getChecksumOriginalDataArray(DIMS, ZFP_TYPE), _catFunc2(hashArray, SCALAR_BITS)((UINT*)inputDataArr, inputDataTotalLen, 1)); } #if DIMS == 1 @@ -110,7 +112,7 @@ TEST_P(TEST_FIXTURE, given_setArray_when_get_then_decompressedValsReturned) arr.get(decompressedArr); uint64 expectedChecksum = getChecksumDecompressedArray(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, GetParam()); - uint64 checksum = hashArray((UINT*)decompressedArr, inputDataTotalLen, 1); + uint64 checksum = _catFunc2(hashArray, SCALAR_BITS)((UINT*)decompressedArr, inputDataTotalLen, 1); EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); delete[] decompressedArr; diff --git a/tests/array/testArrayRefsBase.cpp b/tests/array/testArrayRefsBase.cpp index ed955c351..06b1894c0 100644 --- a/tests/array/testArrayRefsBase.cpp +++ b/tests/array/testArrayRefsBase.cpp @@ -1,6 +1,10 @@ #include "gtest/gtest.h" #include "utils/predicates.h" +extern "C" { + #include "utils/zfpHash.h" +} + // assumes macros ARRAY_DIMS_SCALAR_TEST, ARRAY_DIMS_SCALAR_TEST_REFS defined class ARRAY_DIMS_SCALAR_TEST_REFS : public ARRAY_DIMS_SCALAR_TEST {}; diff --git a/tests/cfp/CMakeLists.txt b/tests/cfp/CMakeLists.txt index 037d2ff50..608cd7461 100644 --- a/tests/cfp/CMakeLists.txt +++ b/tests/cfp/CMakeLists.txt @@ -2,7 +2,7 @@ function(cfp_add_test dims type bits) set(test_name testCfpArray${dims}${type}) add_executable(${test_name} ${test_name}.c) target_link_libraries(${test_name} - cmocka cfp hash${bits}Lib genSmoothRandNumsLib zfpChecksumsLib) + cmocka cfp zfpHashLib genSmoothRandNumsLib zfpChecksumsLib) add_test(NAME ${test_name} COMMAND ${test_name}) endfunction() diff --git a/tests/cfp/testCfpArray1d.c b/tests/cfp/testCfpArray1d.c index 6c3c20796..0b4bb0e6f 100644 --- a/tests/cfp/testCfpArray1d.c +++ b/tests/cfp/testCfpArray1d.c @@ -2,7 +2,6 @@ #include "src/block1.h" #include "constants/1dDouble.h" -#include "utils/hash64.h" #define CFP_ARRAY_TYPE cfp_array1d #define SUB_NAMESPACE array1d diff --git a/tests/cfp/testCfpArray1f.c b/tests/cfp/testCfpArray1f.c index 23ecf4246..925e30dce 100644 --- a/tests/cfp/testCfpArray1f.c +++ b/tests/cfp/testCfpArray1f.c @@ -2,7 +2,6 @@ #include "src/block1.h" #include "constants/1dFloat.h" -#include "utils/hash32.h" #define CFP_ARRAY_TYPE cfp_array1f #define SUB_NAMESPACE array1f diff --git a/tests/cfp/testCfpArray2d.c b/tests/cfp/testCfpArray2d.c index 3c6b75c66..004245540 100644 --- a/tests/cfp/testCfpArray2d.c +++ b/tests/cfp/testCfpArray2d.c @@ -2,7 +2,6 @@ #include "src/block2.h" #include "constants/2dDouble.h" -#include "utils/hash64.h" #define CFP_ARRAY_TYPE cfp_array2d #define SUB_NAMESPACE array2d diff --git a/tests/cfp/testCfpArray2f.c b/tests/cfp/testCfpArray2f.c index d37b2c478..d937ac9be 100644 --- a/tests/cfp/testCfpArray2f.c +++ b/tests/cfp/testCfpArray2f.c @@ -2,7 +2,6 @@ #include "src/block2.h" #include "constants/2dFloat.h" -#include "utils/hash32.h" #define CFP_ARRAY_TYPE cfp_array2f #define SUB_NAMESPACE array2f diff --git a/tests/cfp/testCfpArray3d.c b/tests/cfp/testCfpArray3d.c index 3291f511f..bc845fecf 100644 --- a/tests/cfp/testCfpArray3d.c +++ b/tests/cfp/testCfpArray3d.c @@ -2,7 +2,6 @@ #include "src/block3.h" #include "constants/3dDouble.h" -#include "utils/hash64.h" #define CFP_ARRAY_TYPE cfp_array3d #define SUB_NAMESPACE array3d diff --git a/tests/cfp/testCfpArray3f.c b/tests/cfp/testCfpArray3f.c index 23a877a05..861c4af32 100644 --- a/tests/cfp/testCfpArray3f.c +++ b/tests/cfp/testCfpArray3f.c @@ -2,7 +2,6 @@ #include "src/block3.h" #include "constants/3dFloat.h" -#include "utils/hash32.h" #define CFP_ARRAY_TYPE cfp_array3f #define SUB_NAMESPACE array3f diff --git a/tests/cfp/testCfpArray_source.c b/tests/cfp/testCfpArray_source.c index e376c99fc..629d20809 100644 --- a/tests/cfp/testCfpArray_source.c +++ b/tests/cfp/testCfpArray_source.c @@ -14,6 +14,7 @@ #include "utils/genSmoothRandNums.h" #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpHash.h" #define SIZE_X 20 #define SIZE_Y 31 @@ -225,7 +226,7 @@ static void when_seededRandomSmoothDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - UInt checksum = hashArray((const UInt*)bundle->dataArr, bundle->totalDataLen, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((const UInt*)bundle->dataArr, bundle->totalDataLen, 1); uint64 expectedChecksum = getChecksumOriginalDataArray(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } @@ -418,7 +419,7 @@ _catFunc3(given_, CFP_ARRAY_TYPE, _when_getArray_expect_decompressedArrChecksumM CFP_NAMESPACE.SUB_NAMESPACE.set_array(cfpArr, bundle->dataArr); CFP_NAMESPACE.SUB_NAMESPACE.get_array(cfpArr, bundle->decompressedArr); - UInt checksum = hashArray((UInt*)bundle->decompressedArr, bundle->totalDataLen, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((UInt*)bundle->decompressedArr, bundle->totalDataLen, 1); uint64 expectedChecksum = getChecksumDecompressedArray(DIMS, ZFP_TYPE, zfp_mode_fixed_rate, bundle->paramNum); assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/constants/1dDouble.h b/tests/constants/1dDouble.h index d7b579ff0..e55b490fa 100644 --- a/tests/constants/1dDouble.h +++ b/tests/constants/1dDouble.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "doubleConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_double #define DIM_INT_STR 1dDouble diff --git a/tests/constants/1dFloat.h b/tests/constants/1dFloat.h index 5d3882170..feea2584e 100644 --- a/tests/constants/1dFloat.h +++ b/tests/constants/1dFloat.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "floatConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_float #define DIM_INT_STR 1dFloat diff --git a/tests/constants/1dInt32.h b/tests/constants/1dInt32.h index 7e003ddd0..d2bffba30 100644 --- a/tests/constants/1dInt32.h +++ b/tests/constants/1dInt32.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int32Consts.h" -#define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 1dInt32 diff --git a/tests/constants/1dInt64.h b/tests/constants/1dInt64.h index 088cd0374..e1e0a48c9 100644 --- a/tests/constants/1dInt64.h +++ b/tests/constants/1dInt64.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int64Consts.h" -#define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 1dInt64 diff --git a/tests/constants/2dDouble.h b/tests/constants/2dDouble.h index 59e8b9088..f8c66bace 100644 --- a/tests/constants/2dDouble.h +++ b/tests/constants/2dDouble.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "doubleConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_double #define DIM_INT_STR 2dDouble diff --git a/tests/constants/2dFloat.h b/tests/constants/2dFloat.h index cc3e51e53..cc9bd6e34 100644 --- a/tests/constants/2dFloat.h +++ b/tests/constants/2dFloat.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "floatConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_float #define DIM_INT_STR 2dFloat diff --git a/tests/constants/2dInt32.h b/tests/constants/2dInt32.h index 9ed8f01da..1792ea7a5 100644 --- a/tests/constants/2dInt32.h +++ b/tests/constants/2dInt32.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int32Consts.h" -#define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 2dInt32 diff --git a/tests/constants/2dInt64.h b/tests/constants/2dInt64.h index b967abb23..f81b09b30 100644 --- a/tests/constants/2dInt64.h +++ b/tests/constants/2dInt64.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int64Consts.h" -#define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 2dInt64 diff --git a/tests/constants/3dDouble.h b/tests/constants/3dDouble.h index ef0ef0dec..cc45da6d0 100644 --- a/tests/constants/3dDouble.h +++ b/tests/constants/3dDouble.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "doubleConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_double #define DIM_INT_STR 3dDouble diff --git a/tests/constants/3dFloat.h b/tests/constants/3dFloat.h index 90b10fcc4..65fa0793a 100644 --- a/tests/constants/3dFloat.h +++ b/tests/constants/3dFloat.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "floatConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_float #define DIM_INT_STR 3dFloat diff --git a/tests/constants/3dInt32.h b/tests/constants/3dInt32.h index 4a962de78..a966fc061 100644 --- a/tests/constants/3dInt32.h +++ b/tests/constants/3dInt32.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int32Consts.h" -#define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 3dInt32 diff --git a/tests/constants/3dInt64.h b/tests/constants/3dInt64.h index 18bd3dc35..dc89aaf80 100644 --- a/tests/constants/3dInt64.h +++ b/tests/constants/3dInt64.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int64Consts.h" -#define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 3dInt64 diff --git a/tests/constants/4dDouble.h b/tests/constants/4dDouble.h index 864a46049..308a7f104 100644 --- a/tests/constants/4dDouble.h +++ b/tests/constants/4dDouble.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "doubleConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_double #define DIM_INT_STR 4dDouble diff --git a/tests/constants/4dFloat.h b/tests/constants/4dFloat.h index 29d8f5c62..75e1bc473 100644 --- a/tests/constants/4dFloat.h +++ b/tests/constants/4dFloat.h @@ -1,5 +1,4 @@ #include "universalConsts.h" +#include "floatConsts.h" -#define FL_PT_DATA -#define ZFP_TYPE zfp_type_float #define DIM_INT_STR 4dFloat diff --git a/tests/constants/4dInt32.h b/tests/constants/4dInt32.h index 23754ef07..19087b57b 100644 --- a/tests/constants/4dInt32.h +++ b/tests/constants/4dInt32.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int32Consts.h" -#define ZFP_TYPE zfp_type_int32 #define DIM_INT_STR 4dInt32 diff --git a/tests/constants/4dInt64.h b/tests/constants/4dInt64.h index 6af78053d..b42778abd 100644 --- a/tests/constants/4dInt64.h +++ b/tests/constants/4dInt64.h @@ -1,4 +1,4 @@ #include "universalConsts.h" +#include "int64Consts.h" -#define ZFP_TYPE zfp_type_int64 #define DIM_INT_STR 4dInt64 diff --git a/tests/constants/doubleConsts.h b/tests/constants/doubleConsts.h new file mode 100644 index 000000000..a48c9a50a --- /dev/null +++ b/tests/constants/doubleConsts.h @@ -0,0 +1,3 @@ +#define FL_PT_DATA +#define SCALAR_BITS 64 +#define ZFP_TYPE zfp_type_double diff --git a/tests/constants/floatConsts.h b/tests/constants/floatConsts.h new file mode 100644 index 000000000..679168573 --- /dev/null +++ b/tests/constants/floatConsts.h @@ -0,0 +1,3 @@ +#define FL_PT_DATA +#define SCALAR_BITS 32 +#define ZFP_TYPE zfp_type_float diff --git a/tests/constants/int32Consts.h b/tests/constants/int32Consts.h new file mode 100644 index 000000000..69ec2d286 --- /dev/null +++ b/tests/constants/int32Consts.h @@ -0,0 +1,2 @@ +#define SCALAR_BITS 32 +#define ZFP_TYPE zfp_type_int32 diff --git a/tests/constants/int64Consts.h b/tests/constants/int64Consts.h new file mode 100644 index 000000000..6c1093c37 --- /dev/null +++ b/tests/constants/int64Consts.h @@ -0,0 +1,2 @@ +#define SCALAR_BITS 64 +#define ZFP_TYPE zfp_type_int64 diff --git a/tests/src/decode/CMakeLists.txt b/tests/src/decode/CMakeLists.txt index 4a5b35793..0260e6c01 100644 --- a/tests/src/decode/CMakeLists.txt +++ b/tests/src/decode/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_block_tests dims type bits) set(block_test_name testZfpDecodeBlock${dims}d${type}) add_executable(${block_test_name} ${block_test_name}.c) target_link_libraries(${block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) + cmocka zfp rand${bits}Lib zfpHashLib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${block_test_name} m) endif() @@ -11,7 +11,7 @@ function(zfp_add_block_tests dims type bits) set(strided_block_test_name testZfpDecodeBlockStrided${dims}d${type}) add_executable(${strided_block_test_name} ${strided_block_test_name}.c) target_link_libraries(${strided_block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) + cmocka zfp rand${bits}Lib zfpHashLib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${strided_block_test_name} m) endif() diff --git a/tests/src/decode/testZfpDecodeBlock1dDouble.c b/tests/src/decode/testZfpDecodeBlock1dDouble.c index 04c7e04a4..4e71192b1 100644 --- a/tests/src/decode/testZfpDecodeBlock1dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock1dDouble.c @@ -2,7 +2,6 @@ #include "constants/1dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock1dFloat.c b/tests/src/decode/testZfpDecodeBlock1dFloat.c index 787041509..9631566ad 100644 --- a/tests/src/decode/testZfpDecodeBlock1dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock1dFloat.c @@ -2,7 +2,6 @@ #include "constants/1dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock1dInt32.c b/tests/src/decode/testZfpDecodeBlock1dInt32.c index 396ba452e..180ca0c45 100644 --- a/tests/src/decode/testZfpDecodeBlock1dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock1dInt32.c @@ -2,7 +2,6 @@ #include "constants/1dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock1dInt64.c b/tests/src/decode/testZfpDecodeBlock1dInt64.c index 907fa3985..70f301c9d 100644 --- a/tests/src/decode/testZfpDecodeBlock1dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock1dInt64.c @@ -2,7 +2,6 @@ #include "constants/1dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock2dDouble.c b/tests/src/decode/testZfpDecodeBlock2dDouble.c index fc8e7cc97..4e98097b7 100644 --- a/tests/src/decode/testZfpDecodeBlock2dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock2dDouble.c @@ -2,7 +2,6 @@ #include "constants/2dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock2dFloat.c b/tests/src/decode/testZfpDecodeBlock2dFloat.c index 2959d3519..a88bcb200 100644 --- a/tests/src/decode/testZfpDecodeBlock2dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock2dFloat.c @@ -2,7 +2,6 @@ #include "constants/2dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock2dInt32.c b/tests/src/decode/testZfpDecodeBlock2dInt32.c index 601389f43..406ed5e8f 100644 --- a/tests/src/decode/testZfpDecodeBlock2dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock2dInt32.c @@ -2,7 +2,6 @@ #include "constants/2dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock2dInt64.c b/tests/src/decode/testZfpDecodeBlock2dInt64.c index 1ef785fde..5be19c677 100644 --- a/tests/src/decode/testZfpDecodeBlock2dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock2dInt64.c @@ -2,7 +2,6 @@ #include "constants/2dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock3dDouble.c b/tests/src/decode/testZfpDecodeBlock3dDouble.c index 516938415..7c96c8583 100644 --- a/tests/src/decode/testZfpDecodeBlock3dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock3dDouble.c @@ -2,7 +2,6 @@ #include "constants/3dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock3dFloat.c b/tests/src/decode/testZfpDecodeBlock3dFloat.c index ab2c62015..95b219ca5 100644 --- a/tests/src/decode/testZfpDecodeBlock3dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock3dFloat.c @@ -2,7 +2,6 @@ #include "constants/3dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock3dInt32.c b/tests/src/decode/testZfpDecodeBlock3dInt32.c index 3d5a86834..f183544a0 100644 --- a/tests/src/decode/testZfpDecodeBlock3dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock3dInt32.c @@ -2,7 +2,6 @@ #include "constants/3dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock3dInt64.c b/tests/src/decode/testZfpDecodeBlock3dInt64.c index 5ec730fdb..2b79063a2 100644 --- a/tests/src/decode/testZfpDecodeBlock3dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock3dInt64.c @@ -2,7 +2,6 @@ #include "constants/3dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock4dDouble.c b/tests/src/decode/testZfpDecodeBlock4dDouble.c index 590d62123..6ef1fc710 100644 --- a/tests/src/decode/testZfpDecodeBlock4dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock4dDouble.c @@ -2,7 +2,6 @@ #include "constants/4dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock4dFloat.c b/tests/src/decode/testZfpDecodeBlock4dFloat.c index 25d1ed228..327890d7a 100644 --- a/tests/src/decode/testZfpDecodeBlock4dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock4dFloat.c @@ -2,7 +2,6 @@ #include "constants/4dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock4dInt32.c b/tests/src/decode/testZfpDecodeBlock4dInt32.c index ce7aeab37..0e52729c4 100644 --- a/tests/src/decode/testZfpDecodeBlock4dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock4dInt32.c @@ -2,7 +2,6 @@ #include "constants/4dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlock4dInt64.c b/tests/src/decode/testZfpDecodeBlock4dInt64.c index 4c5fb3d7c..ef28c043c 100644 --- a/tests/src/decode/testZfpDecodeBlock4dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock4dInt64.c @@ -2,7 +2,6 @@ #include "constants/4dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c index 9494114e5..55a6871d7 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c @@ -2,7 +2,6 @@ #include "constants/1dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c index ade775aa2..047b73d9e 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c @@ -2,7 +2,6 @@ #include "constants/1dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c index 6a889e2b5..40f0945c9 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c @@ -2,7 +2,6 @@ #include "constants/1dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c index 0af208002..a5ff18722 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c @@ -2,7 +2,6 @@ #include "constants/1dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c index 06d9ceace..67674f5b9 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c @@ -2,7 +2,6 @@ #include "constants/2dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c index e001c5239..63d2c9dc3 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c @@ -2,7 +2,6 @@ #include "constants/2dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c index 82651c399..318cd9fc3 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c @@ -2,7 +2,6 @@ #include "constants/2dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c index e89e8c1f2..ea5ee3c1e 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c @@ -2,7 +2,6 @@ #include "constants/2dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c index e37312e99..739028140 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c @@ -2,7 +2,6 @@ #include "constants/3dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c index 7cde8214a..8f2252d7a 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c @@ -2,7 +2,6 @@ #include "constants/3dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c index 25fd3d2b6..60da7ce6b 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c @@ -2,7 +2,6 @@ #include "constants/3dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c index 36a12836c..d1754cdfa 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c @@ -2,7 +2,6 @@ #include "constants/3dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c index ba3351d0a..f2181baf3 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c @@ -2,7 +2,6 @@ #include "constants/4dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c index 67aeb0827..92db0eacd 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c @@ -2,7 +2,6 @@ #include "constants/4dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c index 77e4ccb72..c36033e23 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c @@ -2,7 +2,6 @@ #include "constants/4dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c index 9931b10fe..ea1885b10 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c @@ -2,7 +2,6 @@ #include "constants/4dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpDecodeBlockStridedBase.c" int main() diff --git a/tests/src/decode/zfpDecodeBlockBase.c b/tests/src/decode/zfpDecodeBlockBase.c index 4c3deb502..6143f15a7 100644 --- a/tests/src/decode/zfpDecodeBlockBase.c +++ b/tests/src/decode/zfpDecodeBlockBase.c @@ -7,6 +7,7 @@ #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpHash.h" struct setupVars { Scalar* dataArr; @@ -102,7 +103,7 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - UInt checksum = hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } @@ -137,7 +138,7 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ArrayChecksumMatche assert_non_null(decodedDataArr); _t2(zfp_decode_block, Scalar, DIMS)(stream, decodedDataArr); - UInt checksum = hashArray((const UInt*)decodedDataArr, BLOCK_SIZE, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((const UInt*)decodedDataArr, BLOCK_SIZE, 1); free(decodedDataArr); uint64 expectedChecksum = getChecksumDecodedBlock(DIMS, ZFP_TYPE); diff --git a/tests/src/decode/zfpDecodeBlockStridedBase.c b/tests/src/decode/zfpDecodeBlockStridedBase.c index 3df41fdf0..f89f9acef 100644 --- a/tests/src/decode/zfpDecodeBlockStridedBase.c +++ b/tests/src/decode/zfpDecodeBlockStridedBase.c @@ -7,6 +7,7 @@ #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpHash.h" #define SX 2 #define SY (3 * BLOCK_SIDE_LEN*SX) @@ -241,7 +242,7 @@ hashStridedBlock(Scalar* dataArr) int s[4] = {SX, SY, SZ, SW}; - return hashStridedArray((const UInt*)dataArr, n, s); + return _catFunc2(hashStridedArray, SCALAR_BITS)((const UInt*)dataArr, n, s); } uint diff --git a/tests/src/encode/CMakeLists.txt b/tests/src/encode/CMakeLists.txt index 5c71d97f0..3ffa758d5 100644 --- a/tests/src/encode/CMakeLists.txt +++ b/tests/src/encode/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_block_tests dims type bits) set(block_test_name testZfpEncodeBlock${dims}d${type}) add_executable(${block_test_name} ${block_test_name}.c) target_link_libraries(${block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) + cmocka zfp rand${bits}Lib zfpHashLib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${block_test_name} m) endif() @@ -11,7 +11,7 @@ function(zfp_add_block_tests dims type bits) set(strided_block_test_name testZfpEncodeBlockStrided${dims}d${type}) add_executable(${strided_block_test_name} ${strided_block_test_name}.c) target_link_libraries(${strided_block_test_name} - cmocka zfp rand${bits}Lib hash${bits}Lib zfpChecksumsLib) + cmocka zfp rand${bits}Lib zfpHashLib zfpChecksumsLib) if(HAVE_LIBM_MATH) target_link_libraries(${strided_block_test_name} m) endif() diff --git a/tests/src/encode/testZfpEncodeBlock1dDouble.c b/tests/src/encode/testZfpEncodeBlock1dDouble.c index e5d908e7c..9a362c3cf 100644 --- a/tests/src/encode/testZfpEncodeBlock1dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock1dDouble.c @@ -2,7 +2,6 @@ #include "constants/1dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock1dFloat.c b/tests/src/encode/testZfpEncodeBlock1dFloat.c index 8e13d008c..d5cf088fa 100644 --- a/tests/src/encode/testZfpEncodeBlock1dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock1dFloat.c @@ -2,7 +2,6 @@ #include "constants/1dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock1dInt32.c b/tests/src/encode/testZfpEncodeBlock1dInt32.c index d65fcc9bd..7732cc59a 100644 --- a/tests/src/encode/testZfpEncodeBlock1dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock1dInt32.c @@ -2,7 +2,6 @@ #include "constants/1dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock1dInt64.c b/tests/src/encode/testZfpEncodeBlock1dInt64.c index 68a3d38aa..8ef11b1f8 100644 --- a/tests/src/encode/testZfpEncodeBlock1dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock1dInt64.c @@ -2,7 +2,6 @@ #include "constants/1dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock2dDouble.c b/tests/src/encode/testZfpEncodeBlock2dDouble.c index 5f984cb3f..9388a6a05 100644 --- a/tests/src/encode/testZfpEncodeBlock2dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock2dDouble.c @@ -2,7 +2,6 @@ #include "constants/2dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock2dFloat.c b/tests/src/encode/testZfpEncodeBlock2dFloat.c index 35cab3e8e..b58ca5a2a 100644 --- a/tests/src/encode/testZfpEncodeBlock2dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock2dFloat.c @@ -2,7 +2,6 @@ #include "constants/2dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock2dInt32.c b/tests/src/encode/testZfpEncodeBlock2dInt32.c index 845441174..b835e3112 100644 --- a/tests/src/encode/testZfpEncodeBlock2dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock2dInt32.c @@ -2,7 +2,6 @@ #include "constants/2dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock2dInt64.c b/tests/src/encode/testZfpEncodeBlock2dInt64.c index 6b0580cf3..c0d978832 100644 --- a/tests/src/encode/testZfpEncodeBlock2dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock2dInt64.c @@ -2,7 +2,6 @@ #include "constants/2dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock3dDouble.c b/tests/src/encode/testZfpEncodeBlock3dDouble.c index 819611f93..9ef75ae77 100644 --- a/tests/src/encode/testZfpEncodeBlock3dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock3dDouble.c @@ -2,7 +2,6 @@ #include "constants/3dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock3dFloat.c b/tests/src/encode/testZfpEncodeBlock3dFloat.c index d87b25c58..80afef92b 100644 --- a/tests/src/encode/testZfpEncodeBlock3dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock3dFloat.c @@ -2,7 +2,6 @@ #include "constants/3dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock3dInt32.c b/tests/src/encode/testZfpEncodeBlock3dInt32.c index cf1708b10..add9a3018 100644 --- a/tests/src/encode/testZfpEncodeBlock3dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock3dInt32.c @@ -2,7 +2,6 @@ #include "constants/3dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock3dInt64.c b/tests/src/encode/testZfpEncodeBlock3dInt64.c index 2836cb27c..b92a5cff1 100644 --- a/tests/src/encode/testZfpEncodeBlock3dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock3dInt64.c @@ -2,7 +2,6 @@ #include "constants/3dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock4dDouble.c b/tests/src/encode/testZfpEncodeBlock4dDouble.c index 18ba03393..402b9e7ea 100644 --- a/tests/src/encode/testZfpEncodeBlock4dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock4dDouble.c @@ -2,7 +2,6 @@ #include "constants/4dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock4dFloat.c b/tests/src/encode/testZfpEncodeBlock4dFloat.c index 6ee621983..403c573cc 100644 --- a/tests/src/encode/testZfpEncodeBlock4dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock4dFloat.c @@ -2,7 +2,6 @@ #include "constants/4dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock4dInt32.c b/tests/src/encode/testZfpEncodeBlock4dInt32.c index 53e33d2a2..20e125370 100644 --- a/tests/src/encode/testZfpEncodeBlock4dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock4dInt32.c @@ -2,7 +2,6 @@ #include "constants/4dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlock4dInt64.c b/tests/src/encode/testZfpEncodeBlock4dInt64.c index d480afdaf..7f407c4fb 100644 --- a/tests/src/encode/testZfpEncodeBlock4dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock4dInt64.c @@ -2,7 +2,6 @@ #include "constants/4dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c index 2a05e906c..661bb9143 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c @@ -2,7 +2,6 @@ #include "constants/1dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c index 6e07319fb..fdcfff982 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c @@ -2,7 +2,6 @@ #include "constants/1dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c index 09d021f5b..4b4dfaea4 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c @@ -2,7 +2,6 @@ #include "constants/1dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c index 71264195f..c14adef8e 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c @@ -2,7 +2,6 @@ #include "constants/1dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c index 74bbe057a..d251d450b 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c @@ -2,7 +2,6 @@ #include "constants/2dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c index 78640b515..735f8a01c 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c @@ -2,7 +2,6 @@ #include "constants/2dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c index a0326cbde..89455bab6 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c @@ -2,7 +2,6 @@ #include "constants/2dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c index 00f992aa4..691b1bc76 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c @@ -2,7 +2,6 @@ #include "constants/2dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c index 3eee63500..923d7bb81 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c @@ -2,7 +2,6 @@ #include "constants/3dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c index f86a6b557..412ded42c 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c @@ -2,7 +2,6 @@ #include "constants/3dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c index 3442239da..42be0b006 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c @@ -2,7 +2,6 @@ #include "constants/3dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c index 80e08a1e2..1c84e98b4 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c @@ -2,7 +2,6 @@ #include "constants/3dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c index e1246cc4f..1618ce771 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c @@ -2,7 +2,6 @@ #include "constants/4dDouble.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c index 8e3d4d90d..7c9399c0d 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c @@ -2,7 +2,6 @@ #include "constants/4dFloat.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c index 762335a3e..413fbdf14 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c @@ -2,7 +2,6 @@ #include "constants/4dInt32.h" #include "utils/rand32.h" -#include "utils/hash32.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c index e05e8eda3..47d855c13 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c @@ -2,7 +2,6 @@ #include "constants/4dInt64.h" #include "utils/rand64.h" -#include "utils/hash64.h" #include "zfpEncodeBlockStridedBase.c" int main() diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index 474f89664..a783277fc 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -7,6 +7,7 @@ #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpHash.h" struct setupVars { Scalar* dataArr; @@ -101,7 +102,7 @@ static void when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - UInt checksum = hashArray((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((const UInt*)bundle->dataArr, BLOCK_SIZE, 1); uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/encode/zfpEncodeBlockStridedBase.c b/tests/src/encode/zfpEncodeBlockStridedBase.c index ef3a62168..cc631a1ff 100644 --- a/tests/src/encode/zfpEncodeBlockStridedBase.c +++ b/tests/src/encode/zfpEncodeBlockStridedBase.c @@ -7,6 +7,7 @@ #include "utils/testMacros.h" #include "utils/zfpChecksums.h" +#include "utils/zfpHash.h" #define SX 2 #define SY (3 * BLOCK_SIDE_LEN*SX) @@ -269,7 +270,7 @@ when_seededRandomDataGenerated_expect_ChecksumMatches(void **state) int s[4] = {SX, SY, SZ, SW}; - UInt checksum = hashStridedArray((const UInt*)bundle->dataArr, n, s); + UInt checksum = _catFunc2(hashStridedArray, SCALAR_BITS)((const UInt*)bundle->dataArr, n, s); uint64 expectedChecksum = getChecksumOriginalDataBlock(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 6c68c9744..65adf1478 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -2,7 +2,7 @@ function(zfp_add_test dims type bits) set(serial_test_name testZfpSerial${dims}d${type}) add_executable(${serial_test_name} ${serial_test_name}.c) target_link_libraries(${serial_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib zfpChecksumsLib zfpCompressionParamsLib zfpTimerLib) if(HAVE_LIBM_MATH) target_link_libraries(${serial_test_name} m) @@ -14,7 +14,7 @@ function(zfp_add_test dims type bits) add_executable(${omp_test_name} ${omp_test_name}.c) target_compile_options(${omp_test_name} PRIVATE ${OpenMP_C_FLAGS}) target_link_libraries(${omp_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib ${OpenMP_C_LIBRARIES}) if(HAVE_LIBM_MATH) target_link_libraries(${omp_test_name} m) @@ -29,7 +29,7 @@ function(zfp_add_test dims type bits) set(cuda_test_name testZfpCuda${dims}d${type}) add_executable(${cuda_test_name} ${cuda_test_name}.c) target_link_libraries(${cuda_test_name} - cmocka zfp hash${bits}Lib genSmoothRandNumsLib stridedOperationsLib + cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib) if(HAVE_LIBM_MATH) target_link_libraries(${cuda_test_name} m) diff --git a/tests/src/endtoend/testZfpCuda1dDouble.c b/tests/src/endtoend/testZfpCuda1dDouble.c index e6b37a3e2..6d2406b44 100644 --- a/tests/src/endtoend/testZfpCuda1dDouble.c +++ b/tests/src/endtoend/testZfpCuda1dDouble.c @@ -1,7 +1,6 @@ #include "src/encode1d.c" #include "constants/1dDouble.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda1dFloat.c b/tests/src/endtoend/testZfpCuda1dFloat.c index 71a15848a..4374c88d9 100644 --- a/tests/src/endtoend/testZfpCuda1dFloat.c +++ b/tests/src/endtoend/testZfpCuda1dFloat.c @@ -1,7 +1,6 @@ #include "src/encode1f.c" #include "constants/1dFloat.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda1dInt32.c b/tests/src/endtoend/testZfpCuda1dInt32.c index 3d2ff9664..fa33e273f 100644 --- a/tests/src/endtoend/testZfpCuda1dInt32.c +++ b/tests/src/endtoend/testZfpCuda1dInt32.c @@ -1,7 +1,6 @@ #include "src/encode1i.c" #include "constants/1dInt32.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda1dInt64.c b/tests/src/endtoend/testZfpCuda1dInt64.c index cfe808c97..dc1072850 100644 --- a/tests/src/endtoend/testZfpCuda1dInt64.c +++ b/tests/src/endtoend/testZfpCuda1dInt64.c @@ -1,7 +1,6 @@ #include "src/encode1l.c" #include "constants/1dInt64.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda2dDouble.c b/tests/src/endtoend/testZfpCuda2dDouble.c index 02c9ce0d8..af9bd8ef6 100644 --- a/tests/src/endtoend/testZfpCuda2dDouble.c +++ b/tests/src/endtoend/testZfpCuda2dDouble.c @@ -1,7 +1,6 @@ #include "src/encode2d.c" #include "constants/2dDouble.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda2dFloat.c b/tests/src/endtoend/testZfpCuda2dFloat.c index 197baa0ff..39c3a7cae 100644 --- a/tests/src/endtoend/testZfpCuda2dFloat.c +++ b/tests/src/endtoend/testZfpCuda2dFloat.c @@ -1,7 +1,6 @@ #include "src/encode2f.c" #include "constants/2dFloat.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda2dInt32.c b/tests/src/endtoend/testZfpCuda2dInt32.c index a91ef77ed..648abcec0 100644 --- a/tests/src/endtoend/testZfpCuda2dInt32.c +++ b/tests/src/endtoend/testZfpCuda2dInt32.c @@ -1,7 +1,6 @@ #include "src/encode2i.c" #include "constants/2dInt32.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda2dInt64.c b/tests/src/endtoend/testZfpCuda2dInt64.c index 60068a00d..64b180f13 100644 --- a/tests/src/endtoend/testZfpCuda2dInt64.c +++ b/tests/src/endtoend/testZfpCuda2dInt64.c @@ -1,7 +1,6 @@ #include "src/encode2l.c" #include "constants/2dInt64.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda3dDouble.c b/tests/src/endtoend/testZfpCuda3dDouble.c index 632d82e7f..78cb01c6d 100644 --- a/tests/src/endtoend/testZfpCuda3dDouble.c +++ b/tests/src/endtoend/testZfpCuda3dDouble.c @@ -1,7 +1,6 @@ #include "src/encode3d.c" #include "constants/3dDouble.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda3dFloat.c b/tests/src/endtoend/testZfpCuda3dFloat.c index b58e745d5..99eab69b4 100644 --- a/tests/src/endtoend/testZfpCuda3dFloat.c +++ b/tests/src/endtoend/testZfpCuda3dFloat.c @@ -1,7 +1,6 @@ #include "src/encode3f.c" #include "constants/3dFloat.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda3dInt32.c b/tests/src/endtoend/testZfpCuda3dInt32.c index 970a75e84..1ef965dea 100644 --- a/tests/src/endtoend/testZfpCuda3dInt32.c +++ b/tests/src/endtoend/testZfpCuda3dInt32.c @@ -1,7 +1,6 @@ #include "src/encode3i.c" #include "constants/3dInt32.h" -#include "utils/hash32.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpCuda3dInt64.c b/tests/src/endtoend/testZfpCuda3dInt64.c index f3b800b76..631e20851 100644 --- a/tests/src/endtoend/testZfpCuda3dInt64.c +++ b/tests/src/endtoend/testZfpCuda3dInt64.c @@ -1,7 +1,6 @@ #include "src/encode3l.c" #include "constants/3dInt64.h" -#include "utils/hash64.h" #include "cudaExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp1dDouble.c b/tests/src/endtoend/testZfpOmp1dDouble.c index 59e721cd8..cd8166926 100644 --- a/tests/src/endtoend/testZfpOmp1dDouble.c +++ b/tests/src/endtoend/testZfpOmp1dDouble.c @@ -1,7 +1,6 @@ #include "src/encode1d.c" #include "constants/1dDouble.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp1dFloat.c b/tests/src/endtoend/testZfpOmp1dFloat.c index 4cdd2936b..1b0e7c201 100644 --- a/tests/src/endtoend/testZfpOmp1dFloat.c +++ b/tests/src/endtoend/testZfpOmp1dFloat.c @@ -1,7 +1,6 @@ #include "src/encode1f.c" #include "constants/1dFloat.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp1dInt32.c b/tests/src/endtoend/testZfpOmp1dInt32.c index 27e37cd38..b8b5d39bd 100644 --- a/tests/src/endtoend/testZfpOmp1dInt32.c +++ b/tests/src/endtoend/testZfpOmp1dInt32.c @@ -1,7 +1,6 @@ #include "src/encode1i.c" #include "constants/1dInt32.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp1dInt64.c b/tests/src/endtoend/testZfpOmp1dInt64.c index 52968ec5c..57582fdb1 100644 --- a/tests/src/endtoend/testZfpOmp1dInt64.c +++ b/tests/src/endtoend/testZfpOmp1dInt64.c @@ -1,7 +1,6 @@ #include "src/encode1l.c" #include "constants/1dInt64.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp2dDouble.c b/tests/src/endtoend/testZfpOmp2dDouble.c index 3201e1a05..09273dc1b 100644 --- a/tests/src/endtoend/testZfpOmp2dDouble.c +++ b/tests/src/endtoend/testZfpOmp2dDouble.c @@ -1,7 +1,6 @@ #include "src/encode2d.c" #include "constants/2dDouble.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp2dFloat.c b/tests/src/endtoend/testZfpOmp2dFloat.c index 1cb7153e6..aa0d7b3a1 100644 --- a/tests/src/endtoend/testZfpOmp2dFloat.c +++ b/tests/src/endtoend/testZfpOmp2dFloat.c @@ -1,7 +1,6 @@ #include "src/encode2f.c" #include "constants/2dFloat.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp2dInt32.c b/tests/src/endtoend/testZfpOmp2dInt32.c index 76c970251..f91f3f2e4 100644 --- a/tests/src/endtoend/testZfpOmp2dInt32.c +++ b/tests/src/endtoend/testZfpOmp2dInt32.c @@ -1,7 +1,6 @@ #include "src/encode2i.c" #include "constants/2dInt32.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp2dInt64.c b/tests/src/endtoend/testZfpOmp2dInt64.c index 3fc381fde..67e5e75bc 100644 --- a/tests/src/endtoend/testZfpOmp2dInt64.c +++ b/tests/src/endtoend/testZfpOmp2dInt64.c @@ -1,7 +1,6 @@ #include "src/encode2l.c" #include "constants/2dInt64.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp3dDouble.c b/tests/src/endtoend/testZfpOmp3dDouble.c index 67299401b..fa817e733 100644 --- a/tests/src/endtoend/testZfpOmp3dDouble.c +++ b/tests/src/endtoend/testZfpOmp3dDouble.c @@ -1,7 +1,6 @@ #include "src/encode3d.c" #include "constants/3dDouble.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp3dFloat.c b/tests/src/endtoend/testZfpOmp3dFloat.c index ec34e6869..f4dfba206 100644 --- a/tests/src/endtoend/testZfpOmp3dFloat.c +++ b/tests/src/endtoend/testZfpOmp3dFloat.c @@ -1,7 +1,6 @@ #include "src/encode3f.c" #include "constants/3dFloat.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp3dInt32.c b/tests/src/endtoend/testZfpOmp3dInt32.c index ca6e8d636..7bc377551 100644 --- a/tests/src/endtoend/testZfpOmp3dInt32.c +++ b/tests/src/endtoend/testZfpOmp3dInt32.c @@ -1,7 +1,6 @@ #include "src/encode3i.c" #include "constants/3dInt32.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp3dInt64.c b/tests/src/endtoend/testZfpOmp3dInt64.c index d698bf470..cfa7fe881 100644 --- a/tests/src/endtoend/testZfpOmp3dInt64.c +++ b/tests/src/endtoend/testZfpOmp3dInt64.c @@ -1,7 +1,6 @@ #include "src/encode3l.c" #include "constants/3dInt64.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp4dDouble.c b/tests/src/endtoend/testZfpOmp4dDouble.c index 9be273221..a46fc245a 100644 --- a/tests/src/endtoend/testZfpOmp4dDouble.c +++ b/tests/src/endtoend/testZfpOmp4dDouble.c @@ -1,7 +1,6 @@ #include "src/encode4d.c" #include "constants/4dDouble.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp4dFloat.c b/tests/src/endtoend/testZfpOmp4dFloat.c index bf4b3afa5..75648e20b 100644 --- a/tests/src/endtoend/testZfpOmp4dFloat.c +++ b/tests/src/endtoend/testZfpOmp4dFloat.c @@ -1,7 +1,6 @@ #include "src/encode4f.c" #include "constants/4dFloat.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp4dInt32.c b/tests/src/endtoend/testZfpOmp4dInt32.c index 5d0f18308..9b6b59846 100644 --- a/tests/src/endtoend/testZfpOmp4dInt32.c +++ b/tests/src/endtoend/testZfpOmp4dInt32.c @@ -1,7 +1,6 @@ #include "src/encode4i.c" #include "constants/4dInt32.h" -#include "utils/hash32.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpOmp4dInt64.c b/tests/src/endtoend/testZfpOmp4dInt64.c index 0b1439836..7ae5c3cb9 100644 --- a/tests/src/endtoend/testZfpOmp4dInt64.c +++ b/tests/src/endtoend/testZfpOmp4dInt64.c @@ -1,7 +1,6 @@ #include "src/encode4l.c" #include "constants/4dInt64.h" -#include "utils/hash64.h" #include "ompExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial1dDouble.c b/tests/src/endtoend/testZfpSerial1dDouble.c index c634907f0..661824b5a 100644 --- a/tests/src/endtoend/testZfpSerial1dDouble.c +++ b/tests/src/endtoend/testZfpSerial1dDouble.c @@ -1,7 +1,6 @@ #include "src/encode1d.c" #include "constants/1dDouble.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial1dFloat.c b/tests/src/endtoend/testZfpSerial1dFloat.c index 674510200..d25e04324 100644 --- a/tests/src/endtoend/testZfpSerial1dFloat.c +++ b/tests/src/endtoend/testZfpSerial1dFloat.c @@ -1,7 +1,6 @@ #include "src/encode1f.c" #include "constants/1dFloat.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial1dInt32.c b/tests/src/endtoend/testZfpSerial1dInt32.c index 192144fb0..6ee53ce82 100644 --- a/tests/src/endtoend/testZfpSerial1dInt32.c +++ b/tests/src/endtoend/testZfpSerial1dInt32.c @@ -1,7 +1,6 @@ #include "src/encode1i.c" #include "constants/1dInt32.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial1dInt64.c b/tests/src/endtoend/testZfpSerial1dInt64.c index e994f4fbd..4b774cfe8 100644 --- a/tests/src/endtoend/testZfpSerial1dInt64.c +++ b/tests/src/endtoend/testZfpSerial1dInt64.c @@ -1,7 +1,6 @@ #include "src/encode1l.c" #include "constants/1dInt64.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial2dDouble.c b/tests/src/endtoend/testZfpSerial2dDouble.c index fbd37486a..2fb6236cb 100644 --- a/tests/src/endtoend/testZfpSerial2dDouble.c +++ b/tests/src/endtoend/testZfpSerial2dDouble.c @@ -1,7 +1,6 @@ #include "src/encode2d.c" #include "constants/2dDouble.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial2dFloat.c b/tests/src/endtoend/testZfpSerial2dFloat.c index cec55969d..75f25a952 100644 --- a/tests/src/endtoend/testZfpSerial2dFloat.c +++ b/tests/src/endtoend/testZfpSerial2dFloat.c @@ -1,7 +1,6 @@ #include "src/encode2f.c" #include "constants/2dFloat.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial2dInt32.c b/tests/src/endtoend/testZfpSerial2dInt32.c index 26cd087ca..08e986419 100644 --- a/tests/src/endtoend/testZfpSerial2dInt32.c +++ b/tests/src/endtoend/testZfpSerial2dInt32.c @@ -1,7 +1,6 @@ #include "src/encode2i.c" #include "constants/2dInt32.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial2dInt64.c b/tests/src/endtoend/testZfpSerial2dInt64.c index 178b3a6cf..cc4da1b54 100644 --- a/tests/src/endtoend/testZfpSerial2dInt64.c +++ b/tests/src/endtoend/testZfpSerial2dInt64.c @@ -1,7 +1,6 @@ #include "src/encode2l.c" #include "constants/2dInt64.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial3dDouble.c b/tests/src/endtoend/testZfpSerial3dDouble.c index 6956d9741..6ec69c232 100644 --- a/tests/src/endtoend/testZfpSerial3dDouble.c +++ b/tests/src/endtoend/testZfpSerial3dDouble.c @@ -1,7 +1,6 @@ #include "src/encode3d.c" #include "constants/3dDouble.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial3dFloat.c b/tests/src/endtoend/testZfpSerial3dFloat.c index 463e901e4..17ba83d24 100644 --- a/tests/src/endtoend/testZfpSerial3dFloat.c +++ b/tests/src/endtoend/testZfpSerial3dFloat.c @@ -1,7 +1,6 @@ #include "src/encode3f.c" #include "constants/3dFloat.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial3dInt32.c b/tests/src/endtoend/testZfpSerial3dInt32.c index b6b124f7e..bc7e6cf57 100644 --- a/tests/src/endtoend/testZfpSerial3dInt32.c +++ b/tests/src/endtoend/testZfpSerial3dInt32.c @@ -1,7 +1,6 @@ #include "src/encode3i.c" #include "constants/3dInt32.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial3dInt64.c b/tests/src/endtoend/testZfpSerial3dInt64.c index d9d502a5c..c9a6b80a1 100644 --- a/tests/src/endtoend/testZfpSerial3dInt64.c +++ b/tests/src/endtoend/testZfpSerial3dInt64.c @@ -1,7 +1,6 @@ #include "src/encode3l.c" #include "constants/3dInt64.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial4dDouble.c b/tests/src/endtoend/testZfpSerial4dDouble.c index 437f98ef6..584dbaadf 100644 --- a/tests/src/endtoend/testZfpSerial4dDouble.c +++ b/tests/src/endtoend/testZfpSerial4dDouble.c @@ -1,7 +1,6 @@ #include "src/encode4d.c" #include "constants/4dDouble.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial4dFloat.c b/tests/src/endtoend/testZfpSerial4dFloat.c index 8c7fa143b..f7cdd263c 100644 --- a/tests/src/endtoend/testZfpSerial4dFloat.c +++ b/tests/src/endtoend/testZfpSerial4dFloat.c @@ -1,7 +1,6 @@ #include "src/encode4f.c" #include "constants/4dFloat.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial4dInt32.c b/tests/src/endtoend/testZfpSerial4dInt32.c index 5c8ea0c18..5ae1b3d39 100644 --- a/tests/src/endtoend/testZfpSerial4dInt32.c +++ b/tests/src/endtoend/testZfpSerial4dInt32.c @@ -1,7 +1,6 @@ #include "src/encode4i.c" #include "constants/4dInt32.h" -#include "utils/hash32.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/testZfpSerial4dInt64.c b/tests/src/endtoend/testZfpSerial4dInt64.c index e1a7cacce..9c573ab1a 100644 --- a/tests/src/endtoend/testZfpSerial4dInt64.c +++ b/tests/src/endtoend/testZfpSerial4dInt64.c @@ -1,7 +1,6 @@ #include "src/encode4l.c" #include "constants/4dInt64.h" -#include "utils/hash64.h" #include "serialExecBase.c" int main() diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 90f90cfc2..04cfd9c73 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -13,6 +13,7 @@ #include "utils/testMacros.h" #include "utils/zfpChecksums.h" #include "utils/zfpCompressionParams.h" +#include "utils/zfpHash.h" #include "utils/zfpTimer.h" #ifdef FL_PT_DATA @@ -339,7 +340,7 @@ static void when_seededRandomSmoothDataGenerated_expect_ChecksumMatches(void **state) { struct setupVars *bundle = *state; - UInt checksum = hashArray((const UInt*)bundle->randomGenArr, bundle->totalRandomGenArrLen, 1); + UInt checksum = _catFunc2(hashArray, SCALAR_BITS)((const UInt*)bundle->randomGenArr, bundle->totalRandomGenArrLen, 1); uint64 expectedChecksum = getChecksumOriginalDataArray(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } @@ -521,19 +522,19 @@ assertZfpCompressDecompressChecksumMatches(void **state) switch(bundle->stride) { case REVERSED: // arr already points to last element (so strided traverse is legal) - checksum = hashStridedArray(arr, bundle->randomGenArrSideLen, strides); + checksum = _catFunc2(hashStridedArray, SCALAR_BITS)(arr, bundle->randomGenArrSideLen, strides); break; case INTERLEAVED: - checksum = hashArray(arr, bundle->totalRandomGenArrLen, 2); + checksum = _catFunc2(hashArray, SCALAR_BITS)(arr, bundle->totalRandomGenArrLen, 2); break; case PERMUTED: - checksum = hashStridedArray(arr, bundle->randomGenArrSideLen, strides); + checksum = _catFunc2(hashStridedArray, SCALAR_BITS)(arr, bundle->randomGenArrSideLen, strides); break; case AS_IS: - checksum = hashArray(arr, bundle->totalRandomGenArrLen, 1); + checksum = _catFunc2(hashArray, SCALAR_BITS)(arr, bundle->totalRandomGenArrLen, 1); break; } diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index f4b588aa7..1038fd7ff 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -12,11 +12,8 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") PUBLIC $<$:-Wno-pointer-sign>) endif() -add_library(hash32Lib hash32.c hash32.h) -target_link_libraries(hash32Lib hashBaseLib) - -add_library(hash64Lib hash64.c hash64.h) -target_link_libraries(hash64Lib hashBaseLib) +add_library(zfpHashLib zfpHash.c zfpHash.h) +target_link_libraries(zfpHashLib hashBaseLib) # fixed point add_library(fixedpoint96Lib fixedpoint96.c fixedpoint96.h) diff --git a/tests/utils/hash32.c b/tests/utils/hash32.c deleted file mode 100644 index c448f1480..000000000 --- a/tests/utils/hash32.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "hash32.h" - -// all functions are used to hash 32-bit valued arrays (int32, float) - -uint32 -hashArray(const uint32* arr, size_t nx, int sx) -{ - uint32 h = 0; - - for (; nx--; arr += sx) { - hashValue(*arr, &h); - } - - return hashFinish(h); -} - -// unused n[] entries are 0 -uint32 -hashStridedArray(const uint32* arr, size_t n[4], int s[4]) -{ - uint32 h = 0; - - size_t i, j, k, l; - for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { - for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { - for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { - for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { - hashValue(*arr, &h); - } - } - } - } - - return hashFinish(h); -} diff --git a/tests/utils/hash32.h b/tests/utils/hash32.h deleted file mode 100644 index 0dcd076da..000000000 --- a/tests/utils/hash32.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef HASH_32_H -#define HASH_32_H - -#include "include/zfp/types.h" -#include "hashBase.h" - -// all functions are used to hash 32-bit valued arrays (int32, float) - -uint32 -hashArray(const uint32* arr, size_t nx, int sx); - -uint32 -hashStridedArray(const uint32* arr, size_t n[4], int s[4]); - -#endif diff --git a/tests/utils/hash64.c b/tests/utils/hash64.c deleted file mode 100644 index 62beb66cc..000000000 --- a/tests/utils/hash64.c +++ /dev/null @@ -1,42 +0,0 @@ -#include "hash64.h" - -// all functions are used to hash 64-bit valued arrays (int64, double) - -uint64 -hashArray(const uint64* arr, size_t nx, int sx) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - for (; nx--; arr += sx) { - hashValue64(*arr, &h1, &h2); - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} - -// unused n[] entries are 0 -uint64 -hashStridedArray(const uint64* arr, size_t n[4], int s[4]) -{ - uint32 h1 = 0; - uint32 h2 = 0; - - size_t i, j, k, l; - for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { - for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { - for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { - for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { - hashValue64(*arr, &h1, &h2); - } - } - } - } - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} diff --git a/tests/utils/hash64.h b/tests/utils/hash64.h deleted file mode 100644 index 5184c7986..000000000 --- a/tests/utils/hash64.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef HASH_64_H -#define HASH_64_H - -#include "include/zfp/types.h" -#include "hashBase.h" - -// all functions are used to hash 64-bit valued arrays (int64, double) - -uint64 -hashArray(const uint64* arr, size_t nx, int sx); - -uint64 -hashStridedArray(const uint64* arr, size_t n[4], int s[4]); - -#endif diff --git a/tests/utils/testMacros.h b/tests/utils/testMacros.h index fa3cd7c07..96bb9e4c6 100644 --- a/tests/utils/testMacros.h +++ b/tests/utils/testMacros.h @@ -1,3 +1,6 @@ // generate test function names containing macros +#define _catFuncStr2(x, y) x ## y +#define _catFunc2(x, y) _catFuncStr2(x, y) + #define _catFuncStr3(x, y, z) x ## y ## z #define _catFunc3(x, y, z) _catFuncStr3(x, y, z) diff --git a/tests/utils/zfpHash.c b/tests/utils/zfpHash.c new file mode 100644 index 000000000..d519a683f --- /dev/null +++ b/tests/utils/zfpHash.c @@ -0,0 +1,76 @@ +#include "zfpHash.h" + +// hash 32-bit valued arrays (int32, float) + +uint32 +hashArray32(const uint32* arr, size_t nx, int sx) +{ + uint32 h = 0; + + for (; nx--; arr += sx) { + hashValue(*arr, &h); + } + + return hashFinish(h); +} + +// unused n[] entries are 0 +uint32 +hashStridedArray32(const uint32* arr, size_t n[4], int s[4]) +{ + uint32 h = 0; + + size_t i, j, k, l; + for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { + for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { + for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { + for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { + hashValue(*arr, &h); + } + } + } + } + + return hashFinish(h); +} + +// hash 64-bit valued arrays (int64, double) + +uint64 +hashArray64(const uint64* arr, size_t nx, int sx) +{ + uint32 h1 = 0; + uint32 h2 = 0; + + for (; nx--; arr += sx) { + hashValue64(*arr, &h1, &h2); + } + + uint64 result1 = (uint64)hashFinish(h1); + uint64 result2 = (uint64)hashFinish(h2); + + return result1 + (result2 << 32); +} + +// unused n[] entries are 0 +uint64 +hashStridedArray64(const uint64* arr, size_t n[4], int s[4]) +{ + uint32 h1 = 0; + uint32 h2 = 0; + + size_t i, j, k, l; + for (l = 0; l < (n[3] ? n[3] : 1); arr += (s[3] - n[2]*s[2]), l++) { + for (k = 0; k < (n[2] ? n[2] : 1); arr += (s[2] - n[1]*s[1]), k++) { + for (j = 0; j < (n[1] ? n[1] : 1); arr += (s[1] - n[0]*s[0]), j++) { + for (i = 0; i < (n[0] ? n[0] : 1); arr += s[0], i++) { + hashValue64(*arr, &h1, &h2); + } + } + } + } + uint64 result1 = (uint64)hashFinish(h1); + uint64 result2 = (uint64)hashFinish(h2); + + return result1 + (result2 << 32); +} diff --git a/tests/utils/zfpHash.h b/tests/utils/zfpHash.h new file mode 100644 index 000000000..cd3048d9a --- /dev/null +++ b/tests/utils/zfpHash.h @@ -0,0 +1,23 @@ +#ifndef ZFP_HASH_H +#define ZFP_HASH_H + +#include "include/zfp/types.h" +#include "hashBase.h" + +// hash 32-bit valued arrays (int32, float) + +uint32 +hashArray32(const uint32* arr, size_t nx, int sx); + +uint32 +hashStridedArray32(const uint32* arr, size_t n[4], int s[4]); + +// hash 64-bit valued arrays (int64, double) + +uint64 +hashArray64(const uint64* arr, size_t nx, int sx); + +uint64 +hashStridedArray64(const uint64* arr, size_t n[4], int s[4]); + +#endif From 676981d554fbb07c0dc5bf60d710ce2b21ac780d Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 22 Feb 2019 10:32:09 -0800 Subject: [PATCH 030/194] provide casts on stridedOperationsLib void pointer arithmetic to suppress MSVC compiler errors --- tests/utils/stridedOperations.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/utils/stridedOperations.c b/tests/utils/stridedOperations.c index de76709cb..a67f470c7 100644 --- a/tests/utils/stridedOperations.c +++ b/tests/utils/stridedOperations.c @@ -8,14 +8,14 @@ reverseArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zfpTy const size_t elementSizeBytes = zfp_type_size(zfpType); // move ptr to last element - inputArr += elementSizeBytes * (inputArrLen - 1); + inputArr = (char *)inputArr + elementSizeBytes * (inputArrLen - 1); size_t i; for (i = 0; i < inputArrLen; i++) { memcpy(outputArr, inputArr, elementSizeBytes); - outputArr += elementSizeBytes; - inputArr -= elementSizeBytes; + outputArr = (char *)outputArr + elementSizeBytes; + inputArr = (char *)inputArr - elementSizeBytes; } } @@ -28,10 +28,10 @@ interleaveArray(void* inputArr, void* outputArr, size_t inputArrLen, zfp_type zf size_t i; for (i = 0; i < inputArrLen; i++) { memcpy(outputArr, inputArr, elementSizeBytes); - memcpy(outputArr + elementSizeBytes, inputArr, elementSizeBytes); + memcpy((char *)outputArr + elementSizeBytes, inputArr, elementSizeBytes); - inputArr += elementSizeBytes; - outputArr += 2 * elementSizeBytes; + inputArr = (char *)inputArr + elementSizeBytes; + outputArr = (char *)outputArr + 2 * elementSizeBytes; } } @@ -51,7 +51,7 @@ permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zf for (i = 0; i < sideLen; i++) { size_t index = l*sideLen*sideLen*sideLen + k*sideLen*sideLen + j*sideLen + i; size_t transposedIndex = i*sideLen*sideLen*sideLen + j*sideLen*sideLen + k*sideLen + l; - memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + memcpy((char *)outputArr + elementSizeBytes * index, (char *)inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); } } } @@ -65,7 +65,7 @@ permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zf for (i = 0; i < sideLen; i++) { size_t index = k*sideLen*sideLen + j*sideLen + i; size_t transposedIndex = i*sideLen*sideLen + j*sideLen + k; - memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + memcpy((char *)outputArr + elementSizeBytes * index, (char *)inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); } } } @@ -77,7 +77,7 @@ permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, zf for (i = 0; i < sideLen; i++) { size_t index = j*sideLen + i; size_t transposedIndex = i*sideLen + j; - memcpy(outputArr + elementSizeBytes * index, inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); + memcpy((char *)outputArr + elementSizeBytes * index, (char *)inputArr + elementSizeBytes * transposedIndex, elementSizeBytes); } } break; From 66d9116655edfe117bb92b97eaf6f5aa7962eda1 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 22 Feb 2019 16:50:33 -0800 Subject: [PATCH 031/194] simplify tests/ hash lib --- tests/utils/CMakeLists.txt | 7 ++---- tests/utils/hashBase.c | 51 -------------------------------------- tests/utils/hashBase.h | 19 -------------- tests/utils/zfpHash.c | 50 +++++++++++++++++++++++++++++++++++++ tests/utils/zfpHash.h | 5 +++- 5 files changed, 56 insertions(+), 76 deletions(-) delete mode 100644 tests/utils/hashBase.c delete mode 100644 tests/utils/hashBase.h diff --git a/tests/utils/CMakeLists.txt b/tests/utils/CMakeLists.txt index 1038fd7ff..02c44003e 100644 --- a/tests/utils/CMakeLists.txt +++ b/tests/utils/CMakeLists.txt @@ -6,15 +6,12 @@ add_library(rand32Lib rand32.c rand32.h) add_library(rand64Lib rand64.c rand64.h) # hashing -add_library(hashBaseLib hashBase.c hashBase.h) +add_library(zfpHashLib zfpHash.c zfpHash.h) if(CMAKE_C_COMPILER_ID STREQUAL "GNU") - target_compile_options(hashBaseLib + target_compile_options(zfpHashLib PUBLIC $<$:-Wno-pointer-sign>) endif() -add_library(zfpHashLib zfpHash.c zfpHash.h) -target_link_libraries(zfpHashLib hashBaseLib) - # fixed point add_library(fixedpoint96Lib fixedpoint96.c fixedpoint96.h) diff --git a/tests/utils/hashBase.c b/tests/utils/hashBase.c deleted file mode 100644 index 323458478..000000000 --- a/tests/utils/hashBase.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "hashBase.h" - -// Jenkins one-at-a-time hash; see http://www.burtleburtle.net/bob/hash/doobs.html - -#define MASK_32 (0xffffffff) - -void -hashValue(uint32 val, uint32* h) -{ - *h += val; - *h += *h << 10; - *h ^= *h >> 6; -} - -uint32 -hashFinish(uint32 h) -{ - h += h << 3; - h ^= h >> 11; - h += h << 15; - - return h; -} - -void -hashValue64(uint64 val, uint32* h1, uint32* h2) -{ - uint32 val1 = (uint32)(val & MASK_32); - hashValue(val1, h1); - - uint32 val2 = (uint32)((val >> 32) & MASK_32); - hashValue(val2, h2); -} - -uint64 -hashBitstream(uint64* ptrStart, size_t bufsizeBytes) -{ - size_t nx = bufsizeBytes / sizeof(uint64); - - uint32 h1 = 0; - uint32 h2 = 0; - - for (; nx--; ptrStart++) { - hashValue64(*ptrStart, &h1, &h2); - } - - uint64 result1 = (uint64)hashFinish(h1); - uint64 result2 = (uint64)hashFinish(h2); - - return result1 + (result2 << 32); -} diff --git a/tests/utils/hashBase.h b/tests/utils/hashBase.h deleted file mode 100644 index c00503749..000000000 --- a/tests/utils/hashBase.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef HASH_BASE_H -#define HASH_BASE_H - -#include -#include "include/zfp/types.h" - -void -hashValue(uint32 val, uint32* h); - -uint32 -hashFinish(uint32 h); - -void -hashValue64(uint64 val, uint32* h1, uint32* h2); - -uint64 -hashBitstream(uint64* ptrStart, size_t bufsizeBytes); - -#endif diff --git a/tests/utils/zfpHash.c b/tests/utils/zfpHash.c index d519a683f..718b2a937 100644 --- a/tests/utils/zfpHash.c +++ b/tests/utils/zfpHash.c @@ -1,5 +1,55 @@ #include "zfpHash.h" +#define MASK_32 (0xffffffff) + +// Jenkins one-at-a-time hash; see http://www.burtleburtle.net/bob/hash/doobs.html + +static void +hashValue(uint32 val, uint32* h) +{ + *h += val; + *h += *h << 10; + *h ^= *h >> 6; +} + +static uint32 +hashFinish(uint32 h) +{ + h += h << 3; + h ^= h >> 11; + h += h << 15; + + return h; +} + +static void +hashValue64(uint64 val, uint32* h1, uint32* h2) +{ + uint32 val1 = (uint32)(val & MASK_32); + hashValue(val1, h1); + + uint32 val2 = (uint32)((val >> 32) & MASK_32); + hashValue(val2, h2); +} + +uint64 +hashBitstream(uint64* ptrStart, size_t bufsizeBytes) +{ + size_t nx = bufsizeBytes / sizeof(uint64); + + uint32 h1 = 0; + uint32 h2 = 0; + + for (; nx--; ptrStart++) { + hashValue64(*ptrStart, &h1, &h2); + } + + uint64 result1 = (uint64)hashFinish(h1); + uint64 result2 = (uint64)hashFinish(h2); + + return result1 + (result2 << 32); +} + // hash 32-bit valued arrays (int32, float) uint32 diff --git a/tests/utils/zfpHash.h b/tests/utils/zfpHash.h index cd3048d9a..d0ae59b8b 100644 --- a/tests/utils/zfpHash.h +++ b/tests/utils/zfpHash.h @@ -1,8 +1,11 @@ #ifndef ZFP_HASH_H #define ZFP_HASH_H +#include #include "include/zfp/types.h" -#include "hashBase.h" + +uint64 +hashBitstream(uint64* ptrStart, size_t bufsizeBytes); // hash 32-bit valued arrays (int32, float) From b3fed9bb2d9890db61a5f7816d4151ffa8154ea6 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 25 Feb 2019 01:33:57 -0800 Subject: [PATCH 032/194] extract common 1-dimensional endtoend/ tests into separate files. new test macros substitute dims/scalar in ctest output --- tests/src/endtoend/testZfpCuda1dDouble.c | 26 +--- tests/src/endtoend/testZfpCuda1dFloat.c | 26 +--- tests/src/endtoend/testZfpCuda1dInt32.c | 23 +--- tests/src/endtoend/testZfpCuda1dInt64.c | 23 +--- tests/src/endtoend/testZfpOmp1dDouble.c | 134 +------------------- tests/src/endtoend/testZfpOmp1dFloat.c | 134 +------------------- tests/src/endtoend/testZfpOmp1dInt32.c | 97 +-------------- tests/src/endtoend/testZfpOmp1dInt64.c | 97 +-------------- tests/src/endtoend/testZfpSerial1dDouble.c | 35 +----- tests/src/endtoend/testZfpSerial1dFloat.c | 35 +----- tests/src/endtoend/testZfpSerial1dInt32.c | 25 +--- tests/src/endtoend/testZfpSerial1dInt64.c | 25 +--- tests/src/endtoend/testcases/cuda.c | 29 +++++ tests/src/endtoend/testcases/omp.c | 137 +++++++++++++++++++++ tests/src/endtoend/testcases/serial.c | 42 +++++++ tests/utils/testMacros.h | 6 + 16 files changed, 226 insertions(+), 668 deletions(-) create mode 100644 tests/src/endtoend/testcases/cuda.c create mode 100644 tests/src/endtoend/testcases/omp.c create mode 100644 tests/src/endtoend/testcases/serial.c diff --git a/tests/src/endtoend/testZfpCuda1dDouble.c b/tests/src/endtoend/testZfpCuda1dDouble.c index 6d2406b44..d6d77293b 100644 --- a/tests/src/endtoend/testZfpCuda1dDouble.c +++ b/tests/src/endtoend/testZfpCuda1dDouble.c @@ -6,31 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda1dFloat.c b/tests/src/endtoend/testZfpCuda1dFloat.c index 4374c88d9..1bd9e2517 100644 --- a/tests/src/endtoend/testZfpCuda1dFloat.c +++ b/tests/src/endtoend/testZfpCuda1dFloat.c @@ -6,31 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda1dInt32.c b/tests/src/endtoend/testZfpCuda1dInt32.c index fa33e273f..bbc59716d 100644 --- a/tests/src/endtoend/testZfpCuda1dInt32.c +++ b/tests/src/endtoend/testZfpCuda1dInt32.c @@ -6,28 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt32Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda1dInt64.c b/tests/src/endtoend/testZfpCuda1dInt64.c index dc1072850..ed0a3f5c3 100644 --- a/tests/src/endtoend/testZfpCuda1dInt64.c +++ b/tests/src/endtoend/testZfpCuda1dInt64.c @@ -6,28 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_1dInt64Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp1dDouble.c b/tests/src/endtoend/testZfpOmp1dDouble.c index cd8166926..266d355b2 100644 --- a/tests/src/endtoend/testZfpOmp1dDouble.c +++ b/tests/src/endtoend/testZfpOmp1dDouble.c @@ -6,139 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp1dFloat.c b/tests/src/endtoend/testZfpOmp1dFloat.c index 1b0e7c201..5cc1dcf95 100644 --- a/tests/src/endtoend/testZfpOmp1dFloat.c +++ b/tests/src/endtoend/testZfpOmp1dFloat.c @@ -6,139 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp1dInt32.c b/tests/src/endtoend/testZfpOmp1dInt32.c index b8b5d39bd..45e1181f2 100644 --- a/tests/src/endtoend/testZfpOmp1dInt32.c +++ b/tests/src/endtoend/testZfpOmp1dInt32.c @@ -6,102 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp1dInt64.c b/tests/src/endtoend/testZfpOmp1dInt64.c index 57582fdb1..c6d5bf5fa 100644 --- a/tests/src/endtoend/testZfpOmp1dInt64.c +++ b/tests/src/endtoend/testZfpOmp1dInt64.c @@ -6,102 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial1dDouble.c b/tests/src/endtoend/testZfpSerial1dDouble.c index 661824b5a..35b98aefd 100644 --- a/tests/src/endtoend/testZfpSerial1dDouble.c +++ b/tests/src/endtoend/testZfpSerial1dDouble.c @@ -6,40 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_1dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_1dDoubleZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial1dFloat.c b/tests/src/endtoend/testZfpSerial1dFloat.c index d25e04324..8acf55330 100644 --- a/tests/src/endtoend/testZfpSerial1dFloat.c +++ b/tests/src/endtoend/testZfpSerial1dFloat.c @@ -6,40 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_1dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_1dFloatZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial1dInt32.c b/tests/src/endtoend/testZfpSerial1dInt32.c index 6ee53ce82..c16904e03 100644 --- a/tests/src/endtoend/testZfpSerial1dInt32.c +++ b/tests/src/endtoend/testZfpSerial1dInt32.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_1dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_1dInt32ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial1dInt64.c b/tests/src/endtoend/testZfpSerial1dInt64.c index 4b774cfe8..4e815fb0d 100644 --- a/tests/src/endtoend/testZfpSerial1dInt64.c +++ b/tests/src/endtoend/testZfpSerial1dInt64.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_1dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_1dInt64ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testcases/cuda.c b/tests/src/endtoend/testcases/cuda.c new file mode 100644 index 000000000..6e4474d5a --- /dev/null +++ b/tests/src/endtoend/testcases/cuda.c @@ -0,0 +1,29 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), + +/* strided */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupReversed, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupReversed, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupInterleaved, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupInterleaved, teardown), + +/* fixed-rate */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate0Param, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate1Param, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate2Param, teardown), + +/* non fixed-rate */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedPrec1Param, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedPrec1Param, teardown), + +#ifdef FL_PT_DATA +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedAcc1Param, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedAcc1Param, teardown), +#endif diff --git a/tests/src/endtoend/testcases/omp.c b/tests/src/endtoend/testcases/omp.c new file mode 100644 index 000000000..cbf3fe99d --- /dev/null +++ b/tests/src/endtoend/testcases/omp.c @@ -0,0 +1,137 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), + +/* strided tests */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed0Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed1Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved0Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved1Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved2Thread2Chunk, teardown), + +/* fixed-precision */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2Param2Thread2Chunk, teardown), + +/* fixed-rate */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2Param2Thread2Chunk, teardown), + +#ifdef FL_PT_DATA +/* fixed-accuracy */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1Param2Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param2Thread2Chunk, teardown), +#endif diff --git a/tests/src/endtoend/testcases/serial.c b/tests/src/endtoend/testcases/serial.c new file mode 100644 index 000000000..6a3dbbc0f --- /dev/null +++ b/tests/src/endtoend/testcases/serial.c @@ -0,0 +1,42 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), + +/* strided tests */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupReversed, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupReversed, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupInterleaved, teardown), + +/* fixed-precision */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupFixedPrec0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupFixedPrec1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupFixedPrec2, teardown), + +/* fixed-rate */ +_cmocka_unit_test(_catFunc3(given_, DIM_INT_STR, ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly)), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate), setupFixedRate0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate), setupFixedRate1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate), setupFixedRate2, teardown), + +#ifdef FL_PT_DATA +/* fixed-accuracy */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches), setupFixedAccuracy0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy), setupFixedAccuracy0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches), setupFixedAccuracy1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy), setupFixedAccuracy1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches), setupFixedAccuracy2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy), setupFixedAccuracy2, teardown), +#endif diff --git a/tests/utils/testMacros.h b/tests/utils/testMacros.h index 96bb9e4c6..0971ac4ff 100644 --- a/tests/utils/testMacros.h +++ b/tests/utils/testMacros.h @@ -4,3 +4,9 @@ #define _catFuncStr3(x, y, z) x ## y ## z #define _catFunc3(x, y, z) _catFuncStr3(x, y, z) + +#define _cat_cmocka_unit_test(x) cmocka_unit_test(x) +#define _cmocka_unit_test(x) _cat_cmocka_unit_test(x) + +#define _cat_cmocka_unit_test_setup_teardown(x, y, z) cmocka_unit_test_setup_teardown(x, y, z) +#define _cmocka_unit_test_setup_teardown(x, y, z) _cat_cmocka_unit_test_setup_teardown(x, y, z) From 06bfc65a685ddea6a59982ca5966820997b9f607 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 25 Feb 2019 02:28:25 -0800 Subject: [PATCH 033/194] extract 2/3/4d common endtoend test cases into #included files from tests/src/endtoend/testcases --- tests/src/endtoend/testZfpCuda2dDouble.c | 28 +--- tests/src/endtoend/testZfpCuda2dFloat.c | 28 +--- tests/src/endtoend/testZfpCuda2dInt32.c | 25 +--- tests/src/endtoend/testZfpCuda2dInt64.c | 25 +--- tests/src/endtoend/testZfpCuda3dDouble.c | 28 +--- tests/src/endtoend/testZfpCuda3dFloat.c | 28 +--- tests/src/endtoend/testZfpCuda3dInt32.c | 25 +--- tests/src/endtoend/testZfpCuda3dInt64.c | 25 +--- tests/src/endtoend/testZfpOmp2dDouble.c | 144 +-------------------- tests/src/endtoend/testZfpOmp2dFloat.c | 144 +-------------------- tests/src/endtoend/testZfpOmp2dInt32.c | 107 +-------------- tests/src/endtoend/testZfpOmp2dInt64.c | 107 +-------------- tests/src/endtoend/testZfpOmp3dDouble.c | 144 +-------------------- tests/src/endtoend/testZfpOmp3dFloat.c | 144 +-------------------- tests/src/endtoend/testZfpOmp3dInt32.c | 107 +-------------- tests/src/endtoend/testZfpOmp3dInt64.c | 107 +-------------- tests/src/endtoend/testZfpOmp4dDouble.c | 144 +-------------------- tests/src/endtoend/testZfpOmp4dFloat.c | 144 +-------------------- tests/src/endtoend/testZfpOmp4dInt32.c | 107 +-------------- tests/src/endtoend/testZfpOmp4dInt64.c | 107 +-------------- tests/src/endtoend/testZfpSerial2dDouble.c | 37 +----- tests/src/endtoend/testZfpSerial2dFloat.c | 37 +----- tests/src/endtoend/testZfpSerial2dInt32.c | 27 +--- tests/src/endtoend/testZfpSerial2dInt64.c | 27 +--- tests/src/endtoend/testZfpSerial3dDouble.c | 37 +----- tests/src/endtoend/testZfpSerial3dFloat.c | 37 +----- tests/src/endtoend/testZfpSerial3dInt32.c | 27 +--- tests/src/endtoend/testZfpSerial3dInt64.c | 27 +--- tests/src/endtoend/testZfpSerial4dDouble.c | 37 +----- tests/src/endtoend/testZfpSerial4dFloat.c | 37 +----- tests/src/endtoend/testZfpSerial4dInt32.c | 27 +--- tests/src/endtoend/testZfpSerial4dInt64.c | 27 +--- tests/src/endtoend/testcases/cuda.c | 5 + tests/src/endtoend/testcases/omp.c | 12 ++ tests/src/endtoend/testcases/serial.c | 4 + 35 files changed, 53 insertions(+), 2070 deletions(-) diff --git a/tests/src/endtoend/testZfpCuda2dDouble.c b/tests/src/endtoend/testZfpCuda2dDouble.c index af9bd8ef6..75c36bb4c 100644 --- a/tests/src/endtoend/testZfpCuda2dDouble.c +++ b/tests/src/endtoend/testZfpCuda2dDouble.c @@ -6,33 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoublePermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoublePermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda2dFloat.c b/tests/src/endtoend/testZfpCuda2dFloat.c index 39c3a7cae..a12533ae9 100644 --- a/tests/src/endtoend/testZfpCuda2dFloat.c +++ b/tests/src/endtoend/testZfpCuda2dFloat.c @@ -6,33 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatPermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatPermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda2dInt32.c b/tests/src/endtoend/testZfpCuda2dInt32.c index 648abcec0..183c42ad0 100644 --- a/tests/src/endtoend/testZfpCuda2dInt32.c +++ b/tests/src/endtoend/testZfpCuda2dInt32.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32PermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32PermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt32Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda2dInt64.c b/tests/src/endtoend/testZfpCuda2dInt64.c index 64b180f13..daf7f0f50 100644 --- a/tests/src/endtoend/testZfpCuda2dInt64.c +++ b/tests/src/endtoend/testZfpCuda2dInt64.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64PermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64PermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_2dInt64Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda3dDouble.c b/tests/src/endtoend/testZfpCuda3dDouble.c index 78cb01c6d..630feba75 100644 --- a/tests/src/endtoend/testZfpCuda3dDouble.c +++ b/tests/src/endtoend/testZfpCuda3dDouble.c @@ -6,33 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoublePermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoublePermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dDoubleArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda3dFloat.c b/tests/src/endtoend/testZfpCuda3dFloat.c index 99eab69b4..6c7276856 100644 --- a/tests/src/endtoend/testZfpCuda3dFloat.c +++ b/tests/src/endtoend/testZfpCuda3dFloat.c @@ -6,33 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatPermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatPermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatInterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatInterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dFloatArray_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedAcc1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda3dInt32.c b/tests/src/endtoend/testZfpCuda3dInt32.c index 1ef965dea..dd01c9002 100644 --- a/tests/src/endtoend/testZfpCuda3dInt32.c +++ b/tests/src/endtoend/testZfpCuda3dInt32.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32PermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32PermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt32Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpCuda3dInt64.c b/tests/src/endtoend/testZfpCuda3dInt64.c index 631e20851..ee8fbdc03 100644 --- a/tests/src/endtoend/testZfpCuda3dInt64.c +++ b/tests/src/endtoend/testZfpCuda3dInt64.c @@ -6,30 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64ReversedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64ReversedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64PermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64PermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupInterleaved, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1Param, teardown), - - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2Param, teardown), - - /* non fixed-rate */ - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), - cmocka_unit_test_setup_teardown(given_Cuda_3dInt64Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero, setupFixedPrec1Param, teardown), + #include "testcases/cuda.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp2dDouble.c b/tests/src/endtoend/testZfpOmp2dDouble.c index 09273dc1b..9c57161a2 100644 --- a/tests/src/endtoend/testZfpOmp2dDouble.c +++ b/tests/src/endtoend/testZfpOmp2dDouble.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp2dFloat.c b/tests/src/endtoend/testZfpOmp2dFloat.c index aa0d7b3a1..2f3fa175e 100644 --- a/tests/src/endtoend/testZfpOmp2dFloat.c +++ b/tests/src/endtoend/testZfpOmp2dFloat.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp2dInt32.c b/tests/src/endtoend/testZfpOmp2dInt32.c index f91f3f2e4..e93582356 100644 --- a/tests/src/endtoend/testZfpOmp2dInt32.c +++ b/tests/src/endtoend/testZfpOmp2dInt32.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp2dInt64.c b/tests/src/endtoend/testZfpOmp2dInt64.c index 67e5e75bc..05ee2e688 100644 --- a/tests/src/endtoend/testZfpOmp2dInt64.c +++ b/tests/src/endtoend/testZfpOmp2dInt64.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp3dDouble.c b/tests/src/endtoend/testZfpOmp3dDouble.c index fa817e733..c6621ee7b 100644 --- a/tests/src/endtoend/testZfpOmp3dDouble.c +++ b/tests/src/endtoend/testZfpOmp3dDouble.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp3dFloat.c b/tests/src/endtoend/testZfpOmp3dFloat.c index f4dfba206..ff5f9a34c 100644 --- a/tests/src/endtoend/testZfpOmp3dFloat.c +++ b/tests/src/endtoend/testZfpOmp3dFloat.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp3dInt32.c b/tests/src/endtoend/testZfpOmp3dInt32.c index 7bc377551..190a66387 100644 --- a/tests/src/endtoend/testZfpOmp3dInt32.c +++ b/tests/src/endtoend/testZfpOmp3dInt32.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp3dInt64.c b/tests/src/endtoend/testZfpOmp3dInt64.c index cfa7fe881..cb5ca9251 100644 --- a/tests/src/endtoend/testZfpOmp3dInt64.c +++ b/tests/src/endtoend/testZfpOmp3dInt64.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp4dDouble.c b/tests/src/endtoend/testZfpOmp4dDouble.c index a46fc245a..83b69e036 100644 --- a/tests/src/endtoend/testZfpOmp4dDouble.c +++ b/tests/src/endtoend/testZfpOmp4dDouble.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp4dFloat.c b/tests/src/endtoend/testZfpOmp4dFloat.c index 75648e20b..ccff0c4e8 100644 --- a/tests/src/endtoend/testZfpOmp4dFloat.c +++ b/tests/src/endtoend/testZfpOmp4dFloat.c @@ -6,149 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), - - /* fixed-accuracy */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp4dInt32.c b/tests/src/endtoend/testZfpOmp4dInt32.c index 9b6b59846..b4478b812 100644 --- a/tests/src/endtoend/testZfpOmp4dInt32.c +++ b/tests/src/endtoend/testZfpOmp4dInt32.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpOmp4dInt64.c b/tests/src/endtoend/testZfpOmp4dInt64.c index 7ae5c3cb9..1e1765a9e 100644 --- a/tests/src/endtoend/testZfpOmp4dInt64.c +++ b/tests/src/endtoend/testZfpOmp4dInt64.c @@ -6,112 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - /* strided tests */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved0Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved1Thread2Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved2Thread2Chunk, teardown), - - /* fixed-precision */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2Param2Thread2Chunk, teardown), - - /* fixed-rate */ - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1Param2Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param0Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param1Thread2Chunk, teardown), - - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread0Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread1Chunk, teardown), - cmocka_unit_test_setup_teardown(given_OpenMP_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2Param2Thread2Chunk, teardown), + #include "testcases/omp.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial2dDouble.c b/tests/src/endtoend/testZfpSerial2dDouble.c index 2fb6236cb..b293d905f 100644 --- a/tests/src/endtoend/testZfpSerial2dDouble.c +++ b/tests/src/endtoend/testZfpSerial2dDouble.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_2dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_2dDoublePermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_2dDoubleZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial2dFloat.c b/tests/src/endtoend/testZfpSerial2dFloat.c index 75f25a952..3f7709047 100644 --- a/tests/src/endtoend/testZfpSerial2dFloat.c +++ b/tests/src/endtoend/testZfpSerial2dFloat.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_2dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatPermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_2dFloatZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial2dInt32.c b/tests/src/endtoend/testZfpSerial2dInt32.c index 08e986419..61f6a493d 100644 --- a/tests/src/endtoend/testZfpSerial2dInt32.c +++ b/tests/src/endtoend/testZfpSerial2dInt32.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_2dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_2dInt32ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial2dInt64.c b/tests/src/endtoend/testZfpSerial2dInt64.c index cc4da1b54..c07e9b3bf 100644 --- a/tests/src/endtoend/testZfpSerial2dInt64.c +++ b/tests/src/endtoend/testZfpSerial2dInt64.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_2dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_2dInt64ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial3dDouble.c b/tests/src/endtoend/testZfpSerial3dDouble.c index 6ec69c232..e224ae8a4 100644 --- a/tests/src/endtoend/testZfpSerial3dDouble.c +++ b/tests/src/endtoend/testZfpSerial3dDouble.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_3dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_3dDoublePermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_3dDoubleZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial3dFloat.c b/tests/src/endtoend/testZfpSerial3dFloat.c index 17ba83d24..9ae89c67d 100644 --- a/tests/src/endtoend/testZfpSerial3dFloat.c +++ b/tests/src/endtoend/testZfpSerial3dFloat.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_3dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatPermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_3dFloatZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial3dInt32.c b/tests/src/endtoend/testZfpSerial3dInt32.c index bc7e6cf57..9b0e4fc3b 100644 --- a/tests/src/endtoend/testZfpSerial3dInt32.c +++ b/tests/src/endtoend/testZfpSerial3dInt32.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_3dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_3dInt32ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial3dInt64.c b/tests/src/endtoend/testZfpSerial3dInt64.c index c9a6b80a1..5effe0461 100644 --- a/tests/src/endtoend/testZfpSerial3dInt64.c +++ b/tests/src/endtoend/testZfpSerial3dInt64.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_3dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_3dInt64ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial4dDouble.c b/tests/src/endtoend/testZfpSerial4dDouble.c index 584dbaadf..ea515cd4e 100644 --- a/tests/src/endtoend/testZfpSerial4dDouble.c +++ b/tests/src/endtoend/testZfpSerial4dDouble.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_4dDoubleReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dDoublePermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_4dDoublePermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_4dDoubleZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial4dFloat.c b/tests/src/endtoend/testZfpSerial4dFloat.c index f7cdd263c..891b02bbf 100644 --- a/tests/src/endtoend/testZfpSerial4dFloat.c +++ b/tests/src/endtoend/testZfpSerial4dFloat.c @@ -6,42 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_4dFloatReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatInterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatInterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatPermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatPermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_4dFloatZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), - - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy0, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy1, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches, setupFixedAccuracy2, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatArray_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy, setupFixedAccuracy2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial4dInt32.c b/tests/src/endtoend/testZfpSerial4dInt32.c index 5ae1b3d39..bd9067e29 100644 --- a/tests/src/endtoend/testZfpSerial4dInt32.c +++ b/tests/src/endtoend/testZfpSerial4dInt32.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_4dInt32ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_4dInt32ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testZfpSerial4dInt64.c b/tests/src/endtoend/testZfpSerial4dInt64.c index 9c573ab1a..a8a496461 100644 --- a/tests/src/endtoend/testZfpSerial4dInt64.c +++ b/tests/src/endtoend/testZfpSerial4dInt64.c @@ -6,32 +6,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test(when_seededRandomSmoothDataGenerated_expect_ChecksumMatches), - - cmocka_unit_test_setup_teardown(given_4dInt64ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupReversed, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupInterleaved, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupPermuted, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupPermuted, teardown), - - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches, setupFixedPrec2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches, setupFixedPrec2, teardown), - - cmocka_unit_test(given_4dInt64ZfpStream_when_SetRateWithWriteRandomAccess_expect_RateRoundedUpProperly), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate0, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate1, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches, setupFixedRate2, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Array_when_ZfpCompressFixedRate_expect_CompressedBitrateComparableToChosenRate, setupFixedRate2, teardown), + #include "testcases/serial.c" }; return cmocka_run_group_tests(tests, setupRandomData, teardownRandomData); diff --git a/tests/src/endtoend/testcases/cuda.c b/tests/src/endtoend/testcases/cuda.c index 6e4474d5a..a9b27d948 100644 --- a/tests/src/endtoend/testcases/cuda.c +++ b/tests/src/endtoend/testcases/cuda.c @@ -9,6 +9,11 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, ReversedArr _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupInterleaved, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, InterleavedArray_when_ZfpDecompressFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupInterleaved, teardown), +#if DIMS >= 2 +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupPermuted, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, PermutedArray_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupPermuted, teardown), +#endif + /* fixed-rate */ _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressFixedRate_expect_BitstreamChecksumMatches), setupFixedRate0Param, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressFixedRate_expect_ArrayChecksumMatches), setupFixedRate0Param, teardown), diff --git a/tests/src/endtoend/testcases/omp.c b/tests/src/endtoend/testcases/omp.c index cbf3fe99d..0c9ad8ddb 100644 --- a/tests/src/endtoend/testcases/omp.c +++ b/tests/src/endtoend/testcases/omp.c @@ -23,6 +23,18 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Interleav _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved2Thread1Chunk, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved2Thread2Chunk, teardown), +#if DIMS >= 2 +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted0Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted1Thread2Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted2Thread2Chunk, teardown), +#endif + /* fixed-precision */ _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param0Thread0Chunk, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0Param0Thread1Chunk, teardown), diff --git a/tests/src/endtoend/testcases/serial.c b/tests/src/endtoend/testcases/serial.c index 6a3dbbc0f..4f69ba454 100644 --- a/tests/src/endtoend/testcases/serial.c +++ b/tests/src/endtoend/testcases/serial.c @@ -7,6 +7,10 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, ReversedArray_wh _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupReversed, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, InterleavedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupInterleaved, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, InterleavedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupInterleaved, teardown), +#if DIMS >= 2 +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, PermutedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupPermuted, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, PermutedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches), setupPermuted, teardown), +#endif /* fixed-precision */ _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches), setupFixedPrec0, teardown), From 6d0fcb49c93abd4776e15a2004eaab9b35ee2a2e Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 25 Feb 2019 02:57:01 -0800 Subject: [PATCH 034/194] extract common encode/ testcases into #included file testcases/ --- tests/src/encode/testZfpEncodeBlock1dDouble.c | 4 +--- tests/src/encode/testZfpEncodeBlock1dFloat.c | 4 +--- tests/src/encode/testZfpEncodeBlock1dInt32.c | 4 +--- tests/src/encode/testZfpEncodeBlock1dInt64.c | 4 +--- tests/src/encode/testZfpEncodeBlock2dDouble.c | 4 +--- tests/src/encode/testZfpEncodeBlock2dFloat.c | 4 +--- tests/src/encode/testZfpEncodeBlock2dInt32.c | 4 +--- tests/src/encode/testZfpEncodeBlock2dInt64.c | 4 +--- tests/src/encode/testZfpEncodeBlock3dDouble.c | 4 +--- tests/src/encode/testZfpEncodeBlock3dFloat.c | 4 +--- tests/src/encode/testZfpEncodeBlock3dInt32.c | 4 +--- tests/src/encode/testZfpEncodeBlock3dInt64.c | 4 +--- tests/src/encode/testZfpEncodeBlock4dDouble.c | 4 +--- tests/src/encode/testZfpEncodeBlock4dFloat.c | 4 +--- tests/src/encode/testZfpEncodeBlock4dInt32.c | 4 +--- tests/src/encode/testZfpEncodeBlock4dInt64.c | 4 +--- tests/src/encode/testZfpEncodeBlockStrided1dDouble.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided1dFloat.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided1dInt32.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided1dInt64.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided2dDouble.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided2dFloat.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided2dInt32.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided2dInt64.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided3dDouble.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided3dFloat.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided3dInt32.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided3dInt64.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided4dDouble.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided4dFloat.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided4dInt32.c | 9 +-------- tests/src/encode/testZfpEncodeBlockStrided4dInt64.c | 9 +-------- tests/src/encode/testcases/block.c | 6 ++++++ tests/src/encode/testcases/blockStrided.c | 11 +++++++++++ 34 files changed, 49 insertions(+), 176 deletions(-) create mode 100644 tests/src/encode/testcases/block.c create mode 100644 tests/src/encode/testcases/blockStrided.c diff --git a/tests/src/encode/testZfpEncodeBlock1dDouble.c b/tests/src/encode/testZfpEncodeBlock1dDouble.c index 9a362c3cf..eeb43f25f 100644 --- a/tests/src/encode/testZfpEncodeBlock1dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock1dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock1dFloat.c b/tests/src/encode/testZfpEncodeBlock1dFloat.c index d5cf088fa..6584318b2 100644 --- a/tests/src/encode/testZfpEncodeBlock1dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock1dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock1dInt32.c b/tests/src/encode/testZfpEncodeBlock1dInt32.c index 7732cc59a..8a93ebe25 100644 --- a/tests/src/encode/testZfpEncodeBlock1dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock1dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock1dInt64.c b/tests/src/encode/testZfpEncodeBlock1dInt64.c index 8ef11b1f8..3e8f2d752 100644 --- a/tests/src/encode/testZfpEncodeBlock1dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock1dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock2dDouble.c b/tests/src/encode/testZfpEncodeBlock2dDouble.c index 9388a6a05..2986dfbdd 100644 --- a/tests/src/encode/testZfpEncodeBlock2dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock2dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock2dFloat.c b/tests/src/encode/testZfpEncodeBlock2dFloat.c index b58ca5a2a..84d52ff35 100644 --- a/tests/src/encode/testZfpEncodeBlock2dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock2dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock2dInt32.c b/tests/src/encode/testZfpEncodeBlock2dInt32.c index b835e3112..e8c46a3d9 100644 --- a/tests/src/encode/testZfpEncodeBlock2dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock2dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock2dInt64.c b/tests/src/encode/testZfpEncodeBlock2dInt64.c index c0d978832..54ee9e591 100644 --- a/tests/src/encode/testZfpEncodeBlock2dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock2dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock3dDouble.c b/tests/src/encode/testZfpEncodeBlock3dDouble.c index 9ef75ae77..cd0593a6b 100644 --- a/tests/src/encode/testZfpEncodeBlock3dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock3dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock3dFloat.c b/tests/src/encode/testZfpEncodeBlock3dFloat.c index 80afef92b..dca907364 100644 --- a/tests/src/encode/testZfpEncodeBlock3dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock3dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock3dInt32.c b/tests/src/encode/testZfpEncodeBlock3dInt32.c index add9a3018..0524302d8 100644 --- a/tests/src/encode/testZfpEncodeBlock3dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock3dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock3dInt64.c b/tests/src/encode/testZfpEncodeBlock3dInt64.c index b92a5cff1..a6b381e22 100644 --- a/tests/src/encode/testZfpEncodeBlock3dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock3dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock4dDouble.c b/tests/src/encode/testZfpEncodeBlock4dDouble.c index 402b9e7ea..2306de9a9 100644 --- a/tests/src/encode/testZfpEncodeBlock4dDouble.c +++ b/tests/src/encode/testZfpEncodeBlock4dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock4dFloat.c b/tests/src/encode/testZfpEncodeBlock4dFloat.c index 403c573cc..997cf3073 100644 --- a/tests/src/encode/testZfpEncodeBlock4dFloat.c +++ b/tests/src/encode/testZfpEncodeBlock4dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock4dInt32.c b/tests/src/encode/testZfpEncodeBlock4dInt32.c index 20e125370..4cad35991 100644 --- a/tests/src/encode/testZfpEncodeBlock4dInt32.c +++ b/tests/src/encode/testZfpEncodeBlock4dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlock4dInt64.c b/tests/src/encode/testZfpEncodeBlock4dInt64.c index 7f407c4fb..010023913 100644 --- a/tests/src/encode/testZfpEncodeBlock4dInt64.c +++ b/tests/src/encode/testZfpEncodeBlock4dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodeBlock_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c index 661bb9143..59e52e80a 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c index fdcfff982..9e2cc08ba 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c index 4b4dfaea4..0f8ba3fab 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c index c14adef8e..1b3d7ca50 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided1dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c index d251d450b..7cbc30366 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c index 735f8a01c..4421f6253 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c index 89455bab6..ee898c82c 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c index 691b1bc76..82617f028 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided2dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c index 923d7bb81..98eb0563d 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c index 412ded42c..6bb49a7e2 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c index 42be0b006..54d0741de 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c index 1c84e98b4..7e3bfa3e2 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided3dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c b/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c index 1618ce771..71d578c2d 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c b/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c index 7c9399c0d..a002e0cbb 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c b/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c index 413fbdf14..c48410bdb 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c b/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c index 47d855c13..e9f8c622f 100644 --- a/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c +++ b/tests/src/encode/testZfpEncodeBlockStrided4dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/encode/testcases/block.c b/tests/src/encode/testcases/block.c new file mode 100644 index 000000000..337c3f547 --- /dev/null +++ b/tests/src/encode/testcases/block.c @@ -0,0 +1,6 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_BitstreamChecksumMatches), setup, teardown), diff --git a/tests/src/encode/testcases/blockStrided.c b/tests/src/encode/testcases/blockStrided.c new file mode 100644 index 000000000..5bdf739c1 --- /dev/null +++ b/tests/src/encode/testcases/blockStrided.c @@ -0,0 +1,11 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlockStrided_expect_OnlyStridedEntriesUsed), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlockStrided_expect_BitstreamChecksumMatches), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodePartialBlockStrided_expect_ReturnValReflectsNumBitsWrittenToBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodePartialBlockStrided_expect_OnlyStridedEntriesUsed), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodePartialBlockStrided_expect_OnlyEntriesWithinPartialBlockBoundsUsed), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodePartialBlockStrided_expect_BitstreamChecksumMatches), setup, teardown), From fedfca6cb425e959fcfdc9ae7e726e07ca285385 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 25 Feb 2019 03:09:58 -0800 Subject: [PATCH 035/194] extract common decode/ testcases into #included files in testcases/ --- tests/src/decode/testZfpDecodeBlock1dDouble.c | 4 +--- tests/src/decode/testZfpDecodeBlock1dFloat.c | 4 +--- tests/src/decode/testZfpDecodeBlock1dInt32.c | 4 +--- tests/src/decode/testZfpDecodeBlock1dInt64.c | 4 +--- tests/src/decode/testZfpDecodeBlock2dDouble.c | 4 +--- tests/src/decode/testZfpDecodeBlock2dFloat.c | 4 +--- tests/src/decode/testZfpDecodeBlock2dInt32.c | 4 +--- tests/src/decode/testZfpDecodeBlock2dInt64.c | 4 +--- tests/src/decode/testZfpDecodeBlock3dDouble.c | 4 +--- tests/src/decode/testZfpDecodeBlock3dFloat.c | 4 +--- tests/src/decode/testZfpDecodeBlock3dInt32.c | 4 +--- tests/src/decode/testZfpDecodeBlock3dInt64.c | 4 +--- tests/src/decode/testZfpDecodeBlock4dDouble.c | 4 +--- tests/src/decode/testZfpDecodeBlock4dFloat.c | 4 +--- tests/src/decode/testZfpDecodeBlock4dInt32.c | 4 +--- tests/src/decode/testZfpDecodeBlock4dInt64.c | 4 +--- tests/src/decode/testZfpDecodeBlockStrided1dDouble.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided1dFloat.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided1dInt32.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided1dInt64.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided2dDouble.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided2dFloat.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided2dInt32.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided2dInt64.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided3dDouble.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided3dFloat.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided3dInt32.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided3dInt64.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided4dDouble.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided4dFloat.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided4dInt32.c | 9 +-------- tests/src/decode/testZfpDecodeBlockStrided4dInt64.c | 9 +-------- tests/src/decode/testcases/block.c | 6 ++++++ tests/src/decode/testcases/blockStrided.c | 11 +++++++++++ 34 files changed, 49 insertions(+), 176 deletions(-) create mode 100644 tests/src/decode/testcases/block.c create mode 100644 tests/src/decode/testcases/blockStrided.c diff --git a/tests/src/decode/testZfpDecodeBlock1dDouble.c b/tests/src/decode/testZfpDecodeBlock1dDouble.c index 4e71192b1..98a19e4fb 100644 --- a/tests/src/decode/testZfpDecodeBlock1dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock1dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock1dFloat.c b/tests/src/decode/testZfpDecodeBlock1dFloat.c index 9631566ad..3e386c1e9 100644 --- a/tests/src/decode/testZfpDecodeBlock1dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock1dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock1dInt32.c b/tests/src/decode/testZfpDecodeBlock1dInt32.c index 180ca0c45..4925159c8 100644 --- a/tests/src/decode/testZfpDecodeBlock1dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock1dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock1dInt64.c b/tests/src/decode/testZfpDecodeBlock1dInt64.c index 70f301c9d..028b32ff4 100644 --- a/tests/src/decode/testZfpDecodeBlock1dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock1dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock2dDouble.c b/tests/src/decode/testZfpDecodeBlock2dDouble.c index 4e98097b7..dc8973f2d 100644 --- a/tests/src/decode/testZfpDecodeBlock2dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock2dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock2dFloat.c b/tests/src/decode/testZfpDecodeBlock2dFloat.c index a88bcb200..8a0eb1274 100644 --- a/tests/src/decode/testZfpDecodeBlock2dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock2dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock2dInt32.c b/tests/src/decode/testZfpDecodeBlock2dInt32.c index 406ed5e8f..dd44b4637 100644 --- a/tests/src/decode/testZfpDecodeBlock2dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock2dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock2dInt64.c b/tests/src/decode/testZfpDecodeBlock2dInt64.c index 5be19c677..2f079bd07 100644 --- a/tests/src/decode/testZfpDecodeBlock2dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock2dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock3dDouble.c b/tests/src/decode/testZfpDecodeBlock3dDouble.c index 7c96c8583..1f3b5bd92 100644 --- a/tests/src/decode/testZfpDecodeBlock3dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock3dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock3dFloat.c b/tests/src/decode/testZfpDecodeBlock3dFloat.c index 95b219ca5..1f6e04719 100644 --- a/tests/src/decode/testZfpDecodeBlock3dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock3dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock3dInt32.c b/tests/src/decode/testZfpDecodeBlock3dInt32.c index f183544a0..35576d528 100644 --- a/tests/src/decode/testZfpDecodeBlock3dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock3dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock3dInt64.c b/tests/src/decode/testZfpDecodeBlock3dInt64.c index 2b79063a2..9d96cfeea 100644 --- a/tests/src/decode/testZfpDecodeBlock3dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock3dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock4dDouble.c b/tests/src/decode/testZfpDecodeBlock4dDouble.c index 6ef1fc710..3c0308001 100644 --- a/tests/src/decode/testZfpDecodeBlock4dDouble.c +++ b/tests/src/decode/testZfpDecodeBlock4dDouble.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock4dFloat.c b/tests/src/decode/testZfpDecodeBlock4dFloat.c index 327890d7a..ed3737299 100644 --- a/tests/src/decode/testZfpDecodeBlock4dFloat.c +++ b/tests/src/decode/testZfpDecodeBlock4dFloat.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock4dInt32.c b/tests/src/decode/testZfpDecodeBlock4dInt32.c index 0e52729c4..87c60dfff 100644 --- a/tests/src/decode/testZfpDecodeBlock4dInt32.c +++ b/tests/src/decode/testZfpDecodeBlock4dInt32.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlock4dInt64.c b/tests/src/decode/testZfpDecodeBlock4dInt64.c index ef28c043c..84464d1c6 100644 --- a/tests/src/decode/testZfpDecodeBlock4dInt64.c +++ b/tests/src/decode/testZfpDecodeBlock4dInt64.c @@ -7,9 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodeBlock_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/block.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c index 55a6871d7..d6f9af3cf 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dDoubleBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c index 047b73d9e..a67fd3303 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dFloatBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c index 40f0945c9..02ae01fb4 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt32Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c index a5ff18722..e66c0765d 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided1dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_1dInt64Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c index 67674f5b9..9e2691a9c 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dDoubleBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c index 63d2c9dc3..ebf0b0bfc 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dFloatBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c index 318cd9fc3..72659aa0d 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt32Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c index ea5ee3c1e..6244fd900 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided2dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_2dInt64Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c index 739028140..b823ba6e3 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dDoubleBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c index 8f2252d7a..cb0d40f82 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dFloatBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c index 60da7ce6b..285cd4908 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt32Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c index d1754cdfa..7c98991b8 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided3dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_3dInt64Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c b/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c index f2181baf3..da43d4190 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dDouble.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dDoubleBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c b/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c index 92db0eacd..bb7ed2001 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dFloat.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dFloatBlock_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c b/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c index c36033e23..89ec1eede 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dInt32.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt32Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c b/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c index ea1885b10..6d22fc20e 100644 --- a/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c +++ b/tests/src/decode/testZfpDecodeBlockStrided4dInt64.c @@ -7,14 +7,7 @@ int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray, setup, teardown), - cmocka_unit_test_setup_teardown(given_4dInt64Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches, setup, teardown), + #include "testcases/blockStrided.c" }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/decode/testcases/block.c b/tests/src/decode/testcases/block.c new file mode 100644 index 000000000..45a085c66 --- /dev/null +++ b/tests/src/decode/testcases/block.c @@ -0,0 +1,6 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ArrayChecksumMatches), setup, teardown), diff --git a/tests/src/decode/testcases/blockStrided.c b/tests/src/decode/testcases/blockStrided.c new file mode 100644 index 000000000..2a0713570 --- /dev/null +++ b/tests/src/decode/testcases/blockStrided.c @@ -0,0 +1,11 @@ +#include "utils/testMacros.h" + +_cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumMatches, setup, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_OnlyStridedEntriesChangedInDestinationArray), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlockStrided_expect_ArrayChecksumMatches), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_ReturnValReflectsNumBitsReadFromBitstream), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_NonStridedEntriesUnchangedInDestinationArray), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_EntriesOutsidePartialBlockBoundsUnchangedInDestinationArray), setup, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodePartialBlockStrided_expect_ArrayChecksumMatches), setup, teardown), From aa63805dc0560dfbe9f402b7cb5f46bb00fe3f3c Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Wed, 13 Feb 2019 17:08:37 -0500 Subject: [PATCH 036/194] AppVeyor CI builds now report to the zfp cdash instance --- appveyor.yml | 20 +++--------- cmake/appveyor.cmake | 76 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 16 deletions(-) create mode 100644 cmake/appveyor.cmake diff --git a/appveyor.yml b/appveyor.yml index 98d9d523d..cb11c94e9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -75,23 +75,11 @@ build_script: - cd build # build/test without OpenMP, with CFP (and custom namespace) - - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. - - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_WITH_OPENMP=OFF -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 .. - - - if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%" - - if not "%COMPILER%"=="msvc" cmake --build . - - - ctest -V -C "%BUILD_TYPE%" + - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake + - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake - rm -rf ./* # build/test with OpenMP - - if "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DZFP_WITH_OPENMP=ON -DZFP_ENDTOEND_TESTS_ONLY=1 .. - - if not "%COMPILER%"=="msvc" cmake -G "%GENERATOR%" -DCMAKE_BUILD_TYPE="%BUILD_TYPE%" -DCMAKE_SH=CMAKE_SH-NOTFOUND -DZFP_WITH_OPENMP=ON -DZFP_ENDTOEND_TESTS_ONLY=1 .. - - - if "%COMPILER%"=="msvc" cmake --build . --config "%BUILD_TYPE%" - - if not "%COMPILER%"=="msvc" cmake --build . - - # only run tests not run in previous build, due to appveyor time limit (1 hour) - - ctest -V -C "%BUILD_TYPE%" -R ".*Omp.*" - + - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DENDTOEND_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake + - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DENDTOEND_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake diff --git a/cmake/appveyor.cmake b/cmake/appveyor.cmake new file mode 100644 index 000000000..e7d609fe8 --- /dev/null +++ b/cmake/appveyor.cmake @@ -0,0 +1,76 @@ + +set(CTEST_SOURCE_DIRECTORY "$ENV{APPVEYOR_BUILD_FOLDER}") +set(CTEST_BINARY_DIRECTORY "$ENV{APPVEYOR_BUILD_FOLDER}/build") + +#make the appveyor job name have a nicer form for CDash +string(REPLACE ", " "-" job_details "$ENV{APPVEYOR_JOB_NAME}") + +set(CTEST_COMMAND ctest) +include(${CTEST_SOURCE_DIRECTORY}/CTestConfig.cmake) +set(CTEST_SITE "appveyor") +set(CTEST_CMAKE_GENERATOR "${GENERATOR}") +set(CTEST_BUILD_NAME "$ENV{APPVEYOR_REPO_BRANCH}-${job_details}") +set(cfg_options + -DBUILD_CFP=${BUILD_CFP} + -DZFP_WITH_OPENMP=${BUILD_OPENMP} + -DZFP_WITH_CUDA=${BUILD_CUDA} + ) + +# Work-around the fact that sh.exe is on the path +# for appveyor mingw builds which CMake considers +# to be an error. This is sorta-hacky but works for us +if(NOT ${GENERATOR} MATCHES "Visual Studio") + list(APPEND cfg_options + -DCMAKE_SH=CMAKE_SH-NOTFOUND + ) +endif() + +# Add the variants to the testers name so that we can report multiple +# times from the same CI builder +if(BUILD_OPENMP) + set(CTEST_SITE "${CTEST_SITE}_openmp") +endif() + +if(BUILD_CUDA) + set(CTEST_SITE "${CTEST_SITE}_cuda") +endif() + +if(BUILD_CFP) + set(CTEST_SITE "${CTEST_SITE}_cfp") + + if(CFP_NAMESPACE) + list(APPEND cfg_options + -DCFP_NAMESPACE=${CFP_NAMESPACE} + ) + set(CTEST_SITE "${CTEST_SITE}namespace") + endif() +endif() + +if(ENDTOEND_TESTS_ONLY) + list(APPEND cfg_options + -DZFP_ENDTOEND_TESTS_ONLY=1 + ) +endif() + +ctest_start(Experimental TRACK AppVeyor) +ctest_configure(OPTIONS "${cfg_options}") +ctest_submit(PARTS Update Notes Configure) +ctest_build() +ctest_submit(PARTS Build) + +if(BUILD_OPENMP) + # only run tests not run in previous build, due to appveyor time limit (1 hour) + ctest_test(PARALLEL_LEVEL 6 RETURN_VALUE rv INCLUDE ".*Omp.*") +else() + ctest_test(PARALLEL_LEVEL 6 RETURN_VALUE rv) +endif() +ctest_submit(PARTS Test) + +if(WITH_COVERAGE) + ctest_coverage() + ctest_submit(PARTS Coverage) +endif() + +if(NOT rv EQUAL 0) + message(FATAL_ERROR "Test failures occurred.") +endif() From 19728854d58eec7eaba95d18198337559347c381 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 5 Mar 2019 15:11:25 -0800 Subject: [PATCH 037/194] collect execution policy tests into new dir tests/src/execPolicy --- tests/src/CMakeLists.txt | 4 +--- tests/src/execPolicy/CMakeLists.txt | 22 +++++++++++++++++++ tests/src/{misc => execPolicy}/testCuda.c | 0 tests/src/{misc => execPolicy}/testOmp.c | 0 .../{share => execPolicy}/testOmpInternal.c | 12 +++++----- tests/src/misc/CMakeLists.txt | 16 -------------- tests/src/share/CMakeLists.txt | 5 ----- 7 files changed, 29 insertions(+), 30 deletions(-) create mode 100644 tests/src/execPolicy/CMakeLists.txt rename tests/src/{misc => execPolicy}/testCuda.c (100%) rename tests/src/{misc => execPolicy}/testOmp.c (100%) rename tests/src/{share => execPolicy}/testOmpInternal.c (67%) delete mode 100644 tests/src/share/CMakeLists.txt diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index 273b2f26d..245a547c0 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -4,9 +4,7 @@ if(NOT DEFINED ZFP_ENDTOEND_TESTS_ONLY) add_subdirectory(misc) add_subdirectory(encode) add_subdirectory(decode) - if(ZFP_WITH_OPENMP) - add_subdirectory(share) - endif() endif() add_subdirectory(endtoend) +add_subdirectory(execPolicy) diff --git a/tests/src/execPolicy/CMakeLists.txt b/tests/src/execPolicy/CMakeLists.txt new file mode 100644 index 000000000..45c5de162 --- /dev/null +++ b/tests/src/execPolicy/CMakeLists.txt @@ -0,0 +1,22 @@ +add_executable(testOmp testOmp.c) +target_link_libraries(testOmp cmocka zfp) +add_test(NAME testOmp COMMAND testOmp) +if(ZFP_WITH_OPENMP) + target_compile_options(testOmp PRIVATE ${OpenMP_C_FLAGS}) + target_link_libraries(testOmp ${OpenMP_C_LIBRARIES}) + set_property(TEST testOmp PROPERTY RUN_SERIAL TRUE) +endif() + +if(ZFP_WITH_OPENMP) + add_executable(testOmpInternal testOmpInternal.c) + target_compile_options(testOmpInternal PRIVATE ${OpenMP_C_FLAGS}) + target_link_libraries(testOmpInternal + cmocka zfp ${OpenMP_C_FLAGS} ${OpenMP_C_LIBRARIES}) + add_test(NAME testOmpInternal COMMAND testOmpInternal) +endif() + +if(ZFP_WITH_CUDA) + add_executable(testCuda testCuda.c) + target_link_libraries(testCuda cmocka zfp) + add_test(NAME testCuda COMMAND testCuda) +endif() diff --git a/tests/src/misc/testCuda.c b/tests/src/execPolicy/testCuda.c similarity index 100% rename from tests/src/misc/testCuda.c rename to tests/src/execPolicy/testCuda.c diff --git a/tests/src/misc/testOmp.c b/tests/src/execPolicy/testOmp.c similarity index 100% rename from tests/src/misc/testOmp.c rename to tests/src/execPolicy/testOmp.c diff --git a/tests/src/share/testOmpInternal.c b/tests/src/execPolicy/testOmpInternal.c similarity index 67% rename from tests/src/share/testOmpInternal.c rename to tests/src/execPolicy/testOmpInternal.c index 380bcff19..b8eac13ef 100644 --- a/tests/src/share/testOmpInternal.c +++ b/tests/src/execPolicy/testOmpInternal.c @@ -38,7 +38,7 @@ teardown(void **state) } static void -given_zfpStreamOmpThreadsZero_when_threadCountOmp_expect_returnsOmpMaxThreadCount(void **state) +given_withOpenMP_zfpStreamOmpThreadsZero_when_threadCountOmp_expect_returnsOmpMaxThreadCount(void **state) { struct setupVars *bundle = *state; zfp_stream* stream = bundle->stream; @@ -48,7 +48,7 @@ given_zfpStreamOmpThreadsZero_when_threadCountOmp_expect_returnsOmpMaxThreadCoun } static void -given_zfpStreamOmpChunkSizeZero_when_chunkCountOmp_expect_returnsOneChunkPerThread(void **state) +given_withOpenMP_zfpStreamOmpChunkSizeZero_when_chunkCountOmp_expect_returnsOneChunkPerThread(void **state) { struct setupVars *bundle = *state; zfp_stream* stream = bundle->stream; @@ -60,7 +60,7 @@ given_zfpStreamOmpChunkSizeZero_when_chunkCountOmp_expect_returnsOneChunkPerThre } static void -given_zfpStreamOmpChunkSizeNonzero_when_chunkCountOmp_expect_returnsNumChunks(void **state) +given_withOpenMP_zfpStreamOmpChunkSizeNonzero_when_chunkCountOmp_expect_returnsNumChunks(void **state) { struct setupVars *bundle = *state; zfp_stream* stream = bundle->stream; @@ -76,9 +76,9 @@ given_zfpStreamOmpChunkSizeNonzero_when_chunkCountOmp_expect_returnsNumChunks(vo int main() { const struct CMUnitTest tests[] = { - cmocka_unit_test_setup_teardown(given_zfpStreamOmpThreadsZero_when_threadCountOmp_expect_returnsOmpMaxThreadCount, setup, teardown), - cmocka_unit_test_setup_teardown(given_zfpStreamOmpChunkSizeZero_when_chunkCountOmp_expect_returnsOneChunkPerThread, setup, teardown), - cmocka_unit_test_setup_teardown(given_zfpStreamOmpChunkSizeNonzero_when_chunkCountOmp_expect_returnsNumChunks, setup, teardown), + cmocka_unit_test_setup_teardown(given_withOpenMP_zfpStreamOmpThreadsZero_when_threadCountOmp_expect_returnsOmpMaxThreadCount, setup, teardown), + cmocka_unit_test_setup_teardown(given_withOpenMP_zfpStreamOmpChunkSizeZero_when_chunkCountOmp_expect_returnsOneChunkPerThread, setup, teardown), + cmocka_unit_test_setup_teardown(given_withOpenMP_zfpStreamOmpChunkSizeNonzero_when_chunkCountOmp_expect_returnsNumChunks, setup, teardown), }; return cmocka_run_group_tests(tests, NULL, NULL); } diff --git a/tests/src/misc/CMakeLists.txt b/tests/src/misc/CMakeLists.txt index b51b49abe..593a17ad8 100644 --- a/tests/src/misc/CMakeLists.txt +++ b/tests/src/misc/CMakeLists.txt @@ -10,19 +10,3 @@ if(HAVE_LIBM_MATH) target_link_libraries(testZfpHeader m) target_link_libraries(testZfpStream m) endif() - - -add_executable(testOmp testOmp.c) -target_link_libraries(testOmp cmocka zfp) -add_test(NAME testOmp COMMAND testOmp) -if(ZFP_WITH_OPENMP) - target_compile_options(testOmp PRIVATE ${OpenMP_C_FLAGS}) - target_link_libraries(testOmp ${OpenMP_C_LIBRARIES}) - set_property(TEST testOmp PROPERTY RUN_SERIAL TRUE) -endif() - -if(ZFP_WITH_CUDA) - add_executable(testCuda testCuda.c) - target_link_libraries(testCuda cmocka zfp) - add_test(NAME testCuda COMMAND testCuda) -endif() diff --git a/tests/src/share/CMakeLists.txt b/tests/src/share/CMakeLists.txt deleted file mode 100644 index c1f63232c..000000000 --- a/tests/src/share/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -add_executable(testOmpInternal testOmpInternal.c) -target_compile_options(testOmpInternal PRIVATE ${OpenMP_C_FLAGS}) -target_link_libraries(testOmpInternal - cmocka zfp ${OpenMP_C_FLAGS} ${OpenMP_C_LIBRARIES}) -add_test(NAME testOmpInternal COMMAND testOmpInternal) From 6796f4de1a77f299a46487b59d686b8c9d8fe02b Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 5 Mar 2019 15:51:01 -0800 Subject: [PATCH 038/194] testing: rename ZFP_ENDTOEND_TESTS_ONLY to ZFP_OMP_TESTS_ONLY, and change behavior to only compile OpenMP related tests --- tests/CMakeLists.txt | 2 +- tests/src/CMakeLists.txt | 2 +- tests/src/endtoend/CMakeLists.txt | 42 ++++++++++++++++------------- tests/src/execPolicy/CMakeLists.txt | 2 +- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 54e336cc2..d040e817c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -65,7 +65,7 @@ if(MSVC) endif() # TODO: spend time getting googletest to compile on MinGW -if((NOT MINGW) AND (NOT DEFINED ZFP_ENDTOEND_TESTS_ONLY)) +if((NOT MINGW) AND (NOT DEFINED ZFP_OMP_TESTS_ONLY)) # clone googletest into build/ configure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" ${GTEST_ARGS} . diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index 245a547c0..81185f9b8 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -1,5 +1,5 @@ # compile tests -if(NOT DEFINED ZFP_ENDTOEND_TESTS_ONLY) +if(NOT DEFINED ZFP_OMP_TESTS_ONLY) add_subdirectory(inline) add_subdirectory(misc) add_subdirectory(encode) diff --git a/tests/src/endtoend/CMakeLists.txt b/tests/src/endtoend/CMakeLists.txt index 65adf1478..7613485ae 100644 --- a/tests/src/endtoend/CMakeLists.txt +++ b/tests/src/endtoend/CMakeLists.txt @@ -1,13 +1,15 @@ function(zfp_add_test dims type bits) - set(serial_test_name testZfpSerial${dims}d${type}) - add_executable(${serial_test_name} ${serial_test_name}.c) - target_link_libraries(${serial_test_name} - cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib - zfpChecksumsLib zfpCompressionParamsLib zfpTimerLib) - if(HAVE_LIBM_MATH) - target_link_libraries(${serial_test_name} m) + if(NOT DEFINED ZFP_OMP_TESTS_ONLY) + set(serial_test_name testZfpSerial${dims}d${type}) + add_executable(${serial_test_name} ${serial_test_name}.c) + target_link_libraries(${serial_test_name} + cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib + zfpChecksumsLib zfpCompressionParamsLib zfpTimerLib) + if(HAVE_LIBM_MATH) + target_link_libraries(${serial_test_name} m) + endif() + add_test(NAME ${serial_test_name} COMMAND ${serial_test_name}) endif() - add_test(NAME ${serial_test_name} COMMAND ${serial_test_name}) if(ZFP_WITH_OPENMP) set(omp_test_name testZfpOmp${dims}d${type}) @@ -23,19 +25,21 @@ function(zfp_add_test dims type bits) set_property(TEST ${omp_test_name} PROPERTY RUN_SERIAL TRUE) endif() - if(ZFP_WITH_CUDA AND (${dims} LESS 4)) - add_definitions(-DZFP_WITH_CUDA) + if(NOT DEFINED ZFP_OMP_TESTS_ONLY) + if(ZFP_WITH_CUDA AND (${dims} LESS 4)) + add_definitions(-DZFP_WITH_CUDA) - set(cuda_test_name testZfpCuda${dims}d${type}) - add_executable(${cuda_test_name} ${cuda_test_name}.c) - target_link_libraries(${cuda_test_name} - cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib - zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib) - if(HAVE_LIBM_MATH) - target_link_libraries(${cuda_test_name} m) + set(cuda_test_name testZfpCuda${dims}d${type}) + add_executable(${cuda_test_name} ${cuda_test_name}.c) + target_link_libraries(${cuda_test_name} + cmocka zfp zfpHashLib genSmoothRandNumsLib stridedOperationsLib + zfpChecksumsLib zfpTimerLib zfpCompressionParamsLib) + if(HAVE_LIBM_MATH) + target_link_libraries(${cuda_test_name} m) + endif() + add_test(NAME ${cuda_test_name} COMMAND ${cuda_test_name}) + set_property(TEST ${cuda_test_name} PROPERTY RUN_SERIAL TRUE) endif() - add_test(NAME ${cuda_test_name} COMMAND ${cuda_test_name}) - set_property(TEST ${cuda_test_name} PROPERTY RUN_SERIAL TRUE) endif() endfunction() diff --git a/tests/src/execPolicy/CMakeLists.txt b/tests/src/execPolicy/CMakeLists.txt index 45c5de162..f37e16acc 100644 --- a/tests/src/execPolicy/CMakeLists.txt +++ b/tests/src/execPolicy/CMakeLists.txt @@ -15,7 +15,7 @@ if(ZFP_WITH_OPENMP) add_test(NAME testOmpInternal COMMAND testOmpInternal) endif() -if(ZFP_WITH_CUDA) +if(ZFP_WITH_CUDA AND NOT DEFINED ZFP_OMP_TESTS_ONLY) add_executable(testCuda testCuda.c) target_link_libraries(testCuda cmocka zfp) add_test(NAME testCuda COMMAND testCuda) From 614b9a446f4e4ef166bdcbcc1ac7385e2192ec68 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 5 Mar 2019 15:52:32 -0800 Subject: [PATCH 039/194] update CI appveyor and cmake/ files to use ZFP_OMP_TESTS_ONLY --- appveyor.yml | 4 ++-- cmake/appveyor.cmake | 4 ++-- cmake/travis.cmake | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cb11c94e9..3731d036c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -81,5 +81,5 @@ build_script: - rm -rf ./* # build/test with OpenMP - - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DENDTOEND_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake - - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DENDTOEND_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake + - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake + - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake diff --git a/cmake/appveyor.cmake b/cmake/appveyor.cmake index e7d609fe8..6633b16b1 100644 --- a/cmake/appveyor.cmake +++ b/cmake/appveyor.cmake @@ -46,9 +46,9 @@ if(BUILD_CFP) endif() endif() -if(ENDTOEND_TESTS_ONLY) +if(OMP_TESTS_ONLY) list(APPEND cfg_options - -DZFP_ENDTOEND_TESTS_ONLY=1 + -DZFP_OMP_TESTS_ONLY=1 ) endif() diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 71255f038..e434471fd 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -44,9 +44,9 @@ if(WITH_COVERAGE) set(CTEST_SITE "${CTEST_SITE}_coverage") endif() -if(ENDTOEND_TESTS_ONLY) +if(OMP_TESTS_ONLY) list(APPEND cfg_options - -DZFP_ENDTOEND_TESTS_ONLY=1 + -DZFP_OMP_TESTS_ONLY=1 ) endif() From 2471e2918d1dd9baaa3aae78926cfce0acc138c4 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 6 Mar 2019 19:59:24 -0800 Subject: [PATCH 040/194] Extract Appveyor build steps into script appveyor.sh and check for OpenMP before attempting 2nd build --- appveyor.sh | 38 ++++++++++++++++++++++++++++++++++++++ appveyor.yml | 13 +------------ 2 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 appveyor.sh diff --git a/appveyor.sh b/appveyor.sh new file mode 100644 index 000000000..880b7327f --- /dev/null +++ b/appveyor.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env sh +set -e + +# pass additional args in $1 (starting with whitespace character) +run_all () { + run_all_cmd="ctest -V -C $BUILD_TYPE -DGENERATOR=\"$GENERATOR\" -S \"$APPVEYOR_BUILD_FOLDER/cmake/appveyor.cmake\"" + eval "${run_all_cmd}$1" +} + +# create build dir for out-of-source build +mkdir build +cd build + +# config without OpenMP, with CFP (and custom namespace) +run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" + +rm -rf ./* + + +# build empty project requiring OpenMP +# (satisfy mingw builds) +set +e +if [ $COMPILER != "msvc" ]; then + cmake -G "$GENERATOR" "$APPVEYOR_BUILD_FOLDER/tests/ci-utils" -DCMAKE_SH=CMAKE_SH-NOTFOUND +else + cmake -G "$GENERATOR" "$APPVEYOR_BUILD_FOLDER/tests/ci-utils" +fi + +if [ $? -eq 0 ]; then + echo "OpenMP found, starting 2nd zfp build" + set -e + rm -rf ./* + + # only run tests not run in previous build, due to appveyor time limit (1 hour) + run_all " -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=1" +else + echo "OpenMP not found, build completed." +fi diff --git a/appveyor.yml b/appveyor.yml index 3731d036c..0875a9778 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -71,15 +71,4 @@ install: - if "%COMPILER%"=="mingw-w64" set PATH=C:\MinGW\bin;%PATH% build_script: - - mkdir build - - cd build - - # build/test without OpenMP, with CFP (and custom namespace) - - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake - - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake - - - rm -rf ./* - - # build/test with OpenMP - - if "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake - - if not "%COMPILER%"=="msvc" ctest -V -C "%BUILD_TYPE%" -DGENERATOR="%GENERATOR%" -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=ON -S %APPVEYOR_BUILD_FOLDER%/cmake/appveyor.cmake + - sh appveyor.sh From dafb1b5802e554e1d595950ca29999557ad0f29a Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 13 Mar 2019 01:34:52 -0700 Subject: [PATCH 041/194] speedup Appveyor build: only delete CMakeCache.txt before starting 2nd build --- appveyor.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/appveyor.sh b/appveyor.sh index 880b7327f..0811cd28f 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -14,11 +14,10 @@ cd build # config without OpenMP, with CFP (and custom namespace) run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" -rm -rf ./* - - -# build empty project requiring OpenMP -# (satisfy mingw builds) +# build empty project requiring OpenMP, in a temp directory that ZFP is oblivious to +mkdir tmpBuild +cd tmpBuild +# (CMAKE_SH satisfies mingw builds) set +e if [ $COMPILER != "msvc" ]; then cmake -G "$GENERATOR" "$APPVEYOR_BUILD_FOLDER/tests/ci-utils" -DCMAKE_SH=CMAKE_SH-NOTFOUND @@ -29,7 +28,9 @@ fi if [ $? -eq 0 ]; then echo "OpenMP found, starting 2nd zfp build" set -e - rm -rf ./* + cd .. + # keep compiled testing frameworks, to speedup Appveyor + rm CMakeCache.txt # only run tests not run in previous build, due to appveyor time limit (1 hour) run_all " -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=1" From d4148316de2c7596bf613eee3e5f61b346928b23 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 28 Mar 2019 11:44:02 -0700 Subject: [PATCH 042/194] Add macros for printf and scanf integer conversion specifiers --- include/zfp/types.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/zfp/types.h b/include/zfp/types.h index b501ca293..f57e1f896 100644 --- a/include/zfp/types.h +++ b/include/zfp/types.h @@ -8,8 +8,19 @@ typedef unsigned int uint; #if __STDC_VERSION__ >= 199901L /* C99: use standard integer types */ #include + #include #define INT64C(x) INT64_C(x) #define UINT64C(x) UINT64_C(x) + #define INT64PRId PRId64 + #define INT64PRIi PRIi64 + #define UINT64PRIo PRIo64 + #define UINT64PRIu PRIu64 + #define UINT64PRIx PRIx64 + #define INT64SCNd SCNd64 + #define INT64SCNi SCNi64 + #define UINT64SCNo SCNo64 + #define UINT64SCNu SCNu64 + #define UINT64SCNx SCNx64 typedef int8_t int8; typedef uint8_t uint8; typedef int16_t int16; @@ -45,30 +56,52 @@ typedef unsigned int uint; /* signed 64-bit integers */ #if defined(ZFP_INT64) && defined(ZFP_INT64_SUFFIX) #define INT64C(x) _zfp_cat(x, ZFP_INT64_SUFFIX) + #define INT64PRId #ZFP_INT64_SUFFIX "d" + #define INT64PRIi #ZFP_INT64_SUFFIX "i" typedef ZFP_INT64 int64; #elif ZFP_LP64 #define INT64C(x) x ## l + #define INT64PRId "ld" + #define INT64PRIi "li" typedef signed long int64; #elif ZFP_LLP64 #define INT64C(x) x ## ll + #define INT64PRId "lld" + #define INT64PRIi "lli" typedef signed long long int64; #else #error "unknown 64-bit signed integer type" #endif + #define INT64SCNd INT64PRId + #define INT64SCNi INT64PRIi /* unsigned 64-bit integers */ #if defined(ZFP_UINT64) && defined(ZFP_UINT64_SUFFIX) #define UINT64C(x) _zfp_cat(x, ZFP_UINT64_SUFFIX) + #ifdef ZFP_INT64_SUFFIX + #define UINT64PRIo #ZFP_INT64_SUFFIX "o" + #define UINT64PRIu #ZFP_INT64_SUFFIX "u" + #define UINT64PRIx #ZFP_INT64_SUFFIX "x" + #endif typedef ZFP_UINT64 uint64; #elif ZFP_LP64 #define UINT64C(x) x ## ul + #define UINT64PRIo "lo" + #define UINT64PRIu "lu" + #define UINT64PRIx "lx" typedef unsigned long uint64; #elif ZFP_LLP64 #define UINT64C(x) x ## ull + #define UINT64PRIo "llo" + #define UINT64PRIu "llu" + #define UINT64PRIx "llx" typedef unsigned long long uint64; #else #error "unknown 64-bit unsigned integer type" #endif + #define UINT64SCNo UINT64PRIo + #define UINT64SCNu UINT64PRIu + #define UINT64SCNx UINT64PRIx #endif #endif From bf9ae6f0b596618e7b474c8f184ce89a9fc7eace Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 28 Mar 2019 18:39:23 -0700 Subject: [PATCH 043/194] Check array dimensions to ensure they can be encoded in header's 52-bit metadata field --- docs/source/high-level-api.rst | 16 +++++++++++++++- docs/source/limitations.rst | 5 +++++ include/zfp.h | 3 +++ src/zfp.c | 28 +++++++++++++++++++++++++++- 4 files changed, 50 insertions(+), 2 deletions(-) diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 91eadd3ea..055d1474f 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -58,6 +58,14 @@ Macros of doubles, is given by :c:macro:`ZFP_MAX_BITS`. See also :c:type:`zfp_stream`. +.. c:macro:: ZFP_META_NULL + + Null representation of the 52-bit encoding of field metadata. This value + is returned by :c:func:`zfp_field_metadata` when the field metadata cannot + be encoded in 64 bits, such as when the array dimensions are too large + (see :ref:`limitations`). In addition to signaling error, this value + is guaranteed not to represent valid metadata. + .. _header-macros: .. c:macro:: ZFP_HEADER_MAGIC .. c:macro:: ZFP_HEADER_META @@ -495,6 +503,9 @@ Array Metadata .. c:function:: uint64 zfp_field_metadata(const zfp_field* field) Return 52-bit compact encoding of the scalar type and array dimensions. + This function returns :c:macro:`ZFP_META_NULL` on failure, e.g., if the + array dimensions are :ref:`too large ` to be encoded in 52 + bits. .. _zfp_field_set: @@ -572,12 +583,15 @@ Compression and Decompression i.e. the current byte offset or the number of compressed bytes consumed. Zero is returned if decompression failed. +.. _zfp-header: .. c:function:: size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, uint mask) Write an optional header to the stream that encodes compression parameters, array metadata, etc. The header information written is determined by the bit *mask* (see :c:macro:`macros `). The return value is - the number of bits written, or zero upon failure. + the number of bits written, or zero upon failure. See the + :ref:`limitations ` section for limits on the maximum array + size supported by the header. .. c:function:: size_t zfp_read_header(zfp_stream* stream, zfp_field* field, uint mask) diff --git a/docs/source/limitations.rst b/docs/source/limitations.rst index b22efe5e1..1be607ff0 100644 --- a/docs/source/limitations.rst +++ b/docs/source/limitations.rst @@ -24,6 +24,11 @@ that will address some of these limitations. extensions to other floating-point formats should be possible with minor effort. +- The optional |zfp| :ref:`header ` supports arrays with at + most 2\ :sup:`48` elements. Each dimension is limited to 2\ :sup:`48/d` + elements in a *d*-dimensional array, i.e., 2\ :sup:`48`, 2\ :sup:`24`, + 2\ :sup:`16`, and 2\ :sup:`12` for 1D through 4D arrays, respectively. + - Conventional pointers and references to individual array elements are not available. That is, constructions like :code:`double* ptr = &a[i];` are not possible when :code:`a` is a |zfp| array. However, as of diff --git a/include/zfp.h b/include/zfp.h index 2faca1c29..15d2cdc02 100644 --- a/include/zfp.h +++ b/include/zfp.h @@ -104,6 +104,9 @@ #define ZFP_HEADER_MODE 0x4u /* embed 12- or 64-bit compression mode */ #define ZFP_HEADER_FULL 0x7u /* embed all of the above */ +/* field metadata indeterminate state and error code */ +#define ZFP_META_NULL (UINT64C(-1)) + /* number of bits per header entry */ #define ZFP_MAGIC_BITS 32 /* number of magic word bits */ #define ZFP_META_BITS 52 /* number of field metadata bits */ diff --git a/src/zfp.c b/src/zfp.c index 049a58692..8570a5871 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -237,18 +237,32 @@ zfp_field_metadata(const zfp_field* field) /* 48 bits for dimensions */ switch (zfp_field_dimensionality(field)) { case 1: + if ((field->nx - 1) >> 48) + return ZFP_META_NULL; meta <<= 48; meta += field->nx - 1; break; case 2: + if (((field->nx - 1) >> 24) || + ((field->ny - 1) >> 24)) + return ZFP_META_NULL; meta <<= 24; meta += field->ny - 1; meta <<= 24; meta += field->nx - 1; break; case 3: + if (((field->nx - 1) >> 16) || + ((field->ny - 1) >> 16) || + ((field->nz - 1) >> 16)) + return ZFP_META_NULL; meta <<= 16; meta += field->nz - 1; meta <<= 16; meta += field->ny - 1; meta <<= 16; meta += field->nx - 1; break; case 4: + if (((field->nx - 1) >> 12) || + ((field->ny - 1) >> 12) || + ((field->nz - 1) >> 12) || + ((field->nw - 1) >> 12)) + return ZFP_META_NULL; meta <<= 12; meta += field->nw - 1; meta <<= 12; meta += field->nz - 1; meta <<= 12; meta += field->ny - 1; @@ -359,6 +373,9 @@ int zfp_field_set_metadata(zfp_field* field, uint64 meta) { uint64 dims; + /* ensure value is in range */ + if (meta >> ZFP_META_BITS) + return 0; field->type = (zfp_type)((meta & 0x3u) + 1); meta >>= 2; dims = (meta & 0x3u) + 1; meta >>= 2; switch (dims) { @@ -968,6 +985,15 @@ size_t zfp_write_header(zfp_stream* zfp, const zfp_field* field, uint mask) { size_t bits = 0; + uint64 meta = 0; + + /* first make sure field dimensions fit in header */ + if (mask & ZFP_HEADER_META) { + meta = zfp_field_metadata(field); + if (meta == ZFP_META_NULL) + return 0; + } + /* 32-bit magic */ if (mask & ZFP_HEADER_MAGIC) { stream_write_bits(zfp->stream, 'z', 8); @@ -978,7 +1004,6 @@ zfp_write_header(zfp_stream* zfp, const zfp_field* field, uint mask) } /* 52-bit field metadata */ if (mask & ZFP_HEADER_META) { - uint64 meta = zfp_field_metadata(field); stream_write_bits(zfp->stream, meta, ZFP_META_BITS); bits += ZFP_META_BITS; } @@ -989,6 +1014,7 @@ zfp_write_header(zfp_stream* zfp, const zfp_field* field, uint mask) stream_write_bits(zfp->stream, mode, size); bits += size; } + return bits; } From cdd820b05f853161a94b82da2528511b6e5e4a9b Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 29 Mar 2019 13:20:58 -0700 Subject: [PATCH 044/194] Move late declarations to beginning of scope block --- src/zfp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/zfp.c b/src/zfp.c index 8570a5871..0842480ff 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -237,7 +237,7 @@ zfp_field_metadata(const zfp_field* field) /* 48 bits for dimensions */ switch (zfp_field_dimensionality(field)) { case 1: - if ((field->nx - 1) >> 48) + if ((uint64)(field->nx - 1) >> 48) return ZFP_META_NULL; meta <<= 48; meta += field->nx - 1; break; @@ -899,6 +899,7 @@ zfp_compress(zfp_stream* zfp, const zfp_field* field) uint strided = zfp_field_stride(field, NULL); uint dims = zfp_field_dimensionality(field); uint type = field->type; + void (*compress)(zfp_stream*, const zfp_field*); switch (type) { case zfp_type_int32: @@ -911,7 +912,7 @@ zfp_compress(zfp_stream* zfp, const zfp_field* field) } /* return 0 if compression mode is not supported */ - void (*compress)(zfp_stream*, const zfp_field*) = ftable[exec][strided][dims - 1][type - zfp_type_int32]; + compress = ftable[exec][strided][dims - 1][type - zfp_type_int32]; if (!compress) return 0; @@ -958,6 +959,7 @@ zfp_decompress(zfp_stream* zfp, zfp_field* field) uint strided = zfp_field_stride(field, NULL); uint dims = zfp_field_dimensionality(field); uint type = field->type; + void (*decompress)(zfp_stream*, zfp_field*); switch (type) { case zfp_type_int32: @@ -970,7 +972,7 @@ zfp_decompress(zfp_stream* zfp, zfp_field* field) } /* return 0 if decompression mode is not supported */ - void (*decompress)(zfp_stream*, zfp_field*) = ftable[exec][strided][dims - 1][type - zfp_type_int32]; + decompress = ftable[exec][strided][dims - 1][type - zfp_type_int32]; if (!decompress) return 0; From 0c8da9b8ccffb66abdcb815cfe4f0c0d948fc317 Mon Sep 17 00:00:00 2001 From: Anthony Lichnewsky Date: Thu, 28 Mar 2019 22:05:39 -0700 Subject: [PATCH 045/194] Merge pull request #56 from alichnewsky/develop package CFP if built --- CMakeLists.txt | 14 ++++++++++++++ cfp/src/CMakeLists.txt | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 37044f929..77c051f39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -239,6 +239,9 @@ endif() install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(DIRECTORY array/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +if(BUILD_CFP) + install(DIRECTORY cfp/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +endif() #------------------------------------------------------------------------------# # Build type: one of None, Debug, Release, RelWithDebInfo, MinSizeRel #------------------------------------------------------------------------------# @@ -253,6 +256,12 @@ endif() # Add all targets to the build-tree export set export(TARGETS zfp NAMESPACE zfp:: FILE "${PROJECT_BINARY_DIR}/zfp-targets.cmake") + +if(BUILD_CFP) + export(TARGETS cfp NAMESPACE zfp:: + APPEND FILE "${PROJECT_BINARY_DIR}/zfp-targets.cmake") +endif() + configure_file(zfp-config.cmake.in "${PROJECT_BINARY_DIR}/zfp-config.cmake" @ONLY) configure_file(zfp-config-version.cmake.in @@ -267,3 +276,8 @@ install(FILES # Install the export set for use with the install-tree install(EXPORT zfp-targets NAMESPACE zfp:: DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") + +if(BUILD_CFP) + install(EXPORT cfp-targets NAMESPACE zfp:: + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}") +endif() diff --git a/cfp/src/CMakeLists.txt b/cfp/src/CMakeLists.txt index d2e8c680d..0ed71578a 100644 --- a/cfp/src/CMakeLists.txt +++ b/cfp/src/CMakeLists.txt @@ -15,11 +15,22 @@ target_compile_definitions(cfp target_include_directories(cfp PUBLIC - ${ZFP_SOURCE_DIR}/include - ${ZFP_SOURCE_DIR}/cfp/include + $ + $ + $ + $ PRIVATE ${ZFP_SOURCE_DIR}/array ${ZFP_SOURCE_DIR}/src ) target_link_libraries(cfp zfp) + +set_property(TARGET cfp PROPERTY VERSION ${ZFP_VERSION}) +set_property(TARGET cfp PROPERTY SOVERSION ${ZFP_VERSION_MAJOR}) +set_property(TARGET cfp PROPERTY OUTPUT_NAME ${ZFP_LIBRARY_PREFIX}cfp) + +install(TARGETS cfp EXPORT cfp-targets + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) From 37064fc33c617354583aa98936513d90ffcd1534 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sat, 30 Mar 2019 20:28:37 -0700 Subject: [PATCH 046/194] Check malloc failures in parallel compressor --- src/share/parallel.c | 16 +++++++++++++++- src/template/ompcompress.c | 10 ++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/share/parallel.c b/src/share/parallel.c index 8c67d8f49..e778ac7c2 100644 --- a/src/share/parallel.c +++ b/src/share/parallel.c @@ -38,7 +38,7 @@ compress_init_par(zfp_stream* stream, const zfp_field* field, uint chunks, uint f.nw = 4 * (blocks + chunks - 1) / chunks; break; default: - return 0; + return NULL; } size = zfp_stream_maximum_size(stream, &f); @@ -49,12 +49,26 @@ compress_init_par(zfp_stream* stream, const zfp_field* field, uint chunks, uint /* set up buffer for each thread to compress to */ bs = (bitstream**)malloc(chunks * sizeof(bitstream*)); + if (!bs) + return NULL; for (i = 0; i < chunks; i++) { uint block = chunk_offset(blocks, chunks, i); void* buffer = copy ? malloc(size) : (uchar*)stream_data(stream->stream) + stream_size(stream->stream) + block * stream->maxbits / CHAR_BIT; + if (!buffer) + break; bs[i] = stream_open(buffer, size); } + /* handle memory allocation failure */ + if (copy && i < chunks) { + while (i--) { + free(stream_data(bs[i])); + stream_close(bs[i]); + } + free(bs); + bs = NULL; + } + return bs; } diff --git a/src/template/ompcompress.c b/src/template/ompcompress.c index a654ac91a..c6482f4a5 100644 --- a/src/template/ompcompress.c +++ b/src/template/ompcompress.c @@ -15,6 +15,8 @@ _t2(compress_omp, Scalar, 1)(zfp_stream* stream, const zfp_field* field) /* allocate per-thread streams */ bitstream** bs = compress_init_par(stream, field, chunks, blocks); + if (!bs) + return; /* compress chunks of blocks in parallel */ int chunk; @@ -61,6 +63,8 @@ _t2(compress_strided_omp, Scalar, 1)(zfp_stream* stream, const zfp_field* field) /* allocate per-thread streams */ bitstream** bs = compress_init_par(stream, field, chunks, blocks); + if (!bs) + return; /* compress chunks of blocks in parallel */ int chunk; @@ -111,6 +115,8 @@ _t2(compress_strided_omp, Scalar, 2)(zfp_stream* stream, const zfp_field* field) /* allocate per-thread streams */ bitstream** bs = compress_init_par(stream, field, chunks, blocks); + if (!bs) + return; /* compress chunks of blocks in parallel */ int chunk; @@ -167,6 +173,8 @@ _t2(compress_strided_omp, Scalar, 3)(zfp_stream* stream, const zfp_field* field) /* allocate per-thread streams */ bitstream** bs = compress_init_par(stream, field, chunks, blocks); + if (!bs) + return; /* compress chunks of blocks in parallel */ int chunk; @@ -227,6 +235,8 @@ _t2(compress_strided_omp, Scalar, 4)(zfp_stream* stream, const zfp_field* field) /* allocate per-thread streams */ bitstream** bs = compress_init_par(stream, field, chunks, blocks); + if (!bs) + return; /* compress chunks of blocks in parallel */ int chunk; From 62dbe3dc55f03a2998144ff0a1a8c95aa1ba71fa Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 28 Dec 2018 14:22:54 -0800 Subject: [PATCH 047/194] First version of lossless compressor --- include/zfp.h | 24 +++++++++--- src/encode1d.c | 3 ++ src/encode1f.c | 3 ++ src/encode1i.c | 2 + src/encode1l.c | 2 + src/encode2d.c | 3 ++ src/encode2f.c | 3 ++ src/encode2i.c | 2 + src/encode2l.c | 2 + src/encode3d.c | 3 ++ src/encode3f.c | 3 ++ src/encode3i.c | 2 + src/encode3l.c | 2 + src/encode4d.c | 3 ++ src/encode4f.c | 3 ++ src/encode4i.c | 2 + src/encode4l.c | 2 + src/template/codec.h | 1 + src/template/encodef.c | 25 +++++++++---- src/template/encodei.c | 4 +- src/template/revencode.c | 79 +++++++++++++++++++++++++++++++++++++++ src/template/revencode1.c | 9 +++++ src/template/revencode2.c | 14 +++++++ src/template/revencode3.c | 20 ++++++++++ src/template/revencode4.c | 28 ++++++++++++++ src/template/revencodef.c | 62 ++++++++++++++++++++++++++++++ src/traitsd.h | 2 + src/traitsf.h | 2 + src/traitsi.h | 1 + src/traitsl.h | 1 + src/zfp.c | 47 +++++++++++++++++++++-- utils/zfp.c | 19 +++++++--- 32 files changed, 353 insertions(+), 25 deletions(-) create mode 100644 src/template/revencode.c create mode 100644 src/template/revencode1.c create mode 100644 src/template/revencode2.c create mode 100644 src/template/revencode3.c create mode 100644 src/template/revencode4.c create mode 100644 src/template/revencodef.c diff --git a/include/zfp.h b/include/zfp.h index 15d2cdc02..94034d9bb 100644 --- a/include/zfp.h +++ b/include/zfp.h @@ -94,7 +94,7 @@ /* default compression parameters */ #define ZFP_MIN_BITS 1 /* minimum number of bits per block */ -#define ZFP_MAX_BITS 16651 /* maximum number of bits per block */ +#define ZFP_MAX_BITS 16657 /* maximum number of bits per block */ #define ZFP_MAX_PREC 64 /* maximum precision supported */ #define ZFP_MIN_EXP -1074 /* minimum floating-point base-2 exponent */ @@ -156,7 +156,8 @@ typedef enum { zfp_mode_expert = 1, /* expert mode (4 params set manually) */ zfp_mode_fixed_rate = 2, /* fixed rate mode */ zfp_mode_fixed_precision = 3, /* fixed precision mode */ - zfp_mode_fixed_accuracy = 4 /* fixed accuracy mode */ + zfp_mode_fixed_accuracy = 4, /* fixed accuracy mode */ + zfp_mode_reversible = 5 /* reversible (lossless) mode */ } zfp_mode; /* scalar type */ @@ -215,16 +216,21 @@ zfp_stream_bit_stream( const zfp_stream* stream /* compressed stream */ ); +int /* nonzero if lossless compression is enabled */ +zfp_stream_is_reversible( + const zfp_stream* zfp /* compressed stream */ +); + /* returns enum of compression mode */ -zfp_mode /* enum for compression mode */ +zfp_mode /* enum for compression mode */ zfp_stream_compression_mode( - const zfp_stream* zfp /* compressed stream */ + const zfp_stream* zfp /* compressed stream */ ); /* get all compression parameters in a compact representation */ -uint64 /* 12- or 64-bit encoding of parameters */ +uint64 /* 12- or 64-bit encoding of parameters */ zfp_stream_mode( - const zfp_stream* zfp /* compressed stream */ + const zfp_stream* zfp /* compressed stream */ ); /* get all compression parameters (pointers may be NULL) */ @@ -259,6 +265,12 @@ zfp_stream_set_bit_stream( bitstream* bs /* bit stream to read from and write to */ ); +/* enable reversible (lossless) compression */ +void +zfp_stream_set_reversible( + zfp_stream* stream /* compressed stream */ +); + /* set size in compressed bits/scalar (fixed-rate mode) */ double /* actual rate in compressed bits/scalar */ zfp_stream_set_rate( diff --git a/src/encode1d.c b/src/encode1d.c index c96147497..dbf84257b 100644 --- a/src/encode1d.c +++ b/src/encode1d.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode1.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode1.c" diff --git a/src/encode1f.c b/src/encode1f.c index 9e922e516..73fdc7663 100644 --- a/src/encode1f.c +++ b/src/encode1f.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode1.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode1.c" diff --git a/src/encode1i.c b/src/encode1i.c index 2d4a8b6a5..dcd9aa64b 100644 --- a/src/encode1i.c +++ b/src/encode1i.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode1.c" +#include "template/revencode.c" +#include "template/revencode1.c" diff --git a/src/encode1l.c b/src/encode1l.c index 746539bbe..032c3de61 100644 --- a/src/encode1l.c +++ b/src/encode1l.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode1.c" +#include "template/revencode.c" +#include "template/revencode1.c" diff --git a/src/encode2d.c b/src/encode2d.c index 053efe5e5..8be98d0cc 100644 --- a/src/encode2d.c +++ b/src/encode2d.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode2.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode2.c" diff --git a/src/encode2f.c b/src/encode2f.c index 52321e798..c21f170dd 100644 --- a/src/encode2f.c +++ b/src/encode2f.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode2.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode2.c" diff --git a/src/encode2i.c b/src/encode2i.c index c67d0ed01..d0b4b54c6 100644 --- a/src/encode2i.c +++ b/src/encode2i.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode2.c" +#include "template/revencode.c" +#include "template/revencode2.c" diff --git a/src/encode2l.c b/src/encode2l.c index 990bc0104..d834cfa1d 100644 --- a/src/encode2l.c +++ b/src/encode2l.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode2.c" +#include "template/revencode.c" +#include "template/revencode2.c" diff --git a/src/encode3d.c b/src/encode3d.c index 4d8248490..c2cfaba68 100644 --- a/src/encode3d.c +++ b/src/encode3d.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode3.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode3.c" diff --git a/src/encode3f.c b/src/encode3f.c index 0a95c8997..d966b6f86 100644 --- a/src/encode3f.c +++ b/src/encode3f.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode3.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode3.c" diff --git a/src/encode3i.c b/src/encode3i.c index 6c78aac34..c92a1a698 100644 --- a/src/encode3i.c +++ b/src/encode3i.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode3.c" +#include "template/revencode.c" +#include "template/revencode3.c" diff --git a/src/encode3l.c b/src/encode3l.c index 931c7424b..4d53304ed 100644 --- a/src/encode3l.c +++ b/src/encode3l.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode3.c" +#include "template/revencode.c" +#include "template/revencode3.c" diff --git a/src/encode4d.c b/src/encode4d.c index 5ff58e7c4..e5e77a1a6 100644 --- a/src/encode4d.c +++ b/src/encode4d.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode4.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode4.c" diff --git a/src/encode4f.c b/src/encode4f.c index ba24f5867..419ded3db 100644 --- a/src/encode4f.c +++ b/src/encode4f.c @@ -11,3 +11,6 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode4.c" +#include "template/revencode.c" +#include "template/revencodef.c" +#include "template/revencode4.c" diff --git a/src/encode4i.c b/src/encode4i.c index 6e9fc1bfc..ab82e0e2e 100644 --- a/src/encode4i.c +++ b/src/encode4i.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode4.c" +#include "template/revencode.c" +#include "template/revencode4.c" diff --git a/src/encode4l.c b/src/encode4l.c index d5bf86c09..805ee01a6 100644 --- a/src/encode4l.c +++ b/src/encode4l.c @@ -10,3 +10,5 @@ #include "template/encode.c" #include "template/encodei.c" #include "template/encode4.c" +#include "template/revencode.c" +#include "template/revencode4.c" diff --git a/src/template/codec.h b/src/template/codec.h index e7149a98e..e4b4acf95 100644 --- a/src/template/codec.h +++ b/src/template/codec.h @@ -1,3 +1,4 @@ #define PERM _t1(perm, DIMS) /* coefficient order */ #define BLOCK_SIZE (1 << (2 * DIMS)) /* values per block */ #define EBIAS ((1 << (EBITS - 1)) - 1) /* exponent bias */ +#define REVERSIBLE(zfp) ((zfp)->minexp < ZFP_MIN_EXP) /* reversible mode? */ diff --git a/src/template/encodef.c b/src/template/encodef.c index 874597a77..1f21db920 100644 --- a/src/template/encodef.c +++ b/src/template/encodef.c @@ -1,6 +1,8 @@ #include #include +static uint _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock); + /* private functions ------------------------------------------------------- */ /* return normalized floating-point exponent for x >= 0 */ @@ -48,11 +50,9 @@ _t1(fwd_cast, Scalar)(Int* iblock, const Scalar* fblock, uint n, int emax) while (--n); } -/* public functions -------------------------------------------------------- */ - -/* encode contiguous floating-point block */ -uint -_t2(zfp_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) +/* encode contiguous floating-point block using lossy algorithm */ +static uint +_t2(encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) { /* compute maximum exponent */ int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); @@ -62,12 +62,12 @@ _t2(zfp_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) if (e) { cache_align_(Int iblock[BLOCK_SIZE]); /* encode common exponent; LSB indicates that exponent is nonzero */ - int ebits = EBITS + 1; - stream_write_bits(zfp->stream, 2 * e + 1, ebits); + uint bits = EBITS + 1; + stream_write_bits(zfp->stream, 2 * e + 1, bits); /* perform forward block-floating-point transform */ _t1(fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); /* encode integer block */ - return ebits + _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits - ebits, zfp->maxbits - ebits, maxprec, iblock); + return bits + _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, maxprec, iblock); } else { /* write single zero-bit to indicate that all values are zero */ @@ -80,3 +80,12 @@ _t2(zfp_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) return 1; } } + +/* public functions -------------------------------------------------------- */ + +/* encode contiguous floating-point block */ +uint +_t2(zfp_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) +{ + return REVERSIBLE(zfp) ? _t2(rev_encode_block, Scalar, DIMS)(zfp, fblock) : _t2(encode_block, Scalar, DIMS)(zfp, fblock); +} diff --git a/src/template/encodei.c b/src/template/encodei.c index 6f4cb2c11..41d5fbd65 100644 --- a/src/template/encodei.c +++ b/src/template/encodei.c @@ -1,3 +1,5 @@ +static uint _t2(rev_encode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock); + /* public functions -------------------------------------------------------- */ /* encode contiguous integer block */ @@ -9,5 +11,5 @@ _t2(zfp_encode_block, Int, DIMS)(zfp_stream* zfp, const Int* iblock) /* copy block */ for (i = 0; i < BLOCK_SIZE; i++) block[i] = iblock[i]; - return _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, block); + return REVERSIBLE(zfp) ? _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, block) : _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, block); } diff --git a/src/template/revencode.c b/src/template/revencode.c new file mode 100644 index 000000000..bb0a1f5b6 --- /dev/null +++ b/src/template/revencode.c @@ -0,0 +1,79 @@ +static void _t2(rev_fwd_xform, Int, DIMS)(Int* p); + +/* private functions ------------------------------------------------------- */ + +/* reversible forward lifting transform of 4-vector */ +static void +_t1(rev_fwd_lift, Int)(Int* p, uint s) +{ + Int x, y, z, w; + x = *p; p += s; + y = *p; p += s; + z = *p; p += s; + w = *p; p += s; + + /* + ** high-order Lorenzo transform + ** ( 1 0 0 0) (x) + ** (-1 1 0 0) (y) + ** ( 1 -2 1 0) (z) + ** (-1 3 -3 1) (w) + */ + w -= z; z -= y; y -= x; + w -= z; z -= y; + w -= z; + + p -= s; *p = w; + p -= s; *p = z; + p -= s; *p = y; + p -= s; *p = x; +} + +/* return precision required to encode block reversibly */ +static uint +_t1(rev_precision, UInt)(const UInt* block, uint n) +{ + uint p = 0; + uint s; + /* compute bitwise OR of all values */ + UInt m = 0; + while (n--) + m |= *block++; + /* count trailing zeros via binary search */ + for (s = CHAR_BIT * (uint)sizeof(UInt); m; s /= 2) + if ((UInt)(m << (s - 1))) { + m <<= s - 1; + m <<= 1; + p += s; + } + return p; +} + +/* encode block of integers using reversible algorithm */ +static uint +_t2(rev_encode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock) +{ + int bits; + int prec; + cache_align_(UInt ublock[BLOCK_SIZE]); + /* perform decorrelating transform */ + _t2(rev_fwd_xform, Int, DIMS)(iblock); + /* reorder signed coefficients and convert to unsigned integer */ + _t1(fwd_order, Int)(ublock, iblock, PERM, BLOCK_SIZE); + /* determine and encode number of significant bits */ + prec = _t1(rev_precision, UInt)(ublock, BLOCK_SIZE); + prec = MIN(prec, maxprec); + prec = MAX(prec, 1); + stream_write_bits(stream, prec - 1, PBITS); + /* encode integer coefficients */ + if (BLOCK_SIZE <= 64) + bits = _t1(encode_ints, UInt)(stream, maxbits, prec, ublock, BLOCK_SIZE); + else + bits = _t1(encode_many_ints, UInt)(stream, maxbits, prec, ublock, BLOCK_SIZE); + /* write at least minbits bits by padding with zeros */ + if (bits < minbits) { + stream_pad(stream, minbits - bits); + bits = minbits; + } + return bits; +} diff --git a/src/template/revencode1.c b/src/template/revencode1.c new file mode 100644 index 000000000..1e7b29a41 --- /dev/null +++ b/src/template/revencode1.c @@ -0,0 +1,9 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible forward decorrelating 1D transform */ +static void +_t2(rev_fwd_xform, Int, 1)(Int* p) +{ + /* transform along x */ + _t1(rev_fwd_lift, Int)(p, 1); +} diff --git a/src/template/revencode2.c b/src/template/revencode2.c new file mode 100644 index 000000000..621fc0cc6 --- /dev/null +++ b/src/template/revencode2.c @@ -0,0 +1,14 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible forward decorrelating 2D transform */ +static void +_t2(rev_fwd_xform, Int, 2)(Int* p) +{ + uint x, y; + /* transform along x */ + for (y = 0; y < 4; y++) + _t1(rev_fwd_lift, Int)(p + 4 * y, 1); + /* transform along y */ + for (x = 0; x < 4; x++) + _t1(rev_fwd_lift, Int)(p + 1 * x, 4); +} diff --git a/src/template/revencode3.c b/src/template/revencode3.c new file mode 100644 index 000000000..64d49f19d --- /dev/null +++ b/src/template/revencode3.c @@ -0,0 +1,20 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible forward decorrelating 3D transform */ +static void +_t2(rev_fwd_xform, Int, 3)(Int* p) +{ + uint x, y, z; + /* transform along x */ + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + _t1(rev_fwd_lift, Int)(p + 4 * y + 16 * z, 1); + /* transform along y */ + for (x = 0; x < 4; x++) + for (z = 0; z < 4; z++) + _t1(rev_fwd_lift, Int)(p + 16 * z + 1 * x, 4); + /* transform along z */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + _t1(rev_fwd_lift, Int)(p + 1 * x + 4 * y, 16); +} diff --git a/src/template/revencode4.c b/src/template/revencode4.c new file mode 100644 index 000000000..46e2a465c --- /dev/null +++ b/src/template/revencode4.c @@ -0,0 +1,28 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible forward decorrelating 4D transform */ +static void +_t2(rev_fwd_xform, Int, 4)(Int* p) +{ + uint x, y, z, w; + /* transform along x */ + for (w = 0; w < 4; w++) + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + _t1(rev_fwd_lift, Int)(p + 4 * y + 16 * z + 64 * w, 1); + /* transform along y */ + for (x = 0; x < 4; x++) + for (w = 0; w < 4; w++) + for (z = 0; z < 4; z++) + _t1(rev_fwd_lift, Int)(p + 16 * z + 64 * w + 1 * x, 4); + /* transform along z */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + for (w = 0; w < 4; w++) + _t1(rev_fwd_lift, Int)(p + 64 * w + 1 * x + 4 * y, 16); + /* transform along w */ + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + _t1(rev_fwd_lift, Int)(p + 1 * x + 4 * y + 16 * z, 64); +} diff --git a/src/template/revencodef.c b/src/template/revencodef.c new file mode 100644 index 000000000..4578fc2cb --- /dev/null +++ b/src/template/revencodef.c @@ -0,0 +1,62 @@ +#include + +/* private functions ------------------------------------------------------- */ + +/* reversible forward block-floating-point transform to signed integers */ +static int +_t1(rev_fwd_cast, Scalar)(Int* iblock, const Scalar* fblock, uint n, int emax) +{ + /* compute power-of-two scale factor, s, and its reciprocal, r */ + Scalar s = _t1(quantize, Scalar)(1, emax); + Scalar r = 1 / s; + /* convert to integer and make sure transform is reversible */ + do { + /* convert from float, f, to integer, i = s*f, and back to float, g=i/s */ + volatile Scalar f = *fblock++; + Int i = (Int)(s * f); + volatile Scalar g = r * i; + /* return false if transform is not lossless */ + if (f != g) + return 0; + *iblock++ = i; + } while (--n); + return 1; +} + +/* reinterpret floating values as two's complement integers */ +static void +_t1(rev_fwd_reinterpret, Scalar)(Int* iblock, const Scalar* fblock, uint n) +{ + /* reinterpret floating values as sign-magnitude integers */ + memcpy(iblock, fblock, n * sizeof(*iblock)); + /* convert sign-magnitude integers to two's complement integers */ + while (n--) { + Int x = *iblock; + if (x < 0) + *iblock = (Int)((UInt)x ^ TCMASK); + iblock++; + } +} + +/* encode contiguous floating-point block using reversible algorithm */ +static uint +_t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) +{ + uint bits = 1; + cache_align_(Int iblock[BLOCK_SIZE]); + /* compute maximum exponent */ + int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); + /* perform forward block-floating-point transform */ + if (_t1(rev_fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax)) { + /* transform is reversible; encode exponent */ + uint e = emax + EBIAS; + bits += EBITS; + stream_write_bits(zfp->stream, 2 * e + 1, bits); + } + else { + /* transform is irreversible; reinterpret floating values as integers */ + _t1(rev_fwd_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); + stream_write_bit(zfp->stream, 0); + } + return bits + _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); +} diff --git a/src/traitsd.h b/src/traitsd.h index cc612b493..4dfb271b8 100644 --- a/src/traitsd.h +++ b/src/traitsd.h @@ -4,7 +4,9 @@ #define Int int64 /* corresponding signed integer type */ #define UInt uint64 /* corresponding unsigned integer type */ #define EBITS 11 /* number of exponent bits */ +#define PBITS 6 /* number of bits needed to encode precision */ #define NBMASK UINT64C(0xaaaaaaaaaaaaaaaa) /* negabinary mask */ +#define TCMASK UINT64C(0x7fffffffffffffff) /* two's complement mask */ #define FABS(x) fabs(x) #define FREXP(x, e) frexp(x, e) diff --git a/src/traitsf.h b/src/traitsf.h index ba262ac09..408337e1e 100644 --- a/src/traitsf.h +++ b/src/traitsf.h @@ -4,7 +4,9 @@ #define Int int32 /* corresponding signed integer type */ #define UInt uint32 /* corresponding unsigned integer type */ #define EBITS 8 /* number of exponent bits */ +#define PBITS 5 /* number of bits needed to encode precision */ #define NBMASK 0xaaaaaaaau /* negabinary mask */ +#define TCMASK 0x7fffffffu /* two's complement mask */ #if __STDC_VERSION__ >= 199901L #define FABS(x) fabsf(x) diff --git a/src/traitsi.h b/src/traitsi.h index 1daca09f4..a540fb401 100644 --- a/src/traitsi.h +++ b/src/traitsi.h @@ -3,4 +3,5 @@ #define Scalar int32 /* integer type */ #define Int int32 /* corresponding signed integer type */ #define UInt uint32 /* corresponding unsigned integer type */ +#define PBITS 5 /* number of bits needed to encode precision */ #define NBMASK 0xaaaaaaaau /* negabinary mask */ diff --git a/src/traitsl.h b/src/traitsl.h index c4c853467..ffa01e0b7 100644 --- a/src/traitsl.h +++ b/src/traitsl.h @@ -3,4 +3,5 @@ #define Scalar int64 /* integer type */ #define Int int64 /* corresponding signed integer type */ #define UInt uint64 /* corresponding unsigned integer type */ +#define PBITS 6 /* number of bits needed to encode precision */ #define NBMASK UINT64C(0xaaaaaaaaaaaaaaaa) /* negabinary mask */ diff --git a/src/zfp.c b/src/zfp.c index 0842480ff..6a8e727f1 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -438,6 +438,12 @@ zfp_stream_bit_stream(const zfp_stream* zfp) return zfp->stream; } +int +zfp_stream_is_reversible(const zfp_stream* zfp) +{ + return zfp->minexp < ZFP_MIN_EXP; +} + zfp_mode zfp_stream_compression_mode(const zfp_stream* zfp) { @@ -469,9 +475,16 @@ zfp_stream_compression_mode(const zfp_stream* zfp) if (zfp->minbits <= ZFP_MIN_BITS && zfp->maxbits >= ZFP_MAX_BITS && zfp->maxprec >= ZFP_MAX_PREC && - ZFP_MIN_EXP <= zfp->minexp) + zfp->minexp >= ZFP_MIN_EXP) return zfp_mode_fixed_accuracy; + /* reversible? */ + if (zfp->minbits <= ZFP_MIN_BITS && + zfp->maxbits >= ZFP_MAX_BITS && + zfp->maxprec >= ZFP_MAX_PREC && + zfp->minexp < ZFP_MIN_EXP) + return zfp_mode_reversible; + return zfp_mode_expert; } @@ -485,7 +498,7 @@ zfp_stream_mode(const zfp_stream* zfp) uint minexp; /* common configurations mapped to short representation */ - switch(zfp_stream_compression_mode(zfp)) { + switch (zfp_stream_compression_mode(zfp)) { case zfp_mode_fixed_rate: if (zfp->maxbits <= 2048) /* maxbits is [1, 2048] */ @@ -505,9 +518,15 @@ zfp_stream_mode(const zfp_stream* zfp) case zfp_mode_fixed_accuracy: if (zfp->minexp <= 843) /* minexp is [ZFP_MIN_EXP=-1074, 843] */ - /* [2177, ZFP_MODE_SHORT_MAX=4094] */ + /* returns [2177, ZFP_MODE_SHORT_MAX=4094] */ /* +1 because skipped 2176 */ return (zfp->minexp - ZFP_MIN_EXP) + (2048 + 128 + 1); + else + break; + + case zfp_mode_reversible: + /* returns 2176 */ + return 2048 + 128; default: break; @@ -565,9 +584,13 @@ zfp_stream_maximum_size(const zfp_stream* zfp, const zfp_field* field) return 0; case zfp_type_float: maxbits += 8; + if (zfp_stream_is_reversible(zfp)) + maxbits += 5; break; case zfp_type_double: maxbits += 11; + if (zfp_stream_is_reversible(zfp)) + maxbits += 6; break; default: break; @@ -584,6 +607,15 @@ zfp_stream_set_bit_stream(zfp_stream* zfp, bitstream* stream) zfp->stream = stream; } +void +zfp_stream_set_reversible(zfp_stream* zfp) +{ + zfp->minbits = ZFP_MIN_BITS; + zfp->maxbits = ZFP_MAX_BITS; + zfp->maxprec = ZFP_MAX_PREC; + zfp->minexp = ZFP_MIN_EXP - 1; +} + double zfp_stream_set_rate(zfp_stream* zfp, double rate, zfp_type type, uint dims, int wra) { @@ -645,7 +677,7 @@ zfp_stream_set_mode(zfp_stream* zfp, uint64 mode) int minexp; if (mode <= ZFP_MODE_SHORT_MAX) { - /* 12-bit (short) encoding of one of three modes */ + /* 12-bit (short) encoding of one of four modes */ if (mode < 2048) { /* fixed rate */ minbits = maxbits = (uint)mode + 1; @@ -659,6 +691,13 @@ zfp_stream_set_mode(zfp_stream* zfp, uint64 mode) maxprec = (uint)mode + 1 - (2048); minexp = ZFP_MIN_EXP; } + else if (mode == (2048 + 128)) { + /* reversible */ + minbits = ZFP_MIN_BITS; + maxbits = ZFP_MAX_BITS; + maxprec = ZFP_MAX_PREC; + minexp = ZFP_MIN_EXP - 1; + } else { /* fixed accuracy */ minbits = ZFP_MIN_BITS; diff --git a/utils/zfp.c b/utils/zfp.c index 705f01490..97a621f58 100644 --- a/utils/zfp.c +++ b/utils/zfp.c @@ -101,6 +101,7 @@ usage() fprintf(stderr, " -3 : dimensions for 3D array a[nz][ny][nx]\n"); fprintf(stderr, " -4 : dimensions for 4D array a[nw][nz][ny][nx]\n"); fprintf(stderr, "Compression parameters (needed with -i):\n"); + fprintf(stderr, " -R : reversible (lossless) compression\n"); fprintf(stderr, " -r : fixed rate (# compressed bits per floating-point value)\n"); fprintf(stderr, " -p : fixed precision (# uncompressed bits per value)\n"); fprintf(stderr, " -a : fixed accuracy (absolute error tolerance)\n"); @@ -253,6 +254,9 @@ int main(int argc, char* argv[]) usage(); mode = 'r'; break; + case 'R': + mode = 'R'; + break; case 's': stats = 1; break; @@ -442,6 +446,9 @@ int main(int argc, char* argv[]) /* set (de)compression mode */ switch (mode) { + case 'R': + zfp_stream_set_reversible(zfp); + break; case 'a': zfp_stream_set_accuracy(zfp, tolerance); break; @@ -466,12 +473,12 @@ int main(int argc, char* argv[]) /* specify execution policy */ switch (exec) { - case zfp_exec_cuda: - if (!zfp_stream_set_execution(zfp, exec)) { - fprintf(stderr, "cuda execution not available\n"); - return EXIT_FAILURE; - } - break; + case zfp_exec_cuda: + if (!zfp_stream_set_execution(zfp, exec)) { + fprintf(stderr, "cuda execution not available\n"); + return EXIT_FAILURE; + } + break; case zfp_exec_omp: if (!zfp_stream_set_execution(zfp, exec) || !zfp_stream_set_omp_threads(zfp, threads) || From 76b65c0f67bb32821a38a9aff47f1a9b715ae76f Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 28 Dec 2018 16:04:17 -0800 Subject: [PATCH 048/194] Add lossless decompressor --- src/decode1d.c | 3 +++ src/decode1f.c | 3 +++ src/decode1i.c | 2 ++ src/decode1l.c | 2 ++ src/decode2d.c | 3 +++ src/decode2f.c | 3 +++ src/decode2i.c | 2 ++ src/decode2l.c | 2 ++ src/decode3d.c | 3 +++ src/decode3f.c | 3 +++ src/decode3i.c | 2 ++ src/decode3l.c | 2 ++ src/decode4d.c | 3 +++ src/decode4f.c | 3 +++ src/decode4i.c | 2 ++ src/decode4l.c | 2 ++ src/template/decodef.c | 36 +++++++++++++++---------- src/template/decodei.c | 4 ++- src/template/encodef.c | 14 +++++----- src/template/revdecode.c | 55 +++++++++++++++++++++++++++++++++++++++ src/template/revdecode1.c | 9 +++++++ src/template/revdecode2.c | 14 ++++++++++ src/template/revdecode3.c | 20 ++++++++++++++ src/template/revdecode4.c | 28 ++++++++++++++++++++ src/template/revdecodef.c | 43 ++++++++++++++++++++++++++++++ src/template/revencode.c | 6 ++--- src/template/revencodef.c | 3 ++- 27 files changed, 246 insertions(+), 26 deletions(-) create mode 100644 src/template/revdecode.c create mode 100644 src/template/revdecode1.c create mode 100644 src/template/revdecode2.c create mode 100644 src/template/revdecode3.c create mode 100644 src/template/revdecode4.c create mode 100644 src/template/revdecodef.c diff --git a/src/decode1d.c b/src/decode1d.c index 93756bf2b..eb5f39eb3 100644 --- a/src/decode1d.c +++ b/src/decode1d.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode1.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode1.c" diff --git a/src/decode1f.c b/src/decode1f.c index 55808b474..734a9eb90 100644 --- a/src/decode1f.c +++ b/src/decode1f.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode1.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode1.c" diff --git a/src/decode1i.c b/src/decode1i.c index 22529cc25..73f58e6c0 100644 --- a/src/decode1i.c +++ b/src/decode1i.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode1.c" +#include "template/revdecode.c" +#include "template/revdecode1.c" diff --git a/src/decode1l.c b/src/decode1l.c index b980cc5d6..cedcc532e 100644 --- a/src/decode1l.c +++ b/src/decode1l.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode1.c" +#include "template/revdecode.c" +#include "template/revdecode1.c" diff --git a/src/decode2d.c b/src/decode2d.c index 2f72c9fc6..766fbd059 100644 --- a/src/decode2d.c +++ b/src/decode2d.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode2.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode2.c" diff --git a/src/decode2f.c b/src/decode2f.c index a1caffb2a..2cabdc529 100644 --- a/src/decode2f.c +++ b/src/decode2f.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode2.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode2.c" diff --git a/src/decode2i.c b/src/decode2i.c index 65de16ba8..70a4a5a21 100644 --- a/src/decode2i.c +++ b/src/decode2i.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode2.c" +#include "template/revdecode.c" +#include "template/revdecode2.c" diff --git a/src/decode2l.c b/src/decode2l.c index 0ced03504..93a2cf833 100644 --- a/src/decode2l.c +++ b/src/decode2l.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode2.c" +#include "template/revdecode.c" +#include "template/revdecode2.c" diff --git a/src/decode3d.c b/src/decode3d.c index 918741fc2..0921a3403 100644 --- a/src/decode3d.c +++ b/src/decode3d.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode3.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode3.c" diff --git a/src/decode3f.c b/src/decode3f.c index 30587a770..558c4cee4 100644 --- a/src/decode3f.c +++ b/src/decode3f.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode3.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode3.c" diff --git a/src/decode3i.c b/src/decode3i.c index aa30070dc..46af93e06 100644 --- a/src/decode3i.c +++ b/src/decode3i.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode3.c" +#include "template/revdecode.c" +#include "template/revdecode3.c" diff --git a/src/decode3l.c b/src/decode3l.c index 1796b7935..1e76d171a 100644 --- a/src/decode3l.c +++ b/src/decode3l.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode3.c" +#include "template/revdecode.c" +#include "template/revdecode3.c" diff --git a/src/decode4d.c b/src/decode4d.c index 500e802a6..2c0e64e26 100644 --- a/src/decode4d.c +++ b/src/decode4d.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode4.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode4.c" diff --git a/src/decode4f.c b/src/decode4f.c index de15b84fa..d29fef1ab 100644 --- a/src/decode4f.c +++ b/src/decode4f.c @@ -11,3 +11,6 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode4.c" +#include "template/revdecode.c" +#include "template/revdecodef.c" +#include "template/revdecode4.c" diff --git a/src/decode4i.c b/src/decode4i.c index 1bfe4aaf2..b871eba40 100644 --- a/src/decode4i.c +++ b/src/decode4i.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode4.c" +#include "template/revdecode.c" +#include "template/revdecode4.c" diff --git a/src/decode4l.c b/src/decode4l.c index 950f8a0b1..b37e47e11 100644 --- a/src/decode4l.c +++ b/src/decode4l.c @@ -10,3 +10,5 @@ #include "template/decode.c" #include "template/decodei.c" #include "template/decode4.c" +#include "template/revdecode.c" +#include "template/revdecode4.c" diff --git a/src/template/decodef.c b/src/template/decodef.c index b6abec939..26037892a 100644 --- a/src/template/decodef.c +++ b/src/template/decodef.c @@ -1,6 +1,8 @@ #include #include +static uint _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock); + /* private functions ------------------------------------------------------- */ /* map integer x relative to exponent e to floating-point number */ @@ -22,35 +24,41 @@ _t1(inv_cast, Scalar)(const Int* iblock, Scalar* fblock, uint n, int emax) while (--n); } -/* public functions -------------------------------------------------------- */ - -/* decode contiguous floating-point block */ -uint -_t2(zfp_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) +/* decode contiguous floating-point block using lossy algorithm */ +static uint +_t2(decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) { + uint bits = 1; /* test if block has nonzero values */ if (stream_read_bit(zfp->stream)) { cache_align_(Int iblock[BLOCK_SIZE]); /* decode common exponent */ - uint ebits = EBITS + 1; - int emax = (int)stream_read_bits(zfp->stream, ebits - 1) - EBIAS; + bits += EBITS; + int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS; int maxprec = precision(emax, zfp->maxprec, zfp->minexp, DIMS); /* decode integer block */ - uint bits = _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits - ebits, zfp->maxbits - ebits, maxprec, iblock); + bits += _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, maxprec, iblock); /* perform inverse block-floating-point transform */ _t1(inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); - return ebits + bits; } else { /* set all values to zero */ uint i; for (i = 0; i < BLOCK_SIZE; i++) *fblock++ = 0; - if (zfp->minbits > 1) { - stream_skip(zfp->stream, zfp->minbits - 1); - return zfp->minbits; + if (zfp->minbits > bits) { + stream_skip(zfp->stream, zfp->minbits - bits); + bits = zfp->minbits; } - else - return 1; } + return bits; +} + +/* public functions -------------------------------------------------------- */ + +/* decode contiguous floating-point block */ +uint +_t2(zfp_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) +{ + return REVERSIBLE(zfp) ? _t2(rev_decode_block, Scalar, DIMS)(zfp, fblock) : _t2(decode_block, Scalar, DIMS)(zfp, fblock); } diff --git a/src/template/decodei.c b/src/template/decodei.c index b2fb4f440..ad43581f1 100644 --- a/src/template/decodei.c +++ b/src/template/decodei.c @@ -1,8 +1,10 @@ +static uint _t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock); + /* public functions -------------------------------------------------------- */ /* decode contiguous integer block */ uint _t2(zfp_decode_block, Int, DIMS)(zfp_stream* zfp, Int* iblock) { - return _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock); + return REVERSIBLE(zfp) ? _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock) : _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock); } diff --git a/src/template/encodef.c b/src/template/encodef.c index 1f21db920..5c6ec537d 100644 --- a/src/template/encodef.c +++ b/src/template/encodef.c @@ -54,6 +54,7 @@ _t1(fwd_cast, Scalar)(Int* iblock, const Scalar* fblock, uint n, int emax) static uint _t2(encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) { + uint bits = 1; /* compute maximum exponent */ int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); int maxprec = precision(emax, zfp->maxprec, zfp->minexp, DIMS); @@ -62,23 +63,22 @@ _t2(encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) if (e) { cache_align_(Int iblock[BLOCK_SIZE]); /* encode common exponent; LSB indicates that exponent is nonzero */ - uint bits = EBITS + 1; + bits += EBITS; stream_write_bits(zfp->stream, 2 * e + 1, bits); /* perform forward block-floating-point transform */ _t1(fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); /* encode integer block */ - return bits + _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, maxprec, iblock); + bits += _t2(encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, maxprec, iblock); } else { /* write single zero-bit to indicate that all values are zero */ stream_write_bit(zfp->stream, 0); - if (zfp->minbits > 1) { - stream_pad(zfp->stream, zfp->minbits - 1); - return zfp->minbits; + if (zfp->minbits > bits) { + stream_pad(zfp->stream, zfp->minbits - bits); + bits = zfp->minbits; } - else - return 1; } + return bits; } /* public functions -------------------------------------------------------- */ diff --git a/src/template/revdecode.c b/src/template/revdecode.c new file mode 100644 index 000000000..dd8f260bf --- /dev/null +++ b/src/template/revdecode.c @@ -0,0 +1,55 @@ +static void _t2(rev_inv_xform, Int, DIMS)(Int* p); + +/* private functions ------------------------------------------------------- */ + +/* reversible inverse lifting transform of 4-vector */ +static void +_t1(rev_inv_lift, Int)(Int* p, uint s) +{ + Int x, y, z, w; + x = *p; p += s; + y = *p; p += s; + z = *p; p += s; + w = *p; p += s; + + /* + ** high-order Lorenzo transform (P4 Pascal matrix) + ** ( 1 0 0 0) (x) + ** ( 1 1 0 0) (y) + ** ( 1 2 1 0) (z) + ** ( 1 3 3 1) (w) + */ + w += z; + z += y; w += z; + y += x; z += y; w += z; + + p -= s; *p = w; + p -= s; *p = z; + p -= s; *p = y; + p -= s; *p = x; +} + +/* decode block of integers using reversible algorithm */ +static uint +_t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock) +{ + /* decode number of significant bits */ + int bits = PBITS; + int prec = (int)stream_read_bits(stream, PBITS) + 1; + cache_align_(UInt ublock[BLOCK_SIZE]); + /* decode integer coefficients */ + if (BLOCK_SIZE <= 64) + bits += _t1(decode_ints, UInt)(stream, maxbits - bits, prec, ublock, BLOCK_SIZE); + else + bits += _t1(decode_many_ints, UInt)(stream, maxbits - bits, prec, ublock, BLOCK_SIZE); + /* read at least minbits bits */ + if (bits < minbits) { + stream_skip(stream, minbits - bits); + bits = minbits; + } + /* reorder unsigned coefficients and convert to signed integer */ + _t1(inv_order, Int)(ublock, iblock, PERM, BLOCK_SIZE); + /* perform decorrelating transform */ + _t2(rev_inv_xform, Int, DIMS)(iblock); + return bits; +} diff --git a/src/template/revdecode1.c b/src/template/revdecode1.c new file mode 100644 index 000000000..018a10151 --- /dev/null +++ b/src/template/revdecode1.c @@ -0,0 +1,9 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible inverse decorrelating 1D transform */ +static void +_t2(rev_inv_xform, Int, 1)(Int* p) +{ + /* transform along x */ + _t1(rev_inv_lift, Int)(p, 1); +} diff --git a/src/template/revdecode2.c b/src/template/revdecode2.c new file mode 100644 index 000000000..9cb8669c7 --- /dev/null +++ b/src/template/revdecode2.c @@ -0,0 +1,14 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible inverse decorrelating 2D transform */ +static void +_t2(rev_inv_xform, Int, 2)(Int* p) +{ + uint x, y; + /* transform along y */ + for (x = 0; x < 4; x++) + _t1(rev_inv_lift, Int)(p + 1 * x, 4); + /* transform along x */ + for (y = 0; y < 4; y++) + _t1(rev_inv_lift, Int)(p + 4 * y, 1); +} diff --git a/src/template/revdecode3.c b/src/template/revdecode3.c new file mode 100644 index 000000000..121944371 --- /dev/null +++ b/src/template/revdecode3.c @@ -0,0 +1,20 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible inverse decorrelating 3D transform */ +static void +_t2(rev_inv_xform, Int, 3)(Int* p) +{ + uint x, y, z; + /* transform along z */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + _t1(rev_inv_lift, Int)(p + 1 * x + 4 * y, 16); + /* transform along y */ + for (x = 0; x < 4; x++) + for (z = 0; z < 4; z++) + _t1(rev_inv_lift, Int)(p + 16 * z + 1 * x, 4); + /* transform along x */ + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + _t1(rev_inv_lift, Int)(p + 4 * y + 16 * z, 1); +} diff --git a/src/template/revdecode4.c b/src/template/revdecode4.c new file mode 100644 index 000000000..98a98f80b --- /dev/null +++ b/src/template/revdecode4.c @@ -0,0 +1,28 @@ +/* private functions ------------------------------------------------------- */ + +/* reversible inverse decorrelating 4D transform */ +static void +_t2(rev_inv_xform, Int, 4)(Int* p) +{ + uint x, y, z, w; + /* transform along w */ + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + _t1(rev_inv_lift, Int)(p + 1 * x + 4 * y + 16 * z, 64); + /* transform along z */ + for (y = 0; y < 4; y++) + for (x = 0; x < 4; x++) + for (w = 0; w < 4; w++) + _t1(rev_inv_lift, Int)(p + 64 * w + 1 * x + 4 * y, 16); + /* transform along y */ + for (x = 0; x < 4; x++) + for (w = 0; w < 4; w++) + for (z = 0; z < 4; z++) + _t1(rev_inv_lift, Int)(p + 16 * z + 64 * w + 1 * x, 4); + /* transform along x */ + for (w = 0; w < 4; w++) + for (z = 0; z < 4; z++) + for (y = 0; y < 4; y++) + _t1(rev_inv_lift, Int)(p + 4 * y + 16 * z + 64 * w, 1); +} diff --git a/src/template/revdecodef.c b/src/template/revdecodef.c new file mode 100644 index 000000000..770cc1719 --- /dev/null +++ b/src/template/revdecodef.c @@ -0,0 +1,43 @@ +#include + +/* private functions ------------------------------------------------------- */ + +/* reinterpret two's complement integers as floating values */ +static void +_t1(rev_inv_reinterpret, Scalar)(Int* iblock, Scalar* fblock, uint n) +{ + /* convert two's complement integers to sign-magnitude integers */ + uint i; + for (i = 0; i < n; i++) { + Int x = iblock[i]; + if (x < 0) + iblock[i] = (Int)((UInt)x ^ TCMASK); + } + /* reinterpret sign-magnitude integers as floating values */ + memcpy(fblock, iblock, n * sizeof(*fblock)); +} + +/* decode contiguous floating-point block using reversible algorithm */ +static uint +_t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) +{ + uint bits = 1; + cache_align_(Int iblock[BLOCK_SIZE]); + /* test whether to use block-floating-point transform */ + if (stream_read_bit(zfp->stream)) { + /* decode common exponent */ + bits += EBITS; + int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS; + /* decode integer block */ + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + /* perform inverse block-floating-point transform */ + _t1(inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + } + else { + /* decode integer block */ + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + /* reinterpret integers as floating values */ + _t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); + } + return bits; +} diff --git a/src/template/revencode.c b/src/template/revencode.c index bb0a1f5b6..f76238e98 100644 --- a/src/template/revencode.c +++ b/src/template/revencode.c @@ -53,7 +53,7 @@ _t1(rev_precision, UInt)(const UInt* block, uint n) static uint _t2(rev_encode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock) { - int bits; + int bits = PBITS; int prec; cache_align_(UInt ublock[BLOCK_SIZE]); /* perform decorrelating transform */ @@ -67,9 +67,9 @@ _t2(rev_encode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, in stream_write_bits(stream, prec - 1, PBITS); /* encode integer coefficients */ if (BLOCK_SIZE <= 64) - bits = _t1(encode_ints, UInt)(stream, maxbits, prec, ublock, BLOCK_SIZE); + bits += _t1(encode_ints, UInt)(stream, maxbits - bits, prec, ublock, BLOCK_SIZE); else - bits = _t1(encode_many_ints, UInt)(stream, maxbits, prec, ublock, BLOCK_SIZE); + bits += _t1(encode_many_ints, UInt)(stream, maxbits - bits, prec, ublock, BLOCK_SIZE); /* write at least minbits bits by padding with zeros */ if (bits < minbits) { stream_pad(stream, minbits - bits); diff --git a/src/template/revencodef.c b/src/template/revencodef.c index 4578fc2cb..679e8453b 100644 --- a/src/template/revencodef.c +++ b/src/template/revencodef.c @@ -58,5 +58,6 @@ _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) _t1(rev_fwd_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); stream_write_bit(zfp->stream, 0); } - return bits + _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + bits += _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + return bits; } From 2c0de7586df3fc159fd5b34092a59bfa3df9a418 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 30 Dec 2018 08:42:47 -0800 Subject: [PATCH 049/194] Redefine compression mode to handle reversible compression --- src/zfp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/zfp.c b/src/zfp.c index 6a8e727f1..c7bf7a079 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -461,14 +461,14 @@ zfp_stream_compression_mode(const zfp_stream* zfp) if (zfp->minbits == zfp->maxbits && 1 <= zfp->maxbits && zfp->maxbits <= ZFP_MAX_BITS && zfp->maxprec >= ZFP_MAX_PREC && - zfp->minexp <= ZFP_MIN_EXP) + zfp->minexp == ZFP_MIN_EXP) return zfp_mode_fixed_rate; /* fixed precision? */ if (zfp->minbits <= ZFP_MIN_BITS && zfp->maxbits >= ZFP_MAX_BITS && zfp->maxprec >= 1 && - zfp->minexp <= ZFP_MIN_EXP) + zfp->minexp == ZFP_MIN_EXP) return zfp_mode_fixed_precision; /* fixed accuracy? */ From 94a78dd534e950a9812a36517b60608a2f486211 Mon Sep 17 00:00:00 2001 From: lindstro Date: Wed, 20 Mar 2019 16:40:59 -0700 Subject: [PATCH 050/194] Add reversible compression tests to testzfp --- tests/testzfp.cpp | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/tests/testzfp.cpp b/tests/testzfp.cpp index 883e4d56a..3f80e327c 100644 --- a/tests/testzfp.cpp +++ b/tests/testzfp.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -517,6 +518,68 @@ test_accuracy(zfp_stream* stream, const zfp_field* input, Scalar tolerance, size return failures; } +// test reversible mode +template +inline uint +test_reversible(zfp_stream* stream, const zfp_field* input, size_t bytes) +{ + uint failures = 0; + size_t n = zfp_field_size(input, NULL); + + // allocate memory for compressed data + zfp_stream_set_reversible(stream); + size_t bufsize = zfp_stream_maximum_size(stream, input); + uchar* buffer = new uchar[bufsize]; + bitstream* s = stream_open(buffer, bufsize); + zfp_stream_set_bit_stream(stream, s); + + // perform compression test + std::ostringstream status; + status << " compress: "; + status << " reversible"; + zfp_stream_rewind(stream); + size_t outsize = zfp_compress(stream, input); + double ratio = double(n * sizeof(Scalar)) / outsize; + status << " ratio=" << std::fixed << std::setprecision(3) << std::setw(7) << ratio; + bool pass = true; + // make sure compressed size agrees + if (outsize != bytes) { + status << " [" << outsize << " != " << bytes << "]"; + pass = false; + } + std::cout << std::setw(width) << std::left << status.str() << (pass ? " OK " : "FAIL") << std::endl; + if (!pass) + failures++; + + // perform decompression test + status.str(""); + status << " decompress:"; + status << " reversible"; + Scalar* g = new Scalar[n]; + zfp_field* output = zfp_field_alloc(); + *output = *input; + zfp_field_set_pointer(output, g); + zfp_stream_rewind(stream); + pass = !!zfp_decompress(stream, output); + if (!pass) + status << " [decompression failed]"; + else { + // make sure reconstruction is bit-for-bit exact + pass = !memcmp(zfp_field_pointer(input), zfp_field_pointer(output), n * sizeof(Scalar)); + if (!pass) + status << " [reconstruction differs]"; + } + zfp_field_free(output); + delete[] g; + stream_close(s); + delete[] buffer; + std::cout << std::setw(width) << std::left << status.str() << (pass ? " OK " : "FAIL") << std::endl; + if (!pass) + failures++; + + return failures; +} + // perform 1D differencing template inline void @@ -819,6 +882,44 @@ test(uint dims, ArraySize array_size) failures += test_accuracy(stream, field, tol[i], bytes[array_size][t][dims - 1][i]); } + // test reversible + { + // expected compressed sizes + size_t bytes[2][2][4] = { + // small + { + { + 7144, + 5072, + 6088, + 6864, + }, + { + 7656, + 5200, + 6120, + 6872, + }, + }, + // large + { + { + 24514760, + 12666008, + 14159976, + 17129104, + }, + { + 26611912, + 13190296, + 14291048, + 17161872, + }, + } + }; + failures += test_reversible(stream, field, bytes[array_size][t][dims - 1]); + } + // test compressed array support double emax[2][2][3] = { // small From 4347a41a86cde381c3f810bd114a4a72668498c8 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 21 Mar 2019 19:52:00 -0700 Subject: [PATCH 051/194] Change implementation to handle IEEE signed zeros --- src/decode1d.c | 1 + src/decode1f.c | 1 + src/decode2d.c | 1 + src/decode2f.c | 1 + src/decode3d.c | 1 + src/decode3f.c | 1 + src/decode4d.c | 1 + src/decode4f.c | 1 + src/encode1d.c | 1 + src/encode1f.c | 1 + src/encode2d.c | 1 + src/encode2f.c | 1 + src/encode3d.c | 1 + src/encode3f.c | 1 + src/encode4d.c | 1 + src/encode4f.c | 1 + src/template/codecf.c | 22 ++++++++++++++++++++++ src/template/decodef.c | 22 ---------------------- src/template/revcodecf.c | 11 +++++++++++ src/template/revdecodef.c | 2 +- src/template/revencodef.c | 39 ++++++++++++++++++++++----------------- 21 files changed, 72 insertions(+), 40 deletions(-) create mode 100644 src/template/revcodecf.c diff --git a/src/decode1d.c b/src/decode1d.c index eb5f39eb3..436515a92 100644 --- a/src/decode1d.c +++ b/src/decode1d.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode1.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode1.c" diff --git a/src/decode1f.c b/src/decode1f.c index 734a9eb90..443b8522f 100644 --- a/src/decode1f.c +++ b/src/decode1f.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode1.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode1.c" diff --git a/src/decode2d.c b/src/decode2d.c index 766fbd059..8c3a994d6 100644 --- a/src/decode2d.c +++ b/src/decode2d.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode2.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode2.c" diff --git a/src/decode2f.c b/src/decode2f.c index 2cabdc529..7b3c35cf2 100644 --- a/src/decode2f.c +++ b/src/decode2f.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode2.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode2.c" diff --git a/src/decode3d.c b/src/decode3d.c index 0921a3403..b8cb9d18a 100644 --- a/src/decode3d.c +++ b/src/decode3d.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode3.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode3.c" diff --git a/src/decode3f.c b/src/decode3f.c index 558c4cee4..914c49991 100644 --- a/src/decode3f.c +++ b/src/decode3f.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode3.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode3.c" diff --git a/src/decode4d.c b/src/decode4d.c index 2c0e64e26..ee5b31fcc 100644 --- a/src/decode4d.c +++ b/src/decode4d.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode4.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode4.c" diff --git a/src/decode4f.c b/src/decode4f.c index d29fef1ab..5eb3b900f 100644 --- a/src/decode4f.c +++ b/src/decode4f.c @@ -11,6 +11,7 @@ #include "template/decode.c" #include "template/decodef.c" #include "template/decode4.c" +#include "template/revcodecf.c" #include "template/revdecode.c" #include "template/revdecodef.c" #include "template/revdecode4.c" diff --git a/src/encode1d.c b/src/encode1d.c index dbf84257b..84b9ac8c0 100644 --- a/src/encode1d.c +++ b/src/encode1d.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode1.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode1.c" diff --git a/src/encode1f.c b/src/encode1f.c index 73fdc7663..a57a7cf70 100644 --- a/src/encode1f.c +++ b/src/encode1f.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode1.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode1.c" diff --git a/src/encode2d.c b/src/encode2d.c index 8be98d0cc..50e8dd835 100644 --- a/src/encode2d.c +++ b/src/encode2d.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode2.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode2.c" diff --git a/src/encode2f.c b/src/encode2f.c index c21f170dd..713a74e4d 100644 --- a/src/encode2f.c +++ b/src/encode2f.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode2.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode2.c" diff --git a/src/encode3d.c b/src/encode3d.c index c2cfaba68..16c385e28 100644 --- a/src/encode3d.c +++ b/src/encode3d.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode3.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode3.c" diff --git a/src/encode3f.c b/src/encode3f.c index d966b6f86..1668aff87 100644 --- a/src/encode3f.c +++ b/src/encode3f.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode3.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode3.c" diff --git a/src/encode4d.c b/src/encode4d.c index e5e77a1a6..c82d19a1b 100644 --- a/src/encode4d.c +++ b/src/encode4d.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode4.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode4.c" diff --git a/src/encode4f.c b/src/encode4f.c index 419ded3db..e0ce01469 100644 --- a/src/encode4f.c +++ b/src/encode4f.c @@ -11,6 +11,7 @@ #include "template/encode.c" #include "template/encodef.c" #include "template/encode4.c" +#include "template/revcodecf.c" #include "template/revencode.c" #include "template/revencodef.c" #include "template/revencode4.c" diff --git a/src/template/codecf.c b/src/template/codecf.c index 61003cfb2..bc2cc8082 100644 --- a/src/template/codecf.c +++ b/src/template/codecf.c @@ -1,6 +1,28 @@ +#include +#include + /* maximum number of bit planes to encode */ static uint precision(int maxexp, uint maxprec, int minexp, int dims) { return MIN(maxprec, (uint)MAX(0, maxexp - minexp + 2 * (dims + 1))); } + +/* map integer x relative to exponent e to floating-point number */ +static Scalar +_t1(dequantize, Scalar)(Int x, int e) +{ + return LDEXP((Scalar)x, e - (CHAR_BIT * (int)sizeof(Scalar) - 2)); +} + +/* inverse block-floating-point transform from signed integers */ +static void +_t1(inv_cast, Scalar)(const Int* iblock, Scalar* fblock, uint n, int emax) +{ + /* compute power-of-two scale factor s */ + Scalar s = _t1(dequantize, Scalar)(1, emax); + /* compute p-bit float x = s*y where |y| <= 2^(p-2) - 1 */ + do + *fblock++ = (Scalar)(s * *iblock++); + while (--n); +} diff --git a/src/template/decodef.c b/src/template/decodef.c index 26037892a..5df156381 100644 --- a/src/template/decodef.c +++ b/src/template/decodef.c @@ -1,29 +1,7 @@ -#include -#include - static uint _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock); /* private functions ------------------------------------------------------- */ -/* map integer x relative to exponent e to floating-point number */ -static Scalar -_t1(dequantize, Scalar)(Int x, int e) -{ - return LDEXP((Scalar)x, e - (CHAR_BIT * (int)sizeof(Scalar) - 2)); -} - -/* inverse block-floating-point transform from signed integers */ -static void -_t1(inv_cast, Scalar)(const Int* iblock, Scalar* fblock, uint n, int emax) -{ - /* compute power-of-two scale factor s */ - Scalar s = _t1(dequantize, Scalar)(1, emax); - /* compute p-bit float x = s*y where |y| <= 2^(p-2) - 1 */ - do - *fblock++ = (Scalar)(s * *iblock++); - while (--n); -} - /* decode contiguous floating-point block using lossy algorithm */ static uint _t2(decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) diff --git a/src/template/revcodecf.c b/src/template/revcodecf.c new file mode 100644 index 000000000..ad5f78864 --- /dev/null +++ b/src/template/revcodecf.c @@ -0,0 +1,11 @@ +/* inverse block-floating-point transform from signed integers */ +static void +_t1(rev_inv_cast, Scalar)(const Int* iblock, Scalar* fblock, uint n, int emax) +{ + /* test for all-zero block, which needs special treatment */ + if (emax != -EBIAS) + _t1(inv_cast, Scalar)(iblock, fblock, n, emax); + else + while (n--) + *fblock++ = 0; +} diff --git a/src/template/revdecodef.c b/src/template/revdecodef.c index 770cc1719..caf84fcb7 100644 --- a/src/template/revdecodef.c +++ b/src/template/revdecodef.c @@ -31,7 +31,7 @@ _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) /* decode integer block */ bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); /* perform inverse block-floating-point transform */ - _t1(inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + _t1(rev_inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); } else { /* decode integer block */ diff --git a/src/template/revencodef.c b/src/template/revencodef.c index 679e8453b..650108816 100644 --- a/src/template/revencodef.c +++ b/src/template/revencodef.c @@ -2,25 +2,27 @@ /* private functions ------------------------------------------------------- */ -/* reversible forward block-floating-point transform to signed integers */ +/* test if block-floating-point encoding is reversible */ static int +_t1(rev_fwd_reversible, Scalar)(const Int* iblock, const Scalar* fblock, uint n, int emax) +{ + /* reconstruct block */ + cache_align_(Scalar gblock[BLOCK_SIZE]); + _t1(rev_inv_cast, Scalar)(iblock, gblock, n, emax); + /* perform bit-wise comparison */ + return !memcmp(fblock, gblock, n * sizeof(*fblock)); +} + +/* forward block-floating-point transform to signed integers */ +static void _t1(rev_fwd_cast, Scalar)(Int* iblock, const Scalar* fblock, uint n, int emax) { - /* compute power-of-two scale factor, s, and its reciprocal, r */ - Scalar s = _t1(quantize, Scalar)(1, emax); - Scalar r = 1 / s; - /* convert to integer and make sure transform is reversible */ - do { - /* convert from float, f, to integer, i = s*f, and back to float, g=i/s */ - volatile Scalar f = *fblock++; - Int i = (Int)(s * f); - volatile Scalar g = r * i; - /* return false if transform is not lossless */ - if (f != g) - return 0; - *iblock++ = i; - } while (--n); - return 1; + /* test for all-zero block, which needs special treatment */ + if (emax != -EBIAS) + _t1(fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + else + while (n--) + *iblock++ = 0; } /* reinterpret floating values as two's complement integers */ @@ -47,7 +49,9 @@ _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) /* compute maximum exponent */ int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); /* perform forward block-floating-point transform */ - if (_t1(rev_fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax)) { + _t1(rev_fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + /* test if block-floating-point transform is reversible */ + if (_t1(rev_fwd_reversible, Scalar)(iblock, fblock, BLOCK_SIZE, emax)) { /* transform is reversible; encode exponent */ uint e = emax + EBIAS; bits += EBITS; @@ -58,6 +62,7 @@ _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) _t1(rev_fwd_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); stream_write_bit(zfp->stream, 0); } + /* losslessly encode integers */ bits += _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); return bits; } From cd0c5195dd0f4a521b7df18bfdf55c62b4801a66 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 21 Mar 2019 20:16:37 -0700 Subject: [PATCH 052/194] Update compressed sizes in testzfp --- tests/testzfp.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/testzfp.cpp b/tests/testzfp.cpp index 3f80e327c..4bc8bae70 100644 --- a/tests/testzfp.cpp +++ b/tests/testzfp.cpp @@ -904,16 +904,16 @@ test(uint dims, ArraySize array_size) // large { { - 24514760, - 12666008, - 14159976, - 17129104, + 24514552, + 12665464, + 14159312, + 17128912, }, { - 26611912, - 13190296, - 14291048, - 17161872, + 26611704, + 13189752, + 14290384, + 17161680, }, } }; From ab9d80763409477aba9cea83cd64e5aba9b0abff Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 21 Mar 2019 21:06:39 -0700 Subject: [PATCH 053/194] Add unit tests for reversible compression --- tests/constants/checksums/1dDouble.h | 3 +- tests/constants/checksums/1dFloat.h | 3 +- tests/constants/checksums/1dInt32.h | 9 +++- tests/constants/checksums/1dInt64.h | 9 +++- tests/constants/checksums/2dDouble.h | 3 +- tests/constants/checksums/2dFloat.h | 3 +- tests/constants/checksums/2dInt32.h | 9 +++- tests/constants/checksums/2dInt64.h | 9 +++- tests/constants/checksums/3dDouble.h | 3 +- tests/constants/checksums/3dFloat.h | 3 +- tests/constants/checksums/3dInt32.h | 9 +++- tests/constants/checksums/3dInt64.h | 9 +++- tests/constants/checksums/4dDouble.h | 3 +- tests/constants/checksums/4dFloat.h | 3 +- tests/constants/checksums/4dInt32.h | 9 +++- tests/constants/checksums/4dInt64.h | 9 +++- tests/src/endtoend/serialExecBase.c | 7 +++ tests/src/endtoend/testcases/serial.c | 4 ++ tests/src/endtoend/zfpEndtoendBase.c | 63 +++++++++++++++++++++++++++ 19 files changed, 154 insertions(+), 16 deletions(-) diff --git a/tests/constants/checksums/1dDouble.h b/tests/constants/checksums/1dDouble.h index 20189ddb4..e615a181f 100644 --- a/tests/constants/checksums/1dDouble.h +++ b/tests/constants/checksums/1dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _1dDoubleChecksums[24] = { +static const uint64 _1dDoubleChecksums[25] = { UINT64C(0xb519ca1b83e2b23f), UINT64C(0xd1a4b883363919a6), UINT64C(0x7e0c5012d3011a34), @@ -23,4 +23,5 @@ UINT64C(0x8aaa2c3635420ca1), UINT64C(0x033931390025a6c7), UINT64C(0x1245fb8d26d1004b), UINT64C(0x495d680180ba02ab), +UINT64C(0xb52efb4b3d311d48), }; diff --git a/tests/constants/checksums/1dFloat.h b/tests/constants/checksums/1dFloat.h index 00c5add67..025d6925e 100644 --- a/tests/constants/checksums/1dFloat.h +++ b/tests/constants/checksums/1dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _1dFloatChecksums[24] = { +static const uint64 _1dFloatChecksums[25] = { UINT64C(0xa35730c2), UINT64C(0x40bdf65ac73b115c), UINT64C(0xb4fe1804c2e28f46), @@ -23,4 +23,5 @@ UINT64C(0xe7ab29faf14866d1), UINT64C(0xaef278e8), UINT64C(0x60361242), UINT64C(0x67e8c596), +UINT64C(0x5744d9cb189f77f2), }; diff --git a/tests/constants/checksums/1dInt32.h b/tests/constants/checksums/1dInt32.h index 007be8e99..183255332 100644 --- a/tests/constants/checksums/1dInt32.h +++ b/tests/constants/checksums/1dInt32.h @@ -1,4 +1,4 @@ -static const uint64 _1dInt32Checksums[18] = { +static const uint64 _1dInt32Checksums[25] = { UINT64C(0xf3e7c054), UINT64C(0xc9d92bd5bdfd2c41), UINT64C(0x2b7ac04c5f2c27f9), @@ -17,4 +17,11 @@ UINT64C(0xb90d9da736a534a9), UINT64C(0xae502d39), UINT64C(0xdf369702), UINT64C(0x8e2310b0), +0, +0, +0, +0, +0, +0, +UINT64C(0xcd449c2be8c8a337), }; diff --git a/tests/constants/checksums/1dInt64.h b/tests/constants/checksums/1dInt64.h index f4296d7cc..98962e023 100644 --- a/tests/constants/checksums/1dInt64.h +++ b/tests/constants/checksums/1dInt64.h @@ -1,4 +1,4 @@ -static const uint64 _1dInt64Checksums[18] = { +static const uint64 _1dInt64Checksums[25] = { UINT64C(0x10decbfab896db77), UINT64C(0x103c2fc57809b590), UINT64C(0x5a808f85fa746948), @@ -17,4 +17,11 @@ UINT64C(0x2fa06f3672c34330), UINT64C(0xae502d3900000000), UINT64C(0xdf36970200000000), UINT64C(0xc64d5c7c923c2a4e), +0, +0, +0, +0, +0, +0, +UINT64C(0x718abd28a6b2f034), }; diff --git a/tests/constants/checksums/2dDouble.h b/tests/constants/checksums/2dDouble.h index 953cdb5ba..c1a9a11ad 100644 --- a/tests/constants/checksums/2dDouble.h +++ b/tests/constants/checksums/2dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _2dDoubleChecksums[24] = { +static const uint64 _2dDoubleChecksums[25] = { UINT64C(0x1c772c230f3ccbb4), UINT64C(0xc0a1814da6ce303b), UINT64C(0xf47a9d0740fd12f1), @@ -23,4 +23,5 @@ UINT64C(0x8beb41214f9ee0d6), UINT64C(0x2229f480c522c420), UINT64C(0x25f62aac2713f851), UINT64C(0x94fd382138403fb1), +UINT64C(0x84409b2e2208ed52), }; diff --git a/tests/constants/checksums/2dFloat.h b/tests/constants/checksums/2dFloat.h index 7b4121c7b..6c7fde687 100644 --- a/tests/constants/checksums/2dFloat.h +++ b/tests/constants/checksums/2dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _2dFloatChecksums[24] = { +static const uint64 _2dFloatChecksums[25] = { UINT64C(0xd61ebeeb), UINT64C(0xda4c301a8e0f8cee), UINT64C(0x584942f81bec40fb), @@ -23,4 +23,5 @@ UINT64C(0x53ed9feb9ca6dd1a), UINT64C(0x2e0e3c8b), UINT64C(0xb6a7efcb), UINT64C(0x18bad4a1), +UINT64C(0x95e74840e655e635), }; diff --git a/tests/constants/checksums/2dInt32.h b/tests/constants/checksums/2dInt32.h index 87a9d2936..47eb0d890 100644 --- a/tests/constants/checksums/2dInt32.h +++ b/tests/constants/checksums/2dInt32.h @@ -1,4 +1,4 @@ -static const uint64 _2dInt32Checksums[18] = { +static const uint64 _2dInt32Checksums[25] = { UINT64C(0x94aada73), UINT64C(0x1264830f387e560), UINT64C(0xf09d2faf2ba66c16), @@ -17,4 +17,11 @@ UINT64C(0x298cca6049cda102), UINT64C(0xa0b51de9), UINT64C(0x8d1227ea), UINT64C(0xb331c139), +0, +0, +0, +0, +0, +0, +UINT64C(0x55be045ea7268027), }; diff --git a/tests/constants/checksums/2dInt64.h b/tests/constants/checksums/2dInt64.h index c03e91770..bbb0089c4 100644 --- a/tests/constants/checksums/2dInt64.h +++ b/tests/constants/checksums/2dInt64.h @@ -1,4 +1,4 @@ -static const uint64 _2dInt64Checksums[18] = { +static const uint64 _2dInt64Checksums[25] = { UINT64C(0x60569371027435a7), UINT64C(0x74905e21b1d68ae2), UINT64C(0xc83e2f319f07372e), @@ -17,4 +17,11 @@ UINT64C(0x7abe90820ae730a), UINT64C(0xa0b51de900000000), UINT64C(0x8d1227ea00000000), UINT64C(0x4384aefdd310e015), +0, +0, +0, +0, +0, +0, +UINT64C(0xaced76ad1c2ebb9), }; diff --git a/tests/constants/checksums/3dDouble.h b/tests/constants/checksums/3dDouble.h index 288d29466..fe5daf611 100644 --- a/tests/constants/checksums/3dDouble.h +++ b/tests/constants/checksums/3dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _3dDoubleChecksums[24] = { +static const uint64 _3dDoubleChecksums[25] = { UINT64C(0x5f9e82c4fef6f593), UINT64C(0x20a6c761afd4380b), UINT64C(0x9a658e0fe05b9657), @@ -23,4 +23,5 @@ UINT64C(0x5c056eecba4d5349), UINT64C(0x8eaf0fa126b3de89), UINT64C(0xb0dd4ed6a7196f47), UINT64C(0x3262044561f9cceb), +UINT64C(0x47a68c9cc2f63872), }; diff --git a/tests/constants/checksums/3dFloat.h b/tests/constants/checksums/3dFloat.h index cf05bcd2f..399473060 100644 --- a/tests/constants/checksums/3dFloat.h +++ b/tests/constants/checksums/3dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _3dFloatChecksums[24] = { +static const uint64 _3dFloatChecksums[25] = { UINT64C(0x54572f34), UINT64C(0x6ad38b388f18d118), UINT64C(0x256107e3209389ee), @@ -23,4 +23,5 @@ UINT64C(0x73829fdec12a0374), UINT64C(0x3518c38f), UINT64C(0x4f0985dd), UINT64C(0xcb6afbd), +UINT64C(0x1a250a134f9bac0), }; diff --git a/tests/constants/checksums/3dInt32.h b/tests/constants/checksums/3dInt32.h index bf324195d..bd4390a75 100644 --- a/tests/constants/checksums/3dInt32.h +++ b/tests/constants/checksums/3dInt32.h @@ -1,4 +1,4 @@ -static const uint64 _3dInt32Checksums[18] = { +static const uint64 _3dInt32Checksums[25] = { UINT64C(0xab8e83e9), UINT64C(0xda55ac5950c74c2), UINT64C(0xb85a3bd936a5c392), @@ -17,4 +17,11 @@ UINT64C(0xfe72d7ca4ce4cd2b), UINT64C(0xd2482c01), UINT64C(0x9436e0c7), UINT64C(0xea428b3e), +0, +0, +0, +0, +0, +0, +UINT64C(0xf0ab4d96d89cc545), }; diff --git a/tests/constants/checksums/3dInt64.h b/tests/constants/checksums/3dInt64.h index 8462a4bca..cd5b4ec3b 100644 --- a/tests/constants/checksums/3dInt64.h +++ b/tests/constants/checksums/3dInt64.h @@ -1,4 +1,4 @@ -static const uint64 _3dInt64Checksums[18] = { +static const uint64 _3dInt64Checksums[25] = { UINT64C(0xcc5133515849571c), UINT64C(0x6c0ff959c2207d41), UINT64C(0xd6b771a93e2404f4), @@ -17,4 +17,11 @@ UINT64C(0xa8b1239155fdd8ab), UINT64C(0xd2482c0100000000), UINT64C(0x9436e0c700000000), UINT64C(0xc723b42e1e4f2274), +0, +0, +0, +0, +0, +0, +UINT64C(0x43c8d544f70dccc5), }; diff --git a/tests/constants/checksums/4dDouble.h b/tests/constants/checksums/4dDouble.h index 9de5d4be6..11e89691d 100644 --- a/tests/constants/checksums/4dDouble.h +++ b/tests/constants/checksums/4dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _4dDoubleChecksums[24] = { +static const uint64 _4dDoubleChecksums[25] = { UINT64C(0x61f9b8c3ddcbe9b), UINT64C(0x3bd0d8f2da9e9acf), UINT64C(0x1dbd79f0a52ec95b), @@ -23,4 +23,5 @@ UINT64C(0xb920196fca3513eb), UINT64C(0xb8f1525cd842fbd5), UINT64C(0xb14abd4386fddb81), UINT64C(0x249da35a6e8ca411), +UINT64C(0xdafd40ed6a04ab4a), }; diff --git a/tests/constants/checksums/4dFloat.h b/tests/constants/checksums/4dFloat.h index da08009e2..a3c3162b5 100644 --- a/tests/constants/checksums/4dFloat.h +++ b/tests/constants/checksums/4dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _4dFloatChecksums[24] = { +static const uint64 _4dFloatChecksums[25] = { UINT64C(0x8c5867f7), UINT64C(0x26580b0af77ece38), UINT64C(0xb47c6e115d00b400), @@ -23,4 +23,5 @@ UINT64C(0xedc915189e4764f2), UINT64C(0x83f41e), UINT64C(0x425b2a0d), UINT64C(0x3ca6456a), +UINT64C(0x5dc094bc449a8ee0), }; diff --git a/tests/constants/checksums/4dInt32.h b/tests/constants/checksums/4dInt32.h index a0689111f..b21bb81f1 100644 --- a/tests/constants/checksums/4dInt32.h +++ b/tests/constants/checksums/4dInt32.h @@ -1,4 +1,4 @@ -static const uint64 _4dInt32Checksums[18] = { +static const uint64 _4dInt32Checksums[25] = { UINT64C(0x8b21ff0), UINT64C(0xf89b3fdf64ff5b5b), UINT64C(0x8d094f52b8fd6250), @@ -17,4 +17,11 @@ UINT64C(0xb44975c2cdae2907), UINT64C(0xbd347efd), UINT64C(0x6f0e9866), UINT64C(0x539b74c9), +0, +0, +0, +0, +0, +0, +UINT64C(0x8c888a65b12c884), }; diff --git a/tests/constants/checksums/4dInt64.h b/tests/constants/checksums/4dInt64.h index 16d6bfb7f..3a19e36ca 100644 --- a/tests/constants/checksums/4dInt64.h +++ b/tests/constants/checksums/4dInt64.h @@ -1,4 +1,4 @@ -static const uint64 _4dInt64Checksums[18] = { +static const uint64 _4dInt64Checksums[25] = { UINT64C(0xc9f0cadc2b040375), UINT64C(0xbe695ffaef2d6055), UINT64C(0x3bf1627a5fd514a7), @@ -17,4 +17,11 @@ UINT64C(0xf1324a2092943e33), UINT64C(0xbd347efd00000000), UINT64C(0x6f0e986600000000), UINT64C(0x6b2d4650a70cb4be), +0, +0, +0, +0, +0, +0, +UINT64C(0x6e014f2638fd24d2), }; diff --git a/tests/src/endtoend/serialExecBase.c b/tests/src/endtoend/serialExecBase.c index e57c25b7d..5fc60e8f5 100644 --- a/tests/src/endtoend/serialExecBase.c +++ b/tests/src/endtoend/serialExecBase.c @@ -85,3 +85,10 @@ setupFixedAccuracy2(void **state) return setupChosenZfpMode(state, zfp_mode_fixed_accuracy, 2, AS_IS); } #endif + +/* reversible */ +static int +setupReversible(void **state) +{ + return setupChosenZfpMode(state, zfp_mode_reversible, 0, AS_IS); +} diff --git a/tests/src/endtoend/testcases/serial.c b/tests/src/endtoend/testcases/serial.c index 4f69ba454..b03d0bf3f 100644 --- a/tests/src/endtoend/testcases/serial.c +++ b/tests/src/endtoend/testcases/serial.c @@ -44,3 +44,7 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCo _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressFixedAccuracy_expect_ArrayChecksumMatches), setupFixedAccuracy2, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_CompressedValuesWithinAccuracy), setupFixedAccuracy2, teardown), #endif + +/* reversible */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Array_when_ZfpDecompressReversible_expect_ArrayMatchesBitForBit), setupReversible, teardown), diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 04cfd9c73..33e97ecab 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -289,6 +289,11 @@ setupCompressParam(struct setupVars* bundle, zfp_mode zfpMode, int compressParam break; #endif + case zfp_mode_reversible: + zfp_stream_set_reversible(bundle->stream); + + break; + default: fail_msg("Invalid zfp mode during setupChosenZfpMode()"); break; @@ -424,6 +429,17 @@ _catFunc3(given_, DESCRIPTOR, Array_when_ZfpCompressFixedAccuracy_expect_Bitstre } #endif +static void +_catFunc3(given_, DESCRIPTOR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches)(void **state) +{ + struct setupVars *bundle = *state; + if (zfp_stream_compression_mode(bundle->stream) != zfp_mode_reversible) { + fail_msg("Invalid zfp mode during test"); + } + + assertZfpCompressBitstreamChecksumMatches(state); +} + static void _catFunc3(given_, DESCRIPTOR, ReversedArray_when_ZfpCompressFixedPrecision_expect_BitstreamChecksumMatches)(void **state) { @@ -542,6 +558,42 @@ assertZfpCompressDecompressChecksumMatches(void **state) assert_int_equal(checksum, expectedChecksum); } +static void +assertZfpCompressDecompressArrayMatchesBitForBit(void **state) +{ + struct setupVars *bundle = *state; + zfp_field* field = bundle->field; + zfp_stream* stream = bundle->stream; + + size_t compressedBytes = zfp_compress(stream, field); + assert_int_not_equal(compressedBytes, 0); + + zfp_stream_rewind(stream); + + // zfp_decompress() will write to bundle->decompressedArr + // assert bitstream ends in same location + if (zfp_timer_start(bundle->timer)) { + fail_msg("Unknown platform (none of linux, win, osx)"); + } + size_t result = zfp_decompress(stream, bundle->decompressField); + double time = zfp_timer_stop(bundle->timer); + printf("\t\tDecompress time (s): %lf\n", time); + assert_int_equal(compressedBytes, result); + + // verify that uncompressed and decompressed arrays match bit for bit + switch(bundle->stride) { + case REVERSED: + case INTERLEAVED: + case PERMUTED: + fail_msg("Invalid stride during test"); + break; + + case AS_IS: + assert_memory_equal(bundle->compressedArr, bundle->decompressedArr, bundle->totalRandomGenArrLen * sizeof(Scalar)); + break; + } +} + static void _catFunc3(given_, DESCRIPTOR, Array_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches)(void **state) { @@ -577,6 +629,17 @@ _catFunc3(given_, DESCRIPTOR, Array_when_ZfpDecompressFixedAccuracy_expect_Array } #endif +static void +_catFunc3(given_, DESCRIPTOR, Array_when_ZfpDecompressReversible_expect_ArrayMatchesBitForBit)(void **state) +{ + struct setupVars *bundle = *state; + if (zfp_stream_compression_mode(bundle->stream) != zfp_mode_reversible) { + fail_msg("Invalid zfp mode during test"); + } + + assertZfpCompressDecompressArrayMatchesBitForBit(state); +} + static void _catFunc3(given_, DESCRIPTOR, ReversedArray_when_ZfpDecompressFixedPrecision_expect_ArrayChecksumMatches)(void **state) { From 2f83354b24bbe15858c3a5ce49267bb8651003a7 Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 26 Mar 2019 13:40:07 -0700 Subject: [PATCH 054/194] Add reversible compression mode unit test --- tests/src/misc/testZfpStream.c | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/src/misc/testZfpStream.c b/tests/src/misc/testZfpStream.c index 0a15756c2..70673a0fb 100644 --- a/tests/src/misc/testZfpStream.c +++ b/tests/src/misc/testZfpStream.c @@ -169,6 +169,23 @@ given_zfpStreamSetWithFixedAccuracy_when_zfpStreamCompressionMode_expect_returns } } +static void +given_zfpStreamSetWithReversible_when_zfpStreamCompressionMode_expect_returnsReversibleEnum(void **state) +{ + struct setupVars *bundle = *state; + zfp_stream* stream = bundle->stream; + + setDefaultCompressionParams(stream); + + /* set reversible, assert reversible identified */ + zfp_stream_set_reversible(stream); + + zfp_mode mode = zfp_stream_compression_mode(stream); + if (mode != zfp_mode_reversible) { + fail_msg("Setting zfp_stream with reversible returned zfp_mode enum %u", mode); + } +} + static void given_zfpStreamSetWithExpertParams_when_zfpStreamCompressionMode_expect_returnsExpertEnum(void **state) { @@ -360,6 +377,41 @@ given_zfpStreamSetAccuracyModeVal_when_zfpStreamSetMode_expect_returnsFixedAccur } } +static void +given_zfpStreamSetReversibleModeVal_when_zfpStreamSetMode_expect_returnsReversible_and_compressParamsConserved(void **state) +{ + struct setupVars *bundle = *state; + zfp_stream* stream = bundle->stream; + + zfp_stream_set_reversible(stream); + assert_int_equal(zfp_stream_compression_mode(stream), zfp_mode_reversible); + + /* get mode and compression params */ + uint64 mode = zfp_stream_mode(stream); + uint minbits = stream->minbits; + uint maxbits = stream->maxbits; + uint maxprec = stream->maxprec; + int minexp = stream->minexp; + + /* set expert mode */ + setDefaultCompressionParams(stream); + + /* see that mode is updated correctly */ + zfp_mode zfpMode = zfp_stream_set_mode(stream, mode); + if (zfpMode != zfp_mode_reversible) { + fail_msg("Using reversible mode, zfp_stream_compression_mode() incorrectly returned %u", zfpMode); + } + + /* see that compression params conserved */ + if (stream->minbits != minbits + || stream->maxbits != maxbits + || stream->maxprec != maxprec + || stream->minexp != minexp) { + printf("Using reversible mode, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", mode); + fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); + } +} + static void assertCompressParamsBehaviorThroughSetMode(void **state, zfp_mode expectedMode) { @@ -426,6 +478,7 @@ int main() cmocka_unit_test_setup_teardown(given_zfpStreamSetWithFixedPrecision_when_zfpStreamCompressionMode_expect_returnsFixedPrecisionEnum, setup, teardown), cmocka_unit_test_setup_teardown(given_zfpStreamSetWithMaxPrecision_when_zfpStreamCompressionMode_expect_returnsExpertModeEnum, setup, teardown), cmocka_unit_test_setup_teardown(given_zfpStreamSetWithFixedAccuracy_when_zfpStreamCompressionMode_expect_returnsFixedAccuracyEnum, setup, teardown), + cmocka_unit_test_setup_teardown(given_zfpStreamSetWithReversible_when_zfpStreamCompressionMode_expect_returnsReversibleEnum, setup, teardown), cmocka_unit_test_setup_teardown(given_zfpStreamSetWithExpertParams_when_zfpStreamCompressionMode_expect_returnsExpertEnum, setup, teardown), /* test zfp_stream_set_mode() */ @@ -435,6 +488,7 @@ int main() cmocka_unit_test_setup_teardown(given_zfpStreamSetPrecisionModeVal_when_zfpStreamSetMode_expect_returnsFixedPrecision_and_compressParamsConserved, setup, teardown), cmocka_unit_test_setup_teardown(given_fixedPrecisionMaxPrecModeVal_when_zfpStreamSetMode_expect_returnsExpert_and_compressParamsConserved, setup, teardown), cmocka_unit_test_setup_teardown(given_zfpStreamSetAccuracyModeVal_when_zfpStreamSetMode_expect_returnsFixedAccuracy_and_compressParamsConserved, setup, teardown), + cmocka_unit_test_setup_teardown(given_zfpStreamSetReversibleModeVal_when_zfpStreamSetMode_expect_returnsReversible_and_compressParamsConserved, setup, teardown), cmocka_unit_test_setup_teardown(given_customCompressParamsModeVal_when_zfpStreamSetMode_expect_returnsExpert_and_compressParamsConserved, setup, teardown), cmocka_unit_test_setup_teardown(given_invalidCompressParamsModeVal_when_zfpStreamSetMode_expect_returnsNullMode_and_paramsNotSet, setup, teardown), }; From daf3329603efc1663159c1af215c4b2ea151cfb3 Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 26 Mar 2019 14:16:48 -0700 Subject: [PATCH 055/194] Add OpenMP reversible compression tests --- tests/src/endtoend/ompExecBase.c | 55 ++++++++++++++++++++++++++++++ tests/src/endtoend/testcases/omp.c | 13 +++++++ 2 files changed, 68 insertions(+) diff --git a/tests/src/endtoend/ompExecBase.c b/tests/src/endtoend/ompExecBase.c index 054d01c3e..1448a242e 100644 --- a/tests/src/endtoend/ompExecBase.c +++ b/tests/src/endtoend/ompExecBase.c @@ -766,5 +766,60 @@ setupFixedAccuracy2Param2Thread2Chunk(void **state) #endif +/* reversible */ +static int +setupReversible0Thread0Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 0, 0, AS_IS); +} + +static int +setupReversible0Thread1Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 0, 1, AS_IS); +} + +static int +setupReversible0Thread2Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 0, 2, AS_IS); +} + +static int +setupReversible1Thread0Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 1, 0, AS_IS); +} + +static int +setupReversible1Thread1Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 1, 1, AS_IS); +} + +static int +setupReversible1Thread2Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 1, 2, AS_IS); +} + +static int +setupReversible2Thread0Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 2, 0, AS_IS); +} + +static int +setupReversible2Thread1Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 2, 1, AS_IS); +} + +static int +setupReversible2Thread2Chunk(void **state) +{ + return setupOmpConfig(state, zfp_mode_reversible, 0, 2, 2, AS_IS); +} + // end #ifdef _OPENMP #endif diff --git a/tests/src/endtoend/testcases/omp.c b/tests/src/endtoend/testcases/omp.c index 0c9ad8ddb..e2fd3c1e8 100644 --- a/tests/src/endtoend/testcases/omp.c +++ b/tests/src/endtoend/testcases/omp.c @@ -147,3 +147,16 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_whe _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param2Thread1Chunk, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressFixedAccuracy_expect_BitstreamChecksumMatches), setupFixedAccuracy2Param2Thread2Chunk, teardown), #endif + +/* reversible */ +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible0Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible0Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible0Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible1Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible1Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible1Thread2Chunk, teardown), + +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible2Thread0Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible2Thread1Chunk, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_OpenMP_, DIM_INT_STR, Array_when_ZfpCompressReversible_expect_BitstreamChecksumMatches), setupReversible2Thread2Chunk, teardown), From 8803ce3d27eb754138ad2ecd054e3328d89bc328 Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 26 Mar 2019 14:31:12 -0700 Subject: [PATCH 056/194] Add CUDA reversible compression tests --- tests/src/endtoend/cudaExecBase.c | 6 ++++++ tests/src/endtoend/testcases/cuda.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tests/src/endtoend/cudaExecBase.c b/tests/src/endtoend/cudaExecBase.c index 7beaea75d..131c71359 100644 --- a/tests/src/endtoend/cudaExecBase.c +++ b/tests/src/endtoend/cudaExecBase.c @@ -83,5 +83,11 @@ setupFixedAcc1Param(void **state) return setupCudaConfig(state, zfp_mode_fixed_accuracy, 1, AS_IS); } +static int +setupReversible(void **state) +{ + return setupCudaConfig(state, zfp_mode_reversible, 1, AS_IS); +} + // end #ifdef ZFP_WITH_CUDA #endif diff --git a/tests/src/endtoend/testcases/cuda.c b/tests/src/endtoend/testcases/cuda.c index a9b27d948..87c15cafe 100644 --- a/tests/src/endtoend/testcases/cuda.c +++ b/tests/src/endtoend/testcases/cuda.c @@ -32,3 +32,6 @@ _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedAcc1Param, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupFixedAcc1Param, teardown), #endif + +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpCompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupReversible, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_Cuda_, DIM_INT_STR, Array_when_ZfpDecompressNonFixedRate_expect_BitstreamUntouchedAndReturnsZero), setupReversible, teardown), From 56c28f333cd756c711384ad4346c1a05a8aa4e40 Mon Sep 17 00:00:00 2001 From: lindstro Date: Wed, 27 Mar 2019 19:54:15 -0700 Subject: [PATCH 057/194] Add reversible compression tests for special values --- tests/constants/checksums/1dDouble.h | 12 +- tests/constants/checksums/1dFloat.h | 12 +- tests/constants/checksums/2dDouble.h | 12 +- tests/constants/checksums/2dFloat.h | 12 +- tests/constants/checksums/3dDouble.h | 12 +- tests/constants/checksums/3dFloat.h | 12 +- tests/constants/checksums/4dDouble.h | 12 +- tests/constants/checksums/4dFloat.h | 12 +- tests/src/encode/testcases/block.c | 14 ++ tests/src/encode/zfpEncodeBlockBase.c | 183 ++++++++++++++++++++++++++ 10 files changed, 285 insertions(+), 8 deletions(-) diff --git a/tests/constants/checksums/1dDouble.h b/tests/constants/checksums/1dDouble.h index e615a181f..e6a95a396 100644 --- a/tests/constants/checksums/1dDouble.h +++ b/tests/constants/checksums/1dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _1dDoubleChecksums[25] = { +static const uint64 _1dDoubleChecksums[35] = { UINT64C(0xb519ca1b83e2b23f), UINT64C(0xd1a4b883363919a6), UINT64C(0x7e0c5012d3011a34), @@ -24,4 +24,14 @@ UINT64C(0x033931390025a6c7), UINT64C(0x1245fb8d26d1004b), UINT64C(0x495d680180ba02ab), UINT64C(0xb52efb4b3d311d48), +UINT64C(0x124ea49d), +UINT64C(0xd8ec0196), +UINT64C(0x4d0e7b31), +UINT64C(0x968c943c), +UINT64C(0xa4ee26b63cf59f5c), +UINT64C(0x67f40a6f849d94bd), +UINT64C(0x86c63ebae9734113), +UINT64C(0xbcd1ccf7dae1dba1), +UINT64C(0x56ec4940cceb8804), +UINT64C(0x1867515422127e2f), }; diff --git a/tests/constants/checksums/1dFloat.h b/tests/constants/checksums/1dFloat.h index 025d6925e..e8b6992ef 100644 --- a/tests/constants/checksums/1dFloat.h +++ b/tests/constants/checksums/1dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _1dFloatChecksums[25] = { +static const uint64 _1dFloatChecksums[35] = { UINT64C(0xa35730c2), UINT64C(0x40bdf65ac73b115c), UINT64C(0xb4fe1804c2e28f46), @@ -24,4 +24,14 @@ UINT64C(0xaef278e8), UINT64C(0x60361242), UINT64C(0x67e8c596), UINT64C(0x5744d9cb189f77f2), +UINT64C(0x124ea49d), +UINT64C(0x3dc76a426df35bd5), +UINT64C(0x71d55b096df35bd5), +UINT64C(0x38e46d78496f92ce), +UINT64C(0x145537d79bd68d54), +UINT64C(0x3cb46d2529f2818d), +UINT64C(0x693b49ad9f9b3650), +UINT64C(0xd85929543666eba0), +UINT64C(0xcfe894dff5dfe2d8), +UINT64C(0x5773096eda472ba7), }; diff --git a/tests/constants/checksums/2dDouble.h b/tests/constants/checksums/2dDouble.h index c1a9a11ad..54171c26e 100644 --- a/tests/constants/checksums/2dDouble.h +++ b/tests/constants/checksums/2dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _2dDoubleChecksums[25] = { +static const uint64 _2dDoubleChecksums[35] = { UINT64C(0x1c772c230f3ccbb4), UINT64C(0xc0a1814da6ce303b), UINT64C(0xf47a9d0740fd12f1), @@ -24,4 +24,14 @@ UINT64C(0x2229f480c522c420), UINT64C(0x25f62aac2713f851), UINT64C(0x94fd382138403fb1), UINT64C(0x84409b2e2208ed52), +UINT64C(0x124ea49d), +UINT64C(0x4626d9), +UINT64C(0xaa089aa2), +UINT64C(0x81b10ff0), +UINT64C(0x76b8c6f24e67aa9d), +UINT64C(0x3a218eb7cfb5f28c), +UINT64C(0x4c8646e454cc7ca1), +UINT64C(0x5b2ecd2cd3f246ae), +UINT64C(0x5d33e04895f52c2c), +UINT64C(0x4c8646e4fa027b13), }; diff --git a/tests/constants/checksums/2dFloat.h b/tests/constants/checksums/2dFloat.h index 6c7fde687..b29015fb8 100644 --- a/tests/constants/checksums/2dFloat.h +++ b/tests/constants/checksums/2dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _2dFloatChecksums[25] = { +static const uint64 _2dFloatChecksums[35] = { UINT64C(0xd61ebeeb), UINT64C(0xda4c301a8e0f8cee), UINT64C(0x584942f81bec40fb), @@ -24,4 +24,14 @@ UINT64C(0x2e0e3c8b), UINT64C(0xb6a7efcb), UINT64C(0x18bad4a1), UINT64C(0x95e74840e655e635), +UINT64C(0x124ea49d), +UINT64C(0x675344a56df35bd5), +UINT64C(0x1bab25dd6df35bd5), +UINT64C(0x8dd352ea496f92ce), +UINT64C(0x37a822f439642c7), +UINT64C(0x426c0480596cb0a1), +UINT64C(0x493b927685fe1535), +UINT64C(0xabcd449b6eaf0658), +UINT64C(0xceaa986e01e41415), +UINT64C(0x8e63b6b8bf4a546), }; diff --git a/tests/constants/checksums/3dDouble.h b/tests/constants/checksums/3dDouble.h index fe5daf611..1ea8577a6 100644 --- a/tests/constants/checksums/3dDouble.h +++ b/tests/constants/checksums/3dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _3dDoubleChecksums[25] = { +static const uint64 _3dDoubleChecksums[35] = { UINT64C(0x5f9e82c4fef6f593), UINT64C(0x20a6c761afd4380b), UINT64C(0x9a658e0fe05b9657), @@ -24,4 +24,14 @@ UINT64C(0x8eaf0fa126b3de89), UINT64C(0xb0dd4ed6a7196f47), UINT64C(0x3262044561f9cceb), UINT64C(0x47a68c9cc2f63872), +UINT64C(0x124ea49d), +UINT64C(0x493b92769bfc9c3a), +UINT64C(0x9c9d36f0b02de060), +UINT64C(0x4e4e9b785cfdb744), +UINT64C(0x4a736be9d6ef4479), +UINT64C(0xc1617676fe3fd476), +UINT64C(0x72755bc1c42fe962), +UINT64C(0x1839d8edfd759cf3), +UINT64C(0xdfc7d348becbffe1), +UINT64C(0x7990c34b91497f6a), }; diff --git a/tests/constants/checksums/3dFloat.h b/tests/constants/checksums/3dFloat.h index 399473060..c2f126c8f 100644 --- a/tests/constants/checksums/3dFloat.h +++ b/tests/constants/checksums/3dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _3dFloatChecksums[25] = { +static const uint64 _3dFloatChecksums[35] = { UINT64C(0x54572f34), UINT64C(0x6ad38b388f18d118), UINT64C(0x256107e3209389ee), @@ -24,4 +24,14 @@ UINT64C(0x3518c38f), UINT64C(0x4f0985dd), UINT64C(0xcb6afbd), UINT64C(0x1a250a134f9bac0), +UINT64C(0x124ea49d), +UINT64C(0xfedec6501e94f536), +UINT64C(0x79aaf683912d5939), +UINT64C(0x3cfd853b1871ebb4), +UINT64C(0x5d4e3f9d75421b4c), +UINT64C(0x5b21e0471df7ad14), +UINT64C(0x6d0c8ff8fd2802f9), +UINT64C(0xfe5b35251e448b96), +UINT64C(0xaad6e4a362e2dabd), +UINT64C(0x8099218532b23fb5), }; diff --git a/tests/constants/checksums/4dDouble.h b/tests/constants/checksums/4dDouble.h index 11e89691d..8efd3fbc9 100644 --- a/tests/constants/checksums/4dDouble.h +++ b/tests/constants/checksums/4dDouble.h @@ -1,4 +1,4 @@ -static const uint64 _4dDoubleChecksums[25] = { +static const uint64 _4dDoubleChecksums[35] = { UINT64C(0x61f9b8c3ddcbe9b), UINT64C(0x3bd0d8f2da9e9acf), UINT64C(0x1dbd79f0a52ec95b), @@ -24,4 +24,14 @@ UINT64C(0xb8f1525cd842fbd5), UINT64C(0xb14abd4386fddb81), UINT64C(0x249da35a6e8ca411), UINT64C(0xdafd40ed6a04ab4a), +UINT64C(0x124ea49d), +UINT64C(0xf505d6d583113df9), +UINT64C(0x8126589e360ef55), +UINT64C(0x52300f134ea45f5e), +UINT64C(0x9e3663c6201cc0f6), +UINT64C(0x1fda09d432768733), +UINT64C(0x97cb64bf1f05dd76), +UINT64C(0x4ca76064ebdd3c36), +UINT64C(0xe052a4a55853b1e1), +UINT64C(0x757fede7476e0c0), }; diff --git a/tests/constants/checksums/4dFloat.h b/tests/constants/checksums/4dFloat.h index a3c3162b5..fcfff11b3 100644 --- a/tests/constants/checksums/4dFloat.h +++ b/tests/constants/checksums/4dFloat.h @@ -1,4 +1,4 @@ -static const uint64 _4dFloatChecksums[25] = { +static const uint64 _4dFloatChecksums[35] = { UINT64C(0x8c5867f7), UINT64C(0x26580b0af77ece38), UINT64C(0xb47c6e115d00b400), @@ -24,4 +24,14 @@ UINT64C(0x83f41e), UINT64C(0x425b2a0d), UINT64C(0x3ca6456a), UINT64C(0x5dc094bc449a8ee0), +UINT64C(0x124ea49d), +UINT64C(0x732dc5b52142441d), +UINT64C(0x4a1da930d128bfc1), +UINT64C(0x9dc1c5fe7fc627fc), +UINT64C(0xb0272bb24038313), +UINT64C(0x91e1553b42a44080), +UINT64C(0xa001b96c2a49cc12), +UINT64C(0x1c4b9c6efaa50f17), +UINT64C(0x62737f4cc36c6b59), +UINT64C(0x176df740f30b846a), }; diff --git a/tests/src/encode/testcases/block.c b/tests/src/encode/testcases/block.c index 337c3f547..ffe335bc4 100644 --- a/tests/src/encode/testcases/block.c +++ b/tests/src/encode/testcases/block.c @@ -4,3 +4,17 @@ _cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumM _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_ReturnValReflectsNumBitsWrittenToBitstream), setup, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_BitstreamChecksumMatches), setup, teardown), + +#ifdef FL_PT_DATA +// reversible compression of blocks containing special floating-point values +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial3, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial4, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial5, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial6, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial7, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial8, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches), setupSpecial9, teardown), +#endif diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index a783277fc..df60cce66 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -13,6 +13,7 @@ struct setupVars { Scalar* dataArr; void* buffer; zfp_stream* stream; + int specialValueIndex; }; static void @@ -31,6 +32,59 @@ populateInitialArray(Scalar** dataArrPtr) } } +static void +populateInitialArraySpecial(Scalar** dataArrPtr, int index) +{ + // IEEE-754 special values + static const uint32 special_float_values[] = { + 0x00000000u, // +0 + 0x80000000u, // -0 + 0x00000001u, // +FLT_TRUE_MIN + 0x80000001u, // -FLT_TRUE_MIN + 0x7f7fffffu, // +FLT_MAX + 0xff7fffffu, // -FLT_MAX + 0x7f800000u, // +infinity + 0xff800000u, // -infinity + 0x7fc00000u, // qNaN + 0x7fa00000u, // sNaN + }; + static const uint64 special_double_values[] = { + UINT64C(0x0000000000000000), // +0 + UINT64C(0x8000000000000000), // -0 + UINT64C(0x0000000000000001), // +DBL_TRUE_MIN + UINT64C(0x8000000000000001), // -DBL_TRUE_MIN + UINT64C(0x7fefffffffffffff), // +DBL_MAX + UINT64C(0xffefffffffffffff), // -DBL_MAX + UINT64C(0x7ff0000000000000), // +infinity + UINT64C(0xfff0000000000000), // -infinity + UINT64C(0x7ff8000000000000), // qNaN + UINT64C(0x7ff4000000000000), // sNaN + }; + + *dataArrPtr = malloc(sizeof(Scalar) * BLOCK_SIZE); + assert_non_null(*dataArrPtr); + + for (size_t i = 0; i < BLOCK_SIZE; i++) { +#ifdef FL_PT_DATA + // generate special values + if ((i & 3u) == 0) { + switch(ZFP_TYPE) { + case zfp_type_float: + memcpy((*dataArrPtr) + i, &special_float_values[index], sizeof(Scalar)); + break; + case zfp_type_double: + memcpy((*dataArrPtr) + i, &special_double_values[index], sizeof(Scalar)); + break; + } + } + else + (*dataArrPtr)[i] = 0; +#else + (*dataArrPtr)[i] = nextSignedRandInt(); +#endif + } +} + static void setupZfpStream(struct setupVars* bundle) { @@ -69,6 +123,45 @@ setupZfpStream(struct setupVars* bundle) bundle->stream = stream; } +static void +setupZfpStreamSpecial(struct setupVars* bundle, int index) +{ + zfp_type type = ZFP_TYPE; + zfp_field* field; + switch(DIMS) { + case 1: + field = zfp_field_1d(bundle->dataArr, type, BLOCK_SIDE_LEN); + break; + case 2: + field = zfp_field_2d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + case 3: + field = zfp_field_3d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + case 4: + field = zfp_field_4d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + } + + zfp_stream* stream = zfp_stream_open(NULL); + zfp_stream_set_reversible(stream); + + size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + char* buffer = calloc(bufsizeBytes, sizeof(char)); + assert_non_null(buffer); + + bitstream* s = stream_open(buffer, bufsizeBytes); + assert_non_null(s); + + zfp_stream_set_bit_stream(stream, s); + zfp_stream_rewind(stream); + zfp_field_free(field); + + bundle->buffer = buffer; + bundle->stream = stream; + bundle->specialValueIndex = index; +} + static int setup(void **state) { @@ -79,11 +172,86 @@ setup(void **state) populateInitialArray(&bundle->dataArr); setupZfpStream(bundle); + bundle->specialValueIndex = 0; *state = bundle; return 0; } +static int +setupSpecial(void **state, int specialValueIndex) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + populateInitialArraySpecial(&bundle->dataArr, specialValueIndex); + setupZfpStreamSpecial(bundle, specialValueIndex); + + *state = bundle; + + return 0; +} + +static int +setupSpecial0(void **state) +{ + return setupSpecial(state, 0); +} + +static int +setupSpecial1(void **state) +{ + return setupSpecial(state, 1); +} + +static int +setupSpecial2(void **state) +{ + return setupSpecial(state, 2); +} + +static int +setupSpecial3(void **state) +{ + return setupSpecial(state, 3); +} + +static int +setupSpecial4(void **state) +{ + return setupSpecial(state, 4); +} + +static int +setupSpecial5(void **state) +{ + return setupSpecial(state, 5); +} + +static int +setupSpecial6(void **state) +{ + return setupSpecial(state, 6); +} + +static int +setupSpecial7(void **state) +{ + return setupSpecial(state, 7); +} + +static int +setupSpecial8(void **state) +{ + return setupSpecial(state, 8); +} + +static int +setupSpecial9(void **state) +{ + return setupSpecial(state, 9); +} + static int teardown(void **state) { @@ -134,3 +302,18 @@ _catFunc3(given_, DIM_INT_STR, Block_when_EncodeBlock_expect_BitstreamChecksumMa uint64 expectedChecksum = getChecksumEncodedBlock(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } + +static void +_catFunc3(given_, DIM_INT_STR, Block_when_EncodeSpecialBlock_expect_BitstreamChecksumMatches)(void **state) +{ + struct setupVars *bundle = *state; + zfp_stream* stream = bundle->stream; + bitstream* s = zfp_stream_bit_stream(stream); + + _t2(zfp_encode_block, Scalar, DIMS)(stream, bundle->dataArr); + zfp_stream_flush(stream); + + uint64 checksum = hashBitstream(stream_data(s), stream_size(s)); + uint64 expectedChecksum = getChecksumCompressedBitstream(DIMS, ZFP_TYPE, zfp_mode_reversible, bundle->specialValueIndex + 1); + assert_int_equal(checksum, expectedChecksum); +} From bbf31db79baa3789571e88156a94fe604157ca07 Mon Sep 17 00:00:00 2001 From: lindstro Date: Wed, 27 Mar 2019 19:54:49 -0700 Subject: [PATCH 058/194] Add reversible compression tests for strided layouts --- tests/src/endtoend/zfpEndtoendBase.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index 33e97ecab..bded5f01a 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -580,12 +580,27 @@ assertZfpCompressDecompressArrayMatchesBitForBit(void **state) printf("\t\tDecompress time (s): %lf\n", time); assert_int_equal(compressedBytes, result); + // verify that uncompressed and decompressed arrays match bit for bit switch(bundle->stride) { case REVERSED: case INTERLEAVED: - case PERMUTED: - fail_msg("Invalid stride during test"); + case PERMUTED: { + // test one scalar at a time for bitwise equality + const size_t* n = bundle->randomGenArrSideLen; + int strides[4]; + ptrdiff_t offset = 0; + zfp_field_stride(field, strides); + for (size_t l = (n[3] ? n[3] : 1); l--; offset += strides[3] - n[2]*strides[2]) { + for (size_t k = (n[2] ? n[2] : 1); k--; offset += strides[2] - n[1]*strides[1]) { + for (size_t j = (n[1] ? n[1] : 1); j--; offset += strides[1] - n[0]*strides[0]) { + for (size_t i = (n[0] ? n[0] : 1); i--; offset += strides[0]) { + assert_memory_equal(&bundle->compressedArr[offset], &bundle->decompressedArr[offset], sizeof(Scalar)); + } + } + } + } + } break; case AS_IS: From 7b515cde0e79ccbad6abbb38a723923812d1c585 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 28 Mar 2019 11:06:39 -0700 Subject: [PATCH 059/194] Fix C90 noncompliant code --- tests/src/encode/zfpEncodeBlockBase.c | 3 ++- tests/src/endtoend/zfpEndtoendBase.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/src/encode/zfpEncodeBlockBase.c b/tests/src/encode/zfpEncodeBlockBase.c index df60cce66..92ec4e34e 100644 --- a/tests/src/encode/zfpEncodeBlockBase.c +++ b/tests/src/encode/zfpEncodeBlockBase.c @@ -64,7 +64,8 @@ populateInitialArraySpecial(Scalar** dataArrPtr, int index) *dataArrPtr = malloc(sizeof(Scalar) * BLOCK_SIZE); assert_non_null(*dataArrPtr); - for (size_t i = 0; i < BLOCK_SIZE; i++) { + size_t i; + for (i = 0; i < BLOCK_SIZE; i++) { #ifdef FL_PT_DATA // generate special values if ((i & 3u) == 0) { diff --git a/tests/src/endtoend/zfpEndtoendBase.c b/tests/src/endtoend/zfpEndtoendBase.c index bded5f01a..855f68ba6 100644 --- a/tests/src/endtoend/zfpEndtoendBase.c +++ b/tests/src/endtoend/zfpEndtoendBase.c @@ -590,11 +590,12 @@ assertZfpCompressDecompressArrayMatchesBitForBit(void **state) const size_t* n = bundle->randomGenArrSideLen; int strides[4]; ptrdiff_t offset = 0; + size_t i, j, k, l; zfp_field_stride(field, strides); - for (size_t l = (n[3] ? n[3] : 1); l--; offset += strides[3] - n[2]*strides[2]) { - for (size_t k = (n[2] ? n[2] : 1); k--; offset += strides[2] - n[1]*strides[1]) { - for (size_t j = (n[1] ? n[1] : 1); j--; offset += strides[1] - n[0]*strides[0]) { - for (size_t i = (n[0] ? n[0] : 1); i--; offset += strides[0]) { + for (l = (n[3] ? n[3] : 1); l--; offset += strides[3] - n[2]*strides[2]) { + for (k = (n[2] ? n[2] : 1); k--; offset += strides[2] - n[1]*strides[1]) { + for (j = (n[1] ? n[1] : 1); j--; offset += strides[1] - n[0]*strides[0]) { + for (i = (n[0] ? n[0] : 1); i--; offset += strides[0]) { assert_memory_equal(&bundle->compressedArr[offset], &bundle->decompressedArr[offset], sizeof(Scalar)); } } From 3ecacb62a71380859ba705f48a73547f4923495c Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 28 Mar 2019 11:07:01 -0700 Subject: [PATCH 060/194] Add documentation on reversible compression --- docs/source/algorithm.rst | 34 +++++++++++++++++++++-- docs/source/defs.rst | 1 + docs/source/directions.rst | 14 ++++------ docs/source/faq.rst | 44 ++++++++++++++++++------------ docs/source/high-level-api.rst | 2 +- docs/source/introduction.rst | 7 ++--- docs/source/limitations.rst | 13 ++++----- docs/source/modes.rst | 50 +++++++++++++++++++++++++++------- docs/source/overview.rst | 4 +-- docs/source/zfpcmd.rst | 8 +++++- 10 files changed, 124 insertions(+), 53 deletions(-) diff --git a/docs/source/algorithm.rst b/docs/source/algorithm.rst index 2b485d644..9c486ea0f 100644 --- a/docs/source/algorithm.rst +++ b/docs/source/algorithm.rst @@ -5,14 +5,20 @@ Algorithm ========= +|zfp| uses two different algorithms to support lossy and lossless +compression. These algorithms are described in detail below. + +Lossy Compression +----------------- + The |zfp| lossy compression scheme is based on the idea of breaking a *d*-dimensional array into independent blocks of |4powd| values each, -e.g. |4by4by4| values in three dimensions. Each block is +e.g., |4by4by4| values in three dimensions. Each block is compressed/decompressed entirely independently from all other blocks. In this sense, |zfp| is similar to current hardware texture compression schemes for image coding implemented on graphics cards and mobile devices. -The compression scheme implemented in this version of |zfp| has evolved +The lossy compression scheme implemented in this version of |zfp| has evolved from the method described in the :ref:`original paper `, and can conceptually be thought of as consisting of eight sequential steps (in practice some steps are consolidated or exist only for illustrative @@ -102,3 +108,27 @@ purposes): Various parameters are exposed for controlling the quality and compressed size of a block, and can be specified by the user at a very fine granularity. These parameters are discussed :ref:`here `. + +Lossless Compression +-------------------- + +The reversible (lossless) compression algorithm shares many steps with +the lossy algorithm. The main differences are steps 2, 3, and 8, which are +the only sources of error. Since step 2 may introduce loss in the conversion +to |zfp|'s block-floating-point representation, the reversible algorithm adds +a test to see if this conversion is indeed lossless. It does so by converting +the values back to the source format and testing the result for bitwise +equality with the uncompressed data. If this test passes, then a modified +decorrelating transform is performed in step 3 that uses reversible integer +subtraction operations only. Finally, step 8 is modified so that no one-bits +are truncated in the variable-length bit stream. However, all least +significant bit planes with all-zero bits are truncated, and the number of +encoded bit planes is recorded in step 7. + +If the block-floating-point transform is not lossless, then the reversible +compression algorithm falls back on a simpler scheme that reinterprets +floating-point values as integers via *type punning*. This lossless +conversion from floating-point to integer data replaces step 2, and the +algorithm proceeds from there with step 3. Moreover, this conversion +ensures that special values like infinity, NaNs, and negative zero are +preserved. diff --git a/docs/source/defs.rst b/docs/source/defs.rst index 8d2de55fa..641e01bea 100644 --- a/docs/source/defs.rst +++ b/docs/source/defs.rst @@ -20,3 +20,4 @@ .. |viewsrelease| replace:: 0.5.4 .. |cudarelease| replace:: 0.5.4 .. |cfprelease| replace:: 0.5.4 +.. |revrelease| replace:: 0.5.5 diff --git a/docs/source/directions.rst b/docs/source/directions.rst index fe25e42bf..0cfa17a6a 100644 --- a/docs/source/directions.rst +++ b/docs/source/directions.rst @@ -20,15 +20,11 @@ important features, including: accuracy in nearby valid values. See :ref:`FAQ #7 `. - **Support for NaNs and infinities**. Similar to missing values, some - applications store special IEEE floating-point values that are not yet - supported by |zfp|. In fact, the presence of such values will currently - result in undefined behavior and loss of data for all values within a - block that contains non-finite values. - -- **Lossless compression**. Although |zfp| can usually limit compression - errors to within floating-point roundoff error, some applications demand - bit-for-bit accurate reconstruction. Strategies for lossless compression - are currently being evaluated. + applications store special IEEE floating-point values that are supported + by |zfp| only in :ref:`reversible mode `. + In fact, for all lossy compression modes, the presence of such values will + currently result in undefined behavior and loss of data for all values + within a block that contains non-finite values. - **Progressive decompression**. Streaming large data sets from remote storage for visualization can be time consuming, even when the data is diff --git a/docs/source/faq.rst b/docs/source/faq.rst index cb0874f3d..cfabca22e 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -694,16 +694,23 @@ are leading zeros. Q21: *Does zfp support lossless compression?* -A: Yes, and no. For integer data, |zfp| can with few exceptions ensure -lossless compression. For a given *n*-bit integer type (*n* = 32 or -*n* = 64), consider compressing *p*-bit signed integer data, with the sign -bit counting toward the precision. In other words, there are exactly -2\ :sup:`p` possible signed integers. If the integers are unsigned, then -subtract 2\ :sup:`p-1` first so that they range from |minus|\ 2\ :sup:`p-1` -to 2\ :sup:`p-1` - 1. - -Lossless compression is achieved by first promoting the *p*-bit integers to -*n* - 1 bits (see :ref:`Q8 `) such that all integer values fall in +A: Yes. As of |zfp| |revrelease|, bit-for-bit lossless compression is +supported via the :ref:`reversible compression mode `. +This mode supports both integer and floating-point data. + +In addition, it is sometimes possible to ensure lossless compression using +|zfp|'s fixed-precision and fixed-accuracy modes. For integer data, |zfp| +can with few exceptions ensure lossless compression in +:ref:`fixed-precision mode `. +For a given *n*-bit integer type (*n* = 32 or *n* = 64), consider compressing +*p*-bit signed integer data, with the sign bit counting toward the precision. +In other words, there are exactly 2\ :sup:`p` possible signed integers. If +the integers are unsigned, then subtract 2\ :sup:`p-1` first so that they +range from |minus|\ 2\ :sup:`p-1` to 2\ :sup:`p-1` - 1. + +Lossless integer compression in fixed-precision mode is achieved by first +promoting the *p*-bit integers to *n* - 1 bits (see :ref:`Q8 `) +such that all integer values fall in [|minus|\ 2\ :sup:`30`, +2\ :sup:`30`), when *n* = 32, or in [|minus|\ 2\ :sup:`62`, +2\ :sup:`62`), when *n* = 64. In other words, the *p*-bit integers first need to be shifted left by *n* - *p* - 1 bits. After @@ -728,12 +735,11 @@ and 64-bit integer types. Although lossless compression is possible as long as the precision constraint is met, the precision needed to guarantee no loss is generally much higher -than the precision intrinsic in the uncompressed data, making lossless -compression via |zfp| not competitive with compressors designed for lossless -compression. Lossy integer compression with zfp can, on the other hand, work -fairly well by using fewer than q bits of precision. +than the precision intrinsic in the uncompressed data. Therefore, we +recommend using the :ref:`reversible mode ` when lossless +compression is desired. -Furthermore, the minimum precision, *q*, given above is often larger than what +The minimum precision, *q*, given above is often larger than what is necessary in practice. There are worst-case inputs that do require such large *q* values, but they are quite rare. @@ -743,8 +749,10 @@ applied *d* times in *d* dimensions. Each average of two *p*-bit numbers requires *p* + 1 bits to avoid loss, and each transform can be thought of involving up to four such averaging operations. -For floating-point data, fully lossless compression with |zfp| is unlikely, -albeit possible. If the dynamic range is low or varies slowly such that values +For floating-point data, fully lossless compression with |zfp| usually +requires :ref:`reversible mode `, as the other compression +modes are unlikely to guarantee bit-for-bit exact reconstructions. However, +if the dynamic range is low or varies slowly such that values within a |4powd| block have the same or similar exponent, then the precision gained by discarding the 8 or 11 bits of the common floating-point exponents can offset the precision lost in the decorrelating transform. For @@ -755,6 +763,8 @@ and *q* = 55 + 4 |times| *d* |leq| 64 bits of precision for double-precision data. Of course, the constraint imposed by the available integer precision *n* implies that lossless compression of such data is possible only in 1D for single-precision data and only in 1D and 2D for double-precision data. +Finally, to preserve special values such as negative zero, plus and minues +infinity, and NaNs, reversible mode is needed. ------------------------------------------------------------------------------- diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 055d1474f..effaf1767 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -360,7 +360,7 @@ Compression Parameters Set *precision* for :ref:`fixed-precision mode `. The precision specifies how many uncompressed bits per value to store, and indirectly governs the relative error. The actual precision is - returned, e.g. in case the desired precision is out of range. To + returned, e.g., in case the desired precision is out of range. To preserve a certain floating-point mantissa or integer precision in the decompressed data, see :ref:`FAQ #21 `. diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index 9df1bf2fd..ef70f6833 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -25,10 +25,9 @@ paper: |zfp| was originally designed for floating-point arrays only, but has been extended to also support integer data, and could for instance be used to compress images and quantized volumetric data. To achieve high compression -ratios, |zfp| uses lossy but optionally error-bounded compression. Although -bit-for-bit lossless compression of floating-point data is not always -possible, |zfp| is usually accurate to within machine epsilon in near-lossless -mode. +ratios, |zfp| generally uses lossy but optionally error-bounded compression. +Bit-for-bit lossless compression is also possible through one of |zfp|'s +:ref:`compression modes `. |zfp| works best for 2D and 3D arrays that exhibit spatial correlation, such as continuous fields from physics simulations, images, regularly sampled terrain diff --git a/docs/source/limitations.rst b/docs/source/limitations.rst index 1be607ff0..68f9b39fa 100644 --- a/docs/source/limitations.rst +++ b/docs/source/limitations.rst @@ -13,14 +13,10 @@ Below is a list of known limitations of the current version of |zfp|. See the section on :ref:`directions` for a discussion of planned features that will address some of these limitations. -- The current version of |zfp| allows for near lossless compression through - suitable parameter choices, but no guarantees are made that bit-for-bit - lossless compression is achieved. We envision supporting lossless - compression in a future version. - -- Special values like infinity and NaN are not supported. Subnormal +- Special floating-point values like infinity and NaN are supported in + reversible mode but not in |zfp|'s lossy compression modes. Subnormal floating-point numbers are, however, correctly handled. There is an - implicit assumption that floating point conforms to IEEE, though + implicit assumption that floating point conforms to IEEE-754, though extensions to other floating-point formats should be possible with minor effort. @@ -62,6 +58,9 @@ that will address some of these limitations. opportunities for compression, e.g. if the complex magnitude is constant and only the phase varies. +- Version |omprelease| adds support for OpenMP compression. However, + OpenMP decompression is not yet supported. + - Version |cudarelease| adds support for CUDA compression and decompression. However, only the fixed-rate compression mode is so far supported. diff --git a/docs/source/modes.rst b/docs/source/modes.rst index 2c26e1684..515be06f6 100644 --- a/docs/source/modes.rst +++ b/docs/source/modes.rst @@ -9,12 +9,13 @@ Compression Modes |zfp| accepts one or more parameters for specifying how the data is to be compressed to meet various constraints on accuracy or size. At a high -level, there are four different compression modes that are mutually +level, there are five different compression modes that are mutually exclusive: :ref:`expert `, :ref:`fixed-rate `, -:ref:`fixed-precision `, and -:ref:`fixed-accuracy ` mode. +:ref:`fixed-precision `, +:ref:`fixed-accuracy `, and +:ref:`reversible ` mode. The user has to select one of these modes and its corresponding parameters. In streaming I/O applications, the :ref:`fixed-accuracy mode ` is preferred, as @@ -127,9 +128,9 @@ bits per *value*:: rate = maxbits / 4^d -This rate is specified in the :ref:`zfp executable ` via the -r -option, and programmatically via :c:func:`zfp_stream_set_rate`, as a -floating-point value. Fixed-rate mode can also be achieved via the +This rate is specified in the :ref:`zfp executable ` via the +:option:`-r` option, and programmatically via :c:func:`zfp_stream_set_rate`, +as a floating-point value. Fixed-rate mode can also be achieved via the expert mode interface by setting :: @@ -159,7 +160,7 @@ Fixed-Precision Mode In fixed-precision mode, the number of bits used to encode a block may vary, but the number of bit planes (i.e. the precision) encoded for the transform coefficients is fixed. To achieve the desired precision, -use option -p with the :ref:`zfp executable ` or call +use option :option:`-p` with the :ref:`zfp executable ` or call :c:func:`zfp_stream_set_precision`. In expert mode, fixed precision is achieved by specifying the precision in :c:member:`zfp_stream.maxprec` and fully relaxing the size constraints, i.e., @@ -195,7 +196,7 @@ machine epsilon relative to the largest value within a block.) This error tolerance is not always tight (especially for 3D arrays), but can conservatively be set so that even for worst-case inputs the error tolerance is respected. To achieve fixed accuracy to within 'tolerance', -use option -a with the :ref:`zfp executable ` or call +use option :option:`-a` with the :ref:`zfp executable ` or call :c:func:`zfp_stream_set_accuracy`. The corresponding expert mode parameters are:: @@ -205,7 +206,36 @@ parameters are:: minexp = floor(log2(tolerance)) As in fixed-precision mode, the number of bits used per block is not -fixed but is dictated by the data. Use tolerance = 0 to achieve -near-lossless compression. Fixed-accuracy mode gives the highest quality +fixed but is dictated by the data. Use *tolerance* = 0 to achieve +near-lossless compression (see :ref:`mode-reversible` for guaranteed +lossless compression). Fixed-accuracy mode gives the highest quality (in terms of absolute error) for a given compression rate, and is preferable when random access is not needed. + +.. index:: + single: Compression mode; Reversible mode + single: Lossless compression +.. _mode-reversible: + +Reversible Mode +--------------- + +As of |zfp| |revrelease|, reversible (lossless) compression is supported. +As with the other compression modes, each block is compressed and decompressed +independently, but reversible mode uses a different compression algorithm +that ensures a bit-for-bit identical reconstruction of integer and +floating-point data. For IEEE-754 floating-point data, reversible mode +preserves special values such as subnormals, infinities, NaNs, and +positive and negative zero. + +The expert mode parameters corresponding to reversible mode are:: + + minbits = ZFP_MIN_BITS + maxbits = ZFP_MAX_BITS + maxprec = ZFP_MAX_PREC + minexp < ZFP_MIN_EXP + +Reversible mode is enabled via :c:func:`zfp_set_reversible` and through +the :option:`-R` command-line option in the :ref:`zfp executable `. +It is supported by both the low- and high-level interfaces and by the serial +and OpenMP execution policies, but it is not yet implemented in CUDA. diff --git a/docs/source/overview.rst b/docs/source/overview.rst index 3b57ebc31..f2bd961b0 100644 --- a/docs/source/overview.rst +++ b/docs/source/overview.rst @@ -8,8 +8,8 @@ Overview multidimensional arrays. The compressor is primarily *lossy*, meaning that the numerical values are usually only approximately represented, though the user may specify error tolerances to limit the amount of loss. -:ref:`Lossless compression `, where values are represented -exactly, is possible in some circumstances. +Fully :ref:`lossless compression `, where values are +represented exactly, is also possible. The |zfp| software consists of three main components: a C library for compressing whole arrays (or smaller pieces of arrays); C++ classes diff --git a/docs/source/zfpcmd.rst b/docs/source/zfpcmd.rst index c7cfa15d6..6216780c7 100644 --- a/docs/source/zfpcmd.rst +++ b/docs/source/zfpcmd.rst @@ -178,10 +178,12 @@ was stored using :option:`-h` during compression. Compression parameters ^^^^^^^^^^^^^^^^^^^^^^ +One of the following :ref:`compression modes ` must be selected. + .. option:: -r Specify fixed rate in terms of number of compressed bits per - floating-point value. + integer or floating-point value. .. option:: -p @@ -192,6 +194,10 @@ Compression parameters Specify fixed accuracy in terms of absolute error tolerance. +.. option:: -R + + Reversible (lossless) mode. + .. option:: -c Specify expert mode parameters. From 2ada586dcbf026caf89cc222b153d9bb028aad5a Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 29 Mar 2019 13:08:03 -0700 Subject: [PATCH 061/194] Replace PRIu64 with UINT64PRIu --- tests/src/misc/testZfpStream.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/src/misc/testZfpStream.c b/tests/src/misc/testZfpStream.c index 70673a0fb..2a8734b67 100644 --- a/tests/src/misc/testZfpStream.c +++ b/tests/src/misc/testZfpStream.c @@ -222,7 +222,7 @@ given_zfpStreamDefaultModeVal_when_zfpStreamSetMode_expect_returnsExpertMode_and || stream->maxbits != maxbits || stream->maxprec != maxprec || stream->minexp != minexp) { - printf("Using default params, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", mode); + printf("Using default params, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"UINT64PRIu"\n", mode); fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); } } @@ -266,7 +266,7 @@ given_zfpStreamSetRateModeVal_when_zfpStreamSetMode_expect_returnsFixedRate_and_ || stream->maxbits != maxbits || stream->maxprec != maxprec || stream->minexp != minexp) { - printf("Using fixed rate %d, wra %d, zfp_type %u, in %u dimensions, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", rate, wra, zfpType, dims, mode); + printf("Using fixed rate %d, wra %d, zfp_type %u, in %u dimensions, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"UINT64PRIu"\n", rate, wra, zfpType, dims, mode); fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); } } @@ -308,7 +308,7 @@ given_zfpStreamSetPrecisionModeVal_when_zfpStreamSetMode_expect_returnsFixedPrec || stream->maxbits != maxbits || stream->maxprec != maxprec || stream->minexp != minexp) { - printf("Using fixed precision %u, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", prec, mode); + printf("Using fixed precision %u, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"UINT64PRIu"\n", prec, mode); fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); } } @@ -371,7 +371,7 @@ given_zfpStreamSetAccuracyModeVal_when_zfpStreamSetMode_expect_returnsFixedAccur || stream->maxbits != maxbits || stream->maxprec != maxprec || stream->minexp != minexp) { - printf("Using fixed accuracy 2^(%d), zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", accExp, mode); + printf("Using fixed accuracy 2^(%d), zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"UINT64PRIu"\n", accExp, mode); fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); } } @@ -407,7 +407,7 @@ given_zfpStreamSetReversibleModeVal_when_zfpStreamSetMode_expect_returnsReversib || stream->maxbits != maxbits || stream->maxprec != maxprec || stream->minexp != minexp) { - printf("Using reversible mode, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"PRIu64"\n", mode); + printf("Using reversible mode, zfp_stream_set_mode() incorrectly set compression params when fed zfp_stream_mode() = %"UINT64PRIu"\n", mode); fail_msg("The zfp_stream had (minbits, maxbits, maxprec, minexp) = (%u, %u, %u, %d), but was expected to equal (%u, %u, %u, %d)", stream->minbits, stream->maxbits, stream->maxprec, stream->minexp, minbits, maxbits, maxprec, minexp); } } From ad331f24125669562b18f56c0d06172aa69674b2 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 29 Mar 2019 15:48:58 -0700 Subject: [PATCH 062/194] Add decode unit test for special values --- tests/src/decode/testcases/block.c | 14 ++ tests/src/decode/zfpDecodeBlockBase.c | 188 ++++++++++++++++++++++++++ 2 files changed, 202 insertions(+) diff --git a/tests/src/decode/testcases/block.c b/tests/src/decode/testcases/block.c index 45a085c66..c0ba5edf6 100644 --- a/tests/src/decode/testcases/block.c +++ b/tests/src/decode/testcases/block.c @@ -4,3 +4,17 @@ _cmocka_unit_test_setup_teardown(when_seededRandomDataGenerated_expect_ChecksumM _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ReturnValReflectsNumBitsReadFromBitstream), setup, teardown), _cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ArrayChecksumMatches), setup, teardown), + +#ifdef FL_PT_DATA +// reversible compression and decompression of blocks containing special floating-point values +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial0, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial1, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial2, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial3, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial4, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial5, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial6, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial7, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial8, teardown), +_cmocka_unit_test_setup_teardown(_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit), setupSpecial9, teardown), +#endif diff --git a/tests/src/decode/zfpDecodeBlockBase.c b/tests/src/decode/zfpDecodeBlockBase.c index 6143f15a7..e241e25c0 100644 --- a/tests/src/decode/zfpDecodeBlockBase.c +++ b/tests/src/decode/zfpDecodeBlockBase.c @@ -13,6 +13,7 @@ struct setupVars { Scalar* dataArr; void* buffer; zfp_stream* stream; + int specialValueIndex; }; static void @@ -32,6 +33,60 @@ populateInitialArray(Scalar** dataArrPtr) } +static void +populateInitialArraySpecial(Scalar** dataArrPtr, int index) +{ + // IEEE-754 special values + static const uint32 special_float_values[] = { + 0x00000000u, // +0 + 0x80000000u, // -0 + 0x00000001u, // +FLT_TRUE_MIN + 0x80000001u, // -FLT_TRUE_MIN + 0x7f7fffffu, // +FLT_MAX + 0xff7fffffu, // -FLT_MAX + 0x7f800000u, // +infinity + 0xff800000u, // -infinity + 0x7fc00000u, // qNaN + 0x7fa00000u, // sNaN + }; + static const uint64 special_double_values[] = { + UINT64C(0x0000000000000000), // +0 + UINT64C(0x8000000000000000), // -0 + UINT64C(0x0000000000000001), // +DBL_TRUE_MIN + UINT64C(0x8000000000000001), // -DBL_TRUE_MIN + UINT64C(0x7fefffffffffffff), // +DBL_MAX + UINT64C(0xffefffffffffffff), // -DBL_MAX + UINT64C(0x7ff0000000000000), // +infinity + UINT64C(0xfff0000000000000), // -infinity + UINT64C(0x7ff8000000000000), // qNaN + UINT64C(0x7ff4000000000000), // sNaN + }; + + *dataArrPtr = malloc(sizeof(Scalar) * BLOCK_SIZE); + assert_non_null(*dataArrPtr); + + size_t i; + for (i = 0; i < BLOCK_SIZE; i++) { +#ifdef FL_PT_DATA + // generate special values + if ((i & 3u) == 0) { + switch(ZFP_TYPE) { + case zfp_type_float: + memcpy((*dataArrPtr) + i, &special_float_values[index], sizeof(Scalar)); + break; + case zfp_type_double: + memcpy((*dataArrPtr) + i, &special_double_values[index], sizeof(Scalar)); + break; + } + } + else + (*dataArrPtr)[i] = 0; +#else + (*dataArrPtr)[i] = nextSignedRandInt(); +#endif + } +} + static void setupZfpStream(struct setupVars* bundle) { @@ -70,6 +125,45 @@ setupZfpStream(struct setupVars* bundle) bundle->stream = stream; } +static void +setupZfpStreamSpecial(struct setupVars* bundle, int index) +{ + zfp_type type = ZFP_TYPE; + zfp_field* field; + switch(DIMS) { + case 1: + field = zfp_field_1d(bundle->dataArr, type, BLOCK_SIDE_LEN); + break; + case 2: + field = zfp_field_2d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + case 3: + field = zfp_field_3d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + case 4: + field = zfp_field_4d(bundle->dataArr, type, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN, BLOCK_SIDE_LEN); + break; + } + + zfp_stream* stream = zfp_stream_open(NULL); + zfp_stream_set_reversible(stream); + + size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + char* buffer = calloc(bufsizeBytes, sizeof(char)); + assert_non_null(buffer); + + bitstream* s = stream_open(buffer, bufsizeBytes); + assert_non_null(s); + + zfp_stream_set_bit_stream(stream, s); + zfp_stream_rewind(stream); + zfp_field_free(field); + + bundle->buffer = buffer; + bundle->stream = stream; + bundle->specialValueIndex = index; +} + static int setup(void **state) { @@ -85,6 +179,81 @@ setup(void **state) return 0; } +static int +setupSpecial(void **state, int specialValueIndex) +{ + struct setupVars *bundle = malloc(sizeof(struct setupVars)); + assert_non_null(bundle); + + resetRandGen(); + populateInitialArraySpecial(&bundle->dataArr, specialValueIndex); + setupZfpStreamSpecial(bundle, specialValueIndex); + + *state = bundle; + + return 0; +} + +static int +setupSpecial0(void **state) +{ + return setupSpecial(state, 0); +} + +static int +setupSpecial1(void **state) +{ + return setupSpecial(state, 1); +} + +static int +setupSpecial2(void **state) +{ + return setupSpecial(state, 2); +} + +static int +setupSpecial3(void **state) +{ + return setupSpecial(state, 3); +} + +static int +setupSpecial4(void **state) +{ + return setupSpecial(state, 4); +} + +static int +setupSpecial5(void **state) +{ + return setupSpecial(state, 5); +} + +static int +setupSpecial6(void **state) +{ + return setupSpecial(state, 6); +} + +static int +setupSpecial7(void **state) +{ + return setupSpecial(state, 7); +} + +static int +setupSpecial8(void **state) +{ + return setupSpecial(state, 8); +} + +static int +setupSpecial9(void **state) +{ + return setupSpecial(state, 9); +} + static int teardown(void **state) { @@ -144,3 +313,22 @@ _catFunc3(given_, DIM_INT_STR, Block_when_DecodeBlock_expect_ArrayChecksumMatche uint64 expectedChecksum = getChecksumDecodedBlock(DIMS, ZFP_TYPE); assert_int_equal(checksum, expectedChecksum); } + +static void +_catFunc3(given_, DIM_INT_STR, Block_when_DecodeSpecialBlock_expect_ArrayMatchesBitForBit)(void **state) +{ + struct setupVars *bundle = *state; + zfp_stream* stream = bundle->stream; + + _t2(zfp_encode_block, Scalar, DIMS)(stream, bundle->dataArr); + zfp_stream_flush(stream); + zfp_stream_rewind(stream); + + Scalar* decodedDataArr = calloc(BLOCK_SIZE, sizeof(Scalar)); + assert_non_null(decodedDataArr); + _t2(zfp_decode_block, Scalar, DIMS)(stream, decodedDataArr); + + assert_memory_equal(bundle->dataArr, decodedDataArr, BLOCK_SIZE * sizeof(Scalar)); + + free(decodedDataArr); +} From 10a520d04cc166ea187ce908e84826fe517e04fa Mon Sep 17 00:00:00 2001 From: lindstro Date: Sat, 30 Mar 2019 17:37:44 -0700 Subject: [PATCH 063/194] Minor algorithm change to use single bit for all-zero blocks --- docs/source/algorithm.rst | 30 +++++++++++++------- src/template/revdecodef.c | 41 +++++++++++++++++++--------- src/template/revencodef.c | 22 +++++++++++---- tests/constants/checksums/1dDouble.h | 22 +++++++-------- tests/constants/checksums/1dFloat.h | 22 +++++++-------- tests/constants/checksums/2dDouble.h | 22 +++++++-------- tests/constants/checksums/2dFloat.h | 22 +++++++-------- tests/constants/checksums/3dDouble.h | 22 +++++++-------- tests/constants/checksums/3dFloat.h | 22 +++++++-------- tests/constants/checksums/4dDouble.h | 22 +++++++-------- tests/constants/checksums/4dFloat.h | 22 +++++++-------- tests/testzfp.cpp | 28 +++++++++---------- 12 files changed, 167 insertions(+), 130 deletions(-) diff --git a/docs/source/algorithm.rst b/docs/source/algorithm.rst index 9c486ea0f..abd4388f9 100644 --- a/docs/source/algorithm.rst +++ b/docs/source/algorithm.rst @@ -5,8 +5,11 @@ Algorithm ========= -|zfp| uses two different algorithms to support lossy and lossless -compression. These algorithms are described in detail below. +|zfp| uses two different algorithms to support :ref:`lossy ` +and :ref:`lossless ` compression. These algorithms are +described in detail below. + +.. _algorithm-lossy: Lossy Compression ----------------- @@ -109,26 +112,33 @@ Various parameters are exposed for controlling the quality and compressed size of a block, and can be specified by the user at a very fine granularity. These parameters are discussed :ref:`here `. +.. _algorithm-lossless: + Lossless Compression -------------------- -The reversible (lossless) compression algorithm shares many steps with +The reversible (lossless) compression algorithm shares most steps with the lossy algorithm. The main differences are steps 2, 3, and 8, which are the only sources of error. Since step 2 may introduce loss in the conversion to |zfp|'s block-floating-point representation, the reversible algorithm adds -a test to see if this conversion is indeed lossless. It does so by converting -the values back to the source format and testing the result for bitwise -equality with the uncompressed data. If this test passes, then a modified +a test to see if this conversion is lossless. It does so by converting the +values back to the source format and testing the result for bitwise equality +with the uncompressed data. If this test passes, then a modified decorrelating transform is performed in step 3 that uses reversible integer subtraction operations only. Finally, step 8 is modified so that no one-bits are truncated in the variable-length bit stream. However, all least significant bit planes with all-zero bits are truncated, and the number of -encoded bit planes is recorded in step 7. +encoded bit planes is recorded in step 7. As with lossy compression, a +floating-point block consisting of all (positive) zeros is represented as a +single bit, making it possible to efficiently encode sparse data. If the block-floating-point transform is not lossless, then the reversible compression algorithm falls back on a simpler scheme that reinterprets floating-point values as integers via *type punning*. This lossless conversion from floating-point to integer data replaces step 2, and the -algorithm proceeds from there with step 3. Moreover, this conversion -ensures that special values like infinity, NaNs, and negative zero are -preserved. +algorithm proceeds from there with the modified step 3. Moreover, this +conversion ensures that special values like infinities, NaNs, and negative +zero are preserved. + +The lossless algorithm handles integer data also, in which case step 2 +is omitted. diff --git a/src/template/revdecodef.c b/src/template/revdecodef.c index caf84fcb7..2e8a55805 100644 --- a/src/template/revdecodef.c +++ b/src/template/revdecodef.c @@ -21,23 +21,38 @@ _t1(rev_inv_reinterpret, Scalar)(Int* iblock, Scalar* fblock, uint n) static uint _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) { - uint bits = 1; + uint bits = 0; cache_align_(Int iblock[BLOCK_SIZE]); - /* test whether to use block-floating-point transform */ + /* test whether block is all-zero */ + bits++; if (stream_read_bit(zfp->stream)) { - /* decode common exponent */ - bits += EBITS; - int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS; - /* decode integer block */ - bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); - /* perform inverse block-floating-point transform */ - _t1(rev_inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + /* non-zero block; test whether to use block-floating-point transform */ + bits++; + if (stream_read_bit(zfp->stream)) { + /* decode integer block */ + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + /* reinterpret integers as floating values */ + _t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); + } + else { + /* decode common exponent */ + bits += EBITS; + int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS; + /* decode integer block */ + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + /* perform inverse block-floating-point transform */ + _t1(rev_inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); + } } else { - /* decode integer block */ - bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); - /* reinterpret integers as floating values */ - _t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); + /* all-zero block; set all values to zero */ + uint i; + for (i = 0; i < BLOCK_SIZE; i++) + *fblock++ = 0; + if (zfp->minbits > bits) { + stream_skip(zfp->stream, zfp->minbits - bits); + bits = zfp->minbits; + } } return bits; } diff --git a/src/template/revencodef.c b/src/template/revencodef.c index 650108816..44ef37490 100644 --- a/src/template/revencodef.c +++ b/src/template/revencodef.c @@ -44,7 +44,7 @@ _t1(rev_fwd_reinterpret, Scalar)(Int* iblock, const Scalar* fblock, uint n) static uint _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) { - uint bits = 1; + uint bits = 0; cache_align_(Int iblock[BLOCK_SIZE]); /* compute maximum exponent */ int emax = _t1(exponent_block, Scalar)(fblock, BLOCK_SIZE); @@ -52,15 +52,27 @@ _t2(rev_encode_block, Scalar, DIMS)(zfp_stream* zfp, const Scalar* fblock) _t1(rev_fwd_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); /* test if block-floating-point transform is reversible */ if (_t1(rev_fwd_reversible, Scalar)(iblock, fblock, BLOCK_SIZE, emax)) { - /* transform is reversible; encode exponent */ + /* transform is reversible; test if block has any non-zeros */ uint e = emax + EBIAS; - bits += EBITS; - stream_write_bits(zfp->stream, 2 * e + 1, bits); + if (e) { + /* encode common exponent */ + bits += 2; + stream_write_bits(zfp->stream, 1, 2); + bits += EBITS; + stream_write_bits(zfp->stream, e, EBITS); + } + else { + /* emit single bit for all-zero block */ + bits++; + stream_write_bit(zfp->stream, 0); + return bits; + } } else { /* transform is irreversible; reinterpret floating values as integers */ _t1(rev_fwd_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); - stream_write_bit(zfp->stream, 0); + bits++; + stream_write_bits(zfp->stream, 3, 2); } /* losslessly encode integers */ bits += _t2(rev_encode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); diff --git a/tests/constants/checksums/1dDouble.h b/tests/constants/checksums/1dDouble.h index e6a95a396..49d9dc023 100644 --- a/tests/constants/checksums/1dDouble.h +++ b/tests/constants/checksums/1dDouble.h @@ -23,15 +23,15 @@ UINT64C(0x8aaa2c3635420ca1), UINT64C(0x033931390025a6c7), UINT64C(0x1245fb8d26d1004b), UINT64C(0x495d680180ba02ab), -UINT64C(0xb52efb4b3d311d48), -UINT64C(0x124ea49d), -UINT64C(0xd8ec0196), -UINT64C(0x4d0e7b31), -UINT64C(0x968c943c), -UINT64C(0xa4ee26b63cf59f5c), -UINT64C(0x67f40a6f849d94bd), -UINT64C(0x86c63ebae9734113), -UINT64C(0xbcd1ccf7dae1dba1), -UINT64C(0x56ec4940cceb8804), -UINT64C(0x1867515422127e2f), +UINT64C(0x268fd6fbede5ed59), +UINT64C(0), +UINT64C(0xc1de1da8), +UINT64C(0xeb469308), +UINT64C(0x97d201d8), +UINT64C(0x49dccd6ddfc3e6d0), +UINT64C(0xcfe894df52ba0b77), +UINT64C(0xdac7d74cdcc77f2), +UINT64C(0xaea40aaff9d6d766), +UINT64C(0xadd892805c539502), +UINT64C(0x30cf22a9e4dafb50), }; diff --git a/tests/constants/checksums/1dFloat.h b/tests/constants/checksums/1dFloat.h index e8b6992ef..1fef44a4c 100644 --- a/tests/constants/checksums/1dFloat.h +++ b/tests/constants/checksums/1dFloat.h @@ -23,15 +23,15 @@ UINT64C(0xe7ab29faf14866d1), UINT64C(0xaef278e8), UINT64C(0x60361242), UINT64C(0x67e8c596), -UINT64C(0x5744d9cb189f77f2), -UINT64C(0x124ea49d), -UINT64C(0x3dc76a426df35bd5), -UINT64C(0x71d55b096df35bd5), -UINT64C(0x38e46d78496f92ce), -UINT64C(0x145537d79bd68d54), -UINT64C(0x3cb46d2529f2818d), -UINT64C(0x693b49ad9f9b3650), -UINT64C(0xd85929543666eba0), -UINT64C(0xcfe894dff5dfe2d8), -UINT64C(0x5773096eda472ba7), +UINT64C(0xed4507b04c0b7919), +UINT64C(0), +UINT64C(0x7baad4bceaf3d5c4), +UINT64C(0xe3aab612eaf3d5c4), +UINT64C(0x71d55b09a42ac833), +UINT64C(0x8ca6efaedb5cd44e), +UINT64C(0x15845a4aad908133), +UINT64C(0xd277135bdcf92823), +UINT64C(0xed4fc9b68f3c00b8), +UINT64C(0x9fd129bea6d1bbd5), +UINT64C(0xaee692dd4f340c9f), }; diff --git a/tests/constants/checksums/2dDouble.h b/tests/constants/checksums/2dDouble.h index 54171c26e..513bbf359 100644 --- a/tests/constants/checksums/2dDouble.h +++ b/tests/constants/checksums/2dDouble.h @@ -23,15 +23,15 @@ UINT64C(0x8beb41214f9ee0d6), UINT64C(0x2229f480c522c420), UINT64C(0x25f62aac2713f851), UINT64C(0x94fd382138403fb1), -UINT64C(0x84409b2e2208ed52), -UINT64C(0x124ea49d), -UINT64C(0x4626d9), -UINT64C(0xaa089aa2), -UINT64C(0x81b10ff0), -UINT64C(0x76b8c6f24e67aa9d), -UINT64C(0x3a218eb7cfb5f28c), -UINT64C(0x4c8646e454cc7ca1), -UINT64C(0x5b2ecd2cd3f246ae), -UINT64C(0x5d33e04895f52c2c), -UINT64C(0x4c8646e4fa027b13), +UINT64C(0x1481e46e30d0f3ab), +UINT64C(0), +UINT64C(0x83b0d73d), +UINT64C(0x289bae9d), +UINT64C(0x5d6e57cf), +UINT64C(0x52a77478bd871422), +UINT64C(0x5f99e005089267e0), +UINT64C(0x7d108dc9451d2cb7), +UINT64C(0x34c72b14e6ed9d8c), +UINT64C(0xba67c09098a3d01a), +UINT64C(0x7d108dc9271c8a60), }; diff --git a/tests/constants/checksums/2dFloat.h b/tests/constants/checksums/2dFloat.h index b29015fb8..c8b9d6199 100644 --- a/tests/constants/checksums/2dFloat.h +++ b/tests/constants/checksums/2dFloat.h @@ -23,15 +23,15 @@ UINT64C(0x53ed9feb9ca6dd1a), UINT64C(0x2e0e3c8b), UINT64C(0xb6a7efcb), UINT64C(0x18bad4a1), -UINT64C(0x95e74840e655e635), -UINT64C(0x124ea49d), -UINT64C(0x675344a56df35bd5), -UINT64C(0x1bab25dd6df35bd5), -UINT64C(0x8dd352ea496f92ce), -UINT64C(0x37a822f439642c7), -UINT64C(0x426c0480596cb0a1), -UINT64C(0x493b927685fe1535), -UINT64C(0xabcd449b6eaf0658), -UINT64C(0xceaa986e01e41415), -UINT64C(0x8e63b6b8bf4a546), +UINT64C(0xe91cd56d5db78ef), +UINT64C(0), +UINT64C(0xeabd0942eaf3d5c4), +UINT64C(0x37364bbaeaf3d5c4), +UINT64C(0x1bab25dda42ac833), +UINT64C(0x15efe9eb467df9de), +UINT64C(0x646c26ae1386d3f), +UINT64C(0x927724ec9f90816d), +UINT64C(0x8d27f49059a9fe98), +UINT64C(0x9d4930c42f82c1fb), +UINT64C(0x11acf6d756257748), }; diff --git a/tests/constants/checksums/3dDouble.h b/tests/constants/checksums/3dDouble.h index 1ea8577a6..4adbd2451 100644 --- a/tests/constants/checksums/3dDouble.h +++ b/tests/constants/checksums/3dDouble.h @@ -23,15 +23,15 @@ UINT64C(0x5c056eecba4d5349), UINT64C(0x8eaf0fa126b3de89), UINT64C(0xb0dd4ed6a7196f47), UINT64C(0x3262044561f9cceb), -UINT64C(0x47a68c9cc2f63872), -UINT64C(0x124ea49d), -UINT64C(0x493b92769bfc9c3a), -UINT64C(0x9c9d36f0b02de060), -UINT64C(0x4e4e9b785cfdb744), -UINT64C(0x4a736be9d6ef4479), -UINT64C(0xc1617676fe3fd476), -UINT64C(0x72755bc1c42fe962), -UINT64C(0x1839d8edfd759cf3), -UINT64C(0xdfc7d348becbffe1), -UINT64C(0x7990c34b91497f6a), +UINT64C(0xaf95ff6301796621), +UINT64C(0), +UINT64C(0x927724ecdcf219fb), +UINT64C(0x393a6de095b240e0), +UINT64C(0x9c9d36f01c36b045), +UINT64C(0xa71ba2fe0b649fc), +UINT64C(0x7e8c15054d871bd9), +UINT64C(0xe4eab78245c08a26), +UINT64C(0x5ac46921892607c6), +UINT64C(0xbfb026919c6944c4), +UINT64C(0xf3420697931ed828), }; diff --git a/tests/constants/checksums/3dFloat.h b/tests/constants/checksums/3dFloat.h index c2f126c8f..e9cd36eef 100644 --- a/tests/constants/checksums/3dFloat.h +++ b/tests/constants/checksums/3dFloat.h @@ -23,15 +23,15 @@ UINT64C(0x73829fdec12a0374), UINT64C(0x3518c38f), UINT64C(0x4f0985dd), UINT64C(0xcb6afbd), -UINT64C(0x1a250a134f9bac0), -UINT64C(0x124ea49d), -UINT64C(0xfedec6501e94f536), -UINT64C(0x79aaf683912d5939), -UINT64C(0x3cfd853b1871ebb4), -UINT64C(0x5d4e3f9d75421b4c), -UINT64C(0x5b21e0471df7ad14), -UINT64C(0x6d0c8ff8fd2802f9), -UINT64C(0xfe5b35251e448b96), -UINT64C(0xaad6e4a362e2dabd), -UINT64C(0x8099218532b23fb5), +UINT64C(0xb6475a8758f10fe0), +UINT64C(0), +UINT64C(0x4e0632d046a7a0e), +UINT64C(0xf375ed06da7f218c), +UINT64C(0x79aaf683295b4527), +UINT64C(0xc71006bf172ec200), +UINT64C(0x163602c727dbbba2), +UINT64C(0xda199ff1947e73d2), +UINT64C(0x84db4dd6885773b5), +UINT64C(0x68a0b34799c2f1f8), +UINT64C(0xd4b6310ae6d2d4de), }; diff --git a/tests/constants/checksums/4dDouble.h b/tests/constants/checksums/4dDouble.h index 8efd3fbc9..647afb977 100644 --- a/tests/constants/checksums/4dDouble.h +++ b/tests/constants/checksums/4dDouble.h @@ -23,15 +23,15 @@ UINT64C(0xb920196fca3513eb), UINT64C(0xb8f1525cd842fbd5), UINT64C(0xb14abd4386fddb81), UINT64C(0x249da35a6e8ca411), -UINT64C(0xdafd40ed6a04ab4a), -UINT64C(0x124ea49d), -UINT64C(0xf505d6d583113df9), -UINT64C(0x8126589e360ef55), -UINT64C(0x52300f134ea45f5e), -UINT64C(0x9e3663c6201cc0f6), -UINT64C(0x1fda09d432768733), -UINT64C(0x97cb64bf1f05dd76), -UINT64C(0x4ca76064ebdd3c36), -UINT64C(0xe052a4a55853b1e1), -UINT64C(0x757fede7476e0c0), +UINT64C(0xd72af5ab206ebe50), +UINT64C(0), +UINT64C(0xd7e189562d39c484), +UINT64C(0x10254b13cbda2b97), +UINT64C(0x8126589d3735e9d), +UINT64C(0x81c6ab2ae3cbfbac), +UINT64C(0xb7521b04e50f0123), +UINT64C(0x2d382b62747da555), +UINT64C(0xdff214dccadfe445), +UINT64C(0xdab8e4ea9761352b), +UINT64C(0x65fa916b3e3e928e), }; diff --git a/tests/constants/checksums/4dFloat.h b/tests/constants/checksums/4dFloat.h index fcfff11b3..edd33bcb4 100644 --- a/tests/constants/checksums/4dFloat.h +++ b/tests/constants/checksums/4dFloat.h @@ -23,15 +23,15 @@ UINT64C(0xedc915189e4764f2), UINT64C(0x83f41e), UINT64C(0x425b2a0d), UINT64C(0x3ca6456a), -UINT64C(0x5dc094bc449a8ee0), -UINT64C(0x124ea49d), -UINT64C(0x732dc5b52142441d), -UINT64C(0x4a1da930d128bfc1), -UINT64C(0x9dc1c5fe7fc627fc), -UINT64C(0xb0272bb24038313), -UINT64C(0x91e1553b42a44080), -UINT64C(0xa001b96c2a49cc12), -UINT64C(0x1c4b9c6efaa50f17), -UINT64C(0x62737f4cc36c6b59), -UINT64C(0x176df740f30b846a), +UINT64C(0xf2a9c72c87868054), +UINT64C(0), +UINT64C(0xbd6cb9cd6d2735e7), +UINT64C(0x943b526033810b7b), +UINT64C(0x4a1da930b29a371d), +UINT64C(0x276e4805f1ee4de9), +UINT64C(0xcd3a562a15f5f5e9), +UINT64C(0x241372c19e9d3507), +UINT64C(0xbfeec5a9344e5b48), +UINT64C(0xeac7292d88f982bf), +UINT64C(0x667025a3a09f4198), }; diff --git a/tests/testzfp.cpp b/tests/testzfp.cpp index 4bc8bae70..194b1d8af 100644 --- a/tests/testzfp.cpp +++ b/tests/testzfp.cpp @@ -889,31 +889,31 @@ test(uint dims, ArraySize array_size) // small { { - 7144, - 5072, - 6088, + 7272, + 5104, + 6096, 6864, }, { - 7656, - 5200, - 6120, + 7784, + 5232, + 6128, 6872, }, }, // large { { - 24514552, - 12665464, - 14159312, - 17128912, + 25037288, + 12792440, + 14187128, + 17135704, }, { - 26611704, - 13189752, - 14290384, - 17161680, + 27134024, + 13315632, + 14316880, + 17168096, }, } }; From e86c98856e4b17a2b6efb8ffca07f7e61dc77ab3 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 21 Mar 2019 16:19:27 -0700 Subject: [PATCH 064/194] only build CFP example if CFP itself is built --- examples/CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c879beab6..5b047c3ea 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -2,9 +2,10 @@ add_executable(diffusion diffusion.cpp) target_link_libraries(diffusion zfp) target_compile_definitions(diffusion PRIVATE ${zfp_defs}) -add_executable(diffusionC diffusionC.c) -target_link_libraries(diffusionC cfp) -target_compile_definitions(diffusionC PRIVATE ${zfp_defs}) +if(BUILD_CFP) + add_executable(diffusionC diffusionC.c) + target_link_libraries(diffusionC cfp) +endif() add_executable(inplace inplace.c) target_link_libraries(inplace zfp) @@ -28,7 +29,11 @@ target_compile_definitions(speed PRIVATE ${zfp_defs}) if(HAVE_LIBM_MATH) target_link_libraries(diffusion m) - target_link_libraries(diffusionC m) + + if(BUILD_CFP) + target_link_libraries(diffusionC m) + endif() + target_link_libraries(inplace m) target_link_libraries(pgm m) target_link_libraries(simple m) From d43fabc2a24cf0e66214c7fb543fb61aa4513a77 Mon Sep 17 00:00:00 2001 From: Matt Larsen Date: Wed, 10 Apr 2019 07:39:35 -0700 Subject: [PATCH 065/194] update cuda code to suppress deprecation warning (#57) --- src/cuda_zfp/pointers.cuh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/cuda_zfp/pointers.cuh b/src/cuda_zfp/pointers.cuh index ee8d773bc..63538f0ce 100644 --- a/src/cuda_zfp/pointers.cuh +++ b/src/cuda_zfp/pointers.cuh @@ -10,16 +10,21 @@ namespace cuZFP // https://gitlab.kitware.com/third-party/nvpipe/blob/master/encode.c bool is_gpu_ptr(const void *ptr) { - cudaPointerAttributes atts; + cudaPointerAttributes atts; const cudaError_t perr = cudaPointerGetAttributes(&atts, ptr); - // clear last error so other error checking does + // clear last error so other error checking does // not pick it up cudaError_t error = cudaGetLastError(); - +#if CUDART_VERSION >= 1000 + return perr == cudaSuccess && + (atts.type == cudaMemoryTypeDevice || + atts.type == cudaMemoryTypeManaged); +#else return perr == cudaSuccess && atts.memoryType == cudaMemoryTypeDevice; +#endif } -} // namespace cuZFP +} // namespace cuZFP #endif From 77fed79d846eb3795bcbbac2b30709dc002715f4 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 11 Apr 2018 16:54:50 -0700 Subject: [PATCH 066/194] Add compressed array functions: dimensionality() and scalar_type() --- array/zfparray.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/array/zfparray.h b/array/zfparray.h index 5d5e65f6d..0f363aac6 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -86,6 +86,12 @@ class array { return data; } + // dimensionality + uint dimensionality() const { return dims; } + + // underlying scalar type + zfp_type scalar_type() const { return type; } + protected: // number of values per block uint block_size() const { return 1u << (2 * dims); } From 213dc4b3a7df87392f5aaf4cd92bd1a0c8ead4ae Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 3 Jul 2018 12:01:06 -0700 Subject: [PATCH 067/194] Split array/zfp/memory.h functions to require specified alignment or none. Update existing files using those functions (Many compiler-specific aligned_alloc() and aligned_free() functions) zfp::allocate_aligned() throws std::bad_alloc() if alloc fails --- array/zfp/cache.h | 12 ++--- array/zfp/memory.h | 108 ++++++++++++++++++++++++++++++++++++++------- array/zfparray.h | 6 +-- 3 files changed, 100 insertions(+), 26 deletions(-) diff --git a/array/zfp/cache.h b/array/zfp/cache.h index 280ac7081..6fecba7e2 100644 --- a/array/zfp/cache.h +++ b/array/zfp/cache.h @@ -104,8 +104,8 @@ class Cache { // destructor ~Cache() { - deallocate(tag); - deallocate(line); + deallocate_aligned(tag); + deallocate_aligned(line); #ifdef ZFP_WITH_CACHE_PROFILE std::cerr << "cache R1=" << hit[0][0] << " R2=" << hit[1][0] << " RM=" << miss[0] << " RB=" << back[0] << " W1=" << hit[0][1] << " W2=" << hit[1][1] << " WM=" << miss[1] << " WB=" << back[1] << std::endl; @@ -127,8 +127,8 @@ class Cache { void resize(uint minsize) { for (mask = minsize ? minsize - 1 : 1; mask & (mask + 1); mask |= mask + 1); - reallocate(tag, ((size_t)mask + 1) * sizeof(Tag), 0x100); - reallocate(line, ((size_t)mask + 1) * sizeof(Line), 0x100); + reallocate_aligned(tag, ((size_t)mask + 1) * sizeof(Tag), 0x100); + reallocate_aligned(line, ((size_t)mask + 1) * sizeof(Line), 0x100); clear(); } @@ -209,8 +209,8 @@ class Cache { void deep_copy(const Cache& c) { mask = c.mask; - clone(tag, c.tag, mask + 1, 0x100u); - clone(line, c.line, mask + 1, 0x100u); + clone_aligned(tag, c.tag, mask + 1, 0x100u); + clone_aligned(line, c.line, mask + 1, 0x100u); #ifdef ZFP_WITH_CACHE_PROFILE hit[0][0] = c.hit[0][0]; hit[0][1] = c.hit[0][1]; diff --git a/array/zfp/memory.h b/array/zfp/memory.h index ea20b77f5..b06ffe774 100644 --- a/array/zfp/memory.h +++ b/array/zfp/memory.h @@ -1,24 +1,60 @@ #ifndef ZFP_MEMORY_H #define ZFP_MEMORY_H +#ifdef _WIN32 +extern "C" { + #ifdef __MINGW32__ + #include + #endif + + #include +} +#endif + #include #include #include "zfp/types.h" -// allocate size bytes with optional alignment inline void* -allocate(size_t size, size_t alignment = 0) +allocate(size_t size) +{ + return new uchar[size]; +} + +// allocate size bytes with alignment +inline void* +allocate_aligned(size_t size, size_t alignment) { -#if defined(__USE_XOPEN2K) && defined(ZFP_WITH_ALIGNED_ALLOC) void* ptr; - if (alignment > 1) - posix_memalign(&ptr, alignment, size); - else - ptr = malloc(size); - return ptr; + bool is_mem_failed = false; + +#ifdef ZFP_WITH_ALIGNED_ALLOC + #ifdef __INTEL_COMPILER + ptr = _mm_malloc(size, alignment); + + #elif defined(__MINGW32__) + ptr = __mingw_aligned_malloc(size, alignment); + + #elif defined(_WIN32) + ptr = _aligned_malloc(size, alignment); + + #elif defined(__USE_XOPEN2K) || defined(__MACH__) + is_mem_failed = posix_memalign(&ptr, alignment, size); + + #else + ptr = malloc(size); + + #endif + #else - return new uchar[size]; + ptr = malloc(size); + #endif + + if (is_mem_failed || (ptr == NULL)) + throw std::bad_alloc(); + + return ptr; } // deallocate memory pointed to by ptr @@ -26,31 +62,69 @@ template inline void deallocate(T* ptr) { -#if defined(__USE_XOPEN2K) && defined(ZFP_WITH_ALIGNED_ALLOC) + delete[] ptr; +} + +template +inline void +deallocate_aligned(T* ptr) +{ +#ifdef ZFP_WITH_ALIGNED_ALLOC if (ptr) + #ifdef __INTEL_COMPILER + _mm_free(ptr); + #elif defined(__MINGW32__) + __mingw_aligned_free(ptr); + #elif defined(_WIN32) + _aligned_free(ptr); + #else free(ptr); + #endif + #else - delete[] ptr; + if (ptr) + free(ptr); #endif } -// reallocate size bytes with optional alignment +// reallocate size bytes template inline void -reallocate(T*& ptr, size_t size, size_t alignment = 0) +reallocate(T*& ptr, size_t size) { deallocate(ptr); - ptr = static_cast(allocate(size, alignment)); + ptr = static_cast(allocate(size)); +} + +template +inline void +reallocate_aligned(T*& ptr, size_t size, size_t alignment) +{ + deallocate_aligned(ptr); + ptr = static_cast(allocate_aligned(size, alignment)); } -// clone array 'T src[count]' with optional alignment +// clone array 'T src[count]' template inline void -clone(T*& dst, const T* src, size_t count, size_t alignment = 0) +clone(T*& dst, const T* src, size_t count) { deallocate(dst); if (src) { - dst = static_cast(allocate(count * sizeof(T), alignment)); + dst = static_cast(allocate(count * sizeof(T))); + std::copy(src, src + count, dst); + } + else + dst = 0; +} + +template +inline void +clone_aligned(T*& dst, const T* src, size_t count, size_t alignment) +{ + deallocate_aligned(dst); + if (src) { + dst = static_cast(allocate_aligned(count * sizeof(T), alignment)); std::copy(src, src + count, dst); } else diff --git a/array/zfparray.h b/array/zfparray.h index 0f363aac6..9d0e6befe 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -100,7 +100,7 @@ class array { void alloc(bool clear = true) { bytes = blocks * blkbits / CHAR_BIT; - reallocate(data, bytes, 0x100u); + reallocate_aligned(data, bytes, 0x100u); if (clear) std::fill(data, data + bytes, 0); stream_close(zfp->stream); @@ -117,7 +117,7 @@ class array { stream_close(zfp->stream); zfp_stream_set_bit_stream(zfp, 0); bytes = 0; - deallocate(data); + deallocate_aligned(data); data = 0; deallocate(shape); shape = 0; @@ -140,7 +140,7 @@ class array { bytes = a.bytes; // copy dynamically allocated data - clone(data, a.data, bytes, 0x100u); + clone_aligned(data, a.data, bytes, 0x100u); if (zfp) { if (zfp->stream) stream_close(zfp->stream); From 55e08a7048b1f24c4e77189ca2316252d6f3ec5f Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 24 Jul 2018 14:08:03 -0700 Subject: [PATCH 068/194] Place compressed-array internal functions into zfp namespace --- array/zfp/cache.h | 16 ++++++++++------ array/zfp/memory.h | 20 ++++++++++++-------- array/zfparray.h | 10 +++++----- array/zfparray1.h | 10 +++++----- array/zfparray2.h | 10 +++++----- array/zfparray3.h | 10 +++++----- 6 files changed, 42 insertions(+), 34 deletions(-) diff --git a/array/zfp/cache.h b/array/zfp/cache.h index 6fecba7e2..3630910a0 100644 --- a/array/zfp/cache.h +++ b/array/zfp/cache.h @@ -8,6 +8,8 @@ #include #endif +namespace zfp { + // direct-mapped or two-way skew-associative write-back cache template class Cache { @@ -104,8 +106,8 @@ class Cache { // destructor ~Cache() { - deallocate_aligned(tag); - deallocate_aligned(line); + zfp::deallocate_aligned(tag); + zfp::deallocate_aligned(line); #ifdef ZFP_WITH_CACHE_PROFILE std::cerr << "cache R1=" << hit[0][0] << " R2=" << hit[1][0] << " RM=" << miss[0] << " RB=" << back[0] << " W1=" << hit[0][1] << " W2=" << hit[1][1] << " WM=" << miss[1] << " WB=" << back[1] << std::endl; @@ -127,8 +129,8 @@ class Cache { void resize(uint minsize) { for (mask = minsize ? minsize - 1 : 1; mask & (mask + 1); mask |= mask + 1); - reallocate_aligned(tag, ((size_t)mask + 1) * sizeof(Tag), 0x100); - reallocate_aligned(line, ((size_t)mask + 1) * sizeof(Line), 0x100); + zfp::reallocate_aligned(tag, ((size_t)mask + 1) * sizeof(Tag), 0x100); + zfp::reallocate_aligned(line, ((size_t)mask + 1) * sizeof(Line), 0x100); clear(); } @@ -209,8 +211,8 @@ class Cache { void deep_copy(const Cache& c) { mask = c.mask; - clone_aligned(tag, c.tag, mask + 1, 0x100u); - clone_aligned(line, c.line, mask + 1, 0x100u); + zfp::clone_aligned(tag, c.tag, mask + 1, 0x100u); + zfp::clone_aligned(line, c.line, mask + 1, 0x100u); #ifdef ZFP_WITH_CACHE_PROFILE hit[0][0] = c.hit[0][0]; hit[0][1] = c.hit[0][1]; @@ -254,4 +256,6 @@ class Cache { #endif }; +} + #endif diff --git a/array/zfp/memory.h b/array/zfp/memory.h index b06ffe774..32963c737 100644 --- a/array/zfp/memory.h +++ b/array/zfp/memory.h @@ -15,6 +15,8 @@ extern "C" { #include #include "zfp/types.h" +namespace zfp { + inline void* allocate(size_t size) { @@ -92,16 +94,16 @@ template inline void reallocate(T*& ptr, size_t size) { - deallocate(ptr); - ptr = static_cast(allocate(size)); + zfp::deallocate(ptr); + ptr = static_cast(zfp::allocate(size)); } template inline void reallocate_aligned(T*& ptr, size_t size, size_t alignment) { - deallocate_aligned(ptr); - ptr = static_cast(allocate_aligned(size, alignment)); + zfp::deallocate_aligned(ptr); + ptr = static_cast(zfp::allocate_aligned(size, alignment)); } // clone array 'T src[count]' @@ -109,9 +111,9 @@ template inline void clone(T*& dst, const T* src, size_t count) { - deallocate(dst); + zfp::deallocate(dst); if (src) { - dst = static_cast(allocate(count * sizeof(T))); + dst = static_cast(zfp::allocate(count * sizeof(T))); std::copy(src, src + count, dst); } else @@ -122,13 +124,15 @@ template inline void clone_aligned(T*& dst, const T* src, size_t count, size_t alignment) { - deallocate_aligned(dst); + zfp::deallocate_aligned(dst); if (src) { - dst = static_cast(allocate_aligned(count * sizeof(T), alignment)); + dst = static_cast(zfp::allocate_aligned(count * sizeof(T), alignment)); std::copy(src, src + count, dst); } else dst = 0; } +} + #endif diff --git a/array/zfparray.h b/array/zfparray.h index 9d0e6befe..50dcee770 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -100,7 +100,7 @@ class array { void alloc(bool clear = true) { bytes = blocks * blkbits / CHAR_BIT; - reallocate_aligned(data, bytes, 0x100u); + zfp::reallocate_aligned(data, bytes, 0x100u); if (clear) std::fill(data, data + bytes, 0); stream_close(zfp->stream); @@ -117,9 +117,9 @@ class array { stream_close(zfp->stream); zfp_stream_set_bit_stream(zfp, 0); bytes = 0; - deallocate_aligned(data); + zfp::deallocate_aligned(data); data = 0; - deallocate(shape); + zfp::deallocate(shape); shape = 0; } @@ -140,7 +140,7 @@ class array { bytes = a.bytes; // copy dynamically allocated data - clone_aligned(data, a.data, bytes, 0x100u); + zfp::clone_aligned(data, a.data, bytes, 0x100u); if (zfp) { if (zfp->stream) stream_close(zfp->stream); @@ -149,7 +149,7 @@ class array { zfp = zfp_stream_open(0); *zfp = *a.zfp; zfp_stream_set_bit_stream(zfp, stream_open(data, bytes)); - clone(shape, a.shape, blocks); + zfp::clone(shape, a.shape, blocks); } uint dims; // array dimensionality (1, 2, or 3) diff --git a/array/zfparray1.h b/array/zfparray1.h index 7949d83bc..a44fa5178 100644 --- a/array/zfparray1.h +++ b/array/zfparray1.h @@ -86,9 +86,9 @@ class array1 : public array { alloc(clear); // precompute block dimensions - deallocate(shape); + zfp::deallocate(shape); if (nx & 3u) { - shape = (uchar*)allocate(blocks); + shape = (uchar*)zfp::allocate(blocks); uchar* p = shape; for (uint i = 0; i < bx; i++) *p++ = (i == bx - 1 ? -nx & 3u : 0); @@ -114,7 +114,7 @@ class array1 : public array { // flush cache by compressing all modified cached blocks void flush_cache() const { - for (typename Cache::const_iterator p = cache.first(); p; p++) { + for (typename zfp::Cache::const_iterator p = cache.first(); p; p++) { if (p->tag.dirty()) { uint b = p->tag.index() - 1; encode(b, p->line->data()); @@ -223,7 +223,7 @@ class array1 : public array { { CacheLine* p = 0; uint b = block(i); - typename Cache::Tag t = cache.access(p, b + 1, write); + typename zfp::Cache::Tag t = cache.access(p, b + 1, write); uint c = t.index() - 1; if (c != b) { // write back occupied cache line if it is dirty @@ -275,7 +275,7 @@ class array1 : public array { return std::max(n, 1u); } - mutable Cache cache; // cache of decompressed blocks + mutable zfp::Cache cache; // cache of decompressed blocks }; typedef array1 array1f; diff --git a/array/zfparray2.h b/array/zfparray2.h index 152b06698..e8ef90892 100644 --- a/array/zfparray2.h +++ b/array/zfparray2.h @@ -89,9 +89,9 @@ class array2 : public array { alloc(clear); // precompute block dimensions - deallocate(shape); + zfp::deallocate(shape); if ((nx | ny) & 3u) { - shape = (uchar*)allocate(blocks); + shape = (uchar*)zfp::allocate(blocks); uchar* p = shape; for (uint j = 0; j < by; j++) for (uint i = 0; i < bx; i++) @@ -118,7 +118,7 @@ class array2 : public array { // flush cache by compressing all modified cached blocks void flush_cache() const { - for (typename Cache::const_iterator p = cache.first(); p; p++) { + for (typename zfp::Cache::const_iterator p = cache.first(); p; p++) { if (p->tag.dirty()) { uint b = p->tag.index() - 1; encode(b, p->line->data()); @@ -242,7 +242,7 @@ class array2 : public array { { CacheLine* p = 0; uint b = block(i, j); - typename Cache::Tag t = cache.access(p, b + 1, write); + typename zfp::Cache::Tag t = cache.access(p, b + 1, write); uint c = t.index() - 1; if (c != b) { // write back occupied cache line if it is dirty @@ -302,7 +302,7 @@ class array2 : public array { return std::max(n, 1u); } - mutable Cache cache; // cache of decompressed blocks + mutable zfp::Cache cache; // cache of decompressed blocks }; typedef array2 array2f; diff --git a/array/zfparray3.h b/array/zfparray3.h index c4fd7614a..d5be22fa9 100644 --- a/array/zfparray3.h +++ b/array/zfparray3.h @@ -92,9 +92,9 @@ class array3 : public array { alloc(clear); // precompute block dimensions - deallocate(shape); + zfp::deallocate(shape); if ((nx | ny | nz) & 3u) { - shape = (uchar*)allocate(blocks); + shape = (uchar*)zfp::allocate(blocks); uchar* p = shape; for (uint k = 0; k < bz; k++) for (uint j = 0; j < by; j++) @@ -122,7 +122,7 @@ class array3 : public array { // flush cache by compressing all modified cached blocks void flush_cache() const { - for (typename Cache::const_iterator p = cache.first(); p; p++) { + for (typename zfp::Cache::const_iterator p = cache.first(); p; p++) { if (p->tag.dirty()) { uint b = p->tag.index() - 1; encode(b, p->line->data()); @@ -254,7 +254,7 @@ class array3 : public array { { CacheLine* p = 0; uint b = block(i, j, k); - typename Cache::Tag t = cache.access(p, b + 1, write); + typename zfp::Cache::Tag t = cache.access(p, b + 1, write); uint c = t.index() - 1; if (c != b) { // write back occupied cache line if it is dirty @@ -316,7 +316,7 @@ class array3 : public array { return std::max(n, 1u); } - mutable Cache cache; // cache of decompressed blocks + mutable zfp::Cache cache; // cache of decompressed blocks }; typedef array3 array3f; From e8b863418c14750f8e8558e1395cb452de00526d Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 11 Mar 2019 22:00:16 -0700 Subject: [PATCH 069/194] Fix scope of passed definitions in CMake (split zfp_defs into zfp_public_defs, zfp_private_defs, zfp_compressed_array_defs) Fix CMakeLists.txt to pass correct compressed array definitions --- CMakeLists.txt | 20 ++++++++++---------- cfp/src/CMakeLists.txt | 2 ++ examples/CMakeLists.txt | 8 ++------ src/CMakeLists.txt | 7 +++++-- tests/CMakeLists.txt | 2 +- 5 files changed, 20 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 77c051f39..8956be891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,13 +125,13 @@ option(ZFP_WITH_CACHE_PROFILE "Count cache misses" OFF) # Handle compile-time macros if((DEFINED ZFP_INT64) AND (DEFINED ZFP_INT64_SUFFIX)) - list(APPEND zfp_defs ZFP_INT64=${ZFP_INT64}) - list(APPEND zfp_defs ZFP_INT64_SUFFIX=${ZFP_INT64_SUFFIX}) + list(APPEND zfp_public_defs ZFP_INT64=${ZFP_INT64}) + list(APPEND zfp_public_defs ZFP_INT64_SUFFIX=${ZFP_INT64_SUFFIX}) endif() if((DEFINED ZFP_UINT64) AND (DEFINED ZFP_UINT64_SUFFIX)) - list(APPEND zfp_defs ZFP_UINT64=${ZFP_UINT64}) - list(APPEND zfp_defs ZFP_UINT64_SUFFIX=${ZFP_UINT64_SUFFIX}) + list(APPEND zfp_public_defs ZFP_UINT64=${ZFP_UINT64}) + list(APPEND zfp_public_defs ZFP_UINT64_SUFFIX=${ZFP_UINT64_SUFFIX}) endif() # This odd cmake pattern here let's the OpenMP feature be either auto-detected, @@ -168,27 +168,27 @@ if(ZFP_WITH_CUDA) endif() if(NOT (ZFP_BIT_STREAM_WORD_SIZE EQUAL 64)) - list(APPEND zfp_defs BIT_STREAM_WORD_TYPE=uint${ZFP_BIT_STREAM_WORD_SIZE}) + list(APPEND zfp_private_defs BIT_STREAM_WORD_TYPE=uint${ZFP_BIT_STREAM_WORD_SIZE}) endif() if(ZFP_WITH_BIT_STREAM_STRIDED) - list(APPEND zfp_defs BIT_STREAM_STRIDED) + list(APPEND zfp_public_defs BIT_STREAM_STRIDED) endif() if(ZFP_WITH_ALIGNED_ALLOC) - list(APPEND zfp_defs ZFP_ALIGNED_ALLOC) + list(APPEND zfp_compressed_array_defs ZFP_WITH_ALIGNED_ALLOC) endif() if(ZFP_WITH_CACHE_TWOWAY) - list(APPEND zfp_defs ZFP_CACHE_TWOWAY) + list(APPEND zfp_compressed_array_defs ZFP_WITH_CACHE_TWOWAY) endif() if(ZFP_WITH_CACHE_FAST_HASH) - list(APPEND zfp_defs ZFP_CACHE_FAST_HASH) + list(APPEND zfp_compressed_array_defs ZFP_WITH_CACHE_FAST_HASH) endif() if(ZFP_WITH_CACHE_PROFILE) - list(APPEND zfp_defs ZFP_CACHE_PROFILE) + list(APPEND zfp_compressed_array_defs ZFP_WITH_CACHE_PROFILE) endif() # Link libm only if necessary diff --git a/cfp/src/CMakeLists.txt b/cfp/src/CMakeLists.txt index 0ed71578a..386698c63 100644 --- a/cfp/src/CMakeLists.txt +++ b/cfp/src/CMakeLists.txt @@ -4,6 +4,8 @@ if(DEFINED CFP_NAMESPACE) list(APPEND cfp_public_defs "CFP_NAMESPACE=${CFP_NAMESPACE}") endif() +list(APPEND cfp_private_defs ${zfp_compressed_array_defs}) + if(WIN32) # define ZFP_SOURCE when compiling libcfp to export symbols to Windows DLL list(APPEND cfp_private_defs ZFP_SOURCE) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5b047c3ea..7cc760686 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,6 +1,6 @@ add_executable(diffusion diffusion.cpp) target_link_libraries(diffusion zfp) -target_compile_definitions(diffusion PRIVATE ${zfp_defs}) +target_compile_definitions(diffusion PRIVATE ${zfp_compressed_array_defs}) if(BUILD_CFP) add_executable(diffusionC diffusionC.c) @@ -9,23 +9,19 @@ endif() add_executable(inplace inplace.c) target_link_libraries(inplace zfp) -target_compile_definitions(inplace PRIVATE ${zfp_defs}) add_executable(iterator iterator.cpp) target_link_libraries(iterator zfp) -target_compile_definitions(iterator PRIVATE ${zfp_defs}) +target_compile_definitions(iterator PRIVATE ${zfp_compressed_array_defs}) add_executable(pgm pgm.c) target_link_libraries(pgm zfp) -target_compile_definitions(pgm PRIVATE ${zfp_defs}) add_executable(simple simple.c) target_link_libraries(simple zfp) -target_compile_definitions(simple PRIVATE ${zfp_defs}) add_executable(speed speed.c) target_link_libraries(speed zfp) -target_compile_definitions(speed PRIVATE ${zfp_defs}) if(HAVE_LIBM_MATH) target_link_libraries(diffusion m) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b25b18159..468875889 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -38,14 +38,17 @@ endif() if(WIN32) # Define ZFP_SOURCE when compiling libzfp to export symbols to Windows DLL - list(APPEND zfp_defs ZFP_SOURCE) + list(APPEND zfp_private_defs ZFP_SOURCE) endif() if(ZFP_WITH_CUDA) target_link_libraries(zfp PRIVATE ${CUDA_CUDART_LIBRARY} stdc++) endif() -target_compile_definitions(zfp PRIVATE ${zfp_defs}) +target_compile_definitions(zfp + PRIVATE ${zfp_private_defs} + PUBLIC ${zfp_public_defs} +) target_include_directories(zfp PUBLIC diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index d040e817c..8ec4853f1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -105,7 +105,7 @@ endif() add_executable(testzfp testzfp.cpp) target_link_libraries(testzfp zfp) -target_compile_definitions(testzfp PRIVATE ${zfp_defs}) +target_compile_definitions(testzfp PRIVATE ${zfp_compressed_array_defs}) option(ZFP_BUILD_TESTING_SMALL "Enable small-sized array testing" ON) if(ZFP_BUILD_TESTING_SMALL) From c2f9f00d455dd9803fd72736786eaa33b021ef20 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 11 Mar 2019 20:21:29 -0700 Subject: [PATCH 070/194] Add tests for aligned memory --- appveyor.sh | 4 +-- tests/array/CMakeLists.txt | 2 ++ tests/array/utils/gtestSingleFixture.h | 6 +++++ tests/array/utils/gtestTestEnv.h | 8 ++++++ tests/array/zfp/CMakeLists.txt | 5 ++++ tests/array/zfp/testAlignedMemory.cpp | 34 ++++++++++++++++++++++++++ travis.sh | 3 +-- 7 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 tests/array/utils/gtestSingleFixture.h create mode 100644 tests/array/utils/gtestTestEnv.h create mode 100644 tests/array/zfp/CMakeLists.txt create mode 100644 tests/array/zfp/testAlignedMemory.cpp diff --git a/appveyor.sh b/appveyor.sh index 0811cd28f..46dbe4743 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -11,8 +11,8 @@ run_all () { mkdir build cd build -# config without OpenMP, with CFP (and custom namespace) -run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" +# config without OpenMP, with CFP (and custom namespace), with aligned allocations (compressed arrays) +run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" # build empty project requiring OpenMP, in a temp directory that ZFP is oblivious to mkdir tmpBuild diff --git a/tests/array/CMakeLists.txt b/tests/array/CMakeLists.txt index 1430d43c3..84cf79c71 100644 --- a/tests/array/CMakeLists.txt +++ b/tests/array/CMakeLists.txt @@ -42,3 +42,5 @@ zfp_add_cpp_tests(3 f 32) zfp_add_cpp_tests(1 d 64) zfp_add_cpp_tests(2 d 64) zfp_add_cpp_tests(3 d 64) + +add_subdirectory(zfp) diff --git a/tests/array/utils/gtestSingleFixture.h b/tests/array/utils/gtestSingleFixture.h new file mode 100644 index 000000000..b76353b07 --- /dev/null +++ b/tests/array/utils/gtestSingleFixture.h @@ -0,0 +1,6 @@ +#include "gtest/gtest.h" + +class TestFixture : public ::testing::TestWithParam { +protected: + virtual void SetUp() {} +}; diff --git a/tests/array/utils/gtestTestEnv.h b/tests/array/utils/gtestTestEnv.h new file mode 100644 index 000000000..3451027fc --- /dev/null +++ b/tests/array/utils/gtestTestEnv.h @@ -0,0 +1,8 @@ +#include "gtest/gtest.h" + +class TestEnv : public ::testing::Environment { +public: + virtual void SetUp() {} + + virtual void TearDown() {} +}; diff --git a/tests/array/zfp/CMakeLists.txt b/tests/array/zfp/CMakeLists.txt new file mode 100644 index 000000000..2b036526e --- /dev/null +++ b/tests/array/zfp/CMakeLists.txt @@ -0,0 +1,5 @@ +if(ZFP_WITH_ALIGNED_ALLOC) + add_executable(testAlignedMemory testAlignedMemory.cpp) + target_link_libraries(testAlignedMemory gtest gtest_main zfp) + add_test(NAME testAlignedMemory COMMAND testAlignedMemory) +endif() diff --git a/tests/array/zfp/testAlignedMemory.cpp b/tests/array/zfp/testAlignedMemory.cpp new file mode 100644 index 000000000..f991ed10c --- /dev/null +++ b/tests/array/zfp/testAlignedMemory.cpp @@ -0,0 +1,34 @@ +#include "array/zfparray3.h" +using namespace zfp; + +#include "gtest/gtest.h" +#include "../utils/gtestTestEnv.h" +#include "../utils/gtestSingleFixture.h" +#include "../utils/predicates.h" + +#include + +TestEnv* const testEnv = new TestEnv; + +class AlignedMemoryTest : public TestFixture {}; + +#define TEST_FIXTURE AlignedMemoryTest + +INSTANTIATE_TEST_CASE_P(TestManyMemoryAlignments, TEST_FIXTURE, ::testing::Range(4, 11)); + +TEST_P(TEST_FIXTURE, when_allocateAlignedMem_expect_addressAligned) +{ + size_t alignmentBytes = (size_t)(1u << GetParam()); + void* ptr = allocate_aligned(900, alignmentBytes); + + uintptr_t address = (uintptr_t)ptr; + EXPECT_EQ(address % alignmentBytes, 0); + + deallocate_aligned(ptr); +} + +int main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + static_cast(::testing::AddGlobalTestEnvironment(testEnv)); + return RUN_ALL_TESTS(); +} diff --git a/travis.sh b/travis.sh index 2b756a75b..3f6f8dba0 100755 --- a/travis.sh +++ b/travis.sh @@ -4,13 +4,12 @@ set -e mkdir build cd build - if [ -n "${COVERAGE}" ]; then # build ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake else # build/test without OpenMP, with CFP (and custom namespace) - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake rm -rf ./* ; From e33160b0fd46c2296c42889fce7c12d7105f00a1 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 5 Jul 2018 16:33:27 -0700 Subject: [PATCH 071/194] Compressed arrays: add public write_header(), with new struct-type zfp::array::header, and tests --- array/zfparray.h | 31 +++++++++++++++++++ tests/array/testArrayBase.cpp | 58 +++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) diff --git a/array/zfparray.h b/array/zfparray.h index 50dcee770..1e397123d 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -6,10 +6,18 @@ #include "zfp.h" #include "zfp/memory.h" +#define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) +#define ZFP_HEADER_SIZE_BYTES ((ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT) + namespace zfp { // abstract base class for compressed array of scalars class array { +public: + typedef struct { + uchar buffer[ZFP_HEADER_SIZE_BYTES]; + } header; + protected: // default constructor array() : @@ -92,6 +100,29 @@ class array { // underlying scalar type zfp_type scalar_type() const { return type; } + // write header with latest metadata + void write_header(zfp::array::header& h) const + { + // instead of creating new zfp_stream, temporarily + // swap its bitstream, to write to header + bitstream* newBs = stream_open(h.buffer, ZFP_HEADER_SIZE_BYTES); + stream_rewind(newBs); + + bitstream* oldBs = zfp_stream_bit_stream(zfp); + zfp_stream_set_bit_stream(zfp, newBs); + + zfp_field* field = zfp_field_3d(0, type, nx, ny, nz); + + // write header + zfp_write_header(zfp, field, ZFP_HEADER_FULL); + stream_flush(zfp->stream); + + // free + zfp_field_free(field); + zfp_stream_set_bit_stream(zfp, oldBs); + stream_close(newBs); + } + protected: // number of values per block uint block_size() const { return 1u << (2 * dims); } diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 413010a4a..5097e6d3b 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -66,6 +66,64 @@ TEST_F(TEST_FIXTURE, when_setRate_then_compressionRateChanged) EXPECT_GT(oldCompressedSize, newCompressedSize); } +void VerifyProperHeaderWritten(const zfp::array::header& h, uint chosenSizeX, uint chosenSizeY, uint chosenSizeZ, double chosenRate) +{ + // verify valid header (manually through C API) + bitstream* stream = stream_open((zfp::array::header*)&h, ZFP_HEADER_SIZE_BYTES); + + zfp_field* field = zfp_field_alloc(); + zfp_stream* zfp = zfp_stream_open(stream); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, zfp_read_header(zfp, field, ZFP_HEADER_FULL)); + + // verify header contents + EXPECT_EQ(chosenSizeX, field->nx); + EXPECT_EQ(chosenSizeY, field->ny); + EXPECT_EQ(chosenSizeZ, field->nz); + + EXPECT_EQ(ZFP_TYPE, field->type); + + // to verify rate, we can only compare the 4 compression-param basis + zfp_stream* expectedZfpStream = zfp_stream_open(0); + zfp_stream_set_rate(expectedZfpStream, chosenRate, ZFP_TYPE, testEnv->getDims(), 1); + EXPECT_EQ(expectedZfpStream->minbits, zfp->minbits); + EXPECT_EQ(expectedZfpStream->maxbits, zfp->maxbits); + EXPECT_EQ(expectedZfpStream->maxprec, zfp->maxprec); + EXPECT_EQ(expectedZfpStream->minexp, zfp->minexp); + + zfp_stream_close(expectedZfpStream); + zfp_stream_close(zfp); + zfp_field_free(field); + stream_close(stream); +} + +TEST_F(TEST_FIXTURE, when_writeHeader_then_cCompatibleHeaderWritten) +{ + double chosenRate = ZFP_RATE_PARAM_BITS; + + uint chosenSizeX, chosenSizeY, chosenSizeZ; +#if DIMS == 1 + chosenSizeX = 55; + chosenSizeY = 0; + chosenSizeZ = 0; + ZFP_ARRAY_TYPE arr(chosenSizeX, chosenRate); +#elif DIMS == 2 + chosenSizeX = 55; + chosenSizeY = 23; + chosenSizeZ = 0; + ZFP_ARRAY_TYPE arr(chosenSizeX, chosenSizeY, chosenRate); +#elif DIMS == 3 + chosenSizeX = 55; + chosenSizeY = 23; + chosenSizeZ = 31; + ZFP_ARRAY_TYPE arr(chosenSizeX, chosenSizeY, chosenSizeZ, chosenRate); +#endif + + zfp::array::header h; + arr.write_header(h); + + VerifyProperHeaderWritten(h, chosenSizeX, chosenSizeY, chosenSizeZ, chosenRate); +} + TEST_F(TEST_FIXTURE, when_generateRandomData_then_checksumMatches) { EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, getChecksumOriginalDataArray(DIMS, ZFP_TYPE), _catFunc2(hashArray, SCALAR_BITS)((UINT*)inputDataArr, inputDataTotalLen, 1)); From 837680b49cd992604ea881e23f1ec9e694a50d11 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 11:54:18 -0700 Subject: [PATCH 072/194] Add compressed array constructors, from a serialized compressed array. Will throw std::invalid_argument exceptions if unable to construct Add public zfp::array::read_header() --- array/zfparray.h | 127 ++++++++++++++++++++++++++++++++++++++++++++++ array/zfparray1.h | 10 ++++ array/zfparray2.h | 10 ++++ array/zfparray3.h | 10 ++++ 4 files changed, 157 insertions(+) diff --git a/array/zfparray.h b/array/zfparray.h index 1e397123d..f1bb008c5 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -3,12 +3,17 @@ #include #include +#include +#include + #include "zfp.h" #include "zfp/memory.h" #define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) #define ZFP_HEADER_SIZE_BYTES ((ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT) +#define unused_(x) ((void)(x)) + namespace zfp { // abstract base class for compressed array of scalars @@ -41,6 +46,48 @@ class array { shape(0) {} + // constructor, from previously-serialized compressed array + array(uint dims, zfp_type type, const zfp::array::header& h, size_t bufferSizeBytes) : + dims(dims), type(type), + nx(0), ny(0), nz(0), + bx(0), by(0), bz(0), + blocks(0), blkbits(0), + bytes(0), data(0), + zfp(zfp_stream_open(0)), + shape(0) + { + // read header to populate member variables associated with zfp_stream + try { + read_header(h); + } catch (std::invalid_argument const & e) { + unused_(e); + zfp_stream_close(zfp); + throw; + } + + if (bufferSizeBytes != 0) { + // verify buffer is large enough, with what header describes + uint mx = ((std::max(nx, 1u)) + 3) / 4; + uint my = ((std::max(ny, 1u)) + 3) / 4; + uint mz = ((std::max(nz, 1u)) + 3) / 4; + size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; + size_t describedSize = ((blocks * zfp->maxbits + stream_word_bits - 1) & ~(stream_word_bits - 1)) / CHAR_BIT; + + if (bufferSizeBytes < describedSize) { + zfp_stream_close(zfp); + throw std::invalid_argument("ZFP header expects a longer buffer than what was passed in."); + } + } + + // everything is valid + // set remaining class variables, allocate space, copy entire buffer into place + + // set_rate() residual behavior (rate itself was set on zfp_stream* in zfp_read_header()) + blkbits = zfp->maxbits; + + // resize() called in sub-class constructor, followed by memcpy() + } + // copy constructor--performs a deep copy array(const array& a) : data(0), @@ -183,6 +230,84 @@ class array { zfp::clone(shape, a.shape, blocks); } + // returns if dimension lengths consistent with dimensionality + bool is_valid_dims(uint nx, uint ny, uint nz) const + { + bool result = true; + switch(dims) { + case 3: + result &= nz; + case 2: + result &= ny; + case 1: + result &= nx; + break; + + default: + return false; + } + return result; + } + + // attempt reading header from zfp::array::header + // and verify header contents (throws exceptions upon failure) + void read_header(const zfp::array::header& h) + { + // instead of creating new zfp_stream, temporarily + // swap its bitstream, to read from zfp_header + // (we only perform reads, but bitstream cannot accept const) + bitstream* newBs = stream_open((zfp::array::header*)&(h.buffer), ZFP_HEADER_SIZE_BITS); + stream_rewind(newBs); + + bitstream* oldBs = zfp_stream_bit_stream(zfp); + zfp_stream_set_bit_stream(zfp, newBs); + + zfp_field* field = zfp_field_alloc(); + + // read header to populate member variables associated with zfp_stream + if (zfp_read_header(zfp, field, ZFP_HEADER_FULL) != ZFP_HEADER_SIZE_BITS) { + zfp_field_free(field); + zfp_stream_set_bit_stream(zfp, oldBs); + stream_close(newBs); + throw std::invalid_argument("Invalid ZFP header."); + } + + // verify read-header contents + std::string errMsg = ""; + if (type != field->type) + errMsg += "ZFP header specified an underlying scalar type different than that for this object."; + + if (!is_valid_dims(field->nx, field->ny, field->nz)) { + if (!errMsg.empty()) + errMsg += " "; + errMsg += "ZFP header specified a dimensionality different than that for this object."; + } + + if (zfp_stream_compression_mode(zfp) != zfp_mode_fixed_rate) { + if (!errMsg.empty()) + errMsg += " "; + errMsg += "ZFP header specified a non fixed-rate mode, unsupported by this object."; + } + + if (!errMsg.empty()) { + zfp_field_free(field); + zfp_stream_set_bit_stream(zfp, oldBs); + stream_close(newBs); + + throw std::invalid_argument(errMsg); + } + + nx = field->nx; + ny = field->ny; + nz = field->nz; + type = field->type; + + // free, restore bitstream + zfp_field_free(field); + zfp_stream_set_bit_stream(zfp, oldBs); + stream_close(newBs); + } + uint dims; // array dimensionality (1, 2, or 3) zfp_type type; // scalar type uint nx, ny, nz; // array dimensions @@ -195,6 +320,8 @@ class array { uchar* shape; // precomputed block dimensions (or null if uniform) }; +#undef unused_ + } #endif diff --git a/array/zfparray1.h b/array/zfparray1.h index a44fa5178..b6822b3ac 100644 --- a/array/zfparray1.h +++ b/array/zfparray1.h @@ -3,6 +3,7 @@ #include #include +#include #include "zfparray.h" #include "zfpcodec.h" #include "zfp/cache.h" @@ -38,6 +39,15 @@ class array1 : public array { set(p); } + // constructor, from previously-serialized compressed array + array1(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : + array(1, Codec::type, h, bufferSizeBytes) + { + resize(nx, false); + if (buffer) + memcpy(data, buffer, bytes); + } + // copy constructor--performs a deep copy array1(const array1& a) { diff --git a/array/zfparray2.h b/array/zfparray2.h index e8ef90892..71fb9ea1f 100644 --- a/array/zfparray2.h +++ b/array/zfparray2.h @@ -3,6 +3,7 @@ #include #include +#include #include "zfparray.h" #include "zfpcodec.h" #include "zfp/cache.h" @@ -38,6 +39,15 @@ class array2 : public array { set(p); } + // constructor, from previously-serialized compressed array + array2(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : + array(2, Codec::type, h, bufferSizeBytes) + { + resize(nx, ny, false); + if (buffer) + memcpy(data, buffer, bytes); + } + // copy constructor--performs a deep copy array2(const array2& a) { diff --git a/array/zfparray3.h b/array/zfparray3.h index d5be22fa9..3feac56bb 100644 --- a/array/zfparray3.h +++ b/array/zfparray3.h @@ -3,6 +3,7 @@ #include #include +#include #include "zfparray.h" #include "zfpcodec.h" #include "zfp/cache.h" @@ -38,6 +39,15 @@ class array3 : public array { set(p); } + // constructor, from previously-serialized compressed array + array3(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : + array(3, Codec::type, h, bufferSizeBytes) + { + resize(nx, ny, nz, false); + if (buffer) + memcpy(data, buffer, bytes); + } + // copy constructor--performs a deep copy array3(const array3& a) { From f9279c317aefd288ab7a57321f67eb26fdd9da54 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 11:55:48 -0700 Subject: [PATCH 073/194] Add tests constructing compressed arrays from header Differentiate deep copy tests when cache is or is not being tested --- tests/array/testArray1d.cpp | 4 + tests/array/testArray1f.cpp | 4 + tests/array/testArray2d.cpp | 4 + tests/array/testArray2f.cpp | 4 + tests/array/testArray3d.cpp | 4 + tests/array/testArray3f.cpp | 4 + tests/array/testArrayBase.cpp | 289 +++++++++++++++++++++++++++++++++- 7 files changed, 306 insertions(+), 7 deletions(-) diff --git a/tests/array/testArray1d.cpp b/tests/array/testArray1d.cpp index ff8d2267b..fe3e78885 100644 --- a/tests/array/testArray1d.cpp +++ b/tests/array/testArray1d.cpp @@ -1,4 +1,5 @@ #include "array/zfparray1.h" +#include "array/zfparray2.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array1dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array1dTest #define ZFP_ARRAY_TYPE array1d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array1f +#define ZFP_ARRAY_TYPE_WRONG_DIM array2d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array2f #define UINT uint64 #define SCALAR double #define DIMS 1 diff --git a/tests/array/testArray1f.cpp b/tests/array/testArray1f.cpp index 04a334a33..1813d531f 100644 --- a/tests/array/testArray1f.cpp +++ b/tests/array/testArray1f.cpp @@ -1,4 +1,5 @@ #include "array/zfparray1.h" +#include "array/zfparray2.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array1fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array1fTest #define ZFP_ARRAY_TYPE array1f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array1d +#define ZFP_ARRAY_TYPE_WRONG_DIM array2f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array2d #define UINT uint32 #define SCALAR float #define DIMS 1 diff --git a/tests/array/testArray2d.cpp b/tests/array/testArray2d.cpp index a6882f78f..0c2e583c1 100644 --- a/tests/array/testArray2d.cpp +++ b/tests/array/testArray2d.cpp @@ -1,4 +1,5 @@ #include "array/zfparray2.h" +#include "array/zfparray3.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array2dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array2dTest #define ZFP_ARRAY_TYPE array2d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array2f +#define ZFP_ARRAY_TYPE_WRONG_DIM array3d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array3f #define UINT uint64 #define SCALAR double #define DIMS 2 diff --git a/tests/array/testArray2f.cpp b/tests/array/testArray2f.cpp index b2bba1a9f..a4cf4846c 100644 --- a/tests/array/testArray2f.cpp +++ b/tests/array/testArray2f.cpp @@ -1,4 +1,5 @@ #include "array/zfparray2.h" +#include "array/zfparray3.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array2fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array2fTest #define ZFP_ARRAY_TYPE array2f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array2d +#define ZFP_ARRAY_TYPE_WRONG_DIM array3f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array3d #define UINT uint32 #define SCALAR float #define DIMS 2 diff --git a/tests/array/testArray3d.cpp b/tests/array/testArray3d.cpp index b58e1a113..cb80f2015 100644 --- a/tests/array/testArray3d.cpp +++ b/tests/array/testArray3d.cpp @@ -1,4 +1,5 @@ #include "array/zfparray3.h" +#include "array/zfparray1.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array3dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array3dTest #define ZFP_ARRAY_TYPE array3d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array3f +#define ZFP_ARRAY_TYPE_WRONG_DIM array1d +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array1f #define UINT uint64 #define SCALAR double #define DIMS 3 diff --git a/tests/array/testArray3f.cpp b/tests/array/testArray3f.cpp index d38d1d5aa..c842087ae 100644 --- a/tests/array/testArray3f.cpp +++ b/tests/array/testArray3f.cpp @@ -1,4 +1,5 @@ #include "array/zfparray3.h" +#include "array/zfparray1.h" using namespace zfp; extern "C" { @@ -21,6 +22,9 @@ class Array3fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array3fTest #define ZFP_ARRAY_TYPE array3f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR array3d +#define ZFP_ARRAY_TYPE_WRONG_DIM array1f +#define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array1d #define UINT uint32 #define SCALAR float #define DIMS 3 diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 5097e6d3b..2b9467d4c 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -4,6 +4,8 @@ extern "C" { #include "utils/zfpHash.h" } +#include + TEST_F(TEST_FIXTURE, when_constructorCalled_then_rateSetWithWriteRandomAccess) { double rate = ZFP_RATE_PARAM_BITS; @@ -129,6 +131,223 @@ TEST_F(TEST_FIXTURE, when_generateRandomData_then_checksumMatches) EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, getChecksumOriginalDataArray(DIMS, ZFP_TYPE), _catFunc2(hashArray, SCALAR_BITS)((UINT*)inputDataArr, inputDataTotalLen, 1)); } +void FailWhenNoExceptionThrown() +{ + FAIL() << "No exception was thrown when one was expected"; +} + +void FailAndPrintException(std::exception const & e) +{ + FAIL() << "Unexpected exception thrown: " << typeid(e).name() << std::endl << "With message: " << e.what(); +} + +TEST_F(TEST_FIXTURE, when_constructorFromSerializedWithInvalidHeader_then_exceptionThrown) +{ + zfp::array::header h = {0}; + + try { + ZFP_ARRAY_TYPE arr(h, NULL); + FailWhenNoExceptionThrown(); + } catch (std::invalid_argument const & e) { + EXPECT_EQ(e.what(), std::string("Invalid ZFP header.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongScalarType_when_constructorFromSerialized_then_exceptionThrown) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE_WRONG_SCALAR arr(inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 2 + ZFP_ARRAY_TYPE_WRONG_SCALAR arr(inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 3 + ZFP_ARRAY_TYPE_WRONG_SCALAR arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#endif + + zfp::array::header h; + arr.write_header(h); + + try { + ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); + FailWhenNoExceptionThrown(); + } catch (std::invalid_argument const & e) { + EXPECT_EQ(e.what(), std::string("ZFP header specified an underlying scalar type different than that for this object.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongDimensionality_when_constructorFromSerialized_then_exceptionThrown) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE_WRONG_DIM arr(100, 100, ZFP_RATE_PARAM_BITS); +#elif DIMS == 2 + ZFP_ARRAY_TYPE_WRONG_DIM arr(100, 100, 100, ZFP_RATE_PARAM_BITS); +#elif DIMS == 3 + ZFP_ARRAY_TYPE_WRONG_DIM arr(100, ZFP_RATE_PARAM_BITS); +#endif + + zfp::array::header h; + arr.write_header(h); + + try { + ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); + FailWhenNoExceptionThrown(); + } catch (std::invalid_argument const & e) { + EXPECT_EQ(e.what(), std::string("ZFP header specified a dimensionality different than that for this object.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_serializedNonFixedRateHeader_when_constructorFromSerialized_then_exceptionThrown) +{ + // create a compressed stream through C API + // (one that is not supported with compressed arrays) + zfp_field* field; +#if DIMS == 1 + field = zfp_field_1d(inputDataArr, ZFP_TYPE, inputDataSideLen); +#elif DIMS == 2 + field = zfp_field_2d(inputDataArr, ZFP_TYPE, inputDataSideLen, inputDataSideLen); +#elif DIMS == 3 + field = zfp_field_3d(inputDataArr, ZFP_TYPE, inputDataSideLen, inputDataSideLen, inputDataSideLen); +#endif + + zfp_stream* stream = zfp_stream_open(NULL); + + size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + uchar* buffer = new uchar[bufsizeBytes]; + memset(buffer, 0, bufsizeBytes); + + bitstream* bs = stream_open(buffer, bufsizeBytes); + zfp_stream_set_bit_stream(stream, bs); + zfp_stream_rewind(stream); + + zfp_stream_set_precision(stream, 10); + EXPECT_NE(zfp_mode_fixed_rate, zfp_stream_compression_mode(stream)); + + // write header + size_t writtenBits = zfp_write_header(stream, field, ZFP_HEADER_FULL); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, writtenBits); + zfp_stream_flush(stream); + + // copy header into header + size_t headerSizeBytes = (writtenBits + CHAR_BIT - 1) / CHAR_BIT; + zfp::array::header h; + memcpy(h.buffer, buffer, headerSizeBytes); + + // compress data + uchar* compressedDataPtr = (uchar*)stream_data(bs) + headerSizeBytes; + zfp_compress(stream, field); + + // close/free C API things (keep buffer) + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + + try { + ZFP_ARRAY_TYPE arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); + FailWhenNoExceptionThrown(); + } catch (std::invalid_argument const & e) { + EXPECT_EQ(e.what(), std::string("ZFP header specified a non fixed-rate mode, unsupported by this object.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } + + delete[] buffer; +} + +TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensionalityHeader_when_constructorFromSerialized_then_exceptionsThrown) +{ + // create a compressed stream through C API + // (one that is not supported with compressed arrays) + zfp_field* field; + // (inputDataSideLen specific to that dimensionality, can request too much memory if fitted to higher dimensionality) +#if DIMS == 1 + field = zfp_field_2d(inputDataArr, zfp_type_int32, 100, 100); +#elif DIMS == 2 + field = zfp_field_3d(inputDataArr, zfp_type_int32, 100, 100, 100); +#elif DIMS == 3 + field = zfp_field_1d(inputDataArr, zfp_type_int32, 100); +#endif + + zfp_stream* stream = zfp_stream_open(NULL); + + size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + uchar* buffer = new uchar[bufsizeBytes]; + memset(buffer, 0, bufsizeBytes); + + bitstream* bs = stream_open(buffer, bufsizeBytes); + zfp_stream_set_bit_stream(stream, bs); + zfp_stream_rewind(stream); + + zfp_stream_set_precision(stream, 10); + EXPECT_NE(zfp_mode_fixed_rate, zfp_stream_compression_mode(stream)); + + // write header + size_t writtenBits = zfp_write_header(stream, field, ZFP_HEADER_FULL); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, writtenBits); + zfp_stream_flush(stream); + + // copy header into header + size_t headerSizeBytes = (writtenBits + CHAR_BIT - 1) / CHAR_BIT; + zfp::array::header h; + memcpy(h.buffer, buffer, headerSizeBytes); + + // compress data + uchar* compressedDataPtr = (uchar*)stream_data(bs) + headerSizeBytes; + zfp_compress(stream, field); + + // close/free C API things (keep buffer) + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + + try { + ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); + FailWhenNoExceptionThrown(); + + } catch (std::invalid_argument const & e) { + EXPECT_TRUE(strstr(e.what(), "ZFP header specified an underlying scalar type different than that for this object.") != NULL); + EXPECT_TRUE(strstr(e.what(), "ZFP header specified a dimensionality different than that for this object.") != NULL); + EXPECT_TRUE(strstr(e.what(), "ZFP header specified a non fixed-rate mode, unsupported by this object.") != NULL); + + // print exception if any of above were not met + if (HasFailure()) { + FailAndPrintException(e); + } + + } catch (std::exception const & e) { + FailAndPrintException(e); + } + + delete[] buffer; +} + +TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_constructorFromSerialized_then_exceptionThrown) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE arr(inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 2 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 3 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#endif + + zfp::array::header h; + arr.write_header(h); + + try { + ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size() - 1); + FailWhenNoExceptionThrown(); + } catch (std::invalid_argument const & e) { + EXPECT_EQ(e.what(), std::string("ZFP header expects a longer buffer than what was passed in.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + #if DIMS == 1 // with write random access in 1D, fixed-rate params rounded up to multiples of 16 INSTANTIATE_TEST_CASE_P(TestManyCompressionRates, TEST_FIXTURE, ::testing::Values(1, 2)); @@ -220,7 +439,9 @@ TEST_P(TEST_FIXTURE, when_configureCompressedArrayFromDefaultConstructor_then_bi EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); } -void CheckDeepCopyPerformed(ZFP_ARRAY_TYPE arr1, ZFP_ARRAY_TYPE arr2, uchar* arr1UnflushedBitstreamPtr) +// assumes arr1 was given a dirty cache +// this irreversibly changes arr1 (clears entries) +void CheckDeepCopyPerformedViaDirtyCache(ZFP_ARRAY_TYPE& arr1, ZFP_ARRAY_TYPE& arr2, uchar* arr1UnflushedBitstreamPtr) { // flush arr2 first, to ensure arr1 remains unflushed uint64 checksum = hashBitstream((uint64*)arr2.compressed_data(), arr2.compressed_size()); @@ -242,7 +463,8 @@ void CheckDeepCopyPerformed(ZFP_ARRAY_TYPE arr1, ZFP_ARRAY_TYPE arr2, uchar* arr EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); } -void CheckMemberVarsCopied(ZFP_ARRAY_TYPE arr1, ZFP_ARRAY_TYPE arr2) +// this irreversibly changes arr1 (resize + clears entries) +void CheckMemberVarsCopied(ZFP_ARRAY_TYPE& arr1, const ZFP_ARRAY_TYPE& arr2, bool assertCacheSize) { double oldRate = arr1.rate(); size_t oldCompressedSize = arr1.compressed_size(); @@ -271,7 +493,8 @@ void CheckMemberVarsCopied(ZFP_ARRAY_TYPE arr1, ZFP_ARRAY_TYPE arr2) EXPECT_EQ(oldRate, arr2.rate()); EXPECT_EQ(oldCompressedSize, arr2.compressed_size()); - EXPECT_EQ(oldCacheSize, arr2.cache_size()); + if (assertCacheSize) + EXPECT_EQ(oldCacheSize, arr2.cache_size()); #if DIMS == 1 EXPECT_EQ(oldSizeX, arr2.size()); @@ -297,7 +520,7 @@ TEST_P(TEST_FIXTURE, given_compressedArray_when_copyConstructor_then_memberVaria ZFP_ARRAY_TYPE arr2(arr); - CheckMemberVarsCopied(arr, arr2); + CheckMemberVarsCopied(arr, arr2, true); } TEST_P(TEST_FIXTURE, given_compressedArray_when_copyConstructor_then_deepCopyPerformed) @@ -316,7 +539,7 @@ TEST_P(TEST_FIXTURE, given_compressedArray_when_copyConstructor_then_deepCopyPer ZFP_ARRAY_TYPE arr2(arr); - CheckDeepCopyPerformed(arr, arr2, arrUnflushedBitstreamPtr); + CheckDeepCopyPerformedViaDirtyCache(arr, arr2, arrUnflushedBitstreamPtr); } TEST_P(TEST_FIXTURE, given_compressedArray_when_setSecondArrayEqualToFirst_then_memberVariablesCopied) @@ -331,7 +554,7 @@ TEST_P(TEST_FIXTURE, given_compressedArray_when_setSecondArrayEqualToFirst_then_ ZFP_ARRAY_TYPE arr2 = arr; - CheckMemberVarsCopied(arr, arr2); + CheckMemberVarsCopied(arr, arr2, true); } TEST_P(TEST_FIXTURE, given_compressedArray_when_setSecondArrayEqualToFirst_then_deepCopyPerformed) @@ -350,5 +573,57 @@ TEST_P(TEST_FIXTURE, given_compressedArray_when_setSecondArrayEqualToFirst_then_ ZFP_ARRAY_TYPE arr2 = arr; - CheckDeepCopyPerformed(arr, arr2, arrUnflushedBitstreamPtr); + CheckDeepCopyPerformedViaDirtyCache(arr, arr2, arrUnflushedBitstreamPtr); +} + +void CheckHeadersEquivalent(const ZFP_ARRAY_TYPE& arr1, const ZFP_ARRAY_TYPE& arr2) +{ + zfp::array::header h[2]; + arr1.write_header(h[0]); + arr2.write_header(h[1]); + + size_t headerSizeBytes = (ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT; + + uint64 header1Checksum = hashBitstream((uint64*)(h + 0), headerSizeBytes); + uint64 header2Checksum = hashBitstream((uint64*)(h + 1), headerSizeBytes); + EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, header1Checksum, header2Checksum); +} + +// this clears arr1's entries +void CheckDeepCopyPerformed(ZFP_ARRAY_TYPE& arr1, ZFP_ARRAY_TYPE& arr2) +{ + // flush arr1, compute its checksum, clear its bitstream, re-compute arr2's checksum + uint64 expectedChecksum = hashBitstream((uint64*)arr1.compressed_data(), arr1.compressed_size()); + +#if DIMS == 1 + arr1.resize(arr1.size(), true); +#elif DIMS == 2 + arr1.resize(arr1.size_x(), arr1.size_y(), true); +#elif DIMS == 3 + arr1.resize(arr1.size_x(), arr1.size_y(), arr1.size_z(), true); +#endif + + uint64 checksum = hashBitstream((uint64*)arr2.compressed_data(), arr2.compressed_size()); + EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, expectedChecksum, checksum); +} + +TEST_P(TEST_FIXTURE, given_serializedCompressedArray_when_constructorFromSerialized_then_constructedArrIsBasicallyADeepCopy) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE arr(inputDataSideLen, getRate(), inputDataArr); +#elif DIMS == 2 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, getRate(), inputDataArr); +#elif DIMS == 3 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, getRate(), inputDataArr); +#endif + + zfp::array::header h; + arr.write_header(h); + + ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size()); + + CheckHeadersEquivalent(arr, arr2); + CheckDeepCopyPerformed(arr, arr2); + // cache size not preserved + CheckMemberVarsCopied(arr, arr2, false); } From a11688f15b3e0c22331f8c799cce642ab3d3c8ca Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 18 Jul 2018 11:32:54 -0700 Subject: [PATCH 074/194] Create protected `...Handle` classes in zfparray base class, to automatically free resources and redirect bitstreams when dealing with zfp::array::header. Useful when throwing exceptions in read_header() --- array/zfparray.h | 104 ++++++++++++++++++++++++++--------------------- 1 file changed, 57 insertions(+), 47 deletions(-) diff --git a/array/zfparray.h b/array/zfparray.h index f1bb008c5..8e84a1cf8 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -150,27 +150,57 @@ class array { // write header with latest metadata void write_header(zfp::array::header& h) const { - // instead of creating new zfp_stream, temporarily - // swap its bitstream, to write to header - bitstream* newBs = stream_open(h.buffer, ZFP_HEADER_SIZE_BYTES); - stream_rewind(newBs); - - bitstream* oldBs = zfp_stream_bit_stream(zfp); - zfp_stream_set_bit_stream(zfp, newBs); - - zfp_field* field = zfp_field_3d(0, type, nx, ny, nz); + DualBitstreamHandle dbh(zfp, &h, ZFP_HEADER_SIZE_BYTES); + ZfpFieldHandle zfh(type, nx, ny, nz); // write header - zfp_write_header(zfp, field, ZFP_HEADER_FULL); + zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL); stream_flush(zfp->stream); - - // free - zfp_field_free(field); - zfp_stream_set_bit_stream(zfp, oldBs); - stream_close(newBs); } protected: + // "Handle" classes useful when throwing exceptions in read_header() + + // redirect zfp_stream->bitstream to header while object remains in scope + class DualBitstreamHandle { + public: + bitstream* oldBs; + bitstream* newBs; + zfp_stream* zfp; + + DualBitstreamHandle(zfp_stream* zfp, zfp::array::header* h, size_t headerSizeBytes) : + zfp(zfp) + { + oldBs = zfp_stream_bit_stream(zfp); + newBs = stream_open(h->buffer, headerSizeBytes); + + stream_rewind(newBs); + zfp_stream_set_bit_stream(zfp, newBs); + } + + ~DualBitstreamHandle() { + zfp_stream_set_bit_stream(zfp, oldBs); + stream_close(newBs); + } + }; + + class ZfpFieldHandle { + public: + zfp_field* field; + + ZfpFieldHandle() { + field = zfp_field_alloc(); + } + + ZfpFieldHandle(zfp_type type, int nx, int ny, int nz) { + field = zfp_field_3d(0, type, nx, ny, nz); + } + + ~ZfpFieldHandle() { + zfp_field_free(field); + } + }; + // number of values per block uint block_size() const { return 1u << (2 * dims); } @@ -253,31 +283,20 @@ class array { // and verify header contents (throws exceptions upon failure) void read_header(const zfp::array::header& h) { - // instead of creating new zfp_stream, temporarily - // swap its bitstream, to read from zfp_header - // (we only perform reads, but bitstream cannot accept const) - bitstream* newBs = stream_open((zfp::array::header*)&(h.buffer), ZFP_HEADER_SIZE_BITS); - stream_rewind(newBs); - - bitstream* oldBs = zfp_stream_bit_stream(zfp); - zfp_stream_set_bit_stream(zfp, newBs); - - zfp_field* field = zfp_field_alloc(); + // cast off const to satisfy bitstream constructor (we only perform reads anyway) + DualBitstreamHandle dbh(zfp, (zfp::array::header*)&h, ZFP_HEADER_SIZE_BYTES); + ZfpFieldHandle zfh; // read header to populate member variables associated with zfp_stream - if (zfp_read_header(zfp, field, ZFP_HEADER_FULL) != ZFP_HEADER_SIZE_BITS) { - zfp_field_free(field); - zfp_stream_set_bit_stream(zfp, oldBs); - stream_close(newBs); + if (zfp_read_header(zfp, zfh.field, ZFP_HEADER_FULL) != ZFP_HEADER_SIZE_BITS) throw std::invalid_argument("Invalid ZFP header."); - } // verify read-header contents std::string errMsg = ""; - if (type != field->type) + if (type != zfh.field->type) errMsg += "ZFP header specified an underlying scalar type different than that for this object."; - if (!is_valid_dims(field->nx, field->ny, field->nz)) { + if (!is_valid_dims(zfh.field->nx, zfh.field->ny, zfh.field->nz)) { if (!errMsg.empty()) errMsg += " "; errMsg += "ZFP header specified a dimensionality different than that for this object."; @@ -289,23 +308,14 @@ class array { errMsg += "ZFP header specified a non fixed-rate mode, unsupported by this object."; } - if (!errMsg.empty()) { - zfp_field_free(field); - zfp_stream_set_bit_stream(zfp, oldBs); - stream_close(newBs); - + if (!errMsg.empty()) throw std::invalid_argument(errMsg); - } - - nx = field->nx; - ny = field->ny; - nz = field->nz; - type = field->type; - // free, restore bitstream - zfp_field_free(field); - zfp_stream_set_bit_stream(zfp, oldBs); - stream_close(newBs); + // set class variables + nx = zfh.field->nx; + ny = zfh.field->ny; + nz = zfh.field->nz; + type = zfh.field->type; } uint dims; // array dimensionality (1, 2, or 3) From f73bfcc11e741b792227bfaa376fc63436108603 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 11:57:37 -0700 Subject: [PATCH 075/194] Change all compressed arrays' thrown exceptions, from std::invalid_argument to new zfp::array::header_exception --- array/zfparray.h | 27 +++++++++++++++++++++------ tests/array/testArrayBase.cpp | 12 ++++++------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/array/zfparray.h b/array/zfparray.h index 8e84a1cf8..684599749 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -3,7 +3,7 @@ #include #include -#include +#include #include #include "zfp.h" @@ -23,6 +23,22 @@ class array { uchar buffer[ZFP_HEADER_SIZE_BYTES]; } header; + class header_exception : public std::exception { + public: + header_exception(const char* msg) : msg(msg) {} + + header_exception(const std::string& msg) : msg(msg) {} + + virtual ~header_exception() throw (){} + + virtual const char* what() const throw () { + return msg.c_str(); + } + + protected: + std::string msg; + }; + protected: // default constructor array() : @@ -59,7 +75,7 @@ class array { // read header to populate member variables associated with zfp_stream try { read_header(h); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { unused_(e); zfp_stream_close(zfp); throw; @@ -72,10 +88,9 @@ class array { uint mz = ((std::max(nz, 1u)) + 3) / 4; size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; size_t describedSize = ((blocks * zfp->maxbits + stream_word_bits - 1) & ~(stream_word_bits - 1)) / CHAR_BIT; - if (bufferSizeBytes < describedSize) { zfp_stream_close(zfp); - throw std::invalid_argument("ZFP header expects a longer buffer than what was passed in."); + throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); } } @@ -289,7 +304,7 @@ class array { // read header to populate member variables associated with zfp_stream if (zfp_read_header(zfp, zfh.field, ZFP_HEADER_FULL) != ZFP_HEADER_SIZE_BITS) - throw std::invalid_argument("Invalid ZFP header."); + throw zfp::array::header_exception("Invalid ZFP header."); // verify read-header contents std::string errMsg = ""; @@ -309,7 +324,7 @@ class array { } if (!errMsg.empty()) - throw std::invalid_argument(errMsg); + throw zfp::array::header_exception(errMsg); // set class variables nx = zfh.field->nx; diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 2b9467d4c..4adde042a 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -148,7 +148,7 @@ TEST_F(TEST_FIXTURE, when_constructorFromSerializedWithInvalidHeader_then_except try { ZFP_ARRAY_TYPE arr(h, NULL); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("Invalid ZFP header.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -171,7 +171,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongScalarType_when_con try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified an underlying scalar type different than that for this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -194,7 +194,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongDimensionality_when try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified a dimensionality different than that for this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -249,7 +249,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateHeader_when_constructorFromSeri try { ZFP_ARRAY_TYPE arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified a non fixed-rate mode, unsupported by this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -308,7 +308,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_TRUE(strstr(e.what(), "ZFP header specified an underlying scalar type different than that for this object.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP header specified a dimensionality different than that for this object.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP header specified a non fixed-rate mode, unsupported by this object.") != NULL); @@ -341,7 +341,7 @@ TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_const try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size() - 1); FailWhenNoExceptionThrown(); - } catch (std::invalid_argument const & e) { + } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header expects a longer buffer than what was passed in.")); } catch (std::exception const & e) { FailAndPrintException(e); From 40ec330645473d512ddfcee5d9701e94e7aa0c7a Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 11:59:41 -0700 Subject: [PATCH 076/194] Fix invalid accesses in zfp::array::read/write_header(). Bitstream memory must be word aligned --- array/zfparray.h | 45 +++++++++++++++++++++++++++++++---- tests/array/testArrayBase.cpp | 6 ++--- 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/array/zfparray.h b/array/zfparray.h index 684599749..33cafcaa0 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -3,14 +3,21 @@ #include #include +#include #include #include #include "zfp.h" #include "zfp/memory.h" +// header is 96 bits #define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) #define ZFP_HEADER_SIZE_BYTES ((ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT) +// when r/w bitstream, underlying memory needs to be word aligned +// then memcpy() to move data between aligned bitstream mem and unaligned zfp::array::header +#define ZFP_HEADER_SIZE_WORDS ((ZFP_HEADER_SIZE_BITS + stream_word_bits - 1) / stream_word_bits) +#define ZFP_HEADER_PADDED_TO_WORD_BYTES (ZFP_HEADER_SIZE_WORDS * stream_word_bits / CHAR_BIT) +// note: ZFP_HEADER_PADDED_TO_WORD_BYTES >= ZFP_HEADER_SIZE_BYTES #define unused_(x) ((void)(x)) @@ -165,17 +172,43 @@ class array { // write header with latest metadata void write_header(zfp::array::header& h) const { - DualBitstreamHandle dbh(zfp, &h, ZFP_HEADER_SIZE_BYTES); + // intermediate buffer needed (bitstream accesses multiples of wordsize) + AlignedBufferHandle abh; + + DualBitstreamHandle dbh(zfp, abh.buffer, ZFP_HEADER_SIZE_BYTES); ZfpFieldHandle zfh(type, nx, ny, nz); // write header zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL); stream_flush(zfp->stream); + + abh.copy_to_header(&h); } protected: // "Handle" classes useful when throwing exceptions in read_header() + // buffer holds aligned memory for header, suitable for bitstream r/w + class AlignedBufferHandle { + public: + uchar* buffer; + + // can copy a header into aligned buffer + AlignedBufferHandle(const zfp::array::header* h = 0) { + buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; + if (h) + memcpy(buffer, h->buffer, ZFP_HEADER_SIZE_BYTES); + } + + ~AlignedBufferHandle() { + delete[] buffer; + } + + void copy_to_header(zfp::array::header* h) { + memcpy(h, buffer, ZFP_HEADER_SIZE_BYTES); + } + }; + // redirect zfp_stream->bitstream to header while object remains in scope class DualBitstreamHandle { public: @@ -183,11 +216,11 @@ class array { bitstream* newBs; zfp_stream* zfp; - DualBitstreamHandle(zfp_stream* zfp, zfp::array::header* h, size_t headerSizeBytes) : + DualBitstreamHandle(zfp_stream* zfp, uchar* buffer, size_t bufferSizeBytes) : zfp(zfp) { oldBs = zfp_stream_bit_stream(zfp); - newBs = stream_open(h->buffer, headerSizeBytes); + newBs = stream_open(buffer, bufferSizeBytes); stream_rewind(newBs); zfp_stream_set_bit_stream(zfp, newBs); @@ -298,8 +331,10 @@ class array { // and verify header contents (throws exceptions upon failure) void read_header(const zfp::array::header& h) { - // cast off const to satisfy bitstream constructor (we only perform reads anyway) - DualBitstreamHandle dbh(zfp, (zfp::array::header*)&h, ZFP_HEADER_SIZE_BYTES); + // copy header into aligned buffer + AlignedBufferHandle abh(&h); + + DualBitstreamHandle dbh(zfp, abh.buffer, ZFP_HEADER_SIZE_BYTES); ZfpFieldHandle zfh; // read header to populate member variables associated with zfp_stream diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 4adde042a..a61037297 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -582,10 +582,8 @@ void CheckHeadersEquivalent(const ZFP_ARRAY_TYPE& arr1, const ZFP_ARRAY_TYPE& ar arr1.write_header(h[0]); arr2.write_header(h[1]); - size_t headerSizeBytes = (ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT; - - uint64 header1Checksum = hashBitstream((uint64*)(h + 0), headerSizeBytes); - uint64 header2Checksum = hashBitstream((uint64*)(h + 1), headerSizeBytes); + uint64 header1Checksum = hashBitstream((uint64*)(h + 0), ZFP_HEADER_SIZE_BYTES); + uint64 header2Checksum = hashBitstream((uint64*)(h + 1), ZFP_HEADER_SIZE_BYTES); EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, header1Checksum, header2Checksum); } From b334a005c3831723875e1b74a803fe66ce6fc6fa Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 12:03:28 -0700 Subject: [PATCH 077/194] Add static zfp::array::construct(), returning pointer to zfp::array base-class (when constructing an unknown compressed array type from memory). This is optional and requires users to #include zfputils.h last. Throws zfp::header_exception if unable to construct --- array/zfparray.h | 16 ++-- array/zfputils.h | 153 ++++++++++++++++++++++++++++++++++ tests/array/testArray1d.cpp | 1 + tests/array/testArray1f.cpp | 1 + tests/array/testArray2d.cpp | 1 + tests/array/testArray2f.cpp | 1 + tests/array/testArray3d.cpp | 1 + tests/array/testArray3f.cpp | 1 + tests/array/testArrayBase.cpp | 63 ++++++++++++++ 9 files changed, 231 insertions(+), 7 deletions(-) create mode 100644 array/zfputils.h diff --git a/array/zfparray.h b/array/zfparray.h index 33cafcaa0..cc2e78119 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -46,6 +46,8 @@ class array { std::string msg; }; + static zfp::array* construct(const zfp::array::header& header, const uchar* buffer = 0, size_t bufferSizeBytes = 0); + protected: // default constructor array() : @@ -119,13 +121,6 @@ class array { deep_copy(a); } - // protected destructor (cannot delete array through base class pointer) - ~array() - { - free(); - zfp_stream_close(zfp); - } - // assignment operator--performs a deep copy array& operator=(const array& a) { @@ -134,6 +129,13 @@ class array { } public: + // public virtual destructor (can delete array through base class pointer) + virtual ~array() + { + free(); + zfp_stream_close(zfp); + } + // rate in bits per value double rate() const { return double(blkbits) / block_size(); } diff --git a/array/zfputils.h b/array/zfputils.h new file mode 100644 index 000000000..cfd24dfbe --- /dev/null +++ b/array/zfputils.h @@ -0,0 +1,153 @@ +#ifndef ZFP_UTILS_H +#define ZFP_UTILS_H + +// (assumes zfparray.h already included) + +static void read_header_contents(const zfp::array::header& header, size_t bufferSizeBytes, uint& dims, zfp_type& type, double& rate, uint* n) +{ + // create zfp_stream and zfp_field structs to call C API zfp_read_header() + uchar* buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; + memcpy(buffer, header.buffer, ZFP_HEADER_SIZE_BYTES); + + bitstream* bs = stream_open(buffer, ZFP_HEADER_PADDED_TO_WORD_BYTES); + zfp_stream* stream = zfp_stream_open(bs); + zfp_field* field = zfp_field_alloc(); + + std::string errMsg = ""; + if (!zfp_read_header(stream, field, ZFP_HEADER_FULL)) { + errMsg += "Invalid ZFP header."; + } else { + // gather metadata + dims = zfp_field_dimensionality(field); + type = zfp_field_type(field); + + uint numBlockEntries = 1u << (2 * dims); + rate = (double)stream->maxbits / numBlockEntries; + + zfp_field_size(field, n); + + // validate metadata, accumulate exception msgs + if (n[3]) { + errMsg += "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."; + } + + if (type < zfp_type_float) { + if (!errMsg.empty()) + errMsg += " "; + errMsg += "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; + } + + if (bufferSizeBytes != 0) { + // verify buffer is large enough, with what header describes + uint mx = ((std::max(n[0], 1u)) + 3) / 4; + uint my = ((std::max(n[1], 1u)) + 3) / 4; + uint mz = ((std::max(n[2], 1u)) + 3) / 4; + size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; + size_t describedSize = ((blocks * stream->maxbits + stream_word_bits - 1) & ~(stream_word_bits - 1)) / CHAR_BIT; + if (bufferSizeBytes < describedSize) { + if (!errMsg.empty()) + errMsg += " "; + errMsg += "ZFP header expects a longer buffer than what was passed in."; + } + } + } + + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + delete[] buffer; + + if (!errMsg.empty()) + throw zfp::array::header_exception(errMsg); +} + +zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* buffer, size_t bufferSizeBytes) +{ + // gather array metadata via C API, then construct with metadata + uint dims = 0; + zfp_type type = zfp_type_none; + double rate = 0; + uint n[4] = {0}; + + // read once (will throw if reads a noncompatible header) + read_header_contents(header, bufferSizeBytes, dims, type, rate, n); + + // construct once (passing zfp::array::header will read it again) + zfp::array* arr = 0; + std::string errMsg = ""; + switch (dims) { + case 3: +#ifdef ZFP_ARRAY3_H + switch (type) { + case zfp_type_double: + arr = new zfp::array3d(n[0], n[1], n[2], rate); + break; + + case zfp_type_float: + arr = new zfp::array3f(n[0], n[1], n[2], rate); + break; + + default: + errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; + break; + } +#else + errMsg = "Header files for 3 dimensional ZFP compressed arrays were not included."; +#endif + break; + + case 2: +#ifdef ZFP_ARRAY2_H + switch (type) { + case zfp_type_double: + arr = new zfp::array2d(n[0], n[1], rate); + break; + + case zfp_type_float: + arr = new zfp::array2f(n[0], n[1], rate); + break; + + default: + errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; + break; + } +#else + errMsg = "Header files for 2 dimensional ZFP compressed arrays were not included."; +#endif + break; + + case 1: +#ifdef ZFP_ARRAY1_H + switch (type) { + case zfp_type_double: + arr = new zfp::array1d(n[0], rate); + break; + + case zfp_type_float: + arr = new zfp::array1f(n[0], rate); + break; + + default: + errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; + break; + } +#else + errMsg = "Header files for 1 dimensional ZFP compressed arrays were not included."; +#endif + break; + + default: + errMsg = "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."; + break; + } + + if (!errMsg.empty()) { + throw zfp::array::header_exception(errMsg); + } + + memcpy(arr->compressed_data(), buffer, bufferSizeBytes); + + return arr; +} + +#endif diff --git a/tests/array/testArray1d.cpp b/tests/array/testArray1d.cpp index fe3e78885..0209d3198 100644 --- a/tests/array/testArray1d.cpp +++ b/tests/array/testArray1d.cpp @@ -1,5 +1,6 @@ #include "array/zfparray1.h" #include "array/zfparray2.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray1f.cpp b/tests/array/testArray1f.cpp index 1813d531f..e9d333b1e 100644 --- a/tests/array/testArray1f.cpp +++ b/tests/array/testArray1f.cpp @@ -1,5 +1,6 @@ #include "array/zfparray1.h" #include "array/zfparray2.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray2d.cpp b/tests/array/testArray2d.cpp index 0c2e583c1..7c17d9f03 100644 --- a/tests/array/testArray2d.cpp +++ b/tests/array/testArray2d.cpp @@ -1,5 +1,6 @@ #include "array/zfparray2.h" #include "array/zfparray3.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray2f.cpp b/tests/array/testArray2f.cpp index a4cf4846c..4c1b307df 100644 --- a/tests/array/testArray2f.cpp +++ b/tests/array/testArray2f.cpp @@ -1,5 +1,6 @@ #include "array/zfparray2.h" #include "array/zfparray3.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray3d.cpp b/tests/array/testArray3d.cpp index cb80f2015..0255a26aa 100644 --- a/tests/array/testArray3d.cpp +++ b/tests/array/testArray3d.cpp @@ -1,5 +1,6 @@ #include "array/zfparray3.h" #include "array/zfparray1.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray3f.cpp b/tests/array/testArray3f.cpp index c842087ae..0bd508bd5 100644 --- a/tests/array/testArray3f.cpp +++ b/tests/array/testArray3f.cpp @@ -1,5 +1,6 @@ #include "array/zfparray3.h" #include "array/zfparray1.h" +#include "array/zfputils.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index a61037297..ab10d5bf9 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -348,6 +348,69 @@ TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_const } } +TEST_F(TEST_FIXTURE, given_serializedCompressedArrayHeader_when_factoryFuncConstruct_then_correctTypeConstructed) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE arr(inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 2 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 3 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#endif + + zfp::array::header h; + arr.write_header(h); + + array* arr2 = zfp::array::construct(h); + + ASSERT_TRUE(arr2 != 0); + + delete arr2; +} + +TEST_F(TEST_FIXTURE, given_serializedCompressedArray_when_factoryFuncConstruct_then_correctTypeConstructedWithPopulatedEntries) +{ +#if DIMS == 1 + ZFP_ARRAY_TYPE arr(inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 2 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#elif DIMS == 3 + ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); +#endif + + arr[1] = 999.; + + zfp::array::header h; + arr.write_header(h); + + array* arr2 = zfp::array::construct(h, arr.compressed_data(), arr.compressed_size()); + + ASSERT_TRUE(arr2 != 0); + EXPECT_EQ(arr.compressed_size(), arr2->compressed_size()); + ASSERT_TRUE(std::memcmp(arr.compressed_data(), arr2->compressed_data(), arr.compressed_size()) == 0); + + delete arr2; +} + +TEST_F(TEST_FIXTURE, given_uncompatibleSerializedMem_when_factoryFuncConstruct_then_throwsZfpHeaderException) +{ + zfp::array::header h = {0}; + + size_t dummyLen = 1024; + uchar* dummyMem = new uchar[dummyLen]; + memset(dummyMem, 0, dummyLen); + + try { + array* arr = zfp::array::construct(h, dummyMem, dummyLen); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("Invalid ZFP header.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } + + delete[] dummyMem; +} + #if DIMS == 1 // with write random access in 1D, fixed-rate params rounded up to multiples of 16 INSTANTIATE_TEST_CASE_P(TestManyCompressionRates, TEST_FIXTURE, ::testing::Values(1, 2)); From d6b1244336010d90c6e3107ae60772940fffda98 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 13 Mar 2019 00:23:14 -0700 Subject: [PATCH 078/194] Add zfp::array::header test, that something written from C API can be constructed by compressed array object --- tests/array/testArrayBase.cpp | 54 +++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index ab10d5bf9..1f74e1327 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -325,6 +325,60 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional delete[] buffer; } +TEST_F(TEST_FIXTURE, given_compatibleHeaderWrittenViaCApi_when_constructorFromSerialized_then_success) +{ + // create a compressed stream through C API + // (one that is supported with compressed arrays) + zfp_field* field; +#if DIMS == 1 + field = zfp_field_1d(inputDataArr, ZFP_TYPE, inputDataSideLen); +#elif DIMS == 2 + field = zfp_field_2d(inputDataArr, ZFP_TYPE, inputDataSideLen, inputDataSideLen); +#elif DIMS == 3 + field = zfp_field_3d(inputDataArr, ZFP_TYPE, inputDataSideLen, inputDataSideLen, inputDataSideLen); +#endif + + zfp_stream* stream = zfp_stream_open(NULL); + + size_t bufsizeBytes = zfp_stream_maximum_size(stream, field); + uchar* buffer = new uchar[bufsizeBytes]; + memset(buffer, 0, bufsizeBytes); + + bitstream* bs = stream_open(buffer, bufsizeBytes); + zfp_stream_set_bit_stream(stream, bs); + zfp_stream_rewind(stream); + + zfp_stream_set_rate(stream, 10, ZFP_TYPE, DIMS, 1); + EXPECT_EQ(zfp_mode_fixed_rate, zfp_stream_compression_mode(stream)); + + // write header + size_t writtenBits = zfp_write_header(stream, field, ZFP_HEADER_FULL); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, writtenBits); + zfp_stream_flush(stream); + + // copy header into header + size_t headerSizeBytes = (writtenBits + CHAR_BIT - 1) / CHAR_BIT; + zfp::array::header h; + memcpy(h.buffer, buffer, headerSizeBytes); + + // compress data + uchar* compressedDataPtr = (uchar*)stream_data(bs) + headerSizeBytes; + zfp_compress(stream, field); + + // close/free C API things (keep buffer) + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + + try { + ZFP_ARRAY_TYPE arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); + } catch (std::exception const & e) { + FailAndPrintException(e); + } + + delete[] buffer; +} + TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_constructorFromSerialized_then_exceptionThrown) { #if DIMS == 1 From 6f50c9900c99c0270a078ff79eb17ba1645ce6e4 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sun, 31 Mar 2019 17:03:02 -0700 Subject: [PATCH 079/194] compressed arrays throw zfp::array::header_exception when encountered with a long header add tests catching exceptions for zfp::array::construct() --- array/zfparray.h | 10 +- tests/array/CMakeLists.txt | 6 ++ tests/array/testArray1d.cpp | 4 + tests/array/testArray1f.cpp | 4 + tests/array/testArray2d.cpp | 4 + tests/array/testArray2f.cpp | 4 + tests/array/testArray3d.cpp | 4 + tests/array/testArray3f.cpp | 4 + tests/array/testArrayBase.cpp | 44 +++++++++ tests/array/testConstruct.cpp | 144 +++++++++++++++++++++++++++++ tests/array/utils/gtestCApiTest.h | 28 ++++++ tests/array/utils/gtestDoubleEnv.h | 19 ++++ tests/array/utils/gtestFloatEnv.h | 19 ++++ 13 files changed, 292 insertions(+), 2 deletions(-) create mode 100644 tests/array/testConstruct.cpp create mode 100644 tests/array/utils/gtestCApiTest.h diff --git a/array/zfparray.h b/array/zfparray.h index cc2e78119..2d23176e4 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -180,7 +180,10 @@ class array { DualBitstreamHandle dbh(zfp, abh.buffer, ZFP_HEADER_SIZE_BYTES); ZfpFieldHandle zfh(type, nx, ny, nz); - // write header + // avoid long header (alignment issue) + if (zfp_stream_mode(zfp) > ZFP_MODE_SHORT_MAX) + throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); + zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL); stream_flush(zfp->stream); @@ -340,8 +343,11 @@ class array { ZfpFieldHandle zfh; // read header to populate member variables associated with zfp_stream - if (zfp_read_header(zfp, zfh.field, ZFP_HEADER_FULL) != ZFP_HEADER_SIZE_BITS) + size_t readbits = zfp_read_header(zfp, zfh.field, ZFP_HEADER_FULL); + if (!readbits) throw zfp::array::header_exception("Invalid ZFP header."); + else if (readbits != ZFP_HEADER_SIZE_BITS) + throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); // verify read-header contents std::string errMsg = ""; diff --git a/tests/array/CMakeLists.txt b/tests/array/CMakeLists.txt index 84cf79c71..03a742ae2 100644 --- a/tests/array/CMakeLists.txt +++ b/tests/array/CMakeLists.txt @@ -43,4 +43,10 @@ zfp_add_cpp_tests(1 d 64) zfp_add_cpp_tests(2 d 64) zfp_add_cpp_tests(3 d 64) +# test zfp::array::construct() invalid cases +set(test_name testConstruct) +add_executable(testConstruct testConstruct.cpp) +target_link_libraries(testConstruct gtest gtest_main zfp) +add_test(NAME testConstruct COMMAND testConstruct) + add_subdirectory(zfp) diff --git a/tests/array/testArray1d.cpp b/tests/array/testArray1d.cpp index 0209d3198..90b4d0c7f 100644 --- a/tests/array/testArray1d.cpp +++ b/tests/array/testArray1d.cpp @@ -22,13 +22,17 @@ Array1dTestEnv* const testEnv = new Array1dTestEnv; class Array1dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array1dTest + #define ZFP_ARRAY_TYPE array1d #define ZFP_ARRAY_TYPE_WRONG_SCALAR array1f #define ZFP_ARRAY_TYPE_WRONG_DIM array2d #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array2f +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array3d + #define UINT uint64 #define SCALAR double #define DIMS 1 + #include "testArrayBase.cpp" #include "testArray1Base.cpp" diff --git a/tests/array/testArray1f.cpp b/tests/array/testArray1f.cpp index e9d333b1e..17568d70d 100644 --- a/tests/array/testArray1f.cpp +++ b/tests/array/testArray1f.cpp @@ -22,13 +22,17 @@ Array1fTestEnv* const testEnv = new Array1fTestEnv; class Array1fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array1fTest + #define ZFP_ARRAY_TYPE array1f #define ZFP_ARRAY_TYPE_WRONG_SCALAR array1d #define ZFP_ARRAY_TYPE_WRONG_DIM array2f #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array2d +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array3f + #define UINT uint32 #define SCALAR float #define DIMS 1 + #include "testArrayBase.cpp" #include "testArray1Base.cpp" diff --git a/tests/array/testArray2d.cpp b/tests/array/testArray2d.cpp index 7c17d9f03..df1572007 100644 --- a/tests/array/testArray2d.cpp +++ b/tests/array/testArray2d.cpp @@ -22,13 +22,17 @@ Array2dTestEnv* const testEnv = new Array2dTestEnv; class Array2dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array2dTest + #define ZFP_ARRAY_TYPE array2d #define ZFP_ARRAY_TYPE_WRONG_SCALAR array2f #define ZFP_ARRAY_TYPE_WRONG_DIM array3d #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array3f +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array1d + #define UINT uint64 #define SCALAR double #define DIMS 2 + #include "testArrayBase.cpp" #include "testArray2Base.cpp" diff --git a/tests/array/testArray2f.cpp b/tests/array/testArray2f.cpp index 4c1b307df..97bf4fcee 100644 --- a/tests/array/testArray2f.cpp +++ b/tests/array/testArray2f.cpp @@ -22,13 +22,17 @@ Array2fTestEnv* const testEnv = new Array2fTestEnv; class Array2fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array2fTest + #define ZFP_ARRAY_TYPE array2f #define ZFP_ARRAY_TYPE_WRONG_SCALAR array2d #define ZFP_ARRAY_TYPE_WRONG_DIM array3f #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array3d +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array1f + #define UINT uint32 #define SCALAR float #define DIMS 2 + #include "testArrayBase.cpp" #include "testArray2Base.cpp" diff --git a/tests/array/testArray3d.cpp b/tests/array/testArray3d.cpp index 0255a26aa..de75f45b6 100644 --- a/tests/array/testArray3d.cpp +++ b/tests/array/testArray3d.cpp @@ -22,13 +22,17 @@ Array3dTestEnv* const testEnv = new Array3dTestEnv; class Array3dTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array3dTest + #define ZFP_ARRAY_TYPE array3d #define ZFP_ARRAY_TYPE_WRONG_SCALAR array3f #define ZFP_ARRAY_TYPE_WRONG_DIM array1d #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array1f +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array2d + #define UINT uint64 #define SCALAR double #define DIMS 3 + #include "testArrayBase.cpp" #include "testArray3Base.cpp" diff --git a/tests/array/testArray3f.cpp b/tests/array/testArray3f.cpp index 0bd508bd5..56ed2b04f 100644 --- a/tests/array/testArray3f.cpp +++ b/tests/array/testArray3f.cpp @@ -22,13 +22,17 @@ Array3fTestEnv* const testEnv = new Array3fTestEnv; class Array3fTest : public ArrayNdTestFixture {}; #define TEST_FIXTURE Array3fTest + #define ZFP_ARRAY_TYPE array3f #define ZFP_ARRAY_TYPE_WRONG_SCALAR array3d #define ZFP_ARRAY_TYPE_WRONG_DIM array1f #define ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM array1d +#define ZFP_ARRAY_NOT_INCLUDED_TYPE array2f + #define UINT uint32 #define SCALAR float #define DIMS 3 + #include "testArrayBase.cpp" #include "testArray3Base.cpp" diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 1f74e1327..69f9717ca 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -5,6 +5,7 @@ extern "C" { } #include +#include TEST_F(TEST_FIXTURE, when_constructorCalled_then_rateSetWithWriteRandomAccess) { @@ -155,6 +156,49 @@ TEST_F(TEST_FIXTURE, when_constructorFromSerializedWithInvalidHeader_then_except } } +TEST_F(TEST_FIXTURE, given_zfpHeaderForCertainDimensionalityButHeaderMissing_when_construct_expect_zfpArrayHeaderExceptionThrown) +{ + uint missingDim = ((DIMS + 1) % 3) + 1; + zfp_stream_set_rate(stream, 12, ZFP_TYPE, missingDim, 1); + + zfp_field_set_type(field, ZFP_TYPE); + switch(missingDim) { + case 3: + zfp_field_set_size_3d(field, 12, 12, 12); + break; + + case 2: + zfp_field_set_size_2d(field, 12, 12); + break; + + case 1: + zfp_field_set_size_1d(field, 12); + break; + } + + // write header to buffer with C API + zfp_stream_rewind(stream); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, zfp_write_header(stream, field, ZFP_HEADER_FULL)); + zfp_stream_flush(stream); + + zfp::array::header h; + // zfp::array::header collects header up to next byte + memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + + try { + zfp::array* arr = zfp::array::construct(h); + FailWhenNoExceptionThrown(); + + } catch (zfp::array::header_exception const & e) { + std::stringstream ss; + ss << "Header files for " << missingDim << " dimensional ZFP compressed arrays were not included."; + EXPECT_EQ(e.what(), ss.str()); + + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongScalarType_when_constructorFromSerialized_then_exceptionThrown) { #if DIMS == 1 diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp new file mode 100644 index 000000000..5bf4db95d --- /dev/null +++ b/tests/array/testConstruct.cpp @@ -0,0 +1,144 @@ +#include "array/zfparray2.h" +#include "array/zfparray3.h" +#include "array/zfputils.h" +using namespace zfp; + +#include "gtest/gtest.h" +#include "utils/gtestTestEnv.h" +#include "utils/gtestCApiTest.h" +#define TEST_FIXTURE ZfpArrayConstructTest + +TestEnv* const testEnv = new TestEnv; + +void FailWhenNoExceptionThrown() +{ + FAIL() << "No exception was thrown when one was expected"; +} + +void FailAndPrintException(std::exception const & e) +{ + FAIL() << "Unexpected exception thrown: " << typeid(e).name() << std::endl << "With message: " << e.what(); +} + +TEST_F(TEST_FIXTURE, given_zfpHeaderForIntegerData_when_construct_expect_zfpArrayHeaderExceptionThrown) +{ + zfp_type zfpType = zfp_type_int32; + + zfp_stream_set_rate(stream, 16, zfpType, 2, 1); + + zfp_field_set_type(field, zfpType); + zfp_field_set_size_2d(field, 12, 12); + + // write header to buffer with C API + zfp_stream_rewind(stream); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, zfp_write_header(stream, field, ZFP_HEADER_FULL)); + zfp_stream_flush(stream); + + zfp::array::header h; + // zfp::array::header collects header up to next byte + memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + + try { + zfp::array* arr = zfp::array::construct(h); + FailWhenNoExceptionThrown(); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("ZFP compressed arrays do not yet support scalar types beyond floats and doubles.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_zfpHeaderForHigherDimensionalData_when_construct_expect_zfpArrayHeaderExceptionThrown) +{ + zfp_type zfpType = zfp_type_float; + + zfp_stream_set_rate(stream, 6, zfpType, 4, 1); + + zfp_field_set_type(field, zfpType); + zfp_field_set_size_4d(field, 12, 12, 12, 12); + + // write header to buffer with C API + zfp_stream_rewind(stream); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, zfp_write_header(stream, field, ZFP_HEADER_FULL)); + zfp_stream_flush(stream); + + zfp::array::header h; + // zfp::array::header collects header up to next byte + memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + + try { + zfp::array* arr = zfp::array::construct(h); + FailWhenNoExceptionThrown(); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_onlyInclude2D3D_and_zfpHeaderFor1D_when_construct_expect_zfpArrayHeaderExceptionThrown) +{ + zfp_type zfpType = zfp_type_float; + + zfp_stream_set_rate(stream, 12, zfpType, 1, 1); + + zfp_field_set_type(field, zfpType); + zfp_field_set_size_1d(field, 12); + + // write header to buffer with C API + zfp_stream_rewind(stream); + EXPECT_EQ(ZFP_HEADER_SIZE_BITS, zfp_write_header(stream, field, ZFP_HEADER_FULL)); + zfp_stream_flush(stream); + + zfp::array::header h; + // zfp::array::header collects header up to next byte + memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + + try { + zfp::array* arr = zfp::array::construct(h); + FailWhenNoExceptionThrown(); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("Header files for 1 dimensional ZFP compressed arrays were not included.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_validHeaderBuffer_withBufferSizeTooLow_when_construct_expect_zfpArrayHeaderExceptionThrown) +{ + zfp::array3d arr(12, 12, 12, 32); + + zfp::array::header h; + arr.write_header(h); + + try { + zfp::array* arr2 = zfp::array::construct(h, arr.compressed_data(), 1); + FailWhenNoExceptionThrown(); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("ZFP header expects a longer buffer than what was passed in.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +TEST_F(TEST_FIXTURE, given_compressedArrayWithLongHeader_when_writeHeader_expect_zfpArrayHeaderExceptionThrown) +{ + zfp::array3d arr(12, 12, 12, 33); + + zfp::array::header h; + + try { + arr.write_header(h); + FailWhenNoExceptionThrown(); + } catch (zfp::array::header_exception const & e) { + EXPECT_EQ(e.what(), std::string("ZFP compressed arrays only support short headers at this time.")); + } catch (std::exception const & e) { + FailAndPrintException(e); + } +} + +int main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + static_cast(::testing::AddGlobalTestEnvironment(testEnv)); + return RUN_ALL_TESTS(); +} diff --git a/tests/array/utils/gtestCApiTest.h b/tests/array/utils/gtestCApiTest.h new file mode 100644 index 000000000..d7a7be07e --- /dev/null +++ b/tests/array/utils/gtestCApiTest.h @@ -0,0 +1,28 @@ +#include "gtest/gtest.h" + +class ZfpArrayConstructTest : public ::testing::Test { +protected: + virtual void SetUp() { + buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; + bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + stream = zfp_stream_open(bs); + field = zfp_field_alloc(); + } + + virtual void TearDown() { + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + delete[] buffer; + } + + static uchar* buffer; + static bitstream* bs; + static zfp_stream* stream; + static zfp_field* field; +}; + +uchar* ZfpArrayConstructTest::buffer; +bitstream* ZfpArrayConstructTest::bs; +zfp_stream* ZfpArrayConstructTest::stream; +zfp_field* ZfpArrayConstructTest::field; diff --git a/tests/array/utils/gtestDoubleEnv.h b/tests/array/utils/gtestDoubleEnv.h index 3042343ec..b0cf80da0 100644 --- a/tests/array/utils/gtestDoubleEnv.h +++ b/tests/array/utils/gtestDoubleEnv.h @@ -1,23 +1,42 @@ #include "gtest/gtest.h" +#include "zfp.h" extern "C" { #include "utils/genSmoothRandNums.h" } +#define SCALAR double +#define ZFP_TYPE zfp_type_double + const size_t MIN_TOTAL_ELEMENTS = 1000000; size_t inputDataSideLen, inputDataTotalLen; double* inputDataArr; +uchar* buffer; +bitstream* bs; +zfp_stream* stream; +zfp_field* field; + class ArrayDoubleTestEnv : public ::testing::Environment { public: virtual int getDims() = 0; virtual void SetUp() { generateSmoothRandDoubles(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); + + buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; + bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + stream = zfp_stream_open(bs); + field = zfp_field_alloc(); } virtual void TearDown() { free(inputDataArr); + + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + delete[] buffer; } }; diff --git a/tests/array/utils/gtestFloatEnv.h b/tests/array/utils/gtestFloatEnv.h index 735b15a1e..e3ecfd4b2 100644 --- a/tests/array/utils/gtestFloatEnv.h +++ b/tests/array/utils/gtestFloatEnv.h @@ -1,23 +1,42 @@ #include "gtest/gtest.h" +#include "zfp.h" extern "C" { #include "utils/genSmoothRandNums.h" } +#define SCALAR float +#define ZFP_TYPE zfp_type_float + const size_t MIN_TOTAL_ELEMENTS = 1000000; size_t inputDataSideLen, inputDataTotalLen; float* inputDataArr; +uchar* buffer; +bitstream* bs; +zfp_stream* stream; +zfp_field* field; + class ArrayFloatTestEnv : public ::testing::Environment { public: virtual int getDims() = 0; virtual void SetUp() { generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); + + buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; + bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + stream = zfp_stream_open(bs); + field = zfp_field_alloc(); } virtual void TearDown() { free(inputDataArr); + + zfp_field_free(field); + zfp_stream_close(stream); + stream_close(bs); + delete[] buffer; } }; From b36af17b4a2587fffdc66aee64df0640a390cb3c Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 1 Apr 2019 22:48:32 -0700 Subject: [PATCH 080/194] rework header-length macros, construct() and its helper functions, move header_exception and header-related functions/classes into separate header files zfp::array::header_exception now derives from std::runtime_error fix incorrect test --- array/zfp/exceptions.h | 6 + array/zfp/headerHelpers.h | 151 ++++++++++++++++++++++++ array/zfparray.h | 181 ++++++----------------------- array/zfparray1.h | 4 +- array/zfparray2.h | 4 +- array/zfparray3.h | 4 +- array/zfputils.h | 92 ++------------- tests/array/testArrayBase.cpp | 14 +-- tests/array/testConstruct.cpp | 6 +- tests/array/utils/commonMacros.h | 7 ++ tests/array/utils/gtestCApiTest.h | 5 +- tests/array/utils/gtestDoubleEnv.h | 5 +- tests/array/utils/gtestFloatEnv.h | 5 +- 13 files changed, 237 insertions(+), 247 deletions(-) create mode 100644 array/zfp/exceptions.h create mode 100644 array/zfp/headerHelpers.h create mode 100644 tests/array/utils/commonMacros.h diff --git a/array/zfp/exceptions.h b/array/zfp/exceptions.h new file mode 100644 index 000000000..6a1b94ca1 --- /dev/null +++ b/array/zfp/exceptions.h @@ -0,0 +1,6 @@ +class header_exception : public std::runtime_error { +public: + header_exception(const std::string& msg) : runtime_error(msg) {} + + virtual ~header_exception() throw (){} +}; diff --git a/array/zfp/headerHelpers.h b/array/zfp/headerHelpers.h new file mode 100644 index 000000000..910d8a228 --- /dev/null +++ b/array/zfp/headerHelpers.h @@ -0,0 +1,151 @@ +// "Handle" classes useful when throwing exceptions + +// buffer holds aligned memory for header, suitable for bitstream r/w (word-aligned) +class AlignedBufferHandle { + public: + size_t buffer_size_bytes; + // uint64 alignment guarantees bitstream alignment + uint64* buffer; + + // can copy a header into aligned buffer + AlignedBufferHandle(const zfp::array::header* h = 0) { + size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); + buffer = new uint64[num_64bit_entries]; + buffer_size_bytes = num_64bit_entries * sizeof(uint64); + + if (h) + memcpy(buffer, h->buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + } + + ~AlignedBufferHandle() { + delete[] buffer; + } + + void copy_to_header(zfp::array::header* h) { + memcpy(h, buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + } +}; + +// redirect zfp_stream->bitstream to header while object remains in scope +class DualBitstreamHandle { + public: + bitstream* old_bs; + bitstream* new_bs; + zfp_stream* zfp; + + DualBitstreamHandle(zfp_stream* zfp, AlignedBufferHandle& abh) : + zfp(zfp) + { + old_bs = zfp_stream_bit_stream(zfp); + new_bs = stream_open(abh.buffer, abh.buffer_size_bytes); + + stream_rewind(new_bs); + zfp_stream_set_bit_stream(zfp, new_bs); + } + + ~DualBitstreamHandle() { + zfp_stream_set_bit_stream(zfp, old_bs); + stream_close(new_bs); + } +}; + +class ZfpFieldHandle { + public: + zfp_field* field; + + ZfpFieldHandle() { + field = zfp_field_alloc(); + } + + ZfpFieldHandle(zfp_type type, int nx, int ny, int nz) { + field = zfp_field_3d(0, type, nx, ny, nz); + } + + ~ZfpFieldHandle() { + zfp_field_free(field); + } +}; + +class ZfpStreamHandle { + public: + bitstream* bs; + zfp_stream* stream; + + ZfpStreamHandle(AlignedBufferHandle& abh) { + bs = stream_open(abh.buffer, abh.buffer_size_bytes); + stream = zfp_stream_open(bs); + } + + ~ZfpStreamHandle() { + zfp_stream_close(stream); + stream_close(bs); + } +}; + +// verify buffer is large enough, with what header describes +static bool is_valid_buffer_size(const zfp_stream* stream, uint nx, uint ny, uint nz, size_t expected_buffer_size_bytes) +{ + uint mx = ((std::max(nx, 1u)) + 3) / 4; + uint my = ((std::max(ny, 1u)) + 3) / 4; + uint mz = ((std::max(nz, 1u)) + 3) / 4; + size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; + // no rounding because fixed-rate wra implies rate is multiple of word size + size_t described_buffer_size_bytes = blocks * stream->maxbits / CHAR_BIT; + + return expected_buffer_size_bytes >= described_buffer_size_bytes; +} + +static void read_header_contents(const zfp::array::header& header, size_t expected_buffer_size_bytes, uint& dims, zfp_type& type, double& rate, uint n[4]) +{ + // create zfp_stream and zfp_field structs to call C API zfp_read_header() + AlignedBufferHandle abh; + memcpy(abh.buffer, header.buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + + ZfpStreamHandle zsh(abh); + ZfpFieldHandle zfh; + + if (!zfp_read_header(zsh.stream, zfh.field, ZFP_HEADER_FULL)) + throw zfp::array::header_exception("Invalid ZFP header."); + + // gather metadata + dims = zfp_field_dimensionality(zfh.field); + type = zfp_field_type(zfh.field); + + uint num_block_entries = 1u << (2 * dims); + rate = (double)zsh.stream->maxbits / num_block_entries; + + zfp_field_size(zfh.field, n); + + // validate header + std::string err_msg = ""; + verify_header_contents(zsh.stream, zfh.field, err_msg); + + if (!err_msg.empty()) + throw zfp::array::header_exception(err_msg); + + if (expected_buffer_size_bytes && !is_valid_buffer_size(zsh.stream, zfh.field->nx, zfh.field->ny, zfh.field->nz, expected_buffer_size_bytes)) + throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); +} + +// verifies metadata on zfp_stream and zfp_field describe a valid compressed array +static void verify_header_contents(const zfp_stream* stream, const zfp_field* field, std::string& err_msg) +{ + // verify read-header contents + zfp_type type = zfp_field_type(field); + if (type != zfp_type_float && type != zfp_type_double) + concat_sentence(err_msg, "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."); + + uint dims = zfp_field_dimensionality(field); + if (dims < 1 || dims > 3) + concat_sentence(err_msg, "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."); + + if (zfp_stream_compression_mode(stream) != zfp_mode_fixed_rate) + concat_sentence(err_msg, "ZFP header specified a non fixed-rate mode, unsupported by this object."); +} + +static void concat_sentence(std::string& s, const std::string& msg) +{ + if (!s.empty()) + s += " "; + s += msg; +} diff --git a/array/zfparray.h b/array/zfparray.h index 2d23176e4..0ba2f5d0a 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -4,22 +4,17 @@ #include #include #include -#include +#include #include #include "zfp.h" #include "zfp/memory.h" -// header is 96 bits -#define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) -#define ZFP_HEADER_SIZE_BYTES ((ZFP_HEADER_SIZE_BITS + CHAR_BIT - 1) / CHAR_BIT) -// when r/w bitstream, underlying memory needs to be word aligned -// then memcpy() to move data between aligned bitstream mem and unaligned zfp::array::header -#define ZFP_HEADER_SIZE_WORDS ((ZFP_HEADER_SIZE_BITS + stream_word_bits - 1) / stream_word_bits) -#define ZFP_HEADER_PADDED_TO_WORD_BYTES (ZFP_HEADER_SIZE_WORDS * stream_word_bits / CHAR_BIT) -// note: ZFP_HEADER_PADDED_TO_WORD_BYTES >= ZFP_HEADER_SIZE_BYTES +// all undefined at end +#define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) +#define BITS_TO_BYTES(x) DIV_ROUND_UP(x, CHAR_BIT) -#define unused_(x) ((void)(x)) +#define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) namespace zfp { @@ -27,26 +22,12 @@ namespace zfp { class array { public: typedef struct { - uchar buffer[ZFP_HEADER_SIZE_BYTES]; + uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)]; } header; - class header_exception : public std::exception { - public: - header_exception(const char* msg) : msg(msg) {} - - header_exception(const std::string& msg) : msg(msg) {} - - virtual ~header_exception() throw (){} - - virtual const char* what() const throw () { - return msg.c_str(); - } - - protected: - std::string msg; - }; + #include "zfp/exceptions.h" - static zfp::array* construct(const zfp::array::header& header, const uchar* buffer = 0, size_t bufferSizeBytes = 0); + static zfp::array* construct(const zfp::array::header& header, const uchar* buffer = 0, size_t buffer_size_bytes = 0); protected: // default constructor @@ -72,7 +53,7 @@ class array { {} // constructor, from previously-serialized compressed array - array(uint dims, zfp_type type, const zfp::array::header& h, size_t bufferSizeBytes) : + array(uint dims, zfp_type type, const zfp::array::header& h, size_t expected_buffer_size_bytes) : dims(dims), type(type), nx(0), ny(0), nz(0), bx(0), by(0), bz(0), @@ -84,23 +65,14 @@ class array { // read header to populate member variables associated with zfp_stream try { read_header(h); - } catch (zfp::array::header_exception const & e) { - unused_(e); + } catch (zfp::array::header_exception const &) { zfp_stream_close(zfp); throw; } - if (bufferSizeBytes != 0) { - // verify buffer is large enough, with what header describes - uint mx = ((std::max(nx, 1u)) + 3) / 4; - uint my = ((std::max(ny, 1u)) + 3) / 4; - uint mz = ((std::max(nz, 1u)) + 3) / 4; - size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; - size_t describedSize = ((blocks * zfp->maxbits + stream_word_bits - 1) & ~(stream_word_bits - 1)) / CHAR_BIT; - if (bufferSizeBytes < describedSize) { - zfp_stream_close(zfp); - throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); - } + if (expected_buffer_size_bytes && !is_valid_buffer_size(zfp, nx, ny, nz, expected_buffer_size_bytes)) { + zfp_stream_close(zfp); + throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); } // everything is valid @@ -176,84 +148,26 @@ class array { { // intermediate buffer needed (bitstream accesses multiples of wordsize) AlignedBufferHandle abh; + DualBitstreamHandle dbh(zfp, abh); - DualBitstreamHandle dbh(zfp, abh.buffer, ZFP_HEADER_SIZE_BYTES); ZfpFieldHandle zfh(type, nx, ny, nz); // avoid long header (alignment issue) if (zfp_stream_mode(zfp) > ZFP_MODE_SHORT_MAX) throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); - zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL); - stream_flush(zfp->stream); + if (!zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL)) + throw zfp::array::header_exception("ZFP could not write a header to buffer."); + stream_flush(zfp->stream); abh.copy_to_header(&h); } -protected: - // "Handle" classes useful when throwing exceptions in read_header() - - // buffer holds aligned memory for header, suitable for bitstream r/w - class AlignedBufferHandle { - public: - uchar* buffer; - - // can copy a header into aligned buffer - AlignedBufferHandle(const zfp::array::header* h = 0) { - buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; - if (h) - memcpy(buffer, h->buffer, ZFP_HEADER_SIZE_BYTES); - } - - ~AlignedBufferHandle() { - delete[] buffer; - } - - void copy_to_header(zfp::array::header* h) { - memcpy(h, buffer, ZFP_HEADER_SIZE_BYTES); - } - }; - - // redirect zfp_stream->bitstream to header while object remains in scope - class DualBitstreamHandle { - public: - bitstream* oldBs; - bitstream* newBs; - zfp_stream* zfp; - - DualBitstreamHandle(zfp_stream* zfp, uchar* buffer, size_t bufferSizeBytes) : - zfp(zfp) - { - oldBs = zfp_stream_bit_stream(zfp); - newBs = stream_open(buffer, bufferSizeBytes); - - stream_rewind(newBs); - zfp_stream_set_bit_stream(zfp, newBs); - } - - ~DualBitstreamHandle() { - zfp_stream_set_bit_stream(zfp, oldBs); - stream_close(newBs); - } - }; - - class ZfpFieldHandle { - public: - zfp_field* field; - - ZfpFieldHandle() { - field = zfp_field_alloc(); - } - - ZfpFieldHandle(zfp_type type, int nx, int ny, int nz) { - field = zfp_field_3d(0, type, nx, ny, nz); - } - - ~ZfpFieldHandle() { - zfp_field_free(field); - } - }; +private: + // private members used when reading/writing headers + #include "zfp/headerHelpers.h" +protected: // number of values per block uint block_size() const { return 1u << (2 * dims); } @@ -313,33 +227,13 @@ class array { zfp::clone(shape, a.shape, blocks); } - // returns if dimension lengths consistent with dimensionality - bool is_valid_dims(uint nx, uint ny, uint nz) const - { - bool result = true; - switch(dims) { - case 3: - result &= nz; - case 2: - result &= ny; - case 1: - result &= nx; - break; - - default: - return false; - } - return result; - } - // attempt reading header from zfp::array::header // and verify header contents (throws exceptions upon failure) void read_header(const zfp::array::header& h) { // copy header into aligned buffer AlignedBufferHandle abh(&h); - - DualBitstreamHandle dbh(zfp, abh.buffer, ZFP_HEADER_SIZE_BYTES); + DualBitstreamHandle dbh(zfp, abh); ZfpFieldHandle zfh; // read header to populate member variables associated with zfp_stream @@ -349,25 +243,21 @@ class array { else if (readbits != ZFP_HEADER_SIZE_BITS) throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); - // verify read-header contents - std::string errMsg = ""; - if (type != zfh.field->type) - errMsg += "ZFP header specified an underlying scalar type different than that for this object."; + // verify metadata on zfp_field match that for this object + std::string err_msg = ""; + if (type != zfp_field_type(zfh.field)) + err_msg += "ZFP header specified an underlying scalar type different than that for this object."; - if (!is_valid_dims(zfh.field->nx, zfh.field->ny, zfh.field->nz)) { - if (!errMsg.empty()) - errMsg += " "; - errMsg += "ZFP header specified a dimensionality different than that for this object."; + if (dims != zfp_field_dimensionality(zfh.field)) { + if (!err_msg.empty()) + err_msg += " "; + err_msg += "ZFP header specified a dimensionality different than that for this object."; } - if (zfp_stream_compression_mode(zfp) != zfp_mode_fixed_rate) { - if (!errMsg.empty()) - errMsg += " "; - errMsg += "ZFP header specified a non fixed-rate mode, unsupported by this object."; - } + verify_header_contents(zfp, zfh.field, err_msg); - if (!errMsg.empty()) - throw zfp::array::header_exception(errMsg); + if (!err_msg.empty()) + throw zfp::array::header_exception(err_msg); // set class variables nx = zfh.field->nx; @@ -388,7 +278,10 @@ class array { uchar* shape; // precomputed block dimensions (or null if uniform) }; -#undef unused_ +#undef DIV_ROUND_UP +#undef BITS_TO_BYTES + +#undef ZFP_HEADER_SIZE_BITS } diff --git a/array/zfparray1.h b/array/zfparray1.h index b6822b3ac..d102d2c5a 100644 --- a/array/zfparray1.h +++ b/array/zfparray1.h @@ -40,8 +40,8 @@ class array1 : public array { } // constructor, from previously-serialized compressed array - array1(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : - array(1, Codec::type, h, bufferSizeBytes) + array1(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) : + array(1, Codec::type, h, buffer_size_bytes) { resize(nx, false); if (buffer) diff --git a/array/zfparray2.h b/array/zfparray2.h index 71fb9ea1f..62804ecc0 100644 --- a/array/zfparray2.h +++ b/array/zfparray2.h @@ -40,8 +40,8 @@ class array2 : public array { } // constructor, from previously-serialized compressed array - array2(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : - array(2, Codec::type, h, bufferSizeBytes) + array2(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) : + array(2, Codec::type, h, buffer_size_bytes) { resize(nx, ny, false); if (buffer) diff --git a/array/zfparray3.h b/array/zfparray3.h index 3feac56bb..5fb11a8f3 100644 --- a/array/zfparray3.h +++ b/array/zfparray3.h @@ -40,8 +40,8 @@ class array3 : public array { } // constructor, from previously-serialized compressed array - array3(const zfp::array::header& h, const uchar* buffer = 0, size_t bufferSizeBytes = 0) : - array(3, Codec::type, h, bufferSizeBytes) + array3(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) : + array(3, Codec::type, h, buffer_size_bytes) { resize(nx, ny, nz, false); if (buffer) diff --git a/array/zfputils.h b/array/zfputils.h index cfd24dfbe..f12236a09 100644 --- a/array/zfputils.h +++ b/array/zfputils.h @@ -3,65 +3,7 @@ // (assumes zfparray.h already included) -static void read_header_contents(const zfp::array::header& header, size_t bufferSizeBytes, uint& dims, zfp_type& type, double& rate, uint* n) -{ - // create zfp_stream and zfp_field structs to call C API zfp_read_header() - uchar* buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; - memcpy(buffer, header.buffer, ZFP_HEADER_SIZE_BYTES); - - bitstream* bs = stream_open(buffer, ZFP_HEADER_PADDED_TO_WORD_BYTES); - zfp_stream* stream = zfp_stream_open(bs); - zfp_field* field = zfp_field_alloc(); - - std::string errMsg = ""; - if (!zfp_read_header(stream, field, ZFP_HEADER_FULL)) { - errMsg += "Invalid ZFP header."; - } else { - // gather metadata - dims = zfp_field_dimensionality(field); - type = zfp_field_type(field); - - uint numBlockEntries = 1u << (2 * dims); - rate = (double)stream->maxbits / numBlockEntries; - - zfp_field_size(field, n); - - // validate metadata, accumulate exception msgs - if (n[3]) { - errMsg += "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."; - } - - if (type < zfp_type_float) { - if (!errMsg.empty()) - errMsg += " "; - errMsg += "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; - } - - if (bufferSizeBytes != 0) { - // verify buffer is large enough, with what header describes - uint mx = ((std::max(n[0], 1u)) + 3) / 4; - uint my = ((std::max(n[1], 1u)) + 3) / 4; - uint mz = ((std::max(n[2], 1u)) + 3) / 4; - size_t blocks = (size_t)mx * (size_t)my * (size_t)mz; - size_t describedSize = ((blocks * stream->maxbits + stream_word_bits - 1) & ~(stream_word_bits - 1)) / CHAR_BIT; - if (bufferSizeBytes < describedSize) { - if (!errMsg.empty()) - errMsg += " "; - errMsg += "ZFP header expects a longer buffer than what was passed in."; - } - } - } - - zfp_field_free(field); - zfp_stream_close(stream); - stream_close(bs); - delete[] buffer; - - if (!errMsg.empty()) - throw zfp::array::header_exception(errMsg); -} - -zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* buffer, size_t bufferSizeBytes) +zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* buffer, size_t buffer_size_bytes) { // gather array metadata via C API, then construct with metadata uint dims = 0; @@ -70,11 +12,11 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* uint n[4] = {0}; // read once (will throw if reads a noncompatible header) - read_header_contents(header, bufferSizeBytes, dims, type, rate, n); + zfp::array::read_header_contents(header, buffer_size_bytes, dims, type, rate, n); // construct once (passing zfp::array::header will read it again) zfp::array* arr = 0; - std::string errMsg = ""; + std::string err_msg = ""; switch (dims) { case 3: #ifdef ZFP_ARRAY3_H @@ -86,13 +28,9 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array3f(n[0], n[1], n[2], rate); break; - - default: - errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; - break; } #else - errMsg = "Header files for 3 dimensional ZFP compressed arrays were not included."; + err_msg = "Header files for 3 dimensional ZFP compressed arrays were not included."; #endif break; @@ -106,13 +44,9 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array2f(n[0], n[1], rate); break; - - default: - errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; - break; } #else - errMsg = "Header files for 2 dimensional ZFP compressed arrays were not included."; + err_msg = "Header files for 2 dimensional ZFP compressed arrays were not included."; #endif break; @@ -126,26 +60,22 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array1f(n[0], rate); break; - - default: - errMsg = "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."; - break; } #else - errMsg = "Header files for 1 dimensional ZFP compressed arrays were not included."; + err_msg = "Header files for 1 dimensional ZFP compressed arrays were not included."; #endif break; default: - errMsg = "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."; + err_msg = "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."; break; } - if (!errMsg.empty()) { - throw zfp::array::header_exception(errMsg); - } + if (!err_msg.empty()) + throw zfp::array::header_exception(err_msg); - memcpy(arr->compressed_data(), buffer, bufferSizeBytes); + if (buffer) + memcpy(arr->compressed_data(), buffer, arr->compressed_size()); return arr; } diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 69f9717ca..c45672f6b 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -72,7 +72,7 @@ TEST_F(TEST_FIXTURE, when_setRate_then_compressionRateChanged) void VerifyProperHeaderWritten(const zfp::array::header& h, uint chosenSizeX, uint chosenSizeY, uint chosenSizeZ, double chosenRate) { // verify valid header (manually through C API) - bitstream* stream = stream_open((zfp::array::header*)&h, ZFP_HEADER_SIZE_BYTES); + bitstream* stream = stream_open((zfp::array::header*)&h, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); zfp_field* field = zfp_field_alloc(); zfp_stream* zfp = zfp_stream_open(stream); @@ -183,7 +183,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForCertainDimensionalityButHeaderMissing_whe zfp::array::header h; // zfp::array::header collects header up to next byte - memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + memcpy(h.buffer, buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); try { zfp::array* arr = zfp::array::construct(h); @@ -309,11 +309,11 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional zfp_field* field; // (inputDataSideLen specific to that dimensionality, can request too much memory if fitted to higher dimensionality) #if DIMS == 1 - field = zfp_field_2d(inputDataArr, zfp_type_int32, 100, 100); + field = zfp_field_1d(inputDataArr, zfp_type_int32, 100); #elif DIMS == 2 - field = zfp_field_3d(inputDataArr, zfp_type_int32, 100, 100, 100); + field = zfp_field_2d(inputDataArr, zfp_type_int32, 100, 100); #elif DIMS == 3 - field = zfp_field_1d(inputDataArr, zfp_type_int32, 100); + field = zfp_field_3d(inputDataArr, zfp_type_int32, 100, 100, 100); #endif zfp_stream* stream = zfp_stream_open(NULL); @@ -743,8 +743,8 @@ void CheckHeadersEquivalent(const ZFP_ARRAY_TYPE& arr1, const ZFP_ARRAY_TYPE& ar arr1.write_header(h[0]); arr2.write_header(h[1]); - uint64 header1Checksum = hashBitstream((uint64*)(h + 0), ZFP_HEADER_SIZE_BYTES); - uint64 header2Checksum = hashBitstream((uint64*)(h + 1), ZFP_HEADER_SIZE_BYTES); + uint64 header1Checksum = hashBitstream((uint64*)(h + 0), BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + uint64 header2Checksum = hashBitstream((uint64*)(h + 1), BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); EXPECT_PRED_FORMAT2(ExpectEqPrintHexPred, header1Checksum, header2Checksum); } diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp index 5bf4db95d..1a96c6409 100644 --- a/tests/array/testConstruct.cpp +++ b/tests/array/testConstruct.cpp @@ -36,7 +36,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForIntegerData_when_construct_expect_zfpArra zfp::array::header h; // zfp::array::header collects header up to next byte - memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + memcpy(h.buffer, buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); try { zfp::array* arr = zfp::array::construct(h); @@ -64,7 +64,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForHigherDimensionalData_when_construct_expe zfp::array::header h; // zfp::array::header collects header up to next byte - memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + memcpy(h.buffer, buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); try { zfp::array* arr = zfp::array::construct(h); @@ -92,7 +92,7 @@ TEST_F(TEST_FIXTURE, given_onlyInclude2D3D_and_zfpHeaderFor1D_when_construct_exp zfp::array::header h; // zfp::array::header collects header up to next byte - memcpy(h.buffer, buffer, ZFP_HEADER_SIZE_BYTES); + memcpy(h.buffer, buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); try { zfp::array* arr = zfp::array::construct(h); diff --git a/tests/array/utils/commonMacros.h b/tests/array/utils/commonMacros.h new file mode 100644 index 000000000..f71a02da5 --- /dev/null +++ b/tests/array/utils/commonMacros.h @@ -0,0 +1,7 @@ +#include "zfp.h" + +#define ROUND_UP_TO_MULTIPLE(x, y) (((x) + (y) - 1) / (y)) +#define BITS_TO_BYTES(x) ROUND_UP_TO_MULTIPLE(x, CHAR_BIT) +#define BITS_TO_WORDS(x) ROUND_UP_TO_MULTIPLE(x, stream_word_bits) + +#define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) diff --git a/tests/array/utils/gtestCApiTest.h b/tests/array/utils/gtestCApiTest.h index d7a7be07e..2cb31fcb5 100644 --- a/tests/array/utils/gtestCApiTest.h +++ b/tests/array/utils/gtestCApiTest.h @@ -1,10 +1,11 @@ #include "gtest/gtest.h" +#include "commonMacros.h" class ZfpArrayConstructTest : public ::testing::Test { protected: virtual void SetUp() { - buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; - bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; + bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } diff --git a/tests/array/utils/gtestDoubleEnv.h b/tests/array/utils/gtestDoubleEnv.h index b0cf80da0..4b58edebf 100644 --- a/tests/array/utils/gtestDoubleEnv.h +++ b/tests/array/utils/gtestDoubleEnv.h @@ -1,5 +1,6 @@ #include "gtest/gtest.h" #include "zfp.h" +#include "commonMacros.h" extern "C" { #include "utils/genSmoothRandNums.h" @@ -25,8 +26,8 @@ class ArrayDoubleTestEnv : public ::testing::Environment { virtual void SetUp() { generateSmoothRandDoubles(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); - buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; - bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; + bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } diff --git a/tests/array/utils/gtestFloatEnv.h b/tests/array/utils/gtestFloatEnv.h index e3ecfd4b2..312ce89fa 100644 --- a/tests/array/utils/gtestFloatEnv.h +++ b/tests/array/utils/gtestFloatEnv.h @@ -1,5 +1,6 @@ #include "gtest/gtest.h" #include "zfp.h" +#include "commonMacros.h" extern "C" { #include "utils/genSmoothRandNums.h" @@ -25,8 +26,8 @@ class ArrayFloatTestEnv : public ::testing::Environment { virtual void SetUp() { generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); - buffer = new uchar[ZFP_HEADER_PADDED_TO_WORD_BYTES]; - bs = stream_open(buffer, ZFP_HEADER_SIZE_BYTES); + buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; + bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } From 4ca03e001e12f0df3df47bca5224af257898871c Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 3 Apr 2019 20:15:54 -0700 Subject: [PATCH 081/194] update tests to remove macros and use uint64 for buffers --- tests/array/testArrayBase.cpp | 14 ++++++++++++-- tests/array/utils/commonMacros.h | 5 ++--- tests/array/utils/gtestCApiTest.h | 10 ++++++---- tests/array/utils/gtestDoubleEnv.h | 8 +++++--- tests/array/utils/gtestFloatEnv.h | 8 +++++--- 5 files changed, 30 insertions(+), 15 deletions(-) diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index c45672f6b..b99fa4b9b 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -71,8 +71,15 @@ TEST_F(TEST_FIXTURE, when_setRate_then_compressionRateChanged) void VerifyProperHeaderWritten(const zfp::array::header& h, uint chosenSizeX, uint chosenSizeY, uint chosenSizeZ, double chosenRate) { + // copy header into aligned memory suitable for bitstream r/w + size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); + uint64* buffer = new uint64[num_64bit_entries]; + size_t buffer_size_bytes = num_64bit_entries * sizeof(uint64); + + memcpy(buffer, &h, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + // verify valid header (manually through C API) - bitstream* stream = stream_open((zfp::array::header*)&h, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + bitstream* stream = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); zfp_field* field = zfp_field_alloc(); zfp_stream* zfp = zfp_stream_open(stream); @@ -97,6 +104,8 @@ void VerifyProperHeaderWritten(const zfp::array::header& h, uint chosenSizeX, ui zfp_stream_close(zfp); zfp_field_free(field); stream_close(stream); + + delete[] buffer; } TEST_F(TEST_FIXTURE, when_writeHeader_then_cCompatibleHeaderWritten) @@ -277,7 +286,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateHeader_when_constructorFromSeri zfp_stream_flush(stream); // copy header into header - size_t headerSizeBytes = (writtenBits + CHAR_BIT - 1) / CHAR_BIT; + size_t headerSizeBytes = DIV_ROUND_UP(writtenBits, CHAR_BIT); zfp::array::header h; memcpy(h.buffer, buffer, headerSizeBytes); @@ -355,6 +364,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional } catch (zfp::array::header_exception const & e) { EXPECT_TRUE(strstr(e.what(), "ZFP header specified an underlying scalar type different than that for this object.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP header specified a dimensionality different than that for this object.") != NULL); + EXPECT_TRUE(strstr(e.what(), "ZFP compressed arrays do not yet support scalar types beyond floats and doubles.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP header specified a non fixed-rate mode, unsupported by this object.") != NULL); // print exception if any of above were not met diff --git a/tests/array/utils/commonMacros.h b/tests/array/utils/commonMacros.h index f71a02da5..9d2627bd6 100644 --- a/tests/array/utils/commonMacros.h +++ b/tests/array/utils/commonMacros.h @@ -1,7 +1,6 @@ #include "zfp.h" -#define ROUND_UP_TO_MULTIPLE(x, y) (((x) + (y) - 1) / (y)) -#define BITS_TO_BYTES(x) ROUND_UP_TO_MULTIPLE(x, CHAR_BIT) -#define BITS_TO_WORDS(x) ROUND_UP_TO_MULTIPLE(x, stream_word_bits) +#define DIV_ROUND_UP(x, y) (((x) + (y) - 1) / (y)) +#define BITS_TO_BYTES(x) DIV_ROUND_UP(x, CHAR_BIT) #define ZFP_HEADER_SIZE_BITS (ZFP_MAGIC_BITS + ZFP_META_BITS + ZFP_MODE_SHORT_BITS) diff --git a/tests/array/utils/gtestCApiTest.h b/tests/array/utils/gtestCApiTest.h index 2cb31fcb5..b3caff7b6 100644 --- a/tests/array/utils/gtestCApiTest.h +++ b/tests/array/utils/gtestCApiTest.h @@ -4,8 +4,10 @@ class ZfpArrayConstructTest : public ::testing::Test { protected: virtual void SetUp() { - buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; - bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); + buffer = new uint64[num_64bit_entries]; + + bs = stream_open(buffer, num_64bit_entries * sizeof(uint64)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } @@ -17,13 +19,13 @@ class ZfpArrayConstructTest : public ::testing::Test { delete[] buffer; } - static uchar* buffer; + static uint64* buffer; static bitstream* bs; static zfp_stream* stream; static zfp_field* field; }; -uchar* ZfpArrayConstructTest::buffer; +uint64* ZfpArrayConstructTest::buffer; bitstream* ZfpArrayConstructTest::bs; zfp_stream* ZfpArrayConstructTest::stream; zfp_field* ZfpArrayConstructTest::field; diff --git a/tests/array/utils/gtestDoubleEnv.h b/tests/array/utils/gtestDoubleEnv.h index 4b58edebf..1991bc1a3 100644 --- a/tests/array/utils/gtestDoubleEnv.h +++ b/tests/array/utils/gtestDoubleEnv.h @@ -14,7 +14,7 @@ const size_t MIN_TOTAL_ELEMENTS = 1000000; size_t inputDataSideLen, inputDataTotalLen; double* inputDataArr; -uchar* buffer; +uint64* buffer; bitstream* bs; zfp_stream* stream; zfp_field* field; @@ -26,8 +26,10 @@ class ArrayDoubleTestEnv : public ::testing::Environment { virtual void SetUp() { generateSmoothRandDoubles(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); - buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; - bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); + buffer = new uint64[num_64bit_entries]; + + bs = stream_open(buffer, num_64bit_entries * sizeof(uint64)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } diff --git a/tests/array/utils/gtestFloatEnv.h b/tests/array/utils/gtestFloatEnv.h index 312ce89fa..674fc6a66 100644 --- a/tests/array/utils/gtestFloatEnv.h +++ b/tests/array/utils/gtestFloatEnv.h @@ -14,7 +14,7 @@ const size_t MIN_TOTAL_ELEMENTS = 1000000; size_t inputDataSideLen, inputDataTotalLen; float* inputDataArr; -uchar* buffer; +uint64* buffer; bitstream* bs; zfp_stream* stream; zfp_field* field; @@ -26,8 +26,10 @@ class ArrayFloatTestEnv : public ::testing::Environment { virtual void SetUp() { generateSmoothRandFloats(MIN_TOTAL_ELEMENTS, getDims(), &inputDataArr, &inputDataSideLen, &inputDataTotalLen); - buffer = new uchar[BITS_TO_WORDS(ZFP_HEADER_SIZE_BITS) * stream_word_bits / CHAR_BIT]; - bs = stream_open(buffer, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); + size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); + buffer = new uint64[num_64bit_entries]; + + bs = stream_open(buffer, num_64bit_entries * sizeof(uint64)); stream = zfp_stream_open(bs); field = zfp_field_alloc(); } From ae658344c57b3f30d0519d27f8b762c1ba708a05 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 4 Apr 2019 14:00:11 -0700 Subject: [PATCH 082/194] function name/signature changes (write_header to get_header, read_header to read_from_header), and create private static concat_sentence() to build error messages --- array/zfparray.h | 20 ++++++++++---------- tests/array/testArrayBase.cpp | 25 +++++++++---------------- tests/array/testConstruct.cpp | 7 ++----- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/array/zfparray.h b/array/zfparray.h index 0ba2f5d0a..e8d09d040 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -64,7 +64,7 @@ class array { { // read header to populate member variables associated with zfp_stream try { - read_header(h); + read_from_header(h); } catch (zfp::array::header_exception const &) { zfp_stream_close(zfp); throw; @@ -144,7 +144,7 @@ class array { zfp_type scalar_type() const { return type; } // write header with latest metadata - void write_header(zfp::array::header& h) const + zfp::array::header get_header() const { // intermediate buffer needed (bitstream accesses multiples of wordsize) AlignedBufferHandle abh; @@ -158,9 +158,12 @@ class array { if (!zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL)) throw zfp::array::header_exception("ZFP could not write a header to buffer."); - stream_flush(zfp->stream); + + zfp::array::header h; abh.copy_to_header(&h); + + return h; } private: @@ -229,7 +232,7 @@ class array { // attempt reading header from zfp::array::header // and verify header contents (throws exceptions upon failure) - void read_header(const zfp::array::header& h) + void read_from_header(const zfp::array::header& h) { // copy header into aligned buffer AlignedBufferHandle abh(&h); @@ -246,13 +249,10 @@ class array { // verify metadata on zfp_field match that for this object std::string err_msg = ""; if (type != zfp_field_type(zfh.field)) - err_msg += "ZFP header specified an underlying scalar type different than that for this object."; + concat_sentence(err_msg, "ZFP header specified an underlying scalar type different than that for this object."); - if (dims != zfp_field_dimensionality(zfh.field)) { - if (!err_msg.empty()) - err_msg += " "; - err_msg += "ZFP header specified a dimensionality different than that for this object."; - } + if (dims != zfp_field_dimensionality(zfh.field)) + concat_sentence(err_msg, "ZFP header specified a dimensionality different than that for this object."); verify_header_contents(zfp, zfh.field, err_msg); diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index b99fa4b9b..39cc91dda 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -130,8 +130,7 @@ TEST_F(TEST_FIXTURE, when_writeHeader_then_cCompatibleHeaderWritten) ZFP_ARRAY_TYPE arr(chosenSizeX, chosenSizeY, chosenSizeZ, chosenRate); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); VerifyProperHeaderWritten(h, chosenSizeX, chosenSizeY, chosenSizeZ, chosenRate); } @@ -218,8 +217,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongScalarType_when_con ZFP_ARRAY_TYPE_WRONG_SCALAR arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); @@ -241,8 +239,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongDimensionality_when ZFP_ARRAY_TYPE_WRONG_DIM arr(100, ZFP_RATE_PARAM_BITS); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); @@ -443,8 +440,7 @@ TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_const ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size() - 1); @@ -466,8 +462,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayHeader_when_factoryFuncConst ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, ZFP_RATE_PARAM_BITS); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); array* arr2 = zfp::array::construct(h); @@ -488,8 +483,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArray_when_factoryFuncConstruct_t arr[1] = 999.; - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); array* arr2 = zfp::array::construct(h, arr.compressed_data(), arr.compressed_size()); @@ -750,8 +744,8 @@ TEST_P(TEST_FIXTURE, given_compressedArray_when_setSecondArrayEqualToFirst_then_ void CheckHeadersEquivalent(const ZFP_ARRAY_TYPE& arr1, const ZFP_ARRAY_TYPE& arr2) { zfp::array::header h[2]; - arr1.write_header(h[0]); - arr2.write_header(h[1]); + h[0] = arr1.get_header(); + h[1] = arr2.get_header(); uint64 header1Checksum = hashBitstream((uint64*)(h + 0), BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); uint64 header2Checksum = hashBitstream((uint64*)(h + 1), BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); @@ -786,8 +780,7 @@ TEST_P(TEST_FIXTURE, given_serializedCompressedArray_when_constructorFromSeriali ZFP_ARRAY_TYPE arr(inputDataSideLen, inputDataSideLen, inputDataSideLen, getRate(), inputDataArr); #endif - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size()); diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp index 1a96c6409..7432df618 100644 --- a/tests/array/testConstruct.cpp +++ b/tests/array/testConstruct.cpp @@ -108,8 +108,7 @@ TEST_F(TEST_FIXTURE, given_validHeaderBuffer_withBufferSizeTooLow_when_construct { zfp::array3d arr(12, 12, 12, 32); - zfp::array::header h; - arr.write_header(h); + zfp::array::header h = arr.get_header(); try { zfp::array* arr2 = zfp::array::construct(h, arr.compressed_data(), 1); @@ -125,10 +124,8 @@ TEST_F(TEST_FIXTURE, given_compressedArrayWithLongHeader_when_writeHeader_expect { zfp::array3d arr(12, 12, 12, 33); - zfp::array::header h; - try { - arr.write_header(h); + zfp::array::header h = arr.get_header(); FailWhenNoExceptionThrown(); } catch (zfp::array::header_exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP compressed arrays only support short headers at this time.")); From 12fcd30fc319af5a1adf8c80a743411d3a3c9587 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 4 Apr 2019 14:01:08 -0700 Subject: [PATCH 083/194] add test that compressed array params set correctly when using constructor with zfp::array::header, set blkbits where all other class members set --- array/zfparray.h | 9 +-------- tests/array/testArrayBase.cpp | 32 +++++++++++++++++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/array/zfparray.h b/array/zfparray.h index e8d09d040..885cbb0a3 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -74,14 +74,6 @@ class array { zfp_stream_close(zfp); throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); } - - // everything is valid - // set remaining class variables, allocate space, copy entire buffer into place - - // set_rate() residual behavior (rate itself was set on zfp_stream* in zfp_read_header()) - blkbits = zfp->maxbits; - - // resize() called in sub-class constructor, followed by memcpy() } // copy constructor--performs a deep copy @@ -264,6 +256,7 @@ class array { ny = zfh.field->ny; nz = zfh.field->nz; type = zfh.field->type; + blkbits = zfp->maxbits; } uint dims; // array dimensionality (1, 2, or 3) diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 39cc91dda..9935e9643 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -376,7 +376,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional delete[] buffer; } -TEST_F(TEST_FIXTURE, given_compatibleHeaderWrittenViaCApi_when_constructorFromSerialized_then_success) +TEST_F(TEST_FIXTURE, given_compatibleHeaderWrittenViaCApi_when_constructorFromSerialized_then_successWithParamsSet) { // create a compressed stream through C API // (one that is supported with compressed arrays) @@ -399,7 +399,7 @@ TEST_F(TEST_FIXTURE, given_compatibleHeaderWrittenViaCApi_when_constructorFromSe zfp_stream_set_bit_stream(stream, bs); zfp_stream_rewind(stream); - zfp_stream_set_rate(stream, 10, ZFP_TYPE, DIMS, 1); + double rate = zfp_stream_set_rate(stream, 10, ZFP_TYPE, DIMS, 1); EXPECT_EQ(zfp_mode_fixed_rate, zfp_stream_compression_mode(stream)); // write header @@ -416,17 +416,35 @@ TEST_F(TEST_FIXTURE, given_compatibleHeaderWrittenViaCApi_when_constructorFromSe uchar* compressedDataPtr = (uchar*)stream_data(bs) + headerSizeBytes; zfp_compress(stream, field); - // close/free C API things (keep buffer) - zfp_field_free(field); - zfp_stream_close(stream); - stream_close(bs); - try { ZFP_ARRAY_TYPE arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); + + EXPECT_EQ(arr2.dimensionality(), zfp_field_dimensionality(field)); + EXPECT_EQ(arr2.scalar_type(), zfp_field_type(field)); + + uint n[4]; + EXPECT_EQ(arr2.size(), zfp_field_size(field, n)); + +#if DIMS == 1 + EXPECT_EQ(arr2.size_x(), n[0]); +#elif DIMS == 2 + EXPECT_EQ(arr2.size_x(), n[0]); + EXPECT_EQ(arr2.size_y(), n[1]); +#elif DIMS == 3 + EXPECT_EQ(arr2.size_x(), n[0]); + EXPECT_EQ(arr2.size_y(), n[1]); + EXPECT_EQ(arr2.size_z(), n[2]); +#endif + + EXPECT_EQ(arr2.rate(), rate); + } catch (std::exception const & e) { FailAndPrintException(e); } + zfp_stream_close(stream); + stream_close(bs); + zfp_field_free(field); delete[] buffer; } From c930c49fbd768366b9fbc52fbd2df5305086246a Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 4 Apr 2019 14:08:33 -0700 Subject: [PATCH 084/194] check that baseclass pointer can be dynamically cast to derived class on success from zfp::array::construct() --- tests/array/testArrayBase.cpp | 2 ++ tests/array/testConstruct.cpp | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 9935e9643..6037d6746 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -485,6 +485,8 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayHeader_when_factoryFuncConst array* arr2 = zfp::array::construct(h); ASSERT_TRUE(arr2 != 0); + ASSERT_TRUE(dynamic_cast(arr2) != NULL); + ASSERT_TRUE(dynamic_cast(arr2) == NULL); delete arr2; } diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp index 7432df618..573a11f25 100644 --- a/tests/array/testConstruct.cpp +++ b/tests/array/testConstruct.cpp @@ -10,6 +10,10 @@ using namespace zfp; TestEnv* const testEnv = new TestEnv; +// this file tests exceptions thrown from zfp::array::construct() that cannot be +// generalized and run on every {1/2/3 x f/d} combination, or need not be run +// multiple times + void FailWhenNoExceptionThrown() { FAIL() << "No exception was thrown when one was expected"; From 7706ba3b30dcb82de8efe754981a058de6021cc0 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 4 Apr 2019 15:15:58 -0700 Subject: [PATCH 085/194] move zfp::array::header_exception to zfp::array::header::exception --- array/zfp/exceptions.h | 6 ------ array/zfp/header.h | 12 ++++++++++++ array/zfp/headerHelpers.h | 6 +++--- array/zfparray.h | 20 ++++++++------------ array/zfputils.h | 2 +- tests/array/testArrayBase.cpp | 16 ++++++++-------- tests/array/testConstruct.cpp | 10 +++++----- 7 files changed, 37 insertions(+), 35 deletions(-) delete mode 100644 array/zfp/exceptions.h create mode 100644 array/zfp/header.h diff --git a/array/zfp/exceptions.h b/array/zfp/exceptions.h deleted file mode 100644 index 6a1b94ca1..000000000 --- a/array/zfp/exceptions.h +++ /dev/null @@ -1,6 +0,0 @@ -class header_exception : public std::runtime_error { -public: - header_exception(const std::string& msg) : runtime_error(msg) {} - - virtual ~header_exception() throw (){} -}; diff --git a/array/zfp/header.h b/array/zfp/header.h new file mode 100644 index 000000000..d652aadaf --- /dev/null +++ b/array/zfp/header.h @@ -0,0 +1,12 @@ +class header { +public: + class exception : public std::runtime_error { + public: + exception(const std::string& msg) : runtime_error(msg) {} + + virtual ~exception() throw (){} + }; + + uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)]; +}; + diff --git a/array/zfp/headerHelpers.h b/array/zfp/headerHelpers.h index 910d8a228..df57aeaef 100644 --- a/array/zfp/headerHelpers.h +++ b/array/zfp/headerHelpers.h @@ -105,7 +105,7 @@ static void read_header_contents(const zfp::array::header& header, size_t expect ZfpFieldHandle zfh; if (!zfp_read_header(zsh.stream, zfh.field, ZFP_HEADER_FULL)) - throw zfp::array::header_exception("Invalid ZFP header."); + throw zfp::array::header::exception("Invalid ZFP header."); // gather metadata dims = zfp_field_dimensionality(zfh.field); @@ -121,10 +121,10 @@ static void read_header_contents(const zfp::array::header& header, size_t expect verify_header_contents(zsh.stream, zfh.field, err_msg); if (!err_msg.empty()) - throw zfp::array::header_exception(err_msg); + throw zfp::array::header::exception(err_msg); if (expected_buffer_size_bytes && !is_valid_buffer_size(zsh.stream, zfh.field->nx, zfh.field->ny, zfh.field->nz, expected_buffer_size_bytes)) - throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); + throw zfp::array::header::exception("ZFP header expects a longer buffer than what was passed in."); } // verifies metadata on zfp_stream and zfp_field describe a valid compressed array diff --git a/array/zfparray.h b/array/zfparray.h index 885cbb0a3..7a8611389 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -21,11 +21,7 @@ namespace zfp { // abstract base class for compressed array of scalars class array { public: - typedef struct { - uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)]; - } header; - - #include "zfp/exceptions.h" + #include "zfp/header.h" static zfp::array* construct(const zfp::array::header& header, const uchar* buffer = 0, size_t buffer_size_bytes = 0); @@ -65,14 +61,14 @@ class array { // read header to populate member variables associated with zfp_stream try { read_from_header(h); - } catch (zfp::array::header_exception const &) { + } catch (zfp::array::header::exception const &) { zfp_stream_close(zfp); throw; } if (expected_buffer_size_bytes && !is_valid_buffer_size(zfp, nx, ny, nz, expected_buffer_size_bytes)) { zfp_stream_close(zfp); - throw zfp::array::header_exception("ZFP header expects a longer buffer than what was passed in."); + throw zfp::array::header::exception("ZFP header expects a longer buffer than what was passed in."); } } @@ -146,10 +142,10 @@ class array { // avoid long header (alignment issue) if (zfp_stream_mode(zfp) > ZFP_MODE_SHORT_MAX) - throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); + throw zfp::array::header::exception("ZFP compressed arrays only support short headers at this time."); if (!zfp_write_header(zfp, zfh.field, ZFP_HEADER_FULL)) - throw zfp::array::header_exception("ZFP could not write a header to buffer."); + throw zfp::array::header::exception("ZFP could not write a header to buffer."); stream_flush(zfp->stream); zfp::array::header h; @@ -234,9 +230,9 @@ class array { // read header to populate member variables associated with zfp_stream size_t readbits = zfp_read_header(zfp, zfh.field, ZFP_HEADER_FULL); if (!readbits) - throw zfp::array::header_exception("Invalid ZFP header."); + throw zfp::array::header::exception("Invalid ZFP header."); else if (readbits != ZFP_HEADER_SIZE_BITS) - throw zfp::array::header_exception("ZFP compressed arrays only support short headers at this time."); + throw zfp::array::header::exception("ZFP compressed arrays only support short headers at this time."); // verify metadata on zfp_field match that for this object std::string err_msg = ""; @@ -249,7 +245,7 @@ class array { verify_header_contents(zfp, zfh.field, err_msg); if (!err_msg.empty()) - throw zfp::array::header_exception(err_msg); + throw zfp::array::header::exception(err_msg); // set class variables nx = zfh.field->nx; diff --git a/array/zfputils.h b/array/zfputils.h index f12236a09..a5b17001f 100644 --- a/array/zfputils.h +++ b/array/zfputils.h @@ -72,7 +72,7 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* } if (!err_msg.empty()) - throw zfp::array::header_exception(err_msg); + throw zfp::array::header::exception(err_msg); if (buffer) memcpy(arr->compressed_data(), buffer, arr->compressed_size()); diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 6037d6746..583a8cf45 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -157,7 +157,7 @@ TEST_F(TEST_FIXTURE, when_constructorFromSerializedWithInvalidHeader_then_except try { ZFP_ARRAY_TYPE arr(h, NULL); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("Invalid ZFP header.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -197,7 +197,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForCertainDimensionalityButHeaderMissing_whe zfp::array* arr = zfp::array::construct(h); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { std::stringstream ss; ss << "Header files for " << missingDim << " dimensional ZFP compressed arrays were not included."; EXPECT_EQ(e.what(), ss.str()); @@ -222,7 +222,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongScalarType_when_con try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified an underlying scalar type different than that for this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -244,7 +244,7 @@ TEST_F(TEST_FIXTURE, given_serializedCompressedArrayFromWrongDimensionality_when try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data()); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified a dimensionality different than that for this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -299,7 +299,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateHeader_when_constructorFromSeri try { ZFP_ARRAY_TYPE arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header specified a non fixed-rate mode, unsupported by this object.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -358,7 +358,7 @@ TEST_F(TEST_FIXTURE, given_serializedNonFixedRateWrongScalarTypeWrongDimensional ZFP_ARRAY_TYPE_WRONG_SCALAR_DIM arr2(h, compressedDataPtr, bufsizeBytes - headerSizeBytes); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_TRUE(strstr(e.what(), "ZFP header specified an underlying scalar type different than that for this object.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP header specified a dimensionality different than that for this object.") != NULL); EXPECT_TRUE(strstr(e.what(), "ZFP compressed arrays do not yet support scalar types beyond floats and doubles.") != NULL); @@ -463,7 +463,7 @@ TEST_F(TEST_FIXTURE, given_incompleteChunkOfSerializedCompressedArray_when_const try { ZFP_ARRAY_TYPE arr2(h, arr.compressed_data(), arr.compressed_size() - 1); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header expects a longer buffer than what was passed in.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -524,7 +524,7 @@ TEST_F(TEST_FIXTURE, given_uncompatibleSerializedMem_when_factoryFuncConstruct_t try { array* arr = zfp::array::construct(h, dummyMem, dummyLen); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("Invalid ZFP header.")); } catch (std::exception const & e) { FailAndPrintException(e); diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp index 573a11f25..66b873b0b 100644 --- a/tests/array/testConstruct.cpp +++ b/tests/array/testConstruct.cpp @@ -45,7 +45,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForIntegerData_when_construct_expect_zfpArra try { zfp::array* arr = zfp::array::construct(h); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP compressed arrays do not yet support scalar types beyond floats and doubles.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -73,7 +73,7 @@ TEST_F(TEST_FIXTURE, given_zfpHeaderForHigherDimensionalData_when_construct_expe try { zfp::array* arr = zfp::array::construct(h); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -101,7 +101,7 @@ TEST_F(TEST_FIXTURE, given_onlyInclude2D3D_and_zfpHeaderFor1D_when_construct_exp try { zfp::array* arr = zfp::array::construct(h); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("Header files for 1 dimensional ZFP compressed arrays were not included.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -117,7 +117,7 @@ TEST_F(TEST_FIXTURE, given_validHeaderBuffer_withBufferSizeTooLow_when_construct try { zfp::array* arr2 = zfp::array::construct(h, arr.compressed_data(), 1); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP header expects a longer buffer than what was passed in.")); } catch (std::exception const & e) { FailAndPrintException(e); @@ -131,7 +131,7 @@ TEST_F(TEST_FIXTURE, given_compressedArrayWithLongHeader_when_writeHeader_expect try { zfp::array::header h = arr.get_header(); FailWhenNoExceptionThrown(); - } catch (zfp::array::header_exception const & e) { + } catch (zfp::array::header::exception const & e) { EXPECT_EQ(e.what(), std::string("ZFP compressed arrays only support short headers at this time.")); } catch (std::exception const & e) { FailAndPrintException(e); From 1ba6f81e50fd5275ce0249e4f3e34bfa6b7380d8 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 4 Apr 2019 15:35:26 -0700 Subject: [PATCH 086/194] suppress `enumeration not handled` warnings in zfp::array::construct() --- array/zfputils.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/array/zfputils.h b/array/zfputils.h index a5b17001f..e045fd73b 100644 --- a/array/zfputils.h +++ b/array/zfputils.h @@ -28,6 +28,11 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array3f(n[0], n[1], n[2], rate); break; + + default: + /* NOTREACHED */ + err_msg = "Unexpected ZFP type."; + break; } #else err_msg = "Header files for 3 dimensional ZFP compressed arrays were not included."; @@ -44,6 +49,11 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array2f(n[0], n[1], rate); break; + + default: + /* NOTREACHED */ + err_msg = "Unexpected ZFP type."; + break; } #else err_msg = "Header files for 2 dimensional ZFP compressed arrays were not included."; @@ -60,6 +70,11 @@ zfp::array* zfp::array::construct(const zfp::array::header& header, const uchar* case zfp_type_float: arr = new zfp::array1f(n[0], rate); break; + + default: + /* NOTREACHED */ + err_msg = "Unexpected ZFP type."; + break; } #else err_msg = "Header files for 1 dimensional ZFP compressed arrays were not included."; From 9b6e86ced3f8918aa953215a166f464b2062796a Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 5 Apr 2019 01:45:28 -0700 Subject: [PATCH 087/194] move concat_sentence() into zfp::array::header namespace --- array/zfp/header.h | 7 +++++++ array/zfp/headerHelpers.h | 13 +++---------- array/zfparray.h | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/array/zfp/header.h b/array/zfp/header.h index d652aadaf..0ba5011cb 100644 --- a/array/zfp/header.h +++ b/array/zfp/header.h @@ -7,6 +7,13 @@ class header { virtual ~exception() throw (){} }; + static void concat_sentence(std::string& s, const std::string& msg) + { + if (!s.empty()) + s += " "; + s += msg; + } + uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)]; }; diff --git a/array/zfp/headerHelpers.h b/array/zfp/headerHelpers.h index df57aeaef..ed33816a3 100644 --- a/array/zfp/headerHelpers.h +++ b/array/zfp/headerHelpers.h @@ -133,19 +133,12 @@ static void verify_header_contents(const zfp_stream* stream, const zfp_field* fi // verify read-header contents zfp_type type = zfp_field_type(field); if (type != zfp_type_float && type != zfp_type_double) - concat_sentence(err_msg, "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."); + zfp::array::header::concat_sentence(err_msg, "ZFP compressed arrays do not yet support scalar types beyond floats and doubles."); uint dims = zfp_field_dimensionality(field); if (dims < 1 || dims > 3) - concat_sentence(err_msg, "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."); + zfp::array::header::concat_sentence(err_msg, "ZFP compressed arrays do not yet support dimensionalities beyond 1, 2, and 3."); if (zfp_stream_compression_mode(stream) != zfp_mode_fixed_rate) - concat_sentence(err_msg, "ZFP header specified a non fixed-rate mode, unsupported by this object."); -} - -static void concat_sentence(std::string& s, const std::string& msg) -{ - if (!s.empty()) - s += " "; - s += msg; + zfp::array::header::concat_sentence(err_msg, "ZFP header specified a non fixed-rate mode, unsupported by this object."); } diff --git a/array/zfparray.h b/array/zfparray.h index 7a8611389..b60b2419d 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -237,10 +237,10 @@ class array { // verify metadata on zfp_field match that for this object std::string err_msg = ""; if (type != zfp_field_type(zfh.field)) - concat_sentence(err_msg, "ZFP header specified an underlying scalar type different than that for this object."); + zfp::array::header::concat_sentence(err_msg, "ZFP header specified an underlying scalar type different than that for this object."); if (dims != zfp_field_dimensionality(zfh.field)) - concat_sentence(err_msg, "ZFP header specified a dimensionality different than that for this object."); + zfp::array::header::concat_sentence(err_msg, "ZFP header specified a dimensionality different than that for this object."); verify_header_contents(zfp, zfh.field, err_msg); From 0bc9e1d638620a967505935eccd3c6b5ebc8678e Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 10 Apr 2019 15:51:18 -0700 Subject: [PATCH 088/194] rename array/zfputils.h to array/zfpfactory.h --- array/{zfputils.h => zfpfactory.h} | 4 ++-- tests/array/testArray1d.cpp | 2 +- tests/array/testArray1f.cpp | 2 +- tests/array/testArray2d.cpp | 2 +- tests/array/testArray2f.cpp | 2 +- tests/array/testArray3d.cpp | 2 +- tests/array/testArray3f.cpp | 2 +- tests/array/testConstruct.cpp | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename array/{zfputils.h => zfpfactory.h} (98%) diff --git a/array/zfputils.h b/array/zfpfactory.h similarity index 98% rename from array/zfputils.h rename to array/zfpfactory.h index e045fd73b..44910bd25 100644 --- a/array/zfputils.h +++ b/array/zfpfactory.h @@ -1,5 +1,5 @@ -#ifndef ZFP_UTILS_H -#define ZFP_UTILS_H +#ifndef ZFP_FACTORY_H +#define ZFP_FACTORY_H // (assumes zfparray.h already included) diff --git a/tests/array/testArray1d.cpp b/tests/array/testArray1d.cpp index 90b4d0c7f..9d055cfc7 100644 --- a/tests/array/testArray1d.cpp +++ b/tests/array/testArray1d.cpp @@ -1,6 +1,6 @@ #include "array/zfparray1.h" #include "array/zfparray2.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray1f.cpp b/tests/array/testArray1f.cpp index 17568d70d..98ec38a9e 100644 --- a/tests/array/testArray1f.cpp +++ b/tests/array/testArray1f.cpp @@ -1,6 +1,6 @@ #include "array/zfparray1.h" #include "array/zfparray2.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray2d.cpp b/tests/array/testArray2d.cpp index df1572007..324a8606a 100644 --- a/tests/array/testArray2d.cpp +++ b/tests/array/testArray2d.cpp @@ -1,6 +1,6 @@ #include "array/zfparray2.h" #include "array/zfparray3.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray2f.cpp b/tests/array/testArray2f.cpp index 97bf4fcee..d370dd3e3 100644 --- a/tests/array/testArray2f.cpp +++ b/tests/array/testArray2f.cpp @@ -1,6 +1,6 @@ #include "array/zfparray2.h" #include "array/zfparray3.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray3d.cpp b/tests/array/testArray3d.cpp index de75f45b6..da8329ad2 100644 --- a/tests/array/testArray3d.cpp +++ b/tests/array/testArray3d.cpp @@ -1,6 +1,6 @@ #include "array/zfparray3.h" #include "array/zfparray1.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testArray3f.cpp b/tests/array/testArray3f.cpp index 56ed2b04f..b35885ec5 100644 --- a/tests/array/testArray3f.cpp +++ b/tests/array/testArray3f.cpp @@ -1,6 +1,6 @@ #include "array/zfparray3.h" #include "array/zfparray1.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; extern "C" { diff --git a/tests/array/testConstruct.cpp b/tests/array/testConstruct.cpp index 66b873b0b..8e6db95d4 100644 --- a/tests/array/testConstruct.cpp +++ b/tests/array/testConstruct.cpp @@ -1,6 +1,6 @@ #include "array/zfparray2.h" #include "array/zfparray3.h" -#include "array/zfputils.h" +#include "array/zfpfactory.h" using namespace zfp; #include "gtest/gtest.h" From a524fb040bab7d1609bb5c7553bcc7b2c196bc0e Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 26 Nov 2018 16:11:46 -0800 Subject: [PATCH 089/194] Add fortran bindings for [minimal] bitstream API, and [high-level] zfp_stream functions (those without references to zfp_field). Also added fortran POC test file --- CMakeLists.txt | 5 + fortran/CMakeLists.txt | 17 ++ fortran/zfp.f | 302 +++++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 4 + tests/fortran/CMakeLists.txt | 18 +++ tests/fortran/testFortran.f | 29 ++++ 6 files changed, 375 insertions(+) create mode 100644 fortran/CMakeLists.txt create mode 100644 fortran/zfp.f create mode 100644 tests/fortran/CMakeLists.txt create mode 100644 tests/fortran/testFortran.f diff --git a/CMakeLists.txt b/CMakeLists.txt index 8956be891..91afca8be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,11 @@ if(BUILD_CFP) add_subdirectory(cfp) endif() +option(BUILD_ZFORP "Build Fortran library" OFF) +if(BUILD_ZFORP) + add_subdirectory(fortran) +endif() + option(BUILD_UTILITIES "Build command line utilities for zfp" ON) if(BUILD_UTILITIES) add_subdirectory(utils) diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt new file mode 100644 index 000000000..978eae1d5 --- /dev/null +++ b/fortran/CMakeLists.txt @@ -0,0 +1,17 @@ +enable_language(Fortran) + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(dialect "-ffree-form -std=f2008 -fimplicit-none") + set(bounds "-fbounds-check") +endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(dialect "-stand f08 -free -implicitnone") + set(bounds "-check bounds") +endif() + +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules) +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}") + +add_library(zFORp zfp.f) +target_link_libraries(zFORp PRIVATE zfp) diff --git a/fortran/zfp.f b/fortran/zfp.f new file mode 100644 index 000000000..260762c3b --- /dev/null +++ b/fortran/zfp.f @@ -0,0 +1,302 @@ +module zFORp_module + + use, intrinsic :: iso_c_binding, only: c_int, c_int64_t, c_size_t, c_double, c_ptr, c_null_ptr + implicit none + private + + type zFORp_bitstream_type + private + type(c_ptr) :: object = c_null_ptr + end type zFORp_bitstream_type + + type zFORp_stream_type + private + type(c_ptr) :: object = c_null_ptr + end type zFORp_stream_type + + enum, bind(c) + enumerator :: zFORp_type_none = 0, & + zFORp_type_int32 = 1, & + zFORp_type_int64 = 2, & + zFORp_type_float = 3, & + zFORp_type_double = 4 + end enum + + enum, bind(c) + enumerator :: zFORp_mode_null = 0, & + zFORp_mode_expert = 1, & + zFORp_mode_fixed_rate = 2, & + zFORp_mode_fixed_precision = 3, & + zFORp_mode_fixed_accuracy = 4 + end enum + + interface + + ! minimal bitstream API + + function zfp_bitstream_stream_open(buffer, bytes) result(bitstream) bind(c, name="stream_open") + import + type(c_ptr), value :: buffer + integer(c_size_t), value :: bytes + type(c_ptr) :: bitstream + end function zfp_bitstream_stream_open + + subroutine zfp_bitstream_stream_close(bitstream) bind(c, name="stream_close") + import + type(c_ptr), value :: bitstream + end subroutine + + ! high-level API: zfp_stream functions + + function zfp_stream_open(bitstream) result(zfp_stream) bind(c, name="zfp_stream_open") + import + type(c_ptr), value :: bitstream + type(c_ptr) :: zfp_stream + end function zfp_stream_open + + subroutine zfp_stream_close(zfp_stream) bind(c, name="zfp_stream_close") + import + type(c_ptr), value :: zfp_stream + end subroutine + + function zfp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zfp_stream_bit_stream") + import + type(c_ptr), value :: zfp_stream + type(c_ptr) :: bitstream + end function + + function zfp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zfp_stream_compression_mode") + import + type(c_ptr), value :: zfp_stream + integer(c_int) :: zfp_mode + end function + + function zfp_stream_mode(zfp_stream) result(encoded_mode) bind(c, name="zfp_stream_mode") + import + type(c_ptr), value :: zfp_stream + integer(c_int64_t) encoded_mode + end function + + subroutine zfp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) bind(c, name="zfp_stream_params") + import + type(c_ptr), value :: zfp_stream + integer(c_int) :: minbits, maxbits, maxprec, minexp + end subroutine + + function zfp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, name="zfp_stream_compressed_size") + import + type(c_ptr), value :: zfp_stream + integer(c_size_t) compressed_size + end function + + subroutine zfp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zfp_stream_set_bit_stream") + import + type(c_ptr), value :: zfp_stream, bitstream + end subroutine + + function zfp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") + import + type(c_ptr), value :: zfp_stream + real(c_double), value :: rate + integer(c_int), value :: zfp_type + ! no unsigned int in Fortran + integer(c_int), value :: dims, wra + real(c_double) :: rate_result + end function + + function zfp_stream_set_precision(zfp_stream, prec) result(prec_result) bind(c, name="zfp_stream_set_precision") + import + type(c_ptr), value :: zfp_stream + integer(c_int), value :: prec + integer(c_int) prec_result + end function + + function zfp_stream_set_accuracy(zfp_stream, acc) result(acc_result) bind(c, name="zfp_stream_set_accuracy") + import + type(c_ptr), value :: zfp_stream + real(c_double), value :: acc + real(c_double) acc_result + end function + + function zfp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) bind(c, name="zfp_stream_set_mode") + import + type(c_ptr), value :: zfp_stream + integer(c_int64_t), value :: encoded_mode + integer(c_int) mode_result + end function + + function zfp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) & + result(is_success) bind(c, name="zfp_stream_set_params") + import + type(c_ptr), value :: zfp_stream + integer(c_int), value :: minbits, maxbits, maxprec, minexp + integer(c_int) is_success + end function + + end interface + + ! types + + public :: zFORp_bitstream_type, & + zFORp_stream_type + + ! enums + + public :: zFORp_type_none, & + zFORp_type_int32, & + zFORp_type_int64, & + zFORp_type_float, & + zFORp_type_double + + public :: zFORp_mode_null, & + zFORp_mode_expert, & + zFORp_mode_fixed_rate, & + zFORp_mode_fixed_precision, & + zFORp_mode_fixed_accuracy + + ! minimal bitstream API + + public :: zFORp_bitstream_stream_open, & + zFORp_bitstream_stream_close + + ! high-level API: zfp_stream functions + + public :: zFORp_stream_open, & + zFORp_stream_close, & + zFORp_stream_bit_stream, & + zFORp_stream_compression_mode, & + zFORp_stream_mode, & + zFORp_stream_params, & + zFORp_stream_compressed_size, & + zFORp_stream_set_bit_stream, & + zFORp_stream_set_rate, & + zFORp_stream_set_precision, & + zFORp_stream_set_accuracy, & + zFORp_stream_set_mode, & + zFORp_stream_set_params + +contains + + ! minimal bitstream API + + function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) + implicit none + type(zFORp_bitstream_type) :: bitstream + type(c_ptr), intent(in) :: buffer + integer, intent(in) :: bytes + bitstream%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) + end function zFORp_bitstream_stream_open + + subroutine zFORp_bitstream_stream_close(bitstream) + type(zFORp_bitstream_type), intent(inout) :: bitstream + call zfp_bitstream_stream_close(bitstream%object) + bitstream%object = c_null_ptr + end subroutine zFORp_bitstream_stream_close + + ! high-level API: zfp_stream functions + + function zFORp_stream_open(bitstream) result(zfp_stream) + implicit none + type(zFORp_bitstream_type), intent(in) :: bitstream + type(zFORp_stream_type) :: zfp_stream + zfp_stream%object = zfp_stream_open(bitstream%object) + end function zFORp_stream_open + + subroutine zFORp_stream_close(zfp_stream) + type(zFORp_stream_type), intent(inout) :: zfp_stream + call zfp_stream_close(zfp_stream%object) + zfp_stream%object = c_null_ptr + end subroutine zFORp_stream_close + + function zFORp_stream_bit_stream(zfp_stream) result(bitstream) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_bitstream_type) :: bitstream + bitstream%object = zfp_stream_bit_stream(zfp_stream%object) + end function zFORp_stream_bit_stream + + function zFORp_stream_compression_mode(zfp_stream) result(zfp_mode) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer zfp_mode + zfp_mode = zfp_stream_compression_mode(zfp_stream%object) + end function zFORp_stream_compression_mode + + function zFORp_stream_mode(zfp_stream) result(encoded_mode) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer (kind=8) encoded_mode + encoded_mode = zfp_stream_mode(zfp_stream%object) + end function zFORp_stream_mode + + subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(inout) :: minbits, maxbits, maxprec, minexp + call zfp_stream_params(zfp_stream%object, & + int(minbits, c_int), & + int(maxbits, c_int), & + int(maxprec, c_int), & + int(minexp, c_int)) + end subroutine zFORp_stream_params + + function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer compressed_size + compressed_size = zfp_stream_compressed_size(zfp_stream%object) + end function zFORp_stream_compressed_size + + subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_bitstream_type), intent(in) :: bitstream + call zfp_stream_set_bit_stream(zfp_stream%object, bitstream%object) + end subroutine zFORp_stream_set_bit_stream + + function zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + real, intent(in) :: rate + integer, intent(in) :: zfp_type + integer, intent(in) :: dims, wra + real :: rate_result + rate_result = zfp_stream_set_rate(zfp_stream%object, real(rate, c_double), & + int(zfp_type, c_int), int(dims, c_int), int(wra, c_int)) + end function zFORp_stream_set_rate + + function zFORp_stream_set_precision(zfp_stream, prec) result(prec_result) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: prec + integer prec_result + prec_result = zfp_stream_set_precision(zfp_stream%object, int(prec, c_int)) + end function zFORp_stream_set_precision + + function zFORp_stream_set_accuracy(zfp_stream, acc) result(acc_result) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + real (kind=8), intent(in) :: acc + real (kind=8) acc_result + acc_result = zfp_stream_set_accuracy(zfp_stream%object, real(acc, c_double)) + end function zFORp_stream_set_accuracy + + function zFORp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: encoded_mode + integer mode_result + mode_result = zfp_stream_set_mode(zfp_stream%object, int(encoded_mode, c_int64_t)) + end function zFORp_stream_set_mode + + function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) result(is_success) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: minbits, maxbits, maxprec, minexp + integer is_success + is_success = zfp_stream_set_params(zfp_stream%object, & + int(minbits, c_int), & + int(maxbits, c_int), & + int(maxprec, c_int), & + int(minexp, c_int)) + end function zFORp_stream_set_params + +end module zFORp_module diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8ec4853f1..3d5611da2 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -59,6 +59,10 @@ if(BUILD_CFP) add_subdirectory(cfp) endif() +if(BUILD_ZFORP) + add_subdirectory(fortran) +endif() + # needed to compile gtest on MSVC if(MSVC) list(APPEND GTEST_ARGS "/D:_SILENCE_TR1_DEPRECATION_NAMESPACE_WARNING=1") diff --git a/tests/fortran/CMakeLists.txt b/tests/fortran/CMakeLists.txt new file mode 100644 index 000000000..a0490c9c1 --- /dev/null +++ b/tests/fortran/CMakeLists.txt @@ -0,0 +1,18 @@ +enable_language(Fortran) + +if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") + set(dialect "-ffree-form -std=f2008 -fimplicit-none") + set(bounds "-fbounds-check") +endif() +if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") + set(dialect "-stand f08 -free -implicitnone") + set(bounds "-check bounds") +endif() + +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/modules) +set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${bounds}") +set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${dialect}") + +add_executable(testFortran testFortran.f) +target_link_libraries(testFortran zFORp) +add_test(NAME testFortran COMMAND testFortran) diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f new file mode 100644 index 000000000..1ade8a7d5 --- /dev/null +++ b/tests/fortran/testFortran.f @@ -0,0 +1,29 @@ +program main + use zFORp_module + use iso_c_binding + + ! bitstream + character, dimension(:), allocatable, target :: buffer + type(c_ptr) :: buffer_c_ptr + integer bytes + type(zFORp_bitstream_type) :: bitstream, queried_bitstream + + ! zfp_stream + type(zFORp_stream_type) :: zfp_stream + + ! bitstream + bytes = 256 + allocate(buffer(bytes)) + buffer_c_ptr = c_loc(buffer) + bitstream = zFORp_bitstream_stream_open(buffer_c_ptr, bytes) + + ! zfp_stream + zfp_stream = zFORp_stream_open(bitstream) + + queried_bitstream = zFORp_stream_bit_stream(zfp_stream) + + ! deallocations + call zFORp_stream_close(zfp_stream) + call zFORp_bitstream_stream_close(queried_bitstream) + deallocate(buffer) +end program main From 7206eefefa055542b3a8c7daf5c52153c5c33944 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 5 Dec 2018 17:35:11 -0800 Subject: [PATCH 090/194] Add fortran bindings for zfp_field API functions, and compression/decompression --- fortran/zfp.f | 430 +++++++++++++++++++++++++++++++++++- tests/fortran/testFortran.f | 9 + 2 files changed, 437 insertions(+), 2 deletions(-) diff --git a/fortran/zfp.f b/fortran/zfp.f index 260762c3b..fd6f2e08b 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -1,6 +1,6 @@ module zFORp_module - use, intrinsic :: iso_c_binding, only: c_int, c_int64_t, c_size_t, c_double, c_ptr, c_null_ptr + use, intrinsic :: iso_c_binding, only: c_int, c_int64_t, c_size_t, c_double, c_ptr, c_null_ptr, c_loc implicit none private @@ -14,6 +14,11 @@ module zFORp_module type(c_ptr) :: object = c_null_ptr end type zFORp_stream_type + type zFORp_field_type + private + type(c_ptr) :: object = c_null_ptr + end type zFORp_field_type + enum, bind(c) enumerator :: zFORp_type_none = 0, & zFORp_type_int32 = 1, & @@ -133,12 +138,189 @@ function zfp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) & integer(c_int) is_success end function + ! high-level API: zfp_field functions + + function zfp_field_alloc() result(zfp_field) bind(c, name="zfp_field_alloc") + import + type(c_ptr) :: zfp_field + end function + + function zfp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) bind(c, name="zfp_field_1d") + import + type(c_ptr), value :: uncompressed_ptr + type(c_ptr) :: zfp_field + integer(c_int), value :: zfp_type, nx + end function + + function zfp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) bind(c, name="zfp_field_2d") + import + type(c_ptr), value :: uncompressed_ptr + type(c_ptr) :: zfp_field + integer(c_int), value :: zfp_type, nx, ny + end function + + function zfp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) bind(c, name="zfp_field_3d") + import + type(c_ptr), value :: uncompressed_ptr + type(c_ptr) :: zfp_field + integer(c_int), value :: zfp_type, nx, ny, nz + end function + + function zfp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) bind(c, name="zfp_field_4d") + import + type(c_ptr), value :: uncompressed_ptr + type(c_ptr) :: zfp_field + integer(c_int), value :: zfp_type, nx, ny, nz, nw + end function + + subroutine zfp_field_free(zfp_field) bind(c, name="zfp_field_free") + import + type(c_ptr), value :: zfp_field + end subroutine + + function zfp_field_pointer(zfp_field) result(arr_ptr) bind(c, name="zfp_field_pointer") + import + type(c_ptr), value :: zfp_field + type(c_ptr) :: arr_ptr + end function + + function zfp_field_scalar_type(zfp_field) result(zfp_type) bind(c, name="zfp_field_type") + import + type(c_ptr), value :: zfp_field + integer(c_int) zfp_type + end function + + function zfp_field_precision(zfp_field) result(prec) bind(c, name="zfp_field_precision") + import + type(c_ptr), value :: zfp_field + integer(c_int) prec + end function + + function zfp_field_dimensionality(zfp_field) result(dims) bind(c, name="zfp_field_dimensionality") + import + type(c_ptr), value :: zfp_field + integer(c_int) dims + end function + + function zfp_field_size(zfp_field, size_arr) result(total_size) bind(c, name="zfp_field_size") + import + type(c_ptr), value :: zfp_field, size_arr + integer(c_size_t) total_size + end function + + function zfp_field_stride(zfp_field, stride_arr) result(is_strided) bind(c, name="zfp_field_stride") + import + type(c_ptr), value :: zfp_field, stride_arr + integer(c_int) is_strided + end function + + function zfp_field_metadata(zfp_field) result(encoded_metadata) bind(c, name="zfp_field_metadata") + import + type(c_ptr), value :: zfp_field + integer(c_int64_t) encoded_metadata + end function + + subroutine zfp_field_set_pointer(zfp_field, arr_ptr) bind(c, name="zfp_field_set_pointer") + import + type(c_ptr), value :: zfp_field, arr_ptr + end subroutine + + function zfp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) bind(c, name="zfp_field_set_type") + import + type(c_ptr), value :: zfp_field + integer(c_int) zfp_type, zfp_type_result + end function + + subroutine zfp_field_set_size_1d(zfp_field, nx) bind(c, name="zfp_field_set_size_1d") + import + type(c_ptr), value :: zfp_field + integer(c_int) nx + end subroutine + + subroutine zfp_field_set_size_2d(zfp_field, nx, ny) bind(c, name="zfp_field_set_size_2d") + import + type(c_ptr), value :: zfp_field + integer(c_int) nx, ny + end subroutine + + subroutine zfp_field_set_size_3d(zfp_field, nx, ny, nz) bind(c, name="zfp_field_set_size_3d") + import + type(c_ptr), value :: zfp_field + integer(c_int) nx, ny, nz + end subroutine + + subroutine zfp_field_set_size_4d(zfp_field, nx, ny, nz, nw) bind(c, name="zfp_field_set_size_4d") + import + type(c_ptr), value :: zfp_field + integer(c_int) nx, ny, nz, nw + end subroutine + + subroutine zfp_field_set_stride_1d(zfp_field, sx) bind(c, name="zfp_field_set_stride_1d") + import + type(c_ptr), value :: zfp_field + integer(c_int) sx + end subroutine + + subroutine zfp_field_set_stride_2d(zfp_field, sx, sy) bind(c, name="zfp_field_set_stride_2d") + import + type(c_ptr), value :: zfp_field + integer(c_int) sx, sy + end subroutine + + subroutine zfp_field_set_stride_3d(zfp_field, sx, sy, sz) bind(c, name="zfp_field_set_stride_3d") + import + type(c_ptr), value :: zfp_field + integer(c_int) sx, sy, sz + end subroutine + + subroutine zfp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) bind(c, name="zfp_field_set_stride_4d") + import + type(c_ptr), value :: zfp_field + integer(c_int) sx, sy, sz, sw + end subroutine + + function zfp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) bind(c, name="zfp_field_set_metadata") + import + type(c_ptr), value :: zfp_field + integer(c_int64_t) :: encoded_metadata + integer(c_int) is_success + end function + + ! high-level API: compression and decompression + + function zfp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zfp_compress") + import + type(c_ptr), value :: zfp_stream, zfp_field + integer(c_size_t) :: bitstream_offset_bytes + end function + + function zfp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zfp_decompress") + import + type(c_ptr), value :: zfp_stream, zfp_field + integer(c_size_t) :: bitstream_offset_bytes + end function + + function zfp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) bind(c, name="zfp_write_header") + import + type(c_ptr), value :: zfp_stream, zfp_field + integer(c_int) mask + integer(c_size_t) num_bits_written + end function + + function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind(c, name="zfp_read_header") + import + type(c_ptr), value :: zfp_stream, zfp_field + integer(c_int) mask + integer(c_size_t) num_bits_read + end function + end interface ! types public :: zFORp_bitstream_type, & - zFORp_stream_type + zFORp_stream_type, & + zFORp_field_type ! enums @@ -175,6 +357,40 @@ function zfp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) & zFORp_stream_set_mode, & zFORp_stream_set_params + ! high-level API: zfp_field functions + + public :: zFORp_field_alloc, & + zFORp_field_1d, & + zFORp_field_2d, & + zFORp_field_3d, & + zFORp_field_4d, & + zFORp_field_free, & + zFORp_field_pointer, & + zFORp_field_scalar_type, & + zFORp_field_precision, & + zFORp_field_dimensionality, & + zFORp_field_size, & + zFORp_field_stride, & + zFORp_field_metadata, & + zFORp_field_set_pointer, & + zFORp_field_set_type, & + zFORp_field_set_size_1d, & + zFORp_field_set_size_2d, & + zFORp_field_set_size_3d, & + zFORp_field_set_size_4d, & + zFORp_field_set_stride_1d, & + zFORp_field_set_stride_2d, & + zFORp_field_set_stride_3d, & + zFORp_field_set_stride_4d, & + zFORp_field_set_metadata + + ! high-level API: compression and decompression + + public :: zFORp_compress, & + zFORp_decompress, & + zFORp_write_header, & + zFORp_read_header + contains ! minimal bitstream API @@ -299,4 +515,214 @@ function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) int(minexp, c_int)) end function zFORp_stream_set_params + ! high-level API: zfp_field functions + + function zFORp_field_alloc() result(zfp_field) + implicit none + type(zFORp_field_type) zfp_field + zfp_field%object = zfp_field_alloc() + end function zFORp_field_alloc + + function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) + implicit none + type(c_ptr), intent(in) :: uncompressed_ptr + integer, intent(in) :: zfp_type, nx + type(zFORp_field_type) zfp_field + zfp_field%object = zfp_field_1d(uncompressed_ptr, int(zfp_type, c_int), & + int(nx, c_int)) + end function zFORp_field_1d + + function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) + implicit none + type(c_ptr), intent(in) :: uncompressed_ptr + integer, intent(in) :: zfp_type, nx, ny + type(zFORp_field_type) zfp_field + zfp_field%object = zfp_field_2d(uncompressed_ptr, int(zfp_type, c_int), & + int(nx, c_int), int(ny, c_int)) + end function zFORp_field_2d + + function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) + implicit none + type(c_ptr), intent(in) :: uncompressed_ptr + integer, intent(in) :: zfp_type, nx, ny, nz + type(zFORp_field_type) zfp_field + zfp_field%object = zfp_field_3d(uncompressed_ptr, int(zfp_type, c_int), & + int(nx, c_int), int(ny, c_int), & + int(nz, c_int)) + end function zFORp_field_3d + + function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) + implicit none + type(c_ptr), intent(in) :: uncompressed_ptr + integer, intent(in) :: zfp_type, nx, ny, nz, nw + type(zFORp_field_type) zfp_field + zfp_field%object = zfp_field_4d(uncompressed_ptr, int(zfp_type, c_int), & + int(nx, c_int), int(ny, c_int), & + int(nz, c_int), int(nw, c_int)) + end function zFORp_field_4d + + subroutine zFORp_field_free(zfp_field) + type(zFORp_field_type), intent(inout) :: zfp_field + call zfp_field_free(zfp_field%object) + zfp_field%object = c_null_ptr + end subroutine zFORp_field_free + + function zFORp_field_pointer(zfp_field) result(arr_ptr) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + type(c_ptr) arr_ptr + arr_ptr = zfp_field_pointer(zfp_field%object) + end function zFORp_field_pointer + + ! added "scalar" to name to avoid clash with zfp_field_type + function zFORp_field_scalar_type(zfp_field) result(zfp_type) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer zfp_type + zfp_type = zfp_field_scalar_type(zfp_field%object) + end function zFORp_field_scalar_type + + function zFORp_field_precision(zfp_field) result(prec) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer prec + prec = zfp_field_precision(zfp_field%object) + end function zFORp_field_precision + + function zFORp_field_dimensionality(zfp_field) result(dims) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer dims + dims = zfp_field_dimensionality(zfp_field%object) + end function zFORp_field_dimensionality + + function zFORp_field_size(zfp_field, size_arr) result(total_size) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer, dimension(:), target, intent(inout) :: size_arr + integer total_size + total_size = zfp_field_size(zfp_field%object, c_loc(size_arr)) + end function zFORp_field_size + + function zFORp_field_stride(zfp_field, stride_arr) result(is_strided) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer, dimension(:), target, intent(inout) :: stride_arr + integer is_strided + is_strided = zfp_field_stride(zfp_field%object, c_loc(stride_arr)) + end function zFORp_field_stride + + function zFORp_field_metadata(zfp_field) result(encoded_metadata) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer (kind=8) encoded_metadata + encoded_metadata = zfp_field_metadata(zfp_field%object) + end function zFORp_field_metadata + + subroutine zFORp_field_set_pointer(zfp_field, arr_ptr) + type(zFORp_field_type), intent(in) :: zfp_field + type(c_ptr), intent(in) :: arr_ptr + call zfp_field_set_pointer(zfp_field%object, arr_ptr) + end subroutine zFORp_field_set_pointer + + function zFORp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: zfp_type + integer zfp_type_result + zfp_type_result = zfp_field_set_type(zfp_field%object, int(zfp_type, c_int)) + end function zFORp_field_set_type + + subroutine zFORp_field_set_size_1d(zfp_field, nx) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: nx + call zfp_field_set_size_1d(zfp_field%object, int(nx, c_int)) + end subroutine zFORp_field_set_size_1d + + subroutine zFORp_field_set_size_2d(zfp_field, nx, ny) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: nx, ny + call zfp_field_set_size_2d(zfp_field%object, int(nx, c_int), int(ny, c_int)) + end subroutine zFORp_field_set_size_2d + + subroutine zFORp_field_set_size_3d(zfp_field, nx, ny, nz) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: nx, ny, nz + call zfp_field_set_size_3d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int)) + end subroutine zFORp_field_set_size_3d + + subroutine zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: nx, ny, nz, nw + call zfp_field_set_size_4d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int), int(nw, c_int)) + end subroutine zFORp_field_set_size_4d + + subroutine zFORp_field_set_stride_1d(zfp_field, sx) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: sx + call zfp_field_set_stride_1d(zfp_field%object, int(sx, c_int)) + end subroutine zFORp_field_set_stride_1d + + subroutine zFORp_field_set_stride_2d(zfp_field, sx, sy) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: sx, sy + call zfp_field_set_stride_2d(zfp_field%object, int(sx, c_int), int(sy, c_int)) + end subroutine zFORp_field_set_stride_2d + + subroutine zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: sx, sy, sz + call zfp_field_set_stride_3d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int)) + end subroutine zFORp_field_set_stride_3d + + subroutine zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: sx, sy, sz, sw + call zfp_field_set_stride_4d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int), int(sw, c_int)) + end subroutine zFORp_field_set_stride_4d + + function zFORp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) + implicit none + type(zFORp_field_type), intent(in) :: zfp_field + integer (kind=8), intent(in) :: encoded_metadata + integer is_success + is_success = zfp_field_set_metadata(zfp_field%object, int(encoded_metadata, c_int64_t)) + end function zFORp_field_set_metadata + + ! high-level API: compression and decompression + + function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_field_type), intent(in) :: zfp_field + integer bitstream_offset_bytes + bitstream_offset_bytes = zfp_compress(zfp_stream%object, zfp_field%object) + end function zFORp_compress + + function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_field_type), intent(in) :: zfp_field + integer bitstream_offset_bytes + bitstream_offset_bytes = zfp_decompress(zfp_stream%object, zfp_field%object) + end function zFORp_decompress + + function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: mask + integer num_bits_written + num_bits_written = zfp_write_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) + end function zFORp_write_header + + function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_field_type), intent(in) :: zfp_field + integer, intent(in) :: mask + integer num_bits_read + num_bits_read = zfp_read_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) + end function zFORp_read_header + end module zFORp_module diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index 1ade8a7d5..6e87592ad 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -10,6 +10,9 @@ program main ! zfp_stream type(zFORp_stream_type) :: zfp_stream + real :: desired_rate, rate_result + integer :: dims, wra + integer :: zfp_type ! bitstream bytes = 256 @@ -20,6 +23,12 @@ program main ! zfp_stream zfp_stream = zFORp_stream_open(bitstream) + desired_rate = 16.0 + dims = 2 + wra = 0 + zfp_type = zFORp_type_float + rate_result = zFORp_stream_set_rate(zfp_stream, desired_rate, zfp_type, dims, wra) + queried_bitstream = zFORp_stream_bit_stream(zfp_stream) ! deallocations From f1e0dad25eb83dbbfa31a1c729341d4312dc6eb0 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 7 Dec 2018 14:49:44 -0800 Subject: [PATCH 091/194] Finish wrapping ZFP high-level API in Fortran --- fortran/zfp.f | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/fortran/zfp.f b/fortran/zfp.f index fd6f2e08b..25c5f15b8 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -51,6 +51,14 @@ subroutine zfp_bitstream_stream_close(bitstream) bind(c, name="stream_close") type(c_ptr), value :: bitstream end subroutine + ! high-level API: utility functions + + function zfp_type_size(zfp_type) result(type_size) bind(c, name="zfp_type_size") + import + integer(c_int) zfp_type + integer(c_size_t) type_size + end function + ! high-level API: zfp_stream functions function zfp_stream_open(bitstream) result(zfp_stream) bind(c, name="zfp_stream_open") @@ -94,6 +102,12 @@ function zfp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, integer(c_size_t) compressed_size end function + function zfp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) bind(c, name="zfp_stream_maximum_size") + import + type(c_ptr), value :: zfp_stream, zfp_field + integer(c_size_t) max_size + end function + subroutine zfp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zfp_stream_set_bit_stream") import type(c_ptr), value :: zfp_stream, bitstream @@ -138,6 +152,44 @@ function zfp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) & integer(c_int) is_success end function + ! high-level API: execution policy functions + + function zfp_stream_execution(zfp_stream) result(execution_policy) bind(c, name="zfp_stream_execution") + import + type(c_ptr), value :: zfp_stream + integer(c_int) execution_policy + end function + + function zfp_stream_omp_threads(zfp_stream) result(num_threads) bind(c, name="zfp_stream_omp_threads") + import + type(c_ptr), value :: zfp_stream + integer(c_int) num_threads + end function + + function zfp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) bind(c, name="zfp_stream_omp_chunk_size") + import + type(c_ptr), value :: zfp_stream + integer(c_int) chunk_size_blocks + end function + + function zfp_stream_set_execution(zfp_stream, execution_policy) result(is_success) bind(c, name="zfp_stream_set_execution") + import + type(c_ptr), value :: zfp_stream + integer(c_int) execution_policy, is_success + end function + + function zfp_stream_set_omp_threads(zfp_stream, threads) result(is_success) bind(c, name="zfp_stream_set_omp_threads") + import + type(c_ptr), value :: zfp_stream + integer(c_int) threads, is_success + end function + + function zfp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) bind(c, name="zfp_stream_set_omp_chunk_size") + import + type(c_ptr), value :: zfp_stream + integer(c_int) chunk_size, is_success + end function + ! high-level API: zfp_field functions function zfp_field_alloc() result(zfp_field) bind(c, name="zfp_field_alloc") @@ -338,6 +390,8 @@ function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind ! minimal bitstream API + public :: zFORp_type_size + public :: zFORp_bitstream_stream_open, & zFORp_bitstream_stream_close @@ -350,6 +404,7 @@ function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind zFORp_stream_mode, & zFORp_stream_params, & zFORp_stream_compressed_size, & + zFORp_stream_maximum_size, & zFORp_stream_set_bit_stream, & zFORp_stream_set_rate, & zFORp_stream_set_precision, & @@ -357,6 +412,14 @@ function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind zFORp_stream_set_mode, & zFORp_stream_set_params + ! high-level API: execution policy functions + public :: zFORp_stream_execution, & + zFORp_stream_omp_threads, & + zFORp_stream_omp_chunk_size, & + zFORp_stream_set_execution, & + zFORp_stream_set_omp_threads, & + zFORp_stream_set_omp_chunk_size + ! high-level API: zfp_field functions public :: zFORp_field_alloc, & @@ -409,6 +472,15 @@ subroutine zFORp_bitstream_stream_close(bitstream) bitstream%object = c_null_ptr end subroutine zFORp_bitstream_stream_close + ! high-level API: utility functions + + function zFORp_type_size(zfp_type) result(type_size) + implicit none + integer, intent(in) :: zfp_type + integer type_size + type_size = zfp_type_size(int(zfp_type, c_int)) + end function zFORp_type_size + ! high-level API: zfp_stream functions function zFORp_stream_open(bitstream) result(zfp_stream) @@ -462,6 +534,14 @@ function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) compressed_size = zfp_stream_compressed_size(zfp_stream%object) end function zFORp_stream_compressed_size + function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_field_type), intent(in) :: zfp_field + integer max_size + max_size = zfp_stream_maximum_size(zfp_stream%object, zfp_field%object) + end function zFORp_stream_maximum_size + subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_bitstream_type), intent(in) :: bitstream @@ -515,6 +595,53 @@ function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) int(minexp, c_int)) end function zFORp_stream_set_params + ! high-level API: execution policy functions + + function zFORp_stream_execution(zfp_stream) result(execution_policy) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer execution_policy + execution_policy = zfp_stream_execution(zfp_stream%object) + end function zFORp_stream_execution + + function zFORp_stream_omp_threads(zfp_stream) result(thread_count) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer thread_count + thread_count = zfp_stream_omp_threads(zfp_stream%object) + end function zFORp_stream_omp_threads + + function zFORp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer chunk_size_blocks + chunk_size_blocks = zfp_stream_omp_chunk_size(zfp_stream%object) + end function zFORp_stream_omp_chunk_size + + function zFORp_stream_set_execution(zfp_stream, execution_policy) result(is_success) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: execution_policy + integer is_success + is_success = zfp_stream_set_execution(zfp_stream%object, int(execution_policy, c_int)) + end function zFORp_stream_set_execution + + function zFORp_stream_set_omp_threads(zfp_stream, thread_count) result(is_success) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: thread_count + integer is_success + is_success = zfp_stream_set_omp_threads(zfp_stream%object, int(thread_count, c_int)) + end function zFORp_stream_set_omp_threads + + function zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer, intent(in) :: chunk_size + integer is_success + is_success = zfp_stream_set_omp_chunk_size(zfp_stream%object, int(chunk_size, c_int)) + end function zFORp_stream_set_omp_chunk_size + ! high-level API: zfp_field functions function zFORp_field_alloc() result(zfp_field) From bafc9f6bc3476fcb85c71387de89d36be46d084d Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sat, 29 Dec 2018 11:45:24 -0800 Subject: [PATCH 092/194] Wrap zfp_stream_rewind, needed when compressing and decompressing together --- fortran/zfp.f | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fortran/zfp.f b/fortran/zfp.f index 25c5f15b8..b752b6ad2 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -366,6 +366,12 @@ function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind integer(c_size_t) num_bits_read end function + ! low-level API: stream manipulation + subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") + import + type(c_ptr), value :: zfp_stream + end subroutine + end interface ! types @@ -454,6 +460,10 @@ function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind zFORp_write_header, & zFORp_read_header + ! low-level API: stream manipulation + + public :: zFORp_stream_rewind + contains ! minimal bitstream API @@ -852,4 +862,11 @@ function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) num_bits_read = zfp_read_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) end function zFORp_read_header + ! low-level API: stream manipulation + + subroutine zFORp_stream_rewind(zfp_stream) + type(zFORp_stream_type), intent(in) :: zfp_stream + call zfp_stream_rewind(zfp_stream%object) + end subroutine zFORp_stream_rewind + end module zFORp_module From f9f261f60e8639a61e72bf98db8eb22919579645 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sat, 29 Dec 2018 11:09:40 -0800 Subject: [PATCH 093/194] Update Fortran test to perform compression and decompression --- tests/fortran/testFortran.f | 75 +++++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 7 deletions(-) diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index 6e87592ad..5ebbb4281 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -2,10 +2,23 @@ program main use zFORp_module use iso_c_binding + ! loop counters + integer i, j + + ! input/decompressed arrays + integer xLen, yLen + integer, dimension(:, :), allocatable, target :: input_array + integer, dimension(:, :), allocatable, target :: decompressed_array + type(c_ptr) :: array_c_ptr + integer error, max_abs_error + + ! zfp_field + type(zFORp_field_type) :: zfp_field + ! bitstream character, dimension(:), allocatable, target :: buffer type(c_ptr) :: buffer_c_ptr - integer bytes + integer buffer_size_bytes, bitstream_offset_bytes type(zFORp_bitstream_type) :: bitstream, queried_bitstream ! zfp_stream @@ -14,16 +27,33 @@ program main integer :: dims, wra integer :: zfp_type - ! bitstream - bytes = 256 - allocate(buffer(bytes)) + ! initialize input and decompressed arrays + xLen = 8 + yLen = 8 + allocate(input_array(xLen, yLen)) + do i = 1, xLen + do j = 1, yLen + input_array(i, j) = i * i + j * (j + 1) + enddo + enddo + + allocate(decompressed_array(xLen, yLen)) + + ! setup zfp_field + array_c_ptr = c_loc(input_array) + zfp_type = zFORp_type_int32 + zfp_field = zFORp_field_2d(array_c_ptr, zfp_type, xLen, yLen) + + ! setup bitstream + buffer_size_bytes = 256 + allocate(buffer(buffer_size_bytes)) buffer_c_ptr = c_loc(buffer) - bitstream = zFORp_bitstream_stream_open(buffer_c_ptr, bytes) + bitstream = zFORp_bitstream_stream_open(buffer_c_ptr, buffer_size_bytes) - ! zfp_stream + ! setup zfp_stream zfp_stream = zFORp_stream_open(bitstream) - desired_rate = 16.0 + desired_rate = 8.0 dims = 2 wra = 0 zfp_type = zFORp_type_float @@ -31,8 +61,39 @@ program main queried_bitstream = zFORp_stream_bit_stream(zfp_stream) + ! compress + bitstream_offset_bytes = zFORp_compress(zfp_stream, zfp_field) + write(*, *) "After compression, bitstream offset at " + write(*, *) bitstream_offset_bytes + + ! decompress + call zFORp_stream_rewind(zfp_stream) + array_c_ptr = c_loc(decompressed_array) + call zFORp_field_set_pointer(zfp_field, array_c_ptr) + + bitstream_offset_bytes = zFORp_decompress(zfp_stream, zfp_field) + write(*, *) "After decompression, bitstream offset at " + write(*, *) bitstream_offset_bytes + + max_abs_error = 0 + do i = 1, xLen + do j = 1, yLen + error = abs(decompressed_array(i, j) - input_array(i, j)) + max_abs_error = max(error, max_abs_error) + enddo + enddo + write(*, *) "Max absolute error: " + write(*, *) max_abs_error + + write(*, *) "Absolute errors: " + write(*, *) abs(input_array - decompressed_array) + ! deallocations call zFORp_stream_close(zfp_stream) call zFORp_bitstream_stream_close(queried_bitstream) + call zFORp_field_free(zfp_field) + deallocate(buffer) + deallocate(input_array) + deallocate(decompressed_array) end program main From 697c7fa5d687c2844db86aee52db54c5bdbd675b Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 15 Apr 2019 17:43:30 -0700 Subject: [PATCH 094/194] Add `bind(c)` keyword to some zFORp types and functions, so they can be referenced from C tests --- fortran/zfp.f | 123 ++++++++++++++++++------------------ tests/fortran/testFortran.f | 2 +- 2 files changed, 64 insertions(+), 61 deletions(-) diff --git a/fortran/zfp.f b/fortran/zfp.f index b752b6ad2..0ef37028e 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -4,17 +4,18 @@ module zFORp_module implicit none private - type zFORp_bitstream_type + ! bind(c) on types, enums because tests written in C need to reference them + type, bind(c) :: zFORp_bitstream_type private type(c_ptr) :: object = c_null_ptr end type zFORp_bitstream_type - type zFORp_stream_type + type, bind(c) :: zFORp_stream_type private type(c_ptr) :: object = c_null_ptr end type zFORp_stream_type - type zFORp_field_type + type, bind(c) :: zFORp_field_type private type(c_ptr) :: object = c_null_ptr end type zFORp_field_type @@ -468,7 +469,7 @@ subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") ! minimal bitstream API - function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) + function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) bind(c, name="zforp_bitstream_stream_open") implicit none type(zFORp_bitstream_type) :: bitstream type(c_ptr), intent(in) :: buffer @@ -476,7 +477,7 @@ function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) bitstream%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) end function zFORp_bitstream_stream_open - subroutine zFORp_bitstream_stream_close(bitstream) + subroutine zFORp_bitstream_stream_close(bitstream) bind(c, name="zforp_bitstream_stream_close") type(zFORp_bitstream_type), intent(inout) :: bitstream call zfp_bitstream_stream_close(bitstream%object) bitstream%object = c_null_ptr @@ -484,7 +485,7 @@ end subroutine zFORp_bitstream_stream_close ! high-level API: utility functions - function zFORp_type_size(zfp_type) result(type_size) + function zFORp_type_size(zfp_type) result(type_size) bind(c, name="zforp_type_size") implicit none integer, intent(in) :: zfp_type integer type_size @@ -493,41 +494,41 @@ end function zFORp_type_size ! high-level API: zfp_stream functions - function zFORp_stream_open(bitstream) result(zfp_stream) + function zFORp_stream_open(bitstream) result(zfp_stream) bind(c, name="zforp_stream_open") implicit none type(zFORp_bitstream_type), intent(in) :: bitstream type(zFORp_stream_type) :: zfp_stream zfp_stream%object = zfp_stream_open(bitstream%object) end function zFORp_stream_open - subroutine zFORp_stream_close(zfp_stream) + subroutine zFORp_stream_close(zfp_stream) bind(c, name="zforp_stream_close") type(zFORp_stream_type), intent(inout) :: zfp_stream call zfp_stream_close(zfp_stream%object) zfp_stream%object = c_null_ptr end subroutine zFORp_stream_close - function zFORp_stream_bit_stream(zfp_stream) result(bitstream) + function zFORp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zforp_stream_bit_stream") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_bitstream_type) :: bitstream bitstream%object = zfp_stream_bit_stream(zfp_stream%object) end function zFORp_stream_bit_stream - function zFORp_stream_compression_mode(zfp_stream) result(zfp_mode) + function zFORp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer zfp_mode zfp_mode = zfp_stream_compression_mode(zfp_stream%object) end function zFORp_stream_compression_mode - function zFORp_stream_mode(zfp_stream) result(encoded_mode) + function zFORp_stream_mode(zfp_stream) result(encoded_mode) bind(c, name="zforp_stream_mode") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer (kind=8) encoded_mode encoded_mode = zfp_stream_mode(zfp_stream%object) end function zFORp_stream_mode - subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) + subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(inout) :: minbits, maxbits, maxprec, minexp call zfp_stream_params(zfp_stream%object, & @@ -537,14 +538,14 @@ subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) int(minexp, c_int)) end subroutine zFORp_stream_params - function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) + function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, name="zforp_stream_compressed_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer compressed_size compressed_size = zfp_stream_compressed_size(zfp_stream%object) end function zFORp_stream_compressed_size - function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) + function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) bind(c, name="zforp_stream_maximum_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field @@ -552,24 +553,24 @@ function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) max_size = zfp_stream_maximum_size(zfp_stream%object, zfp_field%object) end function zFORp_stream_maximum_size - subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) + subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zforp_stream_set_bit_stream") type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_bitstream_type), intent(in) :: bitstream call zfp_stream_set_bit_stream(zfp_stream%object, bitstream%object) end subroutine zFORp_stream_set_bit_stream - function zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) + function zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream - real, intent(in) :: rate + real (kind=8), intent(in) :: rate integer, intent(in) :: zfp_type integer, intent(in) :: dims, wra - real :: rate_result + real (kind=8) :: rate_result rate_result = zfp_stream_set_rate(zfp_stream%object, real(rate, c_double), & int(zfp_type, c_int), int(dims, c_int), int(wra, c_int)) end function zFORp_stream_set_rate - function zFORp_stream_set_precision(zfp_stream, prec) result(prec_result) + function zFORp_stream_set_precision(zfp_stream, prec) result(prec_result) bind(c, name="zforp_stream_set_precision") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(in) :: prec @@ -577,7 +578,7 @@ function zFORp_stream_set_precision(zfp_stream, prec) result(prec_result) prec_result = zfp_stream_set_precision(zfp_stream%object, int(prec, c_int)) end function zFORp_stream_set_precision - function zFORp_stream_set_accuracy(zfp_stream, acc) result(acc_result) + function zFORp_stream_set_accuracy(zfp_stream, acc) result(acc_result) bind(c, name="zforp_stream_set_accuracy") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream real (kind=8), intent(in) :: acc @@ -585,15 +586,16 @@ function zFORp_stream_set_accuracy(zfp_stream, acc) result(acc_result) acc_result = zfp_stream_set_accuracy(zfp_stream%object, real(acc, c_double)) end function zFORp_stream_set_accuracy - function zFORp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) + function zFORp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) bind(c, name="zforp_stream_set_mode") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream - integer, intent(in) :: encoded_mode + integer (kind=8), intent(in) :: encoded_mode integer mode_result mode_result = zfp_stream_set_mode(zfp_stream%object, int(encoded_mode, c_int64_t)) end function zFORp_stream_set_mode - function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) result(is_success) + function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) result(is_success) & + bind(c, name="zforp_stream_set_params") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(in) :: minbits, maxbits, maxprec, minexp @@ -607,28 +609,28 @@ end function zFORp_stream_set_params ! high-level API: execution policy functions - function zFORp_stream_execution(zfp_stream) result(execution_policy) + function zFORp_stream_execution(zfp_stream) result(execution_policy) bind(c, name="zforp_stream_execution") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer execution_policy execution_policy = zfp_stream_execution(zfp_stream%object) end function zFORp_stream_execution - function zFORp_stream_omp_threads(zfp_stream) result(thread_count) + function zFORp_stream_omp_threads(zfp_stream) result(thread_count) bind(c, name="zforp_stream_omp_threads") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer thread_count thread_count = zfp_stream_omp_threads(zfp_stream%object) end function zFORp_stream_omp_threads - function zFORp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) + function zFORp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) bind(c, name="zforp_stream_omp_chunk_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer chunk_size_blocks chunk_size_blocks = zfp_stream_omp_chunk_size(zfp_stream%object) end function zFORp_stream_omp_chunk_size - function zFORp_stream_set_execution(zfp_stream, execution_policy) result(is_success) + function zFORp_stream_set_execution(zfp_stream, execution_policy) result(is_success) bind(c, name="zforp_stream_set_execution") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(in) :: execution_policy @@ -636,7 +638,7 @@ function zFORp_stream_set_execution(zfp_stream, execution_policy) result(is_succ is_success = zfp_stream_set_execution(zfp_stream%object, int(execution_policy, c_int)) end function zFORp_stream_set_execution - function zFORp_stream_set_omp_threads(zfp_stream, thread_count) result(is_success) + function zFORp_stream_set_omp_threads(zfp_stream, thread_count) result(is_success) bind(c, name="zforp_stream_set_omp_threads") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(in) :: thread_count @@ -644,7 +646,8 @@ function zFORp_stream_set_omp_threads(zfp_stream, thread_count) result(is_succes is_success = zfp_stream_set_omp_threads(zfp_stream%object, int(thread_count, c_int)) end function zFORp_stream_set_omp_threads - function zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) + function zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) & + bind(c, name="zforp_stream_set_omp_chunk_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream integer, intent(in) :: chunk_size @@ -654,13 +657,13 @@ end function zFORp_stream_set_omp_chunk_size ! high-level API: zfp_field functions - function zFORp_field_alloc() result(zfp_field) + function zFORp_field_alloc() result(zfp_field) bind(c, name="zforp_field_alloc") implicit none type(zFORp_field_type) zfp_field zfp_field%object = zfp_field_alloc() end function zFORp_field_alloc - function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) + function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) bind(c, name="zforp_field_1d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx @@ -669,7 +672,7 @@ function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) int(nx, c_int)) end function zFORp_field_1d - function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) + function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) bind(c, name="zforp_field_2d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny @@ -678,7 +681,7 @@ function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) int(nx, c_int), int(ny, c_int)) end function zFORp_field_2d - function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) + function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) bind(c, name="zforp_field_3d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz @@ -688,7 +691,7 @@ function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field int(nz, c_int)) end function zFORp_field_3d - function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) + function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) bind(c, name="zforp_field_4d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz, nw @@ -698,13 +701,13 @@ function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_f int(nz, c_int), int(nw, c_int)) end function zFORp_field_4d - subroutine zFORp_field_free(zfp_field) + subroutine zFORp_field_free(zfp_field) bind(c, name="zforp_field_free") type(zFORp_field_type), intent(inout) :: zfp_field call zfp_field_free(zfp_field%object) zfp_field%object = c_null_ptr end subroutine zFORp_field_free - function zFORp_field_pointer(zfp_field) result(arr_ptr) + function zFORp_field_pointer(zfp_field) result(arr_ptr) bind(c, name="zforp_field_pointer") implicit none type(zFORp_field_type), intent(in) :: zfp_field type(c_ptr) arr_ptr @@ -712,57 +715,57 @@ function zFORp_field_pointer(zfp_field) result(arr_ptr) end function zFORp_field_pointer ! added "scalar" to name to avoid clash with zfp_field_type - function zFORp_field_scalar_type(zfp_field) result(zfp_type) + function zFORp_field_scalar_type(zfp_field) result(zfp_type) bind(c, name="zforp_field_scalar_type") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer zfp_type zfp_type = zfp_field_scalar_type(zfp_field%object) end function zFORp_field_scalar_type - function zFORp_field_precision(zfp_field) result(prec) + function zFORp_field_precision(zfp_field) result(prec) bind(c, name="zforp_field_precision") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer prec prec = zfp_field_precision(zfp_field%object) end function zFORp_field_precision - function zFORp_field_dimensionality(zfp_field) result(dims) + function zFORp_field_dimensionality(zfp_field) result(dims) bind(c, name="zforp_field_dimensionality") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer dims dims = zfp_field_dimensionality(zfp_field%object) end function zFORp_field_dimensionality - function zFORp_field_size(zfp_field, size_arr) result(total_size) + function zFORp_field_size(zfp_field, size_arr) result(total_size) bind(c, name="zforp_field_size") implicit none type(zFORp_field_type), intent(in) :: zfp_field - integer, dimension(:), target, intent(inout) :: size_arr + integer, dimension(4), target, intent(inout) :: size_arr integer total_size total_size = zfp_field_size(zfp_field%object, c_loc(size_arr)) end function zFORp_field_size - function zFORp_field_stride(zfp_field, stride_arr) result(is_strided) + function zFORp_field_stride(zfp_field, stride_arr) result(is_strided) bind(c, name="zforp_field_stride") implicit none type(zFORp_field_type), intent(in) :: zfp_field - integer, dimension(:), target, intent(inout) :: stride_arr + integer, dimension(4), target, intent(inout) :: stride_arr integer is_strided is_strided = zfp_field_stride(zfp_field%object, c_loc(stride_arr)) end function zFORp_field_stride - function zFORp_field_metadata(zfp_field) result(encoded_metadata) + function zFORp_field_metadata(zfp_field) result(encoded_metadata) bind(c, name="zforp_field_metadata") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer (kind=8) encoded_metadata encoded_metadata = zfp_field_metadata(zfp_field%object) end function zFORp_field_metadata - subroutine zFORp_field_set_pointer(zfp_field, arr_ptr) + subroutine zFORp_field_set_pointer(zfp_field, arr_ptr) bind(c, name="zforp_field_set_pointer") type(zFORp_field_type), intent(in) :: zfp_field type(c_ptr), intent(in) :: arr_ptr call zfp_field_set_pointer(zfp_field%object, arr_ptr) end subroutine zFORp_field_set_pointer - function zFORp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) + function zFORp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) bind(c, name="zforp_field_set_type") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: zfp_type @@ -770,55 +773,55 @@ function zFORp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) zfp_type_result = zfp_field_set_type(zfp_field%object, int(zfp_type, c_int)) end function zFORp_field_set_type - subroutine zFORp_field_set_size_1d(zfp_field, nx) + subroutine zFORp_field_set_size_1d(zfp_field, nx) bind(c, name="zforp_field_set_size_1d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: nx call zfp_field_set_size_1d(zfp_field%object, int(nx, c_int)) end subroutine zFORp_field_set_size_1d - subroutine zFORp_field_set_size_2d(zfp_field, nx, ny) + subroutine zFORp_field_set_size_2d(zfp_field, nx, ny) bind(c, name="zforp_field_set_size_2d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: nx, ny call zfp_field_set_size_2d(zfp_field%object, int(nx, c_int), int(ny, c_int)) end subroutine zFORp_field_set_size_2d - subroutine zFORp_field_set_size_3d(zfp_field, nx, ny, nz) + subroutine zFORp_field_set_size_3d(zfp_field, nx, ny, nz) bind(c, name="zforp_field_set_size_3d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: nx, ny, nz call zfp_field_set_size_3d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int)) end subroutine zFORp_field_set_size_3d - subroutine zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) + subroutine zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) bind(c, name="zforp_field_set_size_4d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: nx, ny, nz, nw call zfp_field_set_size_4d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int), int(nw, c_int)) end subroutine zFORp_field_set_size_4d - subroutine zFORp_field_set_stride_1d(zfp_field, sx) + subroutine zFORp_field_set_stride_1d(zfp_field, sx) bind(c, name="zforp_field_set_stride_1d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: sx call zfp_field_set_stride_1d(zfp_field%object, int(sx, c_int)) end subroutine zFORp_field_set_stride_1d - subroutine zFORp_field_set_stride_2d(zfp_field, sx, sy) + subroutine zFORp_field_set_stride_2d(zfp_field, sx, sy) bind(c, name="zforp_field_set_stride_2d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: sx, sy call zfp_field_set_stride_2d(zfp_field%object, int(sx, c_int), int(sy, c_int)) end subroutine zFORp_field_set_stride_2d - subroutine zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) + subroutine zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) bind(c, name="zforp_field_set_stride_3d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: sx, sy, sz call zfp_field_set_stride_3d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int)) end subroutine zFORp_field_set_stride_3d - subroutine zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) + subroutine zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) bind(c, name="zforp_field_set_stride_4d") type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: sx, sy, sz, sw call zfp_field_set_stride_4d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int), int(sw, c_int)) end subroutine zFORp_field_set_stride_4d - function zFORp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) + function zFORp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) bind(c, name="zforp_field_set_metadata") implicit none type(zFORp_field_type), intent(in) :: zfp_field integer (kind=8), intent(in) :: encoded_metadata @@ -828,7 +831,7 @@ end function zFORp_field_set_metadata ! high-level API: compression and decompression - function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) + function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zforp_compress") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field @@ -836,7 +839,7 @@ function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bitstream_offset_bytes = zfp_compress(zfp_stream%object, zfp_field%object) end function zFORp_compress - function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) + function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zforp_decompress") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field @@ -844,7 +847,7 @@ function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bitstream_offset_bytes = zfp_decompress(zfp_stream%object, zfp_field%object) end function zFORp_decompress - function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) + function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) bind(c, name="zforp_write_header") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field @@ -853,7 +856,7 @@ function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written num_bits_written = zfp_write_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) end function zFORp_write_header - function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) + function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind(c, name="zforp_read_header") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field @@ -864,7 +867,7 @@ end function zFORp_read_header ! low-level API: stream manipulation - subroutine zFORp_stream_rewind(zfp_stream) + subroutine zFORp_stream_rewind(zfp_stream) bind(c, name="zforp_stream_rewind") type(zFORp_stream_type), intent(in) :: zfp_stream call zfp_stream_rewind(zfp_stream%object) end subroutine zFORp_stream_rewind diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index 5ebbb4281..9e9ab0789 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -23,7 +23,7 @@ program main ! zfp_stream type(zFORp_stream_type) :: zfp_stream - real :: desired_rate, rate_result + real (kind=8) :: desired_rate, rate_result integer :: dims, wra integer :: zfp_type From 9c4e0be71da2e64b9e76fefc417b6dd4de2484b6 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 15 Apr 2019 17:43:53 -0700 Subject: [PATCH 095/194] wrap all macro constants, and zfp_exec enums --- fortran/zfp.f | 112 ++++++++++++++++++++++++++++++++++++ tests/fortran/testFortran.f | 4 ++ 2 files changed, 116 insertions(+) diff --git a/fortran/zfp.f b/fortran/zfp.f index 0ef37028e..c7cf86b89 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -36,6 +36,86 @@ module zFORp_module zFORp_mode_fixed_accuracy = 4 end enum + enum, bind(c) + enumerator :: zFORp_exec_serial = 0, & + zFORp_exec_omp = 1, & + zFORp_exec_cuda = 2 + end enum + + ! constants are hardcoded + ! const_xyz holds value, but xyz is the public constant + + integer, parameter :: const_zFORp_version_major = 0 + integer, parameter :: const_zFORp_version_minor = 5 + integer, parameter :: const_zFORp_version_patch = 4 + integer, protected, bind(c, name="zFORp_version_major") :: zFORp_version_major + integer, protected, bind(c, name="zFORp_version_minor") :: zFORp_version_minor + integer, protected, bind(c, name="zFORp_version_patch") :: zFORp_version_patch + data zFORp_version_major/const_zFORp_version_major/, & + zFORp_version_minor/const_zFORp_version_minor/, & + zFORp_version_patch/const_zFORp_version_patch/ + + integer, parameter :: const_zFORp_codec_version = 5 + integer, protected, bind(c, name="zFORp_codec_version") :: zFORp_codec_version + data zFORp_codec_version/const_zFORp_codec_version/ + + integer, parameter :: const_zFORp_library_version = 84 ! 0x54 + integer, protected, bind(c, name="zFORp_library_version") :: zFORp_library_version + data zFORp_library_version/const_zFORp_library_version/ + + character(len = 36), parameter :: const_zFORp_version_string = 'zfp version 0.5.4 (October 1, 2018)' + character(len = 36), protected, bind(c, name="zFORp_version_string") :: zFORp_version_string + data zFORp_version_string/const_zFORp_version_string/ + + integer, parameter :: const_zFORp_min_bits = 1 + integer, parameter :: const_zFORp_max_bits = 16657 + integer, parameter :: const_zFORp_max_prec = 64 + integer, parameter :: const_zFORp_min_exp = -1074 + integer, protected, bind(c, name="zFORp_min_bits") :: zFORp_min_bits + integer, protected, bind(c, name="zFORp_max_bits") :: zFORp_max_bits + integer, protected, bind(c, name="zFORp_max_prec") :: zFORp_max_prec + integer, protected, bind(c, name="zFORp_min_exp") :: zFORp_min_exp + data zFORp_min_bits/const_zFORp_min_bits/, & + zFORp_max_bits/const_zFORp_max_bits/, & + zFORp_max_prec/const_zFORp_max_prec/, & + zFORp_min_exp/const_zFORp_min_exp/ + + integer, parameter :: const_zFORp_header_magic = 1 + integer, parameter :: const_zFORp_header_meta = 2 + integer, parameter :: const_zFORp_header_mode = 4 + integer, parameter :: const_zFORp_header_full = 7 + integer, protected, bind(c, name="zFORp_header_magic") :: zFORp_header_magic + integer, protected, bind(c, name="zFORp_header_meta") :: zFORp_header_meta + integer, protected, bind(c, name="zFORp_header_mode") :: zFORp_header_mode + integer, protected, bind(c, name="zFORp_header_full") :: zFORp_header_full + data zFORp_header_magic/const_zFORp_header_magic/, & + zFORp_header_meta/const_zFORp_header_meta/, & + zFORp_header_mode/const_zFORp_header_mode/, & + zFORp_header_full/const_zFORp_header_full/ + + integer (kind=8), parameter :: const_zFORp_meta_null = -1 + integer (kind=8), protected, bind(c, name="zFORp_meta_null") :: zFORp_meta_null + data zFORp_meta_null/const_zFORp_meta_null/ + + integer, parameter :: const_zFORp_magic_bits = 32 + integer, parameter :: const_zFORp_meta_bits = 52 + integer, parameter :: const_zFORp_mode_short_bits = 12 + integer, parameter :: const_zFORp_mode_long_bits = 64 + integer, parameter :: const_zFORp_header_max_bits = 148 + integer, parameter :: const_zFORp_mode_short_max = 4094 + integer, protected, bind(c, name="zFORp_magic_bits") :: zFORp_magic_bits + integer, protected, bind(c, name="zFORp_meta_bits") :: zFORp_meta_bits + integer, protected, bind(c, name="zFORp_mode_short_bits") :: zFORp_mode_short_bits + integer, protected, bind(c, name="zFORp_mode_long_bits") :: zFORp_mode_long_bits + integer, protected, bind(c, name="zFORp_header_max_bits") :: zFORp_header_max_bits + integer, protected, bind(c, name="zFORp_mode_short_max") :: zFORp_mode_short_max + data zFORp_magic_bits/const_zFORp_magic_bits/, & + zFORp_meta_bits/const_zFORp_meta_bits/, & + zFORp_mode_short_bits/const_zFORp_mode_short_bits/, & + zFORp_mode_long_bits/const_zFORp_mode_long_bits/, & + zFORp_header_max_bits/const_zFORp_header_max_bits/, & + zFORp_mode_short_max/const_zFORp_mode_short_max/ + interface ! minimal bitstream API @@ -395,6 +475,38 @@ subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") zFORp_mode_fixed_precision, & zFORp_mode_fixed_accuracy + public :: zFORp_exec_serial, & + zFORp_exec_omp, & + zFORp_exec_cuda + + ! C macros -> constants + public :: zFORp_version_major, & + zFORp_version_minor, & + zFORp_version_patch + + public :: zFORp_codec_version, & + zFORp_library_version, & + zFORp_version_string + + public :: zFORp_min_bits, & + zFORp_max_bits, & + zFORp_max_prec, & + zFORp_min_exp + + public :: zFORp_header_magic, & + zFORp_header_meta, & + zFORp_header_mode, & + zFORp_header_full + + public :: zFORp_meta_null + + public :: zFORp_magic_bits, & + zFORp_meta_bits, & + zFORp_mode_short_bits, & + zFORp_mode_long_bits, & + zFORp_header_max_bits, & + zFORp_mode_short_max + ! minimal bitstream API public :: zFORp_type_size diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index 9e9ab0789..b37518ffa 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -88,6 +88,10 @@ program main write(*, *) "Absolute errors: " write(*, *) abs(input_array - decompressed_array) + ! zfp library info + write(*, *) zFORp_version_string + write(*, *) zFORp_meta_null + ! deallocations call zFORp_stream_close(zfp_stream) call zFORp_bitstream_stream_close(queried_bitstream) From 505d38536717f10c66d5d6bec084fd8876ea368b Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sat, 30 Mar 2019 14:54:48 -0700 Subject: [PATCH 096/194] add fortran to all Travis CI linux builds (not OSX, nor windows), set env vars for compilers on every Travis CI matrix entry --- .travis.yml | 95 +++++++++++++++++++++++++++++++++------------- appveyor.sh | 2 +- cmake/travis.cmake | 5 +++ travis.sh | 14 +++++-- 4 files changed, 84 insertions(+), 32 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ea63a31b..33fa2e184 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,5 @@ language: - - c - -env: - - C_STANDARD=99 CXX_STANDARD=98 + - generic matrix: include: @@ -12,9 +9,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 - env: - - COVERAGE=ON + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' COVERAGE='ON' - os: linux dist: trusty @@ -22,7 +21,10 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty'] - packages: clang-3.6 + packages: + - clang-3.6 + - gfortran-6 + env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' - os: linux dist: trusty @@ -32,7 +34,10 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty'] - packages: clang-3.4 + packages: + - clang-3.4 + - gfortran-6 + env: CC='clang-3.4' CXX='clang++-3.4' FC='gfortran-6' - os: linux dist: trusty @@ -40,7 +45,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-4.4 + packages: + - gcc-4.4 + - g++-4.4 + - gfortran-4.4 + env: CC='gcc-4.4' CXX='g++-4.4' FC='gfortran-4.4' - os: linux dist: trusty @@ -48,7 +57,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-4.7 + packages: + - gcc-4.7 + - g++-4.7 + - gfortran-4.7 + env: CC='gcc-4.7' CXX='g++-4.7' FC='gfortran-4.7' - os: linux dist: trusty @@ -56,7 +69,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-4.8 + packages: + - gcc-4.8 + - g++-4.8 + - gfortran-4.8 + env: CC='gcc-4.8' CXX='g++-4.8' FC='gfortran-4.8' - os: linux dist: trusty @@ -64,7 +81,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-4.9 + packages: + - gcc-4.9 + - g++-4.9 + - gfortran-4.9 + env: CC='gcc-4.9' CXX='g++-4.9' FC='gfortran-4.9' - os: linux dist: trusty @@ -72,7 +93,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-5 + packages: + - gcc-5 + - g++-5 + - gfortran-5 + env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' - os: linux dist: trusty @@ -80,9 +105,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 - env: - - C_STANDARD=90 + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' C_STANDARD='90' - os: linux dist: trusty @@ -90,9 +117,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 - env: - - C_STANDARD=11 + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' C_STANDARD='11' - os: linux dist: trusty @@ -100,9 +129,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 - env: - - CXX_STANDARD=11 + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' CXX_STANDARD='11' - os: linux dist: trusty @@ -110,9 +141,11 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 - env: - - CXX_STANDARD=14 + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' CXX_STANDARD='14' - os: linux dist: trusty @@ -120,23 +153,31 @@ matrix: addons: apt: sources: ubuntu-toolchain-r-test - packages: gcc-6 + packages: + - gcc-6 + - g++-6 + - gfortran-6 + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' - os: osx osx_image: xcode7.3 compiler: gcc + env: CC='gcc' CXX='g++' - os: osx osx_image: xcode8.3 compiler: gcc + env: CC='gcc' CXX='g++' - os: osx osx_image: xcode7.3 compiler: clang + env: CC='clang' CXX='clang++' - os: osx osx_image: xcode8.3 compiler: clang + env: CC='clang' CXX='clang++' script: - ./travis.sh diff --git a/appveyor.sh b/appveyor.sh index 46dbe4743..a00271ba7 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -12,7 +12,7 @@ mkdir build cd build # config without OpenMP, with CFP (and custom namespace), with aligned allocations (compressed arrays) -run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" +run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_ZFORP=OFF -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" # build empty project requiring OpenMP, in a temp directory that ZFP is oblivious to mkdir tmpBuild diff --git a/cmake/travis.cmake b/cmake/travis.cmake index e434471fd..83c005437 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -11,6 +11,7 @@ set(cfg_options -DCMAKE_C_STANDARD=${C_STANDARD} -DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DBUILD_CFP=${BUILD_CFP} + -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_OPENMP=${BUILD_OPENMP} -DZFP_WITH_CUDA=${BUILD_CUDA} ) @@ -36,6 +37,10 @@ if(BUILD_CFP) endif() endif() +if(BUILD_ZFORP) + set(CTEST_SITE "${CTEST_SITE}_zforp") +endif() + if(WITH_COVERAGE) list(APPEND cfg_options -DCMAKE_C_FLAGS=-coverage diff --git a/travis.sh b/travis.sh index 3f6f8dba0..09a563069 100755 --- a/travis.sh +++ b/travis.sh @@ -5,11 +5,17 @@ mkdir build cd build if [ -n "${COVERAGE}" ]; then - # build - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # build (linux) + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_ZFORP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake else - # build/test without OpenMP, with CFP (and custom namespace) - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + # build/test without OpenMP, with CFP (and custom namespace), with Fortran (linux only) + if [[ "$OSTYPE" == "darwin"* ]]; then + BUILD_ZFORP=OFF + else + BUILD_ZFORP=ON + fi + + ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_ZFORP=${BUILD_ZFORP} -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake rm -rf ./* ; From 184e6bbc2b38af1efb73dcc239144be6bdf13bd9 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 11 Apr 2019 15:21:50 -0700 Subject: [PATCH 097/194] clone newer commit hash from googletest/ with PR fix for gcc4.4 --- tests/CMakeLists.txt.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CMakeLists.txt.in b/tests/CMakeLists.txt.in index 49d199674..a6345f93b 100644 --- a/tests/CMakeLists.txt.in +++ b/tests/CMakeLists.txt.in @@ -6,7 +6,7 @@ include(ExternalProject) ExternalProject_Add( googletest GIT_REPOSITORY https://github.com/google/googletest.git - GIT_TAG 0f7f5cd93a7cc866443eb882643acdd8b335cffd + GIT_TAG 4fe76c4d6e667ba588a3868d052a2aa4b423afa3 SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" CONFIGURE_COMMAND "" From b1fa259e1a345a2bf8572f17aa7b8d11bf901032 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Sat, 30 Mar 2019 16:44:32 -0700 Subject: [PATCH 098/194] Travis CI: use clang 3.6 and 4.0, install g++-7 package to upgrade stdlib so cmake gets a compatible CXX compiler --- .travis.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 33fa2e184..51a546940 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,26 +18,28 @@ matrix: - os: linux dist: trusty compiler: clang-3.6 - addons: + addons: &clang36 apt: sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty'] packages: - clang-3.6 + - g++-7 - gfortran-6 env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' - os: linux - dist: trusty - compiler: clang + dist: xenial + compiler: clang-4.0 before_install: - export LD_LIBRARY_PATH=/usr/local/clang/lib:$LD_LIBRARY_PATH - addons: + addons: &clang40 apt: - sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty'] + sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-4.0'] packages: - - clang-3.4 + - clang-4.0 + - g++-7 - gfortran-6 - env: CC='clang-3.4' CXX='clang++-3.4' FC='gfortran-6' + env: CC='clang-4.0' CXX='clang++-4.0' FC='gfortran-6' - os: linux dist: trusty From 323c410925d077ea4a432ede3762b38826156148 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 10 Dec 2018 13:33:33 -0800 Subject: [PATCH 099/194] python: include scikit-build cmake scripts --- python/scikit-build-cmake/FindCython.cmake | 77 +++ .../FindPythonExtensions.cmake | 573 +++++++++++++++++ python/scikit-build-cmake/LICENSE | 53 ++ python/scikit-build-cmake/UseCython.cmake | 395 ++++++++++++ ...targetLinkLibrariesWithDynamicLookup.cmake | 581 ++++++++++++++++++ 5 files changed, 1679 insertions(+) create mode 100644 python/scikit-build-cmake/FindCython.cmake create mode 100644 python/scikit-build-cmake/FindPythonExtensions.cmake create mode 100644 python/scikit-build-cmake/LICENSE create mode 100644 python/scikit-build-cmake/UseCython.cmake create mode 100644 python/scikit-build-cmake/targetLinkLibrariesWithDynamicLookup.cmake diff --git a/python/scikit-build-cmake/FindCython.cmake b/python/scikit-build-cmake/FindCython.cmake new file mode 100644 index 000000000..3d58c4f00 --- /dev/null +++ b/python/scikit-build-cmake/FindCython.cmake @@ -0,0 +1,77 @@ +#.rst: +# +# Find ``cython`` executable. +# +# This module will set the following variables in your project: +# +# ``CYTHON_EXECUTABLE`` +# path to the ``cython`` program +# +# ``CYTHON_VERSION`` +# version of ``cython`` +# +# ``CYTHON_FOUND`` +# true if the program was found +# +# For more information on the Cython project, see http://cython.org/. +# +# *Cython is a language that makes writing C extensions for the Python language +# as easy as Python itself.* +# +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Use the Cython executable that lives next to the Python executable +# if it is a local installation. +find_package(PythonInterp) +if(PYTHONINTERP_FOUND) + get_filename_component(_python_path ${PYTHON_EXECUTABLE} PATH) + find_program(CYTHON_EXECUTABLE + NAMES cython cython.bat cython3 + HINTS ${_python_path} + DOC "path to the cython executable") +else() + find_program(CYTHON_EXECUTABLE + NAMES cython cython.bat cython3 + DOC "path to the cython executable") +endif() + +if(CYTHON_EXECUTABLE) + set(CYTHON_version_command ${CYTHON_EXECUTABLE} --version) + + execute_process(COMMAND ${CYTHON_version_command} + OUTPUT_VARIABLE CYTHON_version_output + ERROR_VARIABLE CYTHON_version_error + RESULT_VARIABLE CYTHON_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT ${CYTHON_version_result} EQUAL 0) + set(_error_msg "Command \"${CYTHON_version_command}\" failed with") + set(_error_msg "${_error_msg} output:\n${CYTHON_version_error}") + message(SEND_ERROR "${_error_msg}") + else() + if("${CYTHON_version_output}" MATCHES "^[Cc]ython version ([^,]+)") + set(CYTHON_VERSION "${CMAKE_MATCH_1}") + endif() + endif() +endif() + +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cython REQUIRED_VARS CYTHON_EXECUTABLE) + +mark_as_advanced(CYTHON_EXECUTABLE) + +include(UseCython) diff --git a/python/scikit-build-cmake/FindPythonExtensions.cmake b/python/scikit-build-cmake/FindPythonExtensions.cmake new file mode 100644 index 000000000..e25c8bfeb --- /dev/null +++ b/python/scikit-build-cmake/FindPythonExtensions.cmake @@ -0,0 +1,573 @@ +#.rst: +# +# This module defines CMake functions to build Python extension modules and +# stand-alone executables. +# +# The following variables are defined: +# :: +# +# PYTHON_PREFIX - absolute path to the current Python +# distribution's prefix +# PYTHON_SITE_PACKAGES_DIR - absolute path to the current Python +# distribution's site-packages directory +# PYTHON_RELATIVE_SITE_PACKAGES_DIR - path to the current Python +# distribution's site-packages directory +# relative to its prefix +# PYTHON_SEPARATOR - separator string for file path +# components. Equivalent to ``os.sep`` in +# Python. +# PYTHON_PATH_SEPARATOR - separator string for PATH-style +# environment variables. Equivalent to +# ``os.pathsep`` in Python. +# PYTHON_EXTENSION_MODULE_SUFFIX - suffix of the compiled module. For example, on +# Linux, based on environment, it could be ``.cpython-35m-x86_64-linux-gnu.so``. +# +# +# +# The following functions are defined: +# +# .. cmake:command:: python_extension_module +# +# For libraries meant to be used as Python extension modules, either dynamically +# loaded or directly linked. Amend the configuration of the library target +# (created using ``add_library``) with additional options needed to build and +# use the referenced library as a Python extension module. +# +# python_extension_module( +# [LINKED_MODULES_VAR ] +# [FORWARD_DECL_MODULES_VAR ] +# [MODULE_SUFFIX ]) +# +# Only extension modules that are configured to be built as MODULE libraries can +# be runtime-loaded through the standard Python import mechanism. All other +# modules can only be included in standalone applications that are written to +# expect their presence. In addition to being linked against the libraries for +# these modules, such applications must forward declare their entry points and +# initialize them prior to use. To generate these forward declarations and +# initializations, see ``python_modules_header``. +# +# If ```` does not refer to a target, then it is assumed to refer to an +# extension module that is not linked at all, but compiled along with other +# source files directly into an executable. Adding these modules does not cause +# any library configuration modifications, and they are not added to the list of +# linked modules. They still must be forward declared and initialized, however, +# and so are added to the forward declared modules list. +# +# If the associated target is of type ``MODULE_LIBRARY``, the LINK_FLAGS target +# property is used to set symbol visibility and export only the module init function. +# This applies to GNU and MSVC compilers. +# +# Options: +# +# ``LINKED_MODULES_VAR `` +# Name of the variable referencing a list of extension modules whose libraries +# must be linked into the executables of any stand-alone applications that use +# them. By default, the global property ``PY_LINKED_MODULES_LIST`` is used. +# +# ``FORWARD_DECL_MODULES_VAR `` +# Name of the variable referencing a list of extension modules whose entry +# points must be forward declared and called by any stand-alone applications +# that use them. By default, the global property +# ``PY_FORWARD_DECL_MODULES_LIST`` is used. +# +# ``MODULE_SUFFIX `` +# Suffix appended to the python extension module file. +# The default suffix is retrieved using ``sysconfig.get_config_var("SO")"``, +# if not available, the default is then ``.so`` on unix and ``.pyd`` on +# windows. +# Setting the variable ``PYTHON_EXTENSION_MODULE_SUFFIX`` in the caller +# scope defines the value used for all extensions not having a suffix +# explicitly specified using ``MODULE_SUFFIX`` parameter. +# +# +# .. cmake:command:: python_standalone_executable +# +# python_standalone_executable() +# +# For standalone executables that initialize their own Python runtime +# (such as when building source files that include one generated by Cython with +# the --embed option). Amend the configuration of the executable target +# (created using ``add_executable``) with additional options needed to properly +# build the referenced executable. +# +# +# .. cmake:command:: python_modules_header +# +# Generate a header file that contains the forward declarations and +# initialization routines for the given list of Python extension modules. +# ```` is the logical name for the header file (no file extensions). +# ```` is the actual destination filename for the header file +# (e.g.: decl_modules.h). +# +# python_modules_header( [HeaderFilename] +# [FORWARD_DECL_MODULES_LIST ] +# [HEADER_OUTPUT_VAR ] +# [INCLUDE_DIR_OUTPUT_VAR ]) +# +# If only ```` is provided, and it ends in the ".h" extension, then it +# is assumed to be the ````. The filename of the header file +# without the extension is used as the logical name. If only ```` is +# provided, and it does not end in the ".h" extension, then the +# ```` is assumed to ``.h``. +# +# The exact contents of the generated header file depend on the logical +# ````. It should be set to a value that corresponds to the target +# application, or for the case of multiple applications, some identifier that +# conveyes its purpose. It is featured in the generated multiple inclusion +# guard as well as the names of the generated initialization routines. +# +# The generated header file includes forward declarations for all listed +# modules, as well as implementations for the following class of routines: +# +# ``int _(void)`` +# Initializes the python extension module, ````. Returns an integer +# handle to the module. +# +# ``void _LoadAllPythonModules(void)`` +# Initializes all listed python extension modules. +# +# ``void CMakeLoadAllPythonModules(void);`` +# Alias for ``_LoadAllPythonModules`` whose name does not depend on +# ````. This function is excluded during preprocessing if the +# preprocessing macro ``EXCLUDE_LOAD_ALL_FUNCTION`` is defined. +# +# ``void Py_Initialize_Wrapper();`` +# Wrapper arpund ``Py_Initialize()`` that initializes all listed python +# extension modules. This function is excluded during preprocessing if the +# preprocessing macro ``EXCLUDE_PY_INIT_WRAPPER`` is defined. If this +# function is generated, then ``Py_Initialize()`` is redefined to a macro +# that calls this function. +# +# Options: +# +# ``FORWARD_DECL_MODULES_LIST `` +# List of extension modules for which to generate forward declarations of +# their entry points and their initializations. By default, the global +# property ``PY_FORWARD_DECL_MODULES_LIST`` is used. +# +# ``HEADER_OUTPUT_VAR `` +# Name of the variable to set to the path to the generated header file. By +# default, ```` is used. +# +# ``INCLUDE_DIR_OUTPUT_VAR `` +# Name of the variable to set to the path to the directory containing the +# generated header file. By default, ``_INCLUDE_DIRS`` is used. +# +# Defined variables: +# +# ```` +# The path to the generated header file +# +# ```` +# Directory containing the generated header file +# +# +# Example usage +# ^^^^^^^^^^^^^ +# +# .. code-block:: cmake +# +# find_package(PythonInterp) +# find_package(PythonLibs) +# find_package(PythonExtensions) +# find_package(Cython) +# find_package(Boost COMPONENTS python) +# +# # Simple Cython Module -- no executables +# add_cython_target(_module.pyx) +# add_library(_module MODULE ${_module}) +# python_extension_module(_module) +# +# # Mix of Cython-generated code and C++ code using Boost Python +# # Stand-alone executable -- no modules +# include_directories(${Boost_INCLUDE_DIRS}) +# add_cython_target(main.pyx CXX EMBED_MAIN) +# add_executable(main boost_python_module.cxx ${main}) +# target_link_libraries(main ${Boost_LIBRARIES}) +# python_standalone_executable(main) +# +# # stand-alone executable with three extension modules: +# # one statically linked, one dynamically linked, and one loaded at runtime +# # +# # Freely mixes Cython-generated code, code using Boost-Python, and +# # hand-written code using the CPython API. +# +# # module1 -- statically linked +# add_cython_target(module1.pyx) +# add_library(module1 STATIC ${module1}) +# python_extension_module(module1 +# LINKED_MODULES_VAR linked_module_list +# FORWARD_DECL_MODULES_VAR fdecl_module_list) +# +# # module2 -- dynamically linked +# include_directories({Boost_INCLUDE_DIRS}) +# add_library(module2 SHARED boost_module2.cxx) +# target_link_libraries(module2 ${Boost_LIBRARIES}) +# python_extension_module(module2 +# LINKED_MODULES_VAR linked_module_list +# FORWARD_DECL_MODULES_VAR fdecl_module_list) +# +# # module3 -- loaded at runtime +# add_cython_target(module3a.pyx) +# add_library(module1 MODULE ${module3a} module3b.cxx) +# target_link_libraries(module3 ${Boost_LIBRARIES}) +# python_extension_module(module3 +# LINKED_MODULES_VAR linked_module_list +# FORWARD_DECL_MODULES_VAR fdecl_module_list) +# +# # application executable -- generated header file + other source files +# python_modules_header(modules +# FORWARD_DECL_MODULES_LIST ${fdecl_module_list}) +# include_directories(${modules_INCLUDE_DIRS}) +# +# add_cython_target(mainA) +# add_cython_target(mainC) +# add_executable(main ${mainA} mainB.cxx ${mainC} mainD.c) +# +# target_link_libraries(main ${linked_module_list} ${Boost_LIBRARIES}) +# python_standalone_executable(main) +# +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +find_package(PythonInterp REQUIRED) +find_package(PythonLibs) +include(targetLinkLibrariesWithDynamicLookup) + +set(_command " +import distutils.sysconfig +import itertools +import os +import os.path +import site +import sys +import sysconfig + +result = None +rel_result = None +candidate_lists = [] + +try: + candidate_lists.append((distutils.sysconfig.get_python_lib(),)) +except AttributeError: pass + +try: + candidate_lists.append(site.getsitepackages()) +except AttributeError: pass + +try: + candidate_lists.append((site.getusersitepackages(),)) +except AttributeError: pass + +candidates = itertools.chain.from_iterable(candidate_lists) + +for candidate in candidates: + rel_candidate = os.path.relpath( + candidate, sys.prefix) + if not rel_candidate.startswith(\"..\"): + result = candidate + rel_result = rel_candidate + break + +sys.stdout.write(\";\".join(( + os.sep, + os.pathsep, + sys.prefix, + result, + rel_result, + sysconfig.get_config_var('SO') +))) +") + +execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "${_command}" + OUTPUT_VARIABLE _list + RESULT_VARIABLE _result) + +list(GET _list 0 _item) +set(PYTHON_SEPARATOR "${_item}") +mark_as_advanced(PYTHON_SEPARATOR) + +list(GET _list 1 _item) +set(PYTHON_PATH_SEPARATOR "${_item}") +mark_as_advanced(PYTHON_PATH_SEPARATOR) + +list(GET _list 2 _item) +set(PYTHON_PREFIX "${_item}") +mark_as_advanced(PYTHON_PREFIX) + +list(GET _list 3 _item) +set(PYTHON_SITE_PACKAGES_DIR "${_item}") +mark_as_advanced(PYTHON_SITE_PACKAGES_DIR) + +list(GET _list 4 _item) +set(PYTHON_RELATIVE_SITE_PACKAGES_DIR "${_item}") +mark_as_advanced(PYTHON_RELATIVE_SITE_PACKAGES_DIR) + +if(NOT DEFINED PYTHON_EXTENSION_MODULE_SUFFIX) + list(GET _list 5 _item) + set(PYTHON_EXTENSION_MODULE_SUFFIX "${_item}") +endif() + +function(_set_python_extension_symbol_visibility _target) + if(PYTHON_VERSION_MAJOR VERSION_GREATER 2) + set(_modinit_prefix "PyInit_") + else() + set(_modinit_prefix "init") + endif() + message("_modinit_prefix:${_modinit_prefix}") + if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") + set_target_properties(${_target} PROPERTIES LINK_FLAGS + "/EXPORT:${_modinit_prefix}${_target}" + ) + elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + set(_script_path + ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${_target}-version-script.map + ) + file(WRITE ${_script_path} + "{global: ${_modinit_prefix}${_target}; local: *; };" + ) + set_property(TARGET ${_target} APPEND_STRING PROPERTY LINK_FLAGS + " -Wl,--version-script=${_script_path}" + ) + endif() +endfunction() + +function(python_extension_module _target) + set(one_ops LINKED_MODULES_VAR FORWARD_DECL_MODULES_VAR MODULE_SUFFIX) + cmake_parse_arguments(_args "" "${one_ops}" "" ${ARGN}) + + set(_lib_type "NA") + if(TARGET ${_target}) + get_property(_lib_type TARGET ${_target} PROPERTY TYPE) + endif() + + set(_is_non_lib TRUE) + + set(_is_static_lib FALSE) + if(_lib_type STREQUAL "STATIC_LIBRARY") + set(_is_static_lib TRUE) + set(_is_non_lib FALSE) + endif() + + set(_is_shared_lib FALSE) + if(_lib_type STREQUAL "SHARED_LIBRARY") + set(_is_shared_lib TRUE) + set(_is_non_lib FALSE) + endif() + + set(_is_module_lib FALSE) + if(_lib_type STREQUAL "MODULE_LIBRARY") + set(_is_module_lib TRUE) + set(_is_non_lib FALSE) + endif() + + if(_is_static_lib OR _is_shared_lib OR _is_non_lib) + + if(_is_static_lib OR _is_shared_lib) + if(_args_LINKED_MODULES_VAR) + set(${_args_LINKED_MODULES_VAR} + ${${_args_LINKED_MODULES_VAR}} ${_target} PARENT_SCOPE) + else() + set_property(GLOBAL APPEND PROPERTY PY_LINKED_MODULES_LIST ${_target}) + endif() + endif() + + if(_args_FORWARD_DECL_MODULES_VAR) + set(${_args_FORWARD_DECL_MODULES_VAR} + ${${_args_FORWARD_DECL_MODULES_VAR}} ${_target} PARENT_SCOPE) + else() + set_property(GLOBAL APPEND PROPERTY + PY_FORWARD_DECL_MODULES_LIST ${_target}) + endif() + endif() + + if(NOT _is_non_lib) + include_directories("${PYTHON_INCLUDE_DIRS}") + endif() + + if(_is_module_lib) + set_target_properties(${_target} PROPERTIES + PREFIX "${PYTHON_MODULE_PREFIX}") + endif() + + if(_is_module_lib OR _is_shared_lib) + if(_is_module_lib) + + if(NOT _args_MODULE_SUFFIX) + set(_args_MODULE_SUFFIX "${PYTHON_EXTENSION_MODULE_SUFFIX}") + endif() + + if(_args_MODULE_SUFFIX STREQUAL "" AND WIN32 AND NOT CYGWIN) + set(_args_MODULE_SUFFIX ".pyd") + endif() + + if(NOT _args_MODULE_SUFFIX STREQUAL "") + set_target_properties(${_target} + PROPERTIES SUFFIX ${_args_MODULE_SUFFIX}) + endif() + endif() + + target_link_libraries_with_dynamic_lookup(${_target} ${PYTHON_LIBRARIES}) + + if(_is_module_lib) + _set_python_extension_symbol_visibility(${_target}) + endif() + endif() +endfunction() + +function(python_standalone_executable _target) + include_directories(${PYTHON_INCLUDE_DIRS}) + target_link_libraries(${_target} ${PYTHON_LIBRARIES}) +endfunction() + +function(python_modules_header _name) + set(one_ops FORWARD_DECL_MODULES_LIST + HEADER_OUTPUT_VAR + INCLUDE_DIR_OUTPUT_VAR) + cmake_parse_arguments(_args "" "${one_ops}" "" ${ARGN}) + + list(GET _args_UNPARSED_ARGUMENTS 0 _arg0) + # if present, use arg0 as the input file path + if(_arg0) + set(_source_file ${_arg0}) + + # otherwise, must determine source file from name, or vice versa + else() + get_filename_component(_name_ext "${_name}" EXT) + + # if extension provided, _name is the source file + if(_name_ext) + set(_source_file ${_name}) + get_filename_component(_name "${_source_file}" NAME_WE) + + # otherwise, assume the source file is ${_name}.h + else() + set(_source_file ${_name}.h) + endif() + endif() + + if(_args_FORWARD_DECL_MODULES_LIST) + set(static_mod_list ${_args_FORWARD_DECL_MODULES_LIST}) + else() + get_property(static_mod_list GLOBAL PROPERTY PY_FORWARD_DECL_MODULES_LIST) + endif() + + string(REPLACE "." "_" _header_name "${_name}") + string(TOUPPER ${_header_name} _header_name_upper) + set(_header_name_upper "_${_header_name_upper}_H") + set(generated_file ${CMAKE_CURRENT_BINARY_DIR}/${_source_file}) + + set(generated_file_tmp "${generated_file}.in") + file(WRITE ${generated_file_tmp} + "/* Created by CMake. DO NOT EDIT; changes will be lost. */\n") + + set(_chunk "") + set(_chunk "${_chunk}#ifndef ${_header_name_upper}\n") + set(_chunk "${_chunk}#define ${_header_name_upper}\n") + set(_chunk "${_chunk}\n") + set(_chunk "${_chunk}#include \n") + set(_chunk "${_chunk}\n") + set(_chunk "${_chunk}#ifdef __cplusplus\n") + set(_chunk "${_chunk}extern \"C\" {\n") + set(_chunk "${_chunk}#endif /* __cplusplus */\n") + set(_chunk "${_chunk}\n") + set(_chunk "${_chunk}#if PY_MAJOR_VERSION < 3\n") + file(APPEND ${generated_file_tmp} "${_chunk}") + + foreach(_module ${static_mod_list}) + file(APPEND ${generated_file_tmp} + "PyMODINIT_FUNC init${PYTHON_MODULE_PREFIX}${_module}(void);\n") + endforeach() + + file(APPEND ${generated_file_tmp} "#else /* PY_MAJOR_VERSION >= 3*/\n") + + foreach(_module ${static_mod_list}) + file(APPEND ${generated_file_tmp} + "PyMODINIT_FUNC PyInit_${PYTHON_MODULE_PREFIX}${_module}(void);\n") + endforeach() + + set(_chunk "") + set(_chunk "${_chunk}#endif /* PY_MAJOR_VERSION >= 3*/\n\n") + set(_chunk "${_chunk}#ifdef __cplusplus\n") + set(_chunk "${_chunk}}\n") + set(_chunk "${_chunk}#endif /* __cplusplus */\n") + set(_chunk "${_chunk}\n") + file(APPEND ${generated_file_tmp} "${_chunk}") + + foreach(_module ${static_mod_list}) + set(_import_function "${_header_name}_${_module}") + set(_prefixed_module "${PYTHON_MODULE_PREFIX}${_module}") + + set(_chunk "") + set(_chunk "${_chunk}int ${_import_function}(void)\n") + set(_chunk "${_chunk}{\n") + set(_chunk "${_chunk} static char name[] = \"${_prefixed_module}\";\n") + set(_chunk "${_chunk} #if PY_MAJOR_VERSION < 3\n") + set(_chunk "${_chunk} return PyImport_AppendInittab(") + set(_chunk "${_chunk}name, init${_prefixed_module});\n") + set(_chunk "${_chunk} #else /* PY_MAJOR_VERSION >= 3 */\n") + set(_chunk "${_chunk} return PyImport_AppendInittab(") + set(_chunk "${_chunk}name, PyInit_${_prefixed_module});\n") + set(_chunk "${_chunk} #endif /* PY_MAJOR_VERSION >= 3 */\n") + set(_chunk "${_chunk}}\n\n") + file(APPEND ${generated_file_tmp} "${_chunk}") + endforeach() + + file(APPEND ${generated_file_tmp} + "void ${_header_name}_LoadAllPythonModules(void)\n{\n") + foreach(_module ${static_mod_list}) + file(APPEND ${generated_file_tmp} " ${_header_name}_${_module}();\n") + endforeach() + file(APPEND ${generated_file_tmp} "}\n\n") + + set(_chunk "") + set(_chunk "${_chunk}#ifndef EXCLUDE_LOAD_ALL_FUNCTION\n") + set(_chunk "${_chunk}void CMakeLoadAllPythonModules(void)\n") + set(_chunk "${_chunk}{\n") + set(_chunk "${_chunk} ${_header_name}_LoadAllPythonModules();\n") + set(_chunk "${_chunk}}\n") + set(_chunk "${_chunk}#endif /* !EXCLUDE_LOAD_ALL_FUNCTION */\n\n") + + set(_chunk "${_chunk}#ifndef EXCLUDE_PY_INIT_WRAPPER\n") + set(_chunk "${_chunk}static void Py_Initialize_Wrapper()\n") + set(_chunk "${_chunk}{\n") + set(_chunk "${_chunk} ${_header_name}_LoadAllPythonModules();\n") + set(_chunk "${_chunk} Py_Initialize();\n") + set(_chunk "${_chunk}}\n") + set(_chunk "${_chunk}#define Py_Initialize Py_Initialize_Wrapper\n") + set(_chunk "${_chunk}#endif /* !EXCLUDE_PY_INIT_WRAPPER */\n\n") + + set(_chunk "${_chunk}#endif /* !${_header_name_upper} */\n") + file(APPEND ${generated_file_tmp} "${_chunk}") + + # with configure_file() cmake complains that you may not use a file created + # using file(WRITE) as input file for configure_file() + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${generated_file_tmp}" "${generated_file}" + OUTPUT_QUIET ERROR_QUIET) + + set(_header_output_var ${_name}) + if(_args_HEADER_OUTPUT_VAR) + set(_header_output_var ${_args_HEADER_OUTPUT_VAR}) + endif() + set(${_header_output_var} ${generated_file} PARENT_SCOPE) + + set(_include_dir_var ${_name}_INCLUDE_DIRS) + if(_args_INCLUDE_DIR_OUTPUT_VAR) + set(_include_dir_var ${_args_INCLUDE_DIR_OUTPUT_VAR}) + endif() + set(${_include_dirs_var} ${CMAKE_CURRENT_BINARY_DIR} PARENT_SCOPE) +endfunction() diff --git a/python/scikit-build-cmake/LICENSE b/python/scikit-build-cmake/LICENSE new file mode 100644 index 000000000..73a9db0f2 --- /dev/null +++ b/python/scikit-build-cmake/LICENSE @@ -0,0 +1,53 @@ +Unless otherwise noted in the file, all files in this directory are +licensed under the MIT license, reproduced below. + +The MIT License (MIT) + +Copyright (c) 2014 Mike Sarahan + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +This project borrows a great deal from the setup tools of the PyNE project. Here is its license: + +Copyright 2011-2014, the PyNE Development Team. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are +permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, this list of + conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright notice, this list + of conditions and the following disclaimer in the documentation and/or other materials + provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE PYNE DEVELOPMENT TEAM ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +The views and conclusions contained in the software and documentation are those of the +authors and should not be interpreted as representing official policies, either expressed +or implied, of the stakeholders of the PyNE project or the employers of PyNE developers. diff --git a/python/scikit-build-cmake/UseCython.cmake b/python/scikit-build-cmake/UseCython.cmake new file mode 100644 index 000000000..f1bdbb709 --- /dev/null +++ b/python/scikit-build-cmake/UseCython.cmake @@ -0,0 +1,395 @@ +#.rst: +# +# The following functions are defined: +# +# .. cmake:command:: add_cython_target +# +# Create a custom rule to generate the source code for a Python extension module +# using cython. +# +# add_cython_target( [] +# [EMBED_MAIN] +# [C | CXX] +# [PY2 | PY3] +# [OUTPUT_VAR ]) +# +# ```` is the name of the new target, and ```` +# is the path to a cython source file. Note that, despite the name, no new +# targets are created by this function. Instead, see ``OUTPUT_VAR`` for +# retrieving the path to the generated source for subsequent targets. +# +# If only ```` is provided, and it ends in the ".pyx" extension, then it +# is assumed to be the ````. The name of the input without the +# extension is used as the target name. If only ```` is provided, and it +# does not end in the ".pyx" extension, then the ```` is assumed to +# be ``.pyx``. +# +# The Cython include search path is amended with any entries found in the +# ``INCLUDE_DIRECTORIES`` property of the directory containing the +# ```` file. Use ``include_directories`` to add to the Cython +# include search path. +# +# Options: +# +# ``EMBED_MAIN`` +# Embed a main() function in the generated output (for stand-alone +# applications that initialize their own Python runtime). +# +# ``C | CXX`` +# Force the generation of either a C or C++ file. By default, a C file is +# generated, unless the C language is not enabled for the project; in this +# case, a C++ file is generated by default. +# +# ``PY2 | PY3`` +# Force compilation using either Python-2 or Python-3 syntax and code +# semantics. By default, Python-2 syntax and semantics are used if the major +# version of Python found is 2. Otherwise, Python-3 syntax and sematics are +# used. +# +# ``OUTPUT_VAR `` +# Set the variable ```` in the parent scope to the path to the +# generated source file. By default, ```` is used as the output +# variable name. +# +# Defined variables: +# +# ```` +# The path of the generated source file. +# +# Cache variables that effect the behavior include: +# +# ``CYTHON_ANNOTATE`` +# whether to create an annotated .html file when compiling +# +# ``CYTHON_FLAGS`` +# additional flags to pass to the Cython compiler +# +# Example usage +# ^^^^^^^^^^^^^ +# +# .. code-block:: cmake +# +# find_package(Cython) +# +# # Note: In this case, either one of these arguments may be omitted; their +# # value would have been inferred from that of the other. +# add_cython_target(cy_code cy_code.pyx) +# +# add_library(cy_code MODULE ${cy_code}) +# target_link_libraries(cy_code ...) +# +#============================================================================= +# Copyright 2011 Kitware, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#============================================================================= + +# Configuration options. +set(CYTHON_ANNOTATE OFF + CACHE BOOL "Create an annotated .html file when compiling *.pyx.") + +set(CYTHON_FLAGS "" CACHE STRING + "Extra flags to the cython compiler.") +mark_as_advanced(CYTHON_ANNOTATE CYTHON_FLAGS) +string(REGEX REPLACE " " ";" CYTHON_FLAGS_LIST "${CYTHON_FLAGS}") + +find_package(PythonLibs REQUIRED) + +set(CYTHON_CXX_EXTENSION "cxx") +set(CYTHON_C_EXTENSION "c") + +get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES) + +function(add_cython_target _name) + set(options EMBED_MAIN C CXX PY2 PY3) + set(options1 OUTPUT_VAR) + cmake_parse_arguments(_args "${options}" "${options1}" "" ${ARGN}) + + list(GET _args_UNPARSED_ARGUMENTS 0 _arg0) + + # if provided, use _arg0 as the input file path + if(_arg0) + set(_source_file ${_arg0}) + + # otherwise, must determine source file from name, or vice versa + else() + get_filename_component(_name_ext "${_name}" EXT) + + # if extension provided, _name is the source file + if(_name_ext) + set(_source_file ${_name}) + get_filename_component(_name "${_source_file}" NAME_WE) + + # otherwise, assume the source file is ${_name}.pyx + else() + set(_source_file ${_name}.pyx) + endif() + endif() + + set(_embed_main FALSE) + + if("C" IN_LIST languages) + set(_output_syntax "C") + elseif("CXX" IN_LIST languages) + set(_output_syntax "CXX") + else() + message(FATAL_ERROR "Either C or CXX must be enabled to use Cython") + endif() + + if("${PYTHONLIBS_VERSION_STRING}" MATCHES "^2.") + set(_input_syntax "PY2") + else() + set(_input_syntax "PY3") + endif() + + if(_args_EMBED_MAIN) + set(_embed_main TRUE) + endif() + + if(_args_C) + set(_output_syntax "C") + endif() + + if(_args_CXX) + set(_output_syntax "CXX") + endif() + + if(_args_PY2) + set(_input_syntax "PY2") + endif() + + if(_args_PY3) + set(_input_syntax "PY3") + endif() + + set(embed_arg "") + if(_embed_main) + set(embed_arg "--embed") + endif() + + set(cxx_arg "") + set(extension "c") + if(_output_syntax STREQUAL "CXX") + set(cxx_arg "--cplus") + set(extension "cxx") + endif() + + set(py_version_arg "") + if(_input_syntax STREQUAL "PY2") + set(py_version_arg "-2") + elseif(_input_syntax STREQUAL "PY3") + set(py_version_arg "-3") + endif() + + set(generated_file "${CMAKE_CURRENT_BINARY_DIR}/${_name}.${extension}") + set_source_files_properties(${generated_file} PROPERTIES GENERATED TRUE) + + set(_output_var ${_name}) + if(_args_OUTPUT_VAR) + set(_output_var ${_args_OUTPUT_VAR}) + endif() + set(${_output_var} ${generated_file} PARENT_SCOPE) + + file(RELATIVE_PATH generated_file_relative + ${CMAKE_BINARY_DIR} ${generated_file}) + + set(comment "Generating ${_output_syntax} source ${generated_file_relative}") + set(cython_include_directories "") + set(pxd_dependencies "") + set(c_header_dependencies "") + + # Get the include directories. + get_source_file_property(pyx_location ${_source_file} LOCATION) + get_filename_component(pyx_path ${pyx_location} PATH) + get_directory_property(cmake_include_directories + DIRECTORY ${pyx_path} + INCLUDE_DIRECTORIES) + list(APPEND cython_include_directories ${cmake_include_directories}) + + # Determine dependencies. + # Add the pxd file with the same basename as the given pyx file. + get_filename_component(pyx_file_basename ${_source_file} NAME_WE) + unset(corresponding_pxd_file CACHE) + find_file(corresponding_pxd_file ${pyx_file_basename}.pxd + PATHS "${pyx_path}" ${cmake_include_directories} + NO_DEFAULT_PATH) + if(corresponding_pxd_file) + list(APPEND pxd_dependencies "${corresponding_pxd_file}") + endif() + + # pxd files to check for additional dependencies + set(pxds_to_check "${_source_file}" "${pxd_dependencies}") + set(pxds_checked "") + set(number_pxds_to_check 1) + while(number_pxds_to_check GREATER 0) + foreach(pxd ${pxds_to_check}) + list(APPEND pxds_checked "${pxd}") + list(REMOVE_ITEM pxds_to_check "${pxd}") + + # look for C headers + file(STRINGS "${pxd}" extern_from_statements + REGEX "cdef[ ]+extern[ ]+from.*$") + foreach(statement ${extern_from_statements}) + # Had trouble getting the quote in the regex + string(REGEX REPLACE + "cdef[ ]+extern[ ]+from[ ]+[\"]([^\"]+)[\"].*" "\\1" + header "${statement}") + unset(header_location CACHE) + find_file(header_location ${header} PATHS ${cmake_include_directories}) + if(header_location) + list(FIND c_header_dependencies "${header_location}" header_idx) + if(${header_idx} LESS 0) + list(APPEND c_header_dependencies "${header_location}") + endif() + endif() + endforeach() + + # check for pxd dependencies + # Look for cimport statements. + set(module_dependencies "") + file(STRINGS "${pxd}" cimport_statements REGEX cimport) + foreach(statement ${cimport_statements}) + if(${statement} MATCHES from) + string(REGEX REPLACE + "from[ ]+([^ ]+).*" "\\1" + module "${statement}") + else() + string(REGEX REPLACE + "cimport[ ]+([^ ]+).*" "\\1" + module "${statement}") + endif() + list(APPEND module_dependencies ${module}) + endforeach() + + # check for pxi dependencies + # Look for include statements. + set(include_dependencies "") + file(STRINGS "${pxd}" include_statements REGEX include) + foreach(statement ${include_statements}) + string(REGEX REPLACE + "include[ ]+[\"]([^\"]+)[\"].*" "\\1" + module "${statement}") + list(APPEND include_dependencies ${module}) + endforeach() + + list(REMOVE_DUPLICATES module_dependencies) + list(REMOVE_DUPLICATES include_dependencies) + + # Add modules to the files to check, if appropriate. + foreach(module ${module_dependencies}) + unset(pxd_location CACHE) + find_file(pxd_location ${module}.pxd + PATHS "${pyx_path}" ${cmake_include_directories} + NO_DEFAULT_PATH) + if(pxd_location) + list(FIND pxds_checked ${pxd_location} pxd_idx) + if(${pxd_idx} LESS 0) + list(FIND pxds_to_check ${pxd_location} pxd_idx) + if(${pxd_idx} LESS 0) + list(APPEND pxds_to_check ${pxd_location}) + list(APPEND pxd_dependencies ${pxd_location}) + endif() # if it is not already going to be checked + endif() # if it has not already been checked + endif() # if pxd file can be found + endforeach() # for each module dependency discovered + + # Add includes to the files to check, if appropriate. + foreach(_include ${include_dependencies}) + unset(pxi_location CACHE) + find_file(pxi_location ${_include} + PATHS "${pyx_path}" ${cmake_include_directories} + NO_DEFAULT_PATH) + if(pxi_location) + list(FIND pxds_checked ${pxi_location} pxd_idx) + if(${pxd_idx} LESS 0) + list(FIND pxds_to_check ${pxi_location} pxd_idx) + if(${pxd_idx} LESS 0) + list(APPEND pxds_to_check ${pxi_location}) + list(APPEND pxd_dependencies ${pxi_location}) + endif() # if it is not already going to be checked + endif() # if it has not already been checked + endif() # if include file can be found + endforeach() # for each include dependency discovered + endforeach() # for each include file to check + + list(LENGTH pxds_to_check number_pxds_to_check) + endwhile() + + # Set additional flags. + set(annotate_arg "") + if(CYTHON_ANNOTATE) + set(annotate_arg "--annotate") + endif() + + set(no_docstrings_arg "") + if(CMAKE_BUILD_TYPE STREQUAL "Release" OR + CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + set(no_docstrings_arg "--no-docstrings") + endif() + + set(cython_debug_arg "") + set(embed_pos_arg "") + set(line_directives_arg "") + if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR + CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") + set(cython_debug_arg "--gdb") + set(embed_pos_arg "--embed-positions") + set(line_directives_arg "--line-directives") + endif() + + # Include directory arguments. + list(REMOVE_DUPLICATES cython_include_directories) + set(include_directory_arg "") + foreach(_include_dir ${cython_include_directories}) + set(include_directory_arg + ${include_directory_arg} "--include-dir" "${_include_dir}") + endforeach() + + list(REMOVE_DUPLICATES pxd_dependencies) + list(REMOVE_DUPLICATES c_header_dependencies) + + # Add the command to run the compiler. + add_custom_command(OUTPUT ${generated_file} + COMMAND ${CYTHON_EXECUTABLE} + ARGS ${cxx_arg} ${include_directory_arg} ${py_version_arg} + ${embed_arg} ${annotate_arg} ${no_docstrings_arg} + ${cython_debug_arg} ${embed_pos_arg} + ${line_directives_arg} ${CYTHON_FLAGS_LIST} ${pyx_location} + --output-file ${generated_file} + DEPENDS ${_source_file} + ${pxd_dependencies} + IMPLICIT_DEPENDS ${_output_syntax} + ${c_header_dependencies} + COMMENT ${comment}) + + # NOTE(opadron): I thought about making a proper target, but after trying it + # out, I decided that it would be far too convenient to use the same name as + # the target for the extension module (e.g.: for single-file modules): + # + # ... + # add_cython_target(_module.pyx) + # add_library(_module ${_module}) + # ... + # + # The above example would not be possible since the "_module" target name + # would already be taken by the cython target. Since I can't think of a + # reason why someone would need the custom target instead of just using the + # generated file directly, I decided to leave this commented out. + # + # add_custom_target(${_name} DEPENDS ${generated_file}) + + # Remove their visibility to the user. + set(corresponding_pxd_file "" CACHE INTERNAL "") + set(header_location "" CACHE INTERNAL "") + set(pxd_location "" CACHE INTERNAL "") +endfunction() diff --git a/python/scikit-build-cmake/targetLinkLibrariesWithDynamicLookup.cmake b/python/scikit-build-cmake/targetLinkLibrariesWithDynamicLookup.cmake new file mode 100644 index 000000000..020fc404a --- /dev/null +++ b/python/scikit-build-cmake/targetLinkLibrariesWithDynamicLookup.cmake @@ -0,0 +1,581 @@ +#.rst: +# +# Public Functions +# ^^^^^^^^^^^^^^^^ +# +# The following functions are defined: +# +# .. cmake:command:: target_link_libraries_with_dynamic_lookup +# +# :: +# +# target_link_libraries_with_dynamic_lookup( []) +# +# +# Useful to "weakly" link a loadable module. For example, it should be used +# when compiling a loadable module when the symbols should be resolve from +# the run-time environment where the module is loaded, and not a specific +# system library. +# +# Like proper linking, except that the given ```` are not necessarily +# linked. Instead, the ```` is produced in a manner that allows for +# symbols unresolved within it to be resolved at runtime, presumably by the +# given ````. If such a target can be produced, the provided +# ```` are not actually linked. +# +# It links a library to a target such that the symbols are resolved at +# run-time not link-time. +# +# The linker is checked to see if it supports undefined +# symbols when linking a shared library. If it does then the library +# is not linked when specified with this function. +# +# On platforms that do not support weak-linking, this function works just +# like ``target_link_libraries``. +# +# .. note:: +# +# For OSX it uses ``undefined dynamic_lookup``. This is similar to using +# ``-shared`` on Linux where undefined symbols are ignored. +# +# For more details, see `blog `_ +# from Tim D. Smith. +# +# +# .. cmake:command:: check_dynamic_lookup +# +# Check if the linker requires a command line flag to allow leaving symbols +# unresolved when producing a target of type ```` that is +# weakly-linked against a dependency of type ````. +# +# ```` +# can be one of "STATIC", "SHARED", "MODULE", or "EXE". +# +# ```` +# can be one of "STATIC", "SHARED", or "MODULE". +# +# Long signature: +# +# :: +# +# check_dynamic_lookup( +# +# +# []) +# +# +# Short signature: +# +# :: +# +# check_dynamic_lookup() # set to "MODULE" +# # set to "SHARED" +# +# +# The result is cached between invocations and recomputed only when the value +# of CMake's linker flag list changes; ``CMAKE_STATIC_LINKER_FLAGS`` if +# ```` is "STATIC", and ``CMAKE_SHARED_LINKER_FLAGS`` otherwise. +# +# +# Defined variables: +# +# ```` +# Whether the current C toolchain supports weak-linking for target binaries of +# type ```` that are weakly-linked against a dependency target of +# type ````. +# +# ```` +# List of flags to add to the linker command to produce a working target +# binary of type ```` that is weakly-linked against a dependency +# target of type ````. +# +# ``HAS_DYNAMIC_LOOKUP__`` +# Cached, global alias for ```` +# +# ``DYNAMIC_LOOKUP_FLAGS__`` +# Cached, global alias for ```` +# +# +# Private Functions +# ^^^^^^^^^^^^^^^^^ +# +# The following private functions are defined: +# +# .. warning:: These functions are not part of the scikit-build API. They +# exist purely as an implementation detail and may change from version +# to version without notice, or even be removed. +# +# We mean it. +# +# +# .. cmake:command:: _get_target_type +# +# :: +# +# _get_target_type( ) +# +# +# Shorthand for querying an abbreviated version of the target type +# of the given ````. +# +# ```` is set to: +# +# - "STATIC" for a STATIC_LIBRARY, +# - "SHARED" for a SHARED_LIBRARY, +# - "MODULE" for a MODULE_LIBRARY, +# - and "EXE" for an EXECUTABLE. +# +# Defined variables: +# +# ```` +# The abbreviated version of the ````'s type. +# +# +# .. cmake:command:: _test_weak_link_project +# +# :: +# +# _test_weak_link_project( +# +# +# ) +# +# +# Attempt to compile and run a test project where a target of type +# ```` is weakly-linked against a dependency of type ````: +# +# - ```` can be one of "STATIC", "SHARED", "MODULE", or "EXE". +# - ```` can be one of "STATIC", "SHARED", or "MODULE". +# +# Defined variables: +# +# ```` +# Whether the current C toolchain can produce a working target binary of type +# ```` that is weakly-linked against a dependency target of type +# ````. +# +# ```` +# List of flags to add to the linker command to produce a working target +# binary of type ```` that is weakly-linked against a dependency +# target of type ````. +# + +function(_get_target_type result_var target) + set(target_type "SHARED_LIBRARY") + if(TARGET ${target}) + get_property(target_type TARGET ${target} PROPERTY TYPE) + endif() + + set(result "STATIC") + + if(target_type STREQUAL "STATIC_LIBRARY") + set(result "STATIC") + endif() + + if(target_type STREQUAL "SHARED_LIBRARY") + set(result "SHARED") + endif() + + if(target_type STREQUAL "MODULE_LIBRARY") + set(result "MODULE") + endif() + + if(target_type STREQUAL "EXECUTABLE") + set(result "EXE") + endif() + + set(${result_var} ${result} PARENT_SCOPE) +endfunction() + + +function(_test_weak_link_project + target_type + lib_type + can_weak_link_var + project_name) + + set(gnu_ld_ignore "-Wl,--unresolved-symbols=ignore-all") + set(osx_dynamic_lookup "-undefined dynamic_lookup") + set(no_flag "") + + foreach(link_flag_spec gnu_ld_ignore osx_dynamic_lookup no_flag) + set(link_flag "${${link_flag_spec}}") + + set(test_project_dir "${PROJECT_BINARY_DIR}/CMakeTmp") + set(test_project_dir "${test_project_dir}/${project_name}") + set(test_project_dir "${test_project_dir}/${link_flag_spec}") + set(test_project_dir "${test_project_dir}/${target_type}") + set(test_project_dir "${test_project_dir}/${lib_type}") + + set(test_project_src_dir "${test_project_dir}/src") + set(test_project_bin_dir "${test_project_dir}/build") + + file(MAKE_DIRECTORY ${test_project_src_dir}) + file(MAKE_DIRECTORY ${test_project_bin_dir}) + + set(mod_type "STATIC") + set(link_mod_lib TRUE) + set(link_exe_lib TRUE) + set(link_exe_mod FALSE) + + if("${target_type}" STREQUAL "EXE") + set(link_exe_lib FALSE) + set(link_exe_mod TRUE) + else() + set(mod_type "${target_type}") + endif() + + if("${mod_type}" STREQUAL "MODULE") + set(link_mod_lib FALSE) + endif() + + + file(WRITE "${test_project_src_dir}/CMakeLists.txt" " + cmake_minimum_required(VERSION ${CMAKE_VERSION}) + project(${project_name} C) + + include_directories(${test_project_src_dir}) + + add_library(number ${lib_type} number.c) + add_library(counter ${mod_type} counter.c) + ") + + if("${mod_type}" STREQUAL "MODULE") + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + set_target_properties(counter PROPERTIES PREFIX \"\") + ") + endif() + + if(link_mod_lib) + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + target_link_libraries(counter number) + ") + elseif(NOT link_flag STREQUAL "") + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + set_target_properties(counter PROPERTIES LINK_FLAGS \"${link_flag}\") + ") + endif() + + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + add_executable(main main.c) + ") + + if(link_exe_lib) + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + target_link_libraries(main number) + ") + elseif(NOT link_flag STREQUAL "") + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + target_link_libraries(main \"${link_flag}\") + ") + endif() + + if(link_exe_mod) + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + target_link_libraries(main counter) + ") + else() + file(APPEND "${test_project_src_dir}/CMakeLists.txt" " + target_link_libraries(main \"${CMAKE_DL_LIBS}\") + ") + endif() + + file(WRITE "${test_project_src_dir}/number.c" " + #include + + static int _number; + void set_number(int number) { _number = number; } + int get_number() { return _number; } + ") + + file(WRITE "${test_project_src_dir}/number.h" " + #ifndef _NUMBER_H + #define _NUMBER_H + extern void set_number(int); + extern int get_number(void); + #endif + ") + + file(WRITE "${test_project_src_dir}/counter.c" " + #include + int count() { + int result = get_number(); + set_number(result + 1); + return result; + } + ") + + file(WRITE "${test_project_src_dir}/counter.h" " + #ifndef _COUNTER_H + #define _COUNTER_H + extern int count(void); + #endif + ") + + file(WRITE "${test_project_src_dir}/main.c" " + #include + #include + #include + ") + + if(NOT link_exe_mod) + file(APPEND "${test_project_src_dir}/main.c" " + #include + ") + endif() + + file(APPEND "${test_project_src_dir}/main.c" " + int my_count() { + int result = get_number(); + set_number(result + 1); + return result; + } + + int main(int argc, char **argv) { + int result; + ") + + if(NOT link_exe_mod) + file(APPEND "${test_project_src_dir}/main.c" " + void *counter_module; + int (*count)(void); + + counter_module = dlopen(\"./counter.so\", RTLD_LAZY | RTLD_GLOBAL); + if(!counter_module) goto error; + + count = dlsym(counter_module, \"count\"); + if(!count) goto error; + ") + endif() + + file(APPEND "${test_project_src_dir}/main.c" " + result = count() != 0 ? EXIT_FAILURE : + my_count() != 1 ? EXIT_FAILURE : + my_count() != 2 ? EXIT_FAILURE : + count() != 3 ? EXIT_FAILURE : + count() != 4 ? EXIT_FAILURE : + count() != 5 ? EXIT_FAILURE : + my_count() != 6 ? EXIT_FAILURE : EXIT_SUCCESS; + ") + + if(NOT link_exe_mod) + file(APPEND "${test_project_src_dir}/main.c" " + goto done; + error: + fprintf(stderr, \"Error occured:\\n %s\\n\", dlerror()); + result = 1; + + done: + if(counter_module) dlclose(counter_module); + ") + endif() + + file(APPEND "${test_project_src_dir}/main.c" " + return result; + } + ") + + set(_rpath_arg) + if(APPLE AND ${CMAKE_VERSION} VERSION_GREATER 2.8.11) + set(_rpath_arg "-DCMAKE_MACOSX_RPATH='${CMAKE_MACOSX_RPATH}'") + endif() + + try_compile(project_compiles + "${test_project_bin_dir}" + "${test_project_src_dir}" + "${project_name}" + CMAKE_FLAGS + "-DCMAKE_SHARED_LINKER_FLAGS='${CMAKE_SHARED_LINKER_FLAGS}'" + "-DCMAKE_ENABLE_EXPORTS=ON" + ${_rpath_arg} + OUTPUT_VARIABLE compile_output) + + set(project_works 1) + set(run_output) + + if(project_compiles) + execute_process(COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} + "${test_project_bin_dir}/main" + WORKING_DIRECTORY "${test_project_bin_dir}" + RESULT_VARIABLE project_works + OUTPUT_VARIABLE run_output + ERROR_VARIABLE run_output) + endif() + + set(test_description + "Weak Link ${target_type} -> ${lib_type} (${link_flag_spec})") + + if(project_works EQUAL 0) + set(project_works TRUE) + message(STATUS "Performing Test ${test_description} - Success") + else() + set(project_works FALSE) + message(STATUS "Performing Test ${test_description} - Failed") + file(APPEND ${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Test ${test_description} failed with the " + "following output:\n" + "BUILD\n-----\n${compile_output}\nRUN\n---\n${run_output}\n") + endif() + + set(${can_weak_link_var} ${project_works} PARENT_SCOPE) + if(project_works) + set(${project_name} ${link_flag} PARENT_SCOPE) + break() + endif() + endforeach() +endfunction() + +function(check_dynamic_lookup) + # Two signatures are supported: + + if(ARGC EQUAL "1") + # + # check_dynamic_lookup() + # + set(target_type "MODULE") + set(lib_type "SHARED") + set(has_dynamic_lookup_var "${ARGV0}") + set(link_flags_var "unused") + + elseif(ARGC GREATER "2") + # + # check_dynamic_lookup( + # + # + # []) + # + set(target_type "${ARGV0}") + set(lib_type "${ARGV1}") + set(has_dynamic_lookup_var "${ARGV2}") + if(ARGC EQUAL "3") + set(link_flags_var "unused") + else() + set(link_flags_var "${ARGV3}") + endif() + else() + message(FATAL_ERROR "missing arguments") + endif() + + _check_dynamic_lookup( + ${target_type} + ${lib_type} + ${has_dynamic_lookup_var} + ${link_flags_var} + ) + set(${has_dynamic_lookup_var} ${${has_dynamic_lookup_var}} PARENT_SCOPE) + if(NOT "x${link_flags_var}x" STREQUAL "xunusedx") + set(${link_flags_var} ${${link_flags_var}} PARENT_SCOPE) + endif() +endfunction() + +function(_check_dynamic_lookup + target_type + lib_type + has_dynamic_lookup_var + link_flags_var + ) + + # hash the CMAKE_FLAGS passed and check cache to know if we need to rerun + if("${target_type}" STREQUAL "STATIC") + string(MD5 cmake_flags_hash "${CMAKE_STATIC_LINKER_FLAGS}") + else() + string(MD5 cmake_flags_hash "${CMAKE_SHARED_LINKER_FLAGS}") + endif() + + set(cache_var "HAS_DYNAMIC_LOOKUP_${target_type}_${lib_type}") + set(cache_hash_var "HAS_DYNAMIC_LOOKUP_${target_type}_${lib_type}_hash") + set(result_var "DYNAMIC_LOOKUP_FLAGS_${target_type}_${lib_type}") + + if( NOT DEFINED ${cache_hash_var} + OR NOT "${${cache_hash_var}}" STREQUAL "${cmake_flags_hash}") + unset(${cache_var} CACHE) + endif() + + if(NOT DEFINED ${cache_var}) + set(skip_test FALSE) + + if(CMAKE_CROSSCOMPILING AND NOT CMAKE_CROSSCOMPILING_EMULATOR) + set(skip_test TRUE) + endif() + + if(skip_test) + set(has_dynamic_lookup FALSE) + set(link_flags) + else() + _test_weak_link_project(${target_type} + ${lib_type} + has_dynamic_lookup + link_flags) + endif() + + set(caveat " (when linking ${target_type} against ${lib_type})") + + set(${cache_var} "${has_dynamic_lookup}" + CACHE BOOL + "linker supports dynamic lookup for undefined symbols${caveat}") + mark_as_advanced(${cache_var}) + + set(${result_var} "${link_flags}" + CACHE STRING + "linker flags for dynamic lookup${caveat}") + mark_as_advanced(${result_var}) + + set(${cache_hash_var} "${cmake_flags_hash}" + CACHE INTERNAL "hashed flags for ${cache_var} check") + endif() + + set(${has_dynamic_lookup_var} "${${cache_var}}" PARENT_SCOPE) + set(${link_flags_var} "${${result_var}}" PARENT_SCOPE) +endfunction() + +function(target_link_libraries_with_dynamic_lookup target) + _get_target_type(target_type ${target}) + + set(link_props) + set(link_items) + set(link_libs) + + foreach(lib ${ARGN}) + _get_target_type(lib_type ${lib}) + check_dynamic_lookup(${target_type} + ${lib_type} + has_dynamic_lookup + dynamic_lookup_flags) + + if(has_dynamic_lookup) + if(dynamic_lookup_flags) + if("${target_type}" STREQUAL "EXE") + list(APPEND link_items "${dynamic_lookup_flags}") + else() + list(APPEND link_props "${dynamic_lookup_flags}") + endif() + endif() + elseif(${lib} MATCHES "(debug|optimized|general)") + # See gh-255 + else() + list(APPEND link_libs "${lib}") + endif() + endforeach() + + if(link_props) + list(REMOVE_DUPLICATES link_props) + endif() + + if(link_items) + list(REMOVE_DUPLICATES link_items) + endif() + + if(link_libs) + list(REMOVE_DUPLICATES link_libs) + endif() + + if(link_props) + set_target_properties(${target} + PROPERTIES LINK_FLAGS "${link_props}") + endif() + + set(links "${link_items}" "${link_libs}") + if(links) + target_link_libraries(${target} "${links}") + endif() +endfunction() From ca5097b7131b6c34b7e88051844baf88398f8d95 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 10 Dec 2018 13:37:47 -0800 Subject: [PATCH 100/194] python: add initial python bindings with minimal numpy support --- CMakeLists.txt | 5 + python/CMakeLists.txt | 26 ++ .../FindPythonExtensions.cmake | 2 +- python/scikit-build-cmake/UseCython.cmake | 8 - python/zfp.pyx | 224 ++++++++++++++++++ 5 files changed, 256 insertions(+), 9 deletions(-) create mode 100644 python/CMakeLists.txt create mode 100644 python/zfp.pyx diff --git a/CMakeLists.txt b/CMakeLists.txt index 91afca8be..69f4649cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -227,6 +227,11 @@ if(BUILD_UTILITIES) add_subdirectory(utils) endif() +option(BUILD_PYTHON "Build python bindings for zfp" OFF) +if(BUILD_PYTHON) + add_subdirectory(python) +endif() + option(BUILD_EXAMPLES "Build Examples" OFF) if(BUILD_EXAMPLES) add_subdirectory(examples) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt new file mode 100644 index 000000000..a2a80081e --- /dev/null +++ b/python/CMakeLists.txt @@ -0,0 +1,26 @@ +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/scikit-build-cmake) +include(UseCython) +include(FindPythonExtensions) + + +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) +find_package(PythonExtensions REQUIRED) +find_package(Cython REQUIRED) + +include_directories(${ZFP_SOURCE_DIR}/include) + +# cannot reuse the zfp target, use _zfp instead +add_cython_target(_zfp zfp.pyx C PY2) +add_library(_zfp MODULE ${_zfp}) +target_link_libraries(_zfp zfp) +python_extension_module(_zfp) + +# Build to the currrent binary dir to avoid conflicts with other libraries named zfp +set(pylib_build_dir "${CMAKE_CURRENT_BINARY_DIR}/lib") +set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${pylib_build_dir}) +# Make sure the final library is called zfp (rather than _zfp) +set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) +# Install to the typical python module directory +set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") +install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) diff --git a/python/scikit-build-cmake/FindPythonExtensions.cmake b/python/scikit-build-cmake/FindPythonExtensions.cmake index e25c8bfeb..9a3d76a0c 100644 --- a/python/scikit-build-cmake/FindPythonExtensions.cmake +++ b/python/scikit-build-cmake/FindPythonExtensions.cmake @@ -423,7 +423,7 @@ function(python_extension_module _target) target_link_libraries_with_dynamic_lookup(${_target} ${PYTHON_LIBRARIES}) if(_is_module_lib) - _set_python_extension_symbol_visibility(${_target}) + #_set_python_extension_symbol_visibility(${_altname}) endif() endif() endfunction() diff --git a/python/scikit-build-cmake/UseCython.cmake b/python/scikit-build-cmake/UseCython.cmake index f1bdbb709..809554e11 100644 --- a/python/scikit-build-cmake/UseCython.cmake +++ b/python/scikit-build-cmake/UseCython.cmake @@ -138,14 +138,6 @@ function(add_cython_target _name) set(_embed_main FALSE) - if("C" IN_LIST languages) - set(_output_syntax "C") - elseif("CXX" IN_LIST languages) - set(_output_syntax "CXX") - else() - message(FATAL_ERROR "Either C or CXX must be enabled to use Cython") - endif() - if("${PYTHONLIBS_VERSION_STRING}" MATCHES "^2.") set(_input_syntax "PY2") else() diff --git a/python/zfp.pyx b/python/zfp.pyx new file mode 100644 index 000000000..3b2dd445b --- /dev/null +++ b/python/zfp.pyx @@ -0,0 +1,224 @@ +import cython +from libc.stdlib cimport malloc, free +import operator +import functools +from cython cimport view +from cpython cimport array +import array + +import numpy as np +cimport numpy as np + +cdef extern from "bitstream.h": + cdef struct bitstream: + pass + bitstream* stream_open(void* data, size_t bytes); + void stream_close(bitstream* stream); + +cdef extern from "zfp.h": + # enums + ctypedef enum zfp_type: + zfp_type_none = 0, + zfp_type_int32 = 1, + zfp_type_int64 = 2, + zfp_type_float = 3, + zfp_type_double = 4 + + # structs + ctypedef struct zfp_field: + zfp_type type + cython.uint nx, ny, nz, nw + int sx, sy, sz, sw + void* data + ctypedef struct zfp_stream: + pass + + # include #define's + cython.uint ZFP_HEADER_MAGIC + cython.uint ZFP_HEADER_META + cython.uint ZFP_HEADER_MODE + cython.uint ZFP_HEADER_FULL + + # function definitions + zfp_stream* zfp_stream_open(bitstream* stream); + void zfp_stream_close(zfp_stream* stream); + size_t zfp_stream_maximum_size(const zfp_stream* stream, const zfp_field* field); + void zfp_stream_set_bit_stream(zfp_stream* stream, bitstream* bs); + cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); + double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); + zfp_field* zfp_field_alloc(); + zfp_field* zfp_field_1d(void* pointer, zfp_type type, cython.uint nx); + zfp_field* zfp_field_2d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny); + zfp_field* zfp_field_3d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny, cython.uint nz); + zfp_field* zfp_field_4d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); + void zfp_field_free(zfp_field* field); + size_t zfp_compress(zfp_stream* stream, const zfp_field* field); + size_t zfp_decompress(zfp_stream* stream, zfp_field* field); + size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, cython.uint mask); + size_t zfp_read_header(zfp_stream* stream, zfp_field* field, cython.uint mask); + void zfp_stream_rewind(zfp_stream* stream); + void zfp_field_set_pointer(zfp_field* field, void* pointer); + +# export #define's +HEADER_MAGIC = ZFP_HEADER_MAGIC +HEADER_META = ZFP_HEADER_META +HEADER_MODE = ZFP_HEADER_MODE +HEADER_FULL = ZFP_HEADER_FULL + +cpdef dtype_to_ztype(dtype): + if dtype == np.int32: + return zfp_type_int32 + elif dtype == np.int64: + return zfp_type_int64 + elif dtype == np.float32: + return zfp_type_float + elif dtype == np.float64: + return zfp_type_double + else: + raise TypeError("Unknown dtype: {}".format(dtype)) + +cpdef dtype_to_format(dtype): + # format characters detailed here: + # https://docs.python.org/2/library/array.html#module-array + if dtype == np.int32: + return 'i' # signed int + elif dtype == np.int64: + return 'l' # signed long + elif dtype == np.float32: + return 'f' # float + elif dtype == np.float64: + return 'd' # double + else: + raise TypeError("Unknown dtype: {}".format(dtype)) + +zfp_to_dtype_map = { + zfp_type_int32: np.int32, + zfp_type_int64: np.int64, + zfp_type_float: np.float32, + zfp_type_double: np.float64, +} +cpdef ztype_to_dtype(zfp_type ztype): + try: + return zfp_to_dtype_map[ztype] + except KeyError: + # TODO: is this the correct type? + print "Using np.bytes_" + return np.bytes_ + +cdef size_t sizeof_ztype(zfp_type ztype): + if ztype == zfp_type_int32: + return sizeof(signed int) + elif ztype == zfp_type_int64: + return sizeof(signed long long) + elif ztype == zfp_type_float: + return sizeof(float) + elif ztype == zfp_type_double: + return sizeof(double) + else: + return -1 + +cdef zfp_field* _init_field(np.ndarray arr): + shape = arr.shape + cdef int ndim = arr.ndim + cdef zfp_type ztype = dtype_to_ztype(arr.dtype) + cdef zfp_field* field + cdef void* pointer = arr.data + if ndim == 1: + field = zfp_field_1d(pointer, ztype, shape[0]) + elif ndim == 2: + field = zfp_field_2d(pointer, ztype, shape[0], shape[1]) + elif ndim == 3: + field = zfp_field_3d(pointer, ztype, shape[0], shape[1], shape[2]) + elif ndim == 4: + field = zfp_field_4d(pointer, ztype, shape[0], shape[1], shape[2], shape[3]) + else: + raise RuntimeError("Greater than 4 dimensions not supported") + return field + +@cython.final +cdef class Memory: + cdef void* data + def __cinit__(self, size_t size): + self.data = malloc(size) + cdef void* __enter__(self): + return self.data + def __exit__(self, exc_type, exc_value, exc_tb): + free(self.data) + +cpdef bytes compress_numpy(np.ndarray arr, double tolerance = 1e-3): + # Input validation + if arr is None: + raise TypeError("Input array cannot be None") + + if not arr.flags['F_CONTIGUOUS']: + # zfp requires a fortran ordered array for optimal compression + # bonus side-effect: we get a contiguous chunk of memory + arr = np.asfortranarray(arr) + + # Setup zfp structs to begin compression + cdef zfp_field* field = _init_field(arr) + stream = zfp_stream_open(NULL) + zfp_stream_set_accuracy(stream, tolerance) + + # Allocate space based on the maximum size potentially required by zfp to + # store the compressed array + cdef bytes compress_str = None + cdef size_t maxsize = zfp_stream_maximum_size(stream, field) + with Memory(maxsize) as data: + bstream = stream_open(data, maxsize) + zfp_stream_set_bit_stream(stream, bstream) + zfp_stream_rewind(stream) + # write the full header so we can reconstruct the numpy array on + # decompression + zfp_write_header(stream, field, HEADER_FULL) + compressed_size = zfp_compress(stream, field) + # copy the compressed data into a perfectly sized bytes object + compress_str = (data)[:compressed_size] + + zfp_field_free(field) + zfp_stream_close(stream) + stream_close(bstream) + + return compress_str + +cdef np.ndarray _decompress_with_view(zfp_field* field, zfp_stream* stream): + cdef zfp_type ztype = field[0].type + dtype = ztype_to_dtype(ztype) + format_type = dtype_to_format(dtype) + + shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + shape = tuple([x for x in shape if x > 0]) + num_elements = functools.reduce(operator.mul, shape) + + cdef view.array decomp_arr = view.array(shape, itemsize=sizeof_ztype(ztype), + format=format_type, mode="fortran", + allocate_buffer=True) + cdef void* pointer = decomp_arr.data + zfp_field_set_pointer(field, pointer) + zfp_decompress(stream, field) + + return np.asarray(decomp_arr) + +cpdef np.ndarray decompress_numpy(bytes compressed_data): + if compressed_data is None: + raise TypeError + + cdef char* comp_data_pointer = compressed_data + cdef bitstream* bstream = stream_open(comp_data_pointer, len(compressed_data)) + cdef zfp_field* field = zfp_field_alloc() + cdef zfp_stream* stream = zfp_stream_open(bstream) + + zfp_stream_rewind(stream) + zfp_read_header(stream, field, HEADER_FULL) + + cdef zfp_type ztype = field[0].type + if ztype == zfp_type_int32 or ztype == zfp_type_int64: + raise NotImplementedError("Integer types not supported") + + output_arr = _decompress_with_view(field, stream) + + zfp_field_free(field) + zfp_stream_close(stream) + stream_close(bstream) + + return output_arr From 655b5f402f205ab467015abbff62b598745ea180 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 10 Dec 2018 13:38:31 -0800 Subject: [PATCH 101/194] python: add test for bindings --- CMakeLists.txt | 7 +++++-- python/CMakeLists.txt | 9 +++++++++ python/test_numpy.py | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 python/test_numpy.py diff --git a/CMakeLists.txt b/CMakeLists.txt index 69f4649cd..c05c8875b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -206,6 +206,11 @@ endif() #------------------------------------------------------------------------------# # Add source code #------------------------------------------------------------------------------# +include(CTest) +if(BUILD_TESTING) + enable_testing() +endif() + set(ZFP_LIBRARY_PREFIX "" CACHE STRING "Prefix to prepend to the output library name") mark_as_advanced(ZFP_LIBRARY_PREFIX) @@ -237,9 +242,7 @@ if(BUILD_EXAMPLES) add_subdirectory(examples) endif() -include(CTest) if(BUILD_TESTING) - enable_testing() add_subdirectory(tests) endif() diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index a2a80081e..c1e3f51f7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -24,3 +24,12 @@ set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) # Install to the typical python module directory set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) + +if(BUILD_TESTING) + add_test(NAME test_numpy + COMMAND ${PYTHON_EXECUTABLE} test_numpy.py + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + + set_tests_properties(test_numpy PROPERTIES + ENVIRONMENT PYTHONPATH=${pylib_build_dir}:$ENV{PYTHONPATH}) +endif() diff --git a/python/test_numpy.py b/python/test_numpy.py new file mode 100644 index 000000000..3a30879de --- /dev/null +++ b/python/test_numpy.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python + +import unittest + +import zfp +import numpy as np + + +class TestNumpy(unittest.TestCase): + def round_trip(self, orig_array): + compressed_array = zfp.compress_numpy(orig_array) + decompressed_array = zfp.decompress_numpy(compressed_array) + self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1e-3)) + + def test_large_zeros_array(self): + zero_array = np.zeros((1000,1000), dtype=np.float64) + self.round_trip(zero_array) + + def test_different_dimensions(self): + for dimensions in range(1, 5): + shape = range(5, 5 + dimensions) + + c_array = np.random.rand(*shape) + self.round_trip(c_array) + + f_array = np.asfortranarray(c_array) + self.round_trip(f_array) + + def test_different_dtypes(self): + shape = (5, 10) + num_elements = 50 + + for dtype in [np.float32, np.float64]: + elements = np.random.random_sample(num_elements) + elements = elements.astype(dtype, casting="same_kind") + array = np.reshape(elements, newshape=shape) + self.round_trip(array) + + for dtype in [np.int32, np.int64]: + array = np.random.randint(2**30, size=shape, dtype=dtype) + with self.assertRaises(NotImplementedError): + self.round_trip(array) + +if __name__ == "__main__": + unittest.main(verbosity=2) From f9c4a5c2fb1c57349357caa508a437560391c32b Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sat, 22 Dec 2018 22:49:08 -0800 Subject: [PATCH 102/194] python: add FindNumPy cmake module adds support for numpy installations that aren't in system directories --- python/CMakeLists.txt | 5 +++- python/eyescale-cmake/FindNumPy.cmake | 41 +++++++++++++++++++++++++++ python/eyescale-cmake/LICENSE.txt | 26 +++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 python/eyescale-cmake/FindNumPy.cmake create mode 100644 python/eyescale-cmake/LICENSE.txt diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c1e3f51f7..4400ad0dc 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -1,14 +1,17 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/scikit-build-cmake) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/eyescale-cmake) include(UseCython) include(FindPythonExtensions) - +include(FindNumPy) find_package(PythonInterp REQUIRED) find_package(PythonLibs REQUIRED) find_package(PythonExtensions REQUIRED) find_package(Cython REQUIRED) +find_package(NumPy REQUIRED) include_directories(${ZFP_SOURCE_DIR}/include) +include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) # cannot reuse the zfp target, use _zfp instead add_cython_target(_zfp zfp.pyx C PY2) diff --git a/python/eyescale-cmake/FindNumPy.cmake b/python/eyescale-cmake/FindNumPy.cmake new file mode 100644 index 000000000..8aba4e696 --- /dev/null +++ b/python/eyescale-cmake/FindNumPy.cmake @@ -0,0 +1,41 @@ +# Find the Python NumPy package +# PYTHON_NUMPY_INCLUDE_DIR +# PYTHON_NUMPY_FOUND +# will be set by this script + +# cmake_minimum_required(VERSION 2.6) + +if(NOT PYTHON_EXECUTABLE) + if(NumPy_FIND_QUIETLY) + find_package(PythonInterp QUIET) + else() + find_package(PythonInterp) + set(__numpy_out 1) + endif() +endif() + +if (PYTHON_EXECUTABLE) + # Find out the include path + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.get_include(), end='')\nexcept:pass\n" + OUTPUT_VARIABLE __numpy_path) + # And the version + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" -c + "from __future__ import print_function\ntry: import numpy; print(numpy.__version__, end='')\nexcept:pass\n" + OUTPUT_VARIABLE __numpy_version) +elseif(__numpy_out) + message(STATUS "Python executable not found.") +endif(PYTHON_EXECUTABLE) + +find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h + HINTS "${__numpy_path}" "${PYTHON_INCLUDE_PATH}" NO_DEFAULT_PATH) + +if(PYTHON_NUMPY_INCLUDE_DIR) + set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found") +endif(PYTHON_NUMPY_INCLUDE_DIR) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NumPy REQUIRED_VARS PYTHON_NUMPY_INCLUDE_DIR + VERSION_VAR __numpy_version) diff --git a/python/eyescale-cmake/LICENSE.txt b/python/eyescale-cmake/LICENSE.txt new file mode 100644 index 000000000..307d54e59 --- /dev/null +++ b/python/eyescale-cmake/LICENSE.txt @@ -0,0 +1,26 @@ +Unless otherwise noted in the file, all files in this directory are +licensed under the BSD license, reproduced below. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +- Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. +- Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. +- Neither the name of Eyescale Software GmbH nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. From ccf5f4fada5c633255fa6e96244644b9de8eb8f4 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Fri, 28 Dec 2018 00:37:38 -0500 Subject: [PATCH 103/194] python: add error checking around decompress and malloc raise RuntimeError and MemoryError exceptions, respectively --- python/zfp.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 3b2dd445b..3cf5c2eb9 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -140,6 +140,8 @@ cdef class Memory: cdef void* data def __cinit__(self, size_t size): self.data = malloc(size) + if self.data == NULL: + raise MemoryError() cdef void* __enter__(self): return self.data def __exit__(self, exc_type, exc_value, exc_tb): @@ -195,7 +197,8 @@ cdef np.ndarray _decompress_with_view(zfp_field* field, zfp_stream* stream): allocate_buffer=True) cdef void* pointer = decomp_arr.data zfp_field_set_pointer(field, pointer) - zfp_decompress(stream, field) + if zfp_decompress(stream, field) == 0: + raise RuntimeError("error during zfp decompression") return np.asarray(decomp_arr) From fb1fa61209364c665b5b63735c4e5de6b6e9de73 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 23 Dec 2018 10:42:29 -0500 Subject: [PATCH 104/194] travis: add BUILD_PYTHON to build matrix --- .travis.yml | 16 ++++++++++++++++ travis.sh | 8 +++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 51a546940..8d7827fc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,22 @@ matrix: - gcc-6 - g++-6 - gfortran-6 + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' BUILD_PYTHON='ON' + + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: ubuntu-toolchain-r-test + packages: + - gcc-6 + - g++-6 + - gfortran-6 + - cython3 + - python3-numpy env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' COVERAGE='ON' - os: linux diff --git a/travis.sh b/travis.sh index 09a563069..28b84a407 100755 --- a/travis.sh +++ b/travis.sh @@ -4,9 +4,11 @@ set -e mkdir build cd build +CTEST_FLAGS="-V -C \"Debug\" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_PYTHON=${BUILD_PYTHON:-off}" + if [ -n "${COVERAGE}" ]; then # build (linux) - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DBUILD_ZFORP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + ctest ${CTEST_FLAGS} -DBUILD_CFP=ON -DBUILD_ZFORP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake else # build/test without OpenMP, with CFP (and custom namespace), with Fortran (linux only) if [[ "$OSTYPE" == "darwin"* ]]; then @@ -15,7 +17,7 @@ else BUILD_ZFORP=ON fi - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_ZFORP=${BUILD_ZFORP} -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + ctest ${CTEST_FLAGS} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake rm -rf ./* ; @@ -24,6 +26,6 @@ else rm -rf ./* ; # build/test with OpenMP - ctest -V -C "Debug" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + ctest ${CTEST_FLAGS} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake fi fi From 61c4f234d40d5d7469b5469f5619ee0677142086 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Fri, 28 Dec 2018 00:33:41 -0500 Subject: [PATCH 105/194] python: add support for fixed-rate and fixed-precision modes --- python/test_numpy.py | 35 ++++++++++++++++++++++++++++------- python/zfp.pyx | 21 ++++++++++++++++++--- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/python/test_numpy.py b/python/test_numpy.py index 3a30879de..0c63e7a28 100644 --- a/python/test_numpy.py +++ b/python/test_numpy.py @@ -7,24 +7,24 @@ class TestNumpy(unittest.TestCase): - def round_trip(self, orig_array): - compressed_array = zfp.compress_numpy(orig_array) + def tolerance_round_trip(self, orig_array): + compressed_array = zfp.compress_numpy(orig_array, tolerance=1e-4) decompressed_array = zfp.decompress_numpy(compressed_array) self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1e-3)) def test_large_zeros_array(self): zero_array = np.zeros((1000,1000), dtype=np.float64) - self.round_trip(zero_array) + self.tolerance_round_trip(zero_array) def test_different_dimensions(self): for dimensions in range(1, 5): shape = range(5, 5 + dimensions) c_array = np.random.rand(*shape) - self.round_trip(c_array) + self.tolerance_round_trip(c_array) f_array = np.asfortranarray(c_array) - self.round_trip(f_array) + self.tolerance_round_trip(f_array) def test_different_dtypes(self): shape = (5, 10) @@ -34,12 +34,33 @@ def test_different_dtypes(self): elements = np.random.random_sample(num_elements) elements = elements.astype(dtype, casting="same_kind") array = np.reshape(elements, newshape=shape) - self.round_trip(array) + self.tolerance_round_trip(array) for dtype in [np.int32, np.int64]: array = np.random.randint(2**30, size=shape, dtype=dtype) with self.assertRaises(NotImplementedError): - self.round_trip(array) + self.tolerance_round_trip(array) + + def test_fixed_rate(self): + c_array = np.random.rand(25, 25, 25) + + decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, rate=15)) + self.assertIsNone(np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3)) + + decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, rate=1)) + with self.assertRaises(AssertionError): + np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) + + def test_fixed_precision(self): + c_array = np.random.rand(25, 25, 25) + + decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, precision=24)) + self.assertIsNone(np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3)) + + decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, precision=1)) + with self.assertRaises(AssertionError): + np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) + if __name__ == "__main__": unittest.main(verbosity=2) diff --git a/python/zfp.pyx b/python/zfp.pyx index 3cf5c2eb9..df1fe5e85 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -46,6 +46,7 @@ cdef extern from "zfp.h": void zfp_stream_set_bit_stream(zfp_stream* stream, bitstream* bs); cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); + double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); zfp_field* zfp_field_alloc(); zfp_field* zfp_field_1d(void* pointer, zfp_type type, cython.uint nx); zfp_field* zfp_field_2d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny); @@ -147,11 +148,16 @@ cdef class Memory: def __exit__(self, exc_type, exc_value, exc_tb): free(self.data) -cpdef bytes compress_numpy(np.ndarray arr, double tolerance = 1e-3): +cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, + double rate = -1, int precision = -1): # Input validation if arr is None: raise TypeError("Input array cannot be None") - + num_params_set = sum([1 for x in [tolerance, rate, precision] if x > -1]) + if num_params_set == 0: + raise ValueError("Either tolerance, rate, or precision must be set") + elif num_params_set > 1: + raise ValueError("Only one of tolerance, rate, or precision can be set") if not arr.flags['F_CONTIGUOUS']: # zfp requires a fortran ordered array for optimal compression # bonus side-effect: we get a contiguous chunk of memory @@ -160,7 +166,16 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = 1e-3): # Setup zfp structs to begin compression cdef zfp_field* field = _init_field(arr) stream = zfp_stream_open(NULL) - zfp_stream_set_accuracy(stream, tolerance) + + cdef zfp_type ztype = zfp_type_none; + cdef int ndim = arr.ndim; + if tolerance > -1: + zfp_stream_set_accuracy(stream, tolerance) + elif rate > -1: + ztype = dtype_to_ztype(arr.dtype) + zfp_stream_set_rate(stream, rate, ztype, ndim, 0) + elif precision > -1: + zfp_stream_set_precision(stream, precision) # Allocate space based on the maximum size potentially required by zfp to # store the compressed array From 16237e9ef9046087e249ad3f0a41d196f96d1a52 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Fri, 28 Dec 2018 02:06:33 -0500 Subject: [PATCH 106/194] python: move tests from python to tests/python --- python/CMakeLists.txt | 13 ++----------- tests/CMakeLists.txt | 4 ++++ tests/python/CMakeLists.txt | 6 ++++++ {python => tests/python}/test_numpy.py | 0 4 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 tests/python/CMakeLists.txt rename {python => tests/python}/test_numpy.py (100%) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 4400ad0dc..429e063e7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -20,19 +20,10 @@ target_link_libraries(_zfp zfp) python_extension_module(_zfp) # Build to the currrent binary dir to avoid conflicts with other libraries named zfp -set(pylib_build_dir "${CMAKE_CURRENT_BINARY_DIR}/lib") -set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${pylib_build_dir}) +set(PYLIB_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE PATH "Directory where zfp python library will be built") +set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) # Make sure the final library is called zfp (rather than _zfp) set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) # Install to the typical python module directory set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) - -if(BUILD_TESTING) - add_test(NAME test_numpy - COMMAND ${PYTHON_EXECUTABLE} test_numpy.py - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - - set_tests_properties(test_numpy PROPERTIES - ENVIRONMENT PYTHONPATH=${pylib_build_dir}:$ENV{PYTHONPATH}) -endif() diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3d5611da2..f39f775bb 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -128,3 +128,7 @@ if(ZFP_BUILD_TESTING_LARGE) endforeach() endforeach() endif() + +if(BUILD_PYTHON) + add_subdirectory(python) +endif() diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt new file mode 100644 index 000000000..163a95d16 --- /dev/null +++ b/tests/python/CMakeLists.txt @@ -0,0 +1,6 @@ +add_test(NAME test_numpy + COMMAND ${PYTHON_EXECUTABLE} test_numpy.py + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + +set_tests_properties(test_numpy PROPERTIES + ENVIRONMENT PYTHONPATH=${PYLIB_BUILD_DIR}:$ENV{PYTHONPATH}) diff --git a/python/test_numpy.py b/tests/python/test_numpy.py similarity index 100% rename from python/test_numpy.py rename to tests/python/test_numpy.py From 86193ce0886249efd9a6b9dc0ae7abceb984d09b Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 31 Dec 2018 03:48:16 +0000 Subject: [PATCH 107/194] python: avoid use of reserved keywords --- python/zfp.pyx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index df1fe5e85..a1ac63514 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -12,7 +12,7 @@ cimport numpy as np cdef extern from "bitstream.h": cdef struct bitstream: pass - bitstream* stream_open(void* data, size_t bytes); + bitstream* stream_open(void* data, size_t); void stream_close(bitstream* stream); cdef extern from "zfp.h": @@ -26,7 +26,7 @@ cdef extern from "zfp.h": # structs ctypedef struct zfp_field: - zfp_type type + zfp_type _type "type" cython.uint nx, ny, nz, nw int sx, sy, sz, sw void* data @@ -48,10 +48,10 @@ cdef extern from "zfp.h": double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); zfp_field* zfp_field_alloc(); - zfp_field* zfp_field_1d(void* pointer, zfp_type type, cython.uint nx); - zfp_field* zfp_field_2d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny); - zfp_field* zfp_field_3d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny, cython.uint nz); - zfp_field* zfp_field_4d(void* pointer, zfp_type type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); + zfp_field* zfp_field_1d(void* pointer, zfp_type, cython.uint nx); + zfp_field* zfp_field_2d(void* pointer, zfp_type, cython.uint nx, cython.uint ny); + zfp_field* zfp_field_3d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz); + zfp_field* zfp_field_4d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); void zfp_field_free(zfp_field* field); size_t zfp_compress(zfp_stream* stream, const zfp_field* field); size_t zfp_decompress(zfp_stream* stream, zfp_field* field); @@ -199,7 +199,7 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, return compress_str cdef np.ndarray _decompress_with_view(zfp_field* field, zfp_stream* stream): - cdef zfp_type ztype = field[0].type + cdef zfp_type ztype = field[0]._type dtype = ztype_to_dtype(ztype) format_type = dtype_to_format(dtype) @@ -229,7 +229,7 @@ cpdef np.ndarray decompress_numpy(bytes compressed_data): zfp_stream_rewind(stream) zfp_read_header(stream, field, HEADER_FULL) - cdef zfp_type ztype = field[0].type + cdef zfp_type ztype = field[0]._type if ztype == zfp_type_int32 or ztype == zfp_type_int64: raise NotImplementedError("Integer types not supported") From 2d5c133cd69caa1909747d7337939e38e3770249 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 31 Dec 2018 04:07:40 +0000 Subject: [PATCH 108/194] travis: switch python tests to ubuntu xenial from trusty --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8d7827fc0..1fd45ba9b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: matrix: include: - os: linux - dist: trusty + dist: xenial compiler: gcc-6 addons: apt: From 573cb09bd9fa67c0fd029f69f0ac55dc3b68fcf4 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 3 Mar 2019 18:28:54 -0500 Subject: [PATCH 109/194] python: split zfp into pxd header and pyx implementation files paves the way for importing the pxd header from other cython files --- python/zfp.pxd | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ python/zfp.pyx | 53 ++------------------------------------------- 2 files changed, 61 insertions(+), 51 deletions(-) create mode 100644 python/zfp.pxd diff --git a/python/zfp.pxd b/python/zfp.pxd new file mode 100644 index 000000000..0096d7301 --- /dev/null +++ b/python/zfp.pxd @@ -0,0 +1,59 @@ +import cython + +cdef extern from "bitstream.h": + cdef struct bitstream: + pass + bitstream* stream_open(void* data, size_t); + void stream_close(bitstream* stream); + +cdef extern from "zfp.h": + # enums + ctypedef enum zfp_type: + zfp_type_none = 0, + zfp_type_int32 = 1, + zfp_type_int64 = 2, + zfp_type_float = 3, + zfp_type_double = 4 + + ctypedef enum zfp_mode: + zfp_mode_null = 0, + zfp_mode_expert = 1, + zfp_mode_fixed_rate = 2, + zfp_mode_fixed_precision = 3, + zfp_mode_fixed_accuracy = 4 + + # structs + ctypedef struct zfp_field: + zfp_type _type "type" + cython.uint nx, ny, nz, nw + int sx, sy, sz, sw + void* data + ctypedef struct zfp_stream: + pass + + # include #define's + cython.uint ZFP_HEADER_MAGIC + cython.uint ZFP_HEADER_META + cython.uint ZFP_HEADER_MODE + cython.uint ZFP_HEADER_FULL + + # function definitions + zfp_stream* zfp_stream_open(bitstream* stream); + void zfp_stream_close(zfp_stream* stream); + size_t zfp_stream_maximum_size(const zfp_stream* stream, const zfp_field* field); + void zfp_stream_set_bit_stream(zfp_stream* stream, bitstream* bs); + cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); + double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); + double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); + zfp_field* zfp_field_alloc(); + zfp_field* zfp_field_1d(void* pointer, zfp_type, cython.uint nx); + zfp_field* zfp_field_2d(void* pointer, zfp_type, cython.uint nx, cython.uint ny); + zfp_field* zfp_field_3d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz); + zfp_field* zfp_field_4d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); + void zfp_field_free(zfp_field* field); + size_t zfp_compress(zfp_stream* stream, const zfp_field* field); + size_t zfp_decompress(zfp_stream* stream, zfp_field* field); + size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, cython.uint mask); + size_t zfp_read_header(zfp_stream* stream, zfp_field* field, cython.uint mask); + void zfp_stream_rewind(zfp_stream* stream); + void zfp_field_set_pointer(zfp_field* field, void* pointer); diff --git a/python/zfp.pyx b/python/zfp.pyx index a1ac63514..634c16c28 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -6,60 +6,11 @@ from cython cimport view from cpython cimport array import array +cimport zfp + import numpy as np cimport numpy as np -cdef extern from "bitstream.h": - cdef struct bitstream: - pass - bitstream* stream_open(void* data, size_t); - void stream_close(bitstream* stream); - -cdef extern from "zfp.h": - # enums - ctypedef enum zfp_type: - zfp_type_none = 0, - zfp_type_int32 = 1, - zfp_type_int64 = 2, - zfp_type_float = 3, - zfp_type_double = 4 - - # structs - ctypedef struct zfp_field: - zfp_type _type "type" - cython.uint nx, ny, nz, nw - int sx, sy, sz, sw - void* data - ctypedef struct zfp_stream: - pass - - # include #define's - cython.uint ZFP_HEADER_MAGIC - cython.uint ZFP_HEADER_META - cython.uint ZFP_HEADER_MODE - cython.uint ZFP_HEADER_FULL - - # function definitions - zfp_stream* zfp_stream_open(bitstream* stream); - void zfp_stream_close(zfp_stream* stream); - size_t zfp_stream_maximum_size(const zfp_stream* stream, const zfp_field* field); - void zfp_stream_set_bit_stream(zfp_stream* stream, bitstream* bs); - cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); - double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); - double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); - zfp_field* zfp_field_alloc(); - zfp_field* zfp_field_1d(void* pointer, zfp_type, cython.uint nx); - zfp_field* zfp_field_2d(void* pointer, zfp_type, cython.uint nx, cython.uint ny); - zfp_field* zfp_field_3d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz); - zfp_field* zfp_field_4d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); - void zfp_field_free(zfp_field* field); - size_t zfp_compress(zfp_stream* stream, const zfp_field* field); - size_t zfp_decompress(zfp_stream* stream, zfp_field* field); - size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, cython.uint mask); - size_t zfp_read_header(zfp_stream* stream, zfp_field* field, cython.uint mask); - void zfp_stream_rewind(zfp_stream* stream); - void zfp_field_set_pointer(zfp_field* field, void* pointer); - # export #define's HEADER_MAGIC = ZFP_HEADER_MAGIC HEADER_META = ZFP_HEADER_META From f9e2874e1b7435c0005b4ba6e7b2db3dce45b3e5 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 3 Mar 2019 18:29:47 -0500 Subject: [PATCH 110/194] python: remove PY2 reference in cmake --- python/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 429e063e7..c43aab12b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -14,7 +14,7 @@ include_directories(${ZFP_SOURCE_DIR}/include) include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) # cannot reuse the zfp target, use _zfp instead -add_cython_target(_zfp zfp.pyx C PY2) +add_cython_target(_zfp zfp.pyx C) add_library(_zfp MODULE ${_zfp}) target_link_libraries(_zfp zfp) python_extension_module(_zfp) From b1f4151564b5959103c040e516b59f73c548ea99 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 08:34:23 -0700 Subject: [PATCH 111/194] python: add `write_header` option to `compress_numpy` --- python/zfp.pyx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 634c16c28..1008a954b 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -100,7 +100,8 @@ cdef class Memory: free(self.data) cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, - double rate = -1, int precision = -1): + double rate = -1, int precision = -1, + write_header=True): # Input validation if arr is None: raise TypeError("Input array cannot be None") @@ -138,7 +139,8 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, zfp_stream_rewind(stream) # write the full header so we can reconstruct the numpy array on # decompression - zfp_write_header(stream, field, HEADER_FULL) + if write_header: + zfp_write_header(stream, field, HEADER_FULL) compressed_size = zfp_compress(stream, field) # copy the compressed data into a perfectly sized bytes object compress_str = (data)[:compressed_size] From 41f215fa568b4b32ad7aaa56a3df901cd162257a Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 08:34:39 -0700 Subject: [PATCH 112/194] python: re-enable integer types in `compress_numpy` --- python/zfp.pyx | 2 -- 1 file changed, 2 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 1008a954b..664b02f21 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -183,8 +183,6 @@ cpdef np.ndarray decompress_numpy(bytes compressed_data): zfp_read_header(stream, field, HEADER_FULL) cdef zfp_type ztype = field[0]._type - if ztype == zfp_type_int32 or ztype == zfp_type_int64: - raise NotImplementedError("Integer types not supported") output_arr = _decompress_with_view(field, stream) From cc26739db140b2967a3ed29abeb1b39941954e8d Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 08:35:12 -0700 Subject: [PATCH 113/194] python: export zfp_mode and zfp_type enum values --- python/zfp.pyx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/python/zfp.pyx b/python/zfp.pyx index 664b02f21..e3f51b9df 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -17,6 +17,19 @@ HEADER_META = ZFP_HEADER_META HEADER_MODE = ZFP_HEADER_MODE HEADER_FULL = ZFP_HEADER_FULL +# export enums +type_none = zfp_type_none +type_int32 = zfp_type_int32 +type_int64 = zfp_type_int64 +type_float = zfp_type_float +type_double = zfp_type_double +mode_null = zfp_mode_null +mode_expert = zfp_mode_expert +mode_fixed_rate = zfp_mode_fixed_rate +mode_fixed_precision = zfp_mode_fixed_precision +mode_fixed_accuracy = zfp_mode_fixed_accuracy + + cpdef dtype_to_ztype(dtype): if dtype == np.int32: return zfp_type_int32 From ab64253d47759333c36a776e27cbccedd763e35d Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 08:40:30 -0700 Subject: [PATCH 114/194] python/test_utils: add initial bindings for test utilities --- python/CMakeLists.txt | 8 ++ python/test_utils.pyx | 253 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 261 insertions(+) create mode 100644 python/test_utils.pyx diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c43aab12b..429fd8fe7 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,3 +27,11 @@ set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) # Install to the typical python module directory set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) + +include_directories(${ZFP_SOURCE_DIR}/tests/utils) +include_directories(${ZFP_SOURCE_DIR}) +add_cython_target(test_utils test_utils.pyx C) +add_library(test_utils MODULE ${test_utils}) +target_link_libraries(test_utils zfp genSmoothRandNumsLib stridedOperationsLib zfpCompressionParamsLib zfpChecksumsLib zfpHashLib) +python_extension_module(test_utils) +set_target_properties(test_utils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) diff --git a/python/test_utils.pyx b/python/test_utils.pyx new file mode 100644 index 000000000..bd0982a3b --- /dev/null +++ b/python/test_utils.pyx @@ -0,0 +1,253 @@ +import cython +from libc.stdlib cimport free +cimport libc.stdint as stdint +from cython cimport view + +import zfp +cimport zfp + +import numpy as np +cimport numpy as np + +ctypedef stdint.int32_t int32_t +ctypedef stdint.int64_t int64_t +ctypedef stdint.uint32_t uint32_t +ctypedef stdint.uint64_t uint64_t + +cdef extern from "genSmoothRandNums.h": + size_t intPow(size_t base, int exponent); + void generateSmoothRandInts64(size_t minTotalElements, + int numDims, + int amplitudeExp, + int64_t** outputArr, + size_t* outputSideLen, + size_t* outputTotalLen); + void generateSmoothRandInts32(size_t minTotalElements, + int numDims, + int amplitudeExp, + int32_t** outputArr32Ptr, + size_t* outputSideLen, + size_t* outputTotalLen); + void generateSmoothRandFloats(size_t minTotalElements, + int numDims, + float** outputArrPtr, + size_t* outputSideLen, + size_t* outputTotalLen); + void generateSmoothRandDoubles(size_t minTotalElements, + int numDims, + double** outputArrPtr, + size_t* outputSideLen, + size_t* outputTotalLen); + +cdef extern from "stridedOperations.h": + ctypedef enum stride_config: + AS_IS = 0, + PERMUTED = 1, + INTERLEAVED = 2, + REVERSED = 3 + + void reverseArray(void* inputArr, + void* outputArr, + size_t inputArrLen, + zfp.zfp_type zfpType); + void interleaveArray(void* inputArr, + void* outputArr, + size_t inputArrLen, + zfp.zfp_type zfpType); + int permuteSquareArray(void* inputArr, + void* outputArr, + size_t sideLen, + int dims, + zfp.zfp_type zfpType); + void getReversedStrides(int dims, + size_t n[4], + int s[4]); + void getInterleavedStrides(int dims, + size_t n[4], + int s[4]); + void getPermutedStrides(int dims, + size_t n[4], + int s[4]); + +cdef extern from "zfpCompressionParams.h": + int computeFixedPrecisionParam(int param); + size_t computeFixedRateParam(int param); + double computeFixedAccuracyParam(int param); + +cdef extern from "zfpChecksums.h": + uint64_t getChecksumOriginalDataBlock(int dims, + zfp.zfp_type type); + uint64_t getChecksumEncodedBlock(int dims, + zfp.zfp_type type); + uint64_t getChecksumEncodedPartialBlock(int dims, + zfp.zfp_type type); + uint64_t getChecksumDecodedBlock(int dims, + zfp.zfp_type type); + uint64_t getChecksumDecodedPartialBlock(int dims, + zfp.zfp_type type); + uint64_t getChecksumOriginalDataArray(int dims, + zfp.zfp_type type); + uint64_t getChecksumCompressedBitstream(int dims, + zfp.zfp_type type, + zfp.zfp_mode mode, + int compressParamNum); + uint64_t getChecksumDecompressedArray(int dims, + zfp.zfp_type type, + zfp.zfp_mode mode, + int compressParamNum); + +cdef extern from "zfpHash.h": + uint64_t hashBitstream(uint64_t* ptrStart, + size_t bufsizeBytes); + uint32_t hashArray32(const uint32_t* arr, + size_t nx, + int sx); + uint32_t hashStridedArray32(const uint32_t* arr, + size_t n[4], + int s[4]); + uint64_t hashArray64(const uint64_t* arr, + size_t nx, + int sx); + uint64_t hashStridedArray64(const uint64_t* arr, + size_t n[4], + int s[4]); + +cpdef getRandNumpyArray( + int numDims, + zfp.zfp_type ztype, +): + cdef size_t minTotalElements = 0 + cdef int amplitudeExp = 0 + + if ztype in [zfp.type_float, zfp.type_double]: + minTotalElements = 1000000 + elif ztype in [zfp.type_int32, zfp.type_int64]: + minTotalElements = 4096 + else: + raise ValueError("Unsupported zfp_type: {}".format(ztype)) + + # ztype = zfp.dtype_to_ztype(dtype) + # format_type = zfp.dtype_to_format(dtype) + + cdef int64_t* outputArrInt64 = NULL + cdef int32_t* outputArrInt32 = NULL + cdef float* outputArrFloat = NULL + cdef double* outputArrDouble = NULL + cdef size_t outputSideLen = 0 + cdef size_t outputTotalLen = 0 + cdef view.array viewArr = None + + if ztype == zfp.type_int64: + amplitudeExp = 64 - 2 + generateSmoothRandInts64(minTotalElements, + numDims, + amplitudeExp, + &outputArrInt64, + &outputSideLen, + &outputTotalLen) + # TODO: all dimensions + if numDims == 1: + viewArr = outputArrInt64 + elif numDims == 2: + viewArr = outputArrInt64 + elif numDims == 3: + viewArr = outputArrInt64 + elif numDims == 4: + viewArr = outputArrInt64 + elif ztype == zfp.type_int32: + amplitudeExp = 32 - 2 + generateSmoothRandInts32(minTotalElements, + numDims, + amplitudeExp, + &outputArrInt32, + &outputSideLen, + &outputTotalLen) + if numDims == 1: + viewArr = outputArrInt32 + elif numDims == 2: + viewArr = outputArrInt32 + elif numDims == 3: + viewArr = outputArrInt32 + elif numDims == 4: + viewArr = outputArrInt32 + elif ztype == zfp.type_float: + generateSmoothRandFloats(minTotalElements, + numDims, + &outputArrFloat, + &outputSideLen, + &outputTotalLen) + if numDims == 1: + viewArr = outputArrFloat + elif numDims == 2: + viewArr = outputArrFloat + elif numDims == 3: + viewArr = outputArrFloat + elif numDims == 4: + viewArr = outputArrFloat + elif ztype == zfp.type_double: + generateSmoothRandDoubles(minTotalElements, + numDims, + &outputArrDouble, + &outputSideLen, + &outputTotalLen) + if numDims == 1: + viewArr = outputArrDouble + elif numDims == 2: + viewArr = outputArrDouble + elif numDims == 3: + viewArr = outputArrDouble + elif numDims == 4: + viewArr = outputArrDouble + else: + raise ValueError("Unknown zfp_type: {}".format(ztype)) + + return np.asarray(viewArr) + +cpdef uint64_t getChecksumOrigArray( + int dims, + zfp.zfp_type ztype +): + return getChecksumOriginalDataArray(dims, ztype) + +cpdef uint64_t getChecksumCompArray( + int dims, + zfp.zfp_type ztype, + zfp.zfp_mode mode, + int compressParamNum +): + return getChecksumCompressedBitstream(dims, ztype, mode, compressParamNum) + +cpdef uint64_t getChecksumDecompArray( + int dims, + zfp.zfp_type ztype, + zfp.zfp_mode mode, + int compressParamNum +): + return getChecksumDecompressedArray(dims, ztype, mode, compressParamNum) + +cpdef computeParameterValue(zfp.zfp_mode mode, int param): + if mode == zfp.mode_fixed_accuracy: + return computeFixedAccuracyParam(param) + elif mode == zfp.mode_fixed_precision: + return computeFixedPrecisionParam(param) + elif mode == zfp.mode_fixed_rate: + return computeFixedRateParam(param) + +cpdef hashNumpyArray( + np.ndarray nparray, +): + dtype = nparray.dtype + size = nparray.size + # TODO: support strided arrays + if dtype == np.int32 or dtype == np.float32: + return hashArray32(nparray.data, size, 1) + elif dtype == np.int64 or dtype == np.float64: + return hashArray64(nparray.data, size, 1) + else: + raise ValueError("Unsupported numpy type: {}".format(dtype)) + +cpdef hashCompressedArray( + bytes array, +): + cdef const char* c_array = array + return hashBitstream( c_array, len(array)) From f15669e95654ec31ed34278b79159980dc4c4d09 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 08:42:34 -0700 Subject: [PATCH 115/194] python/test_numpy: add checksumming tests via the test_utils --- tests/python/test_numpy.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index 0c63e7a28..e84ef9940 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -3,6 +3,7 @@ import unittest import zfp +import test_utils import numpy as np @@ -61,6 +62,36 @@ def test_fixed_precision(self): with self.assertRaises(AssertionError): np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) + def test_utils(self): + # TODO: more dimensions + for ndims in [1]: + for ztype in [zfp.type_float, zfp.type_double]: + random_array = test_utils.getRandNumpyArray(ndims, ztype) + orig_checksum = test_utils.getChecksumOrigArray(ndims, ztype) + actual_checksum = test_utils.hashNumpyArray(random_array) + self.assertEqual(orig_checksum, actual_checksum) + # TODO: strided arrays + + for compress_param_num in range(3): + for mode, mode_str in [(zfp.mode_fixed_accuracy, "tolerance"), + (zfp.mode_fixed_precision, "precision"), + (zfp.mode_fixed_rate, "rate")]: + kwargs = { + mode_str: test_utils.computeParameterValue(mode, compress_param_num), + "write_header" : False, + } + compressed_array = zfp.compress_numpy(random_array, **kwargs) + compressed_checksum = test_utils.getChecksumCompArray(ndims, ztype, mode, compress_param_num) + actual_checksum = test_utils.hashCompressedArray(compressed_array) + self.assertEqual(compressed_checksum, actual_checksum) + + kwargs['write_header'] = True + compressed_array = zfp.compress_numpy(random_array, **kwargs) + + decompressed_array = zfp.decompress_numpy(compressed_array) + decompressed_checksum = test_utils.getChecksumDecompArray(ndims, ztype, mode, compress_param_num) + actual_checksum = test_utils.hashNumpyArray(decompressed_array) + self.assertEqual(decompressed_checksum, actual_checksum) if __name__ == "__main__": unittest.main(verbosity=2) From 32d599fb6ad4e7eb0ef72ae3276222646a7ea984 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 13 Mar 2019 11:11:34 -0700 Subject: [PATCH 116/194] python/test_utils: add input argument validation includes validation for number of dimentions, zfp_type, zfp_mode, and compression parameter number --- python/test_utils.pyx | 46 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index bd0982a3b..554e63b5c 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -112,10 +112,38 @@ cdef extern from "zfpHash.h": size_t n[4], int s[4]); +cdef validate_num_dimensions(int dims): + if dims > 4 or dims < 1: + raise ValueError("Unsupported number of dimensions: {}".format(dims)) + +cdef validate_ztype(zfp.zfp_type ztype): + if ztype not in [ + zfp.type_float, + zfp.type_double, + zfp.type_int32, + zfp.type_int64 + ]: + raise ValueError("Unsupported ztype: {}".format(ztype)) + +cdef validate_mode(zfp.zfp_mode mode): + if mode not in [ + zfp.mode_fixed_rate, + zfp.mode_fixed_precision, + zfp.mode_fixed_accuracy, + ]: + raise ValueError("Unsupported mode: {}".format(mode)) + +cdef validate_compress_param(int comp_param): + if comp_param not in range(3): # i.e., [0, 1, 2] + raise ValueError("Unsupported compression parameter number: {}".format(comp_param)) + cpdef getRandNumpyArray( int numDims, zfp.zfp_type ztype, ): + validate_num_dimensions(numDims) + validate_ztype(ztype) + cdef size_t minTotalElements = 0 cdef int amplitudeExp = 0 @@ -123,8 +151,6 @@ cpdef getRandNumpyArray( minTotalElements = 1000000 elif ztype in [zfp.type_int32, zfp.type_int64]: minTotalElements = 4096 - else: - raise ValueError("Unsupported zfp_type: {}".format(ztype)) # ztype = zfp.dtype_to_ztype(dtype) # format_type = zfp.dtype_to_format(dtype) @@ -207,6 +233,9 @@ cpdef uint64_t getChecksumOrigArray( int dims, zfp.zfp_type ztype ): + validate_num_dimensions(dims) + validate_ztype(ztype) + return getChecksumOriginalDataArray(dims, ztype) cpdef uint64_t getChecksumCompArray( @@ -215,6 +244,11 @@ cpdef uint64_t getChecksumCompArray( zfp.zfp_mode mode, int compressParamNum ): + validate_num_dimensions(dims) + validate_ztype(ztype) + validate_mode(mode) + validate_compress_param(compressParamNum) + return getChecksumCompressedBitstream(dims, ztype, mode, compressParamNum) cpdef uint64_t getChecksumDecompArray( @@ -223,9 +257,17 @@ cpdef uint64_t getChecksumDecompArray( zfp.zfp_mode mode, int compressParamNum ): + validate_num_dimensions(dims) + validate_ztype(ztype) + validate_mode(mode) + validate_compress_param(compressParamNum) + return getChecksumDecompressedArray(dims, ztype, mode, compressParamNum) cpdef computeParameterValue(zfp.zfp_mode mode, int param): + validate_mode(mode) + validate_compress_param(param) + if mode == zfp.mode_fixed_accuracy: return computeFixedAccuracyParam(param) elif mode == zfp.mode_fixed_precision: From 82c86b1553d1118d4d85c08f918b4a9785a93dea Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Thu, 14 Mar 2019 06:57:17 -0700 Subject: [PATCH 117/194] python: replace fortran-contig transformation with setting strides remove call to `asfortranarray` in `compress_numpy`, replace with calls to `zfp_field_set_stride_*d` when creating the `zfp_field` tests of floating point arrays beyond 1D now work --- python/test_utils.pyx | 6 +++++- python/zfp.pxd | 5 +++++ python/zfp.pyx | 12 ++++++++---- tests/python/test_numpy.py | 3 +-- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index 554e63b5c..3bac1cbae 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -227,7 +227,11 @@ cpdef getRandNumpyArray( else: raise ValueError("Unknown zfp_type: {}".format(ztype)) - return np.asarray(viewArr) + np_arr = np.asarray(viewArr) + return np.lib.stride_tricks.as_strided( + np_arr, + strides=reversed(np_arr.strides) + ) cpdef uint64_t getChecksumOrigArray( int dims, diff --git a/python/zfp.pxd b/python/zfp.pxd index 0096d7301..d21114334 100644 --- a/python/zfp.pxd +++ b/python/zfp.pxd @@ -50,6 +50,11 @@ cdef extern from "zfp.h": zfp_field* zfp_field_2d(void* pointer, zfp_type, cython.uint nx, cython.uint ny); zfp_field* zfp_field_3d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz); zfp_field* zfp_field_4d(void* pointer, zfp_type, cython.uint nx, cython.uint ny, cython.uint nz, cython.uint nw); + void zfp_field_set_stride_1d(zfp_field* field, int sx); + void zfp_field_set_stride_2d(zfp_field* field, int sx, int sy); + void zfp_field_set_stride_3d(zfp_field* field, int sx, int sy, int sz); + void zfp_field_set_stride_4d(zfp_field* field, int sx, int sy, int sz, int sw); + int zfp_field_stride(const zfp_field* field, int* stride) void zfp_field_free(zfp_field* field); size_t zfp_compress(zfp_stream* stream, const zfp_field* field); size_t zfp_decompress(zfp_stream* stream, zfp_field* field); diff --git a/python/zfp.pyx b/python/zfp.pyx index e3f51b9df..1456c2cb4 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -88,16 +88,24 @@ cdef zfp_field* _init_field(np.ndarray arr): cdef zfp_type ztype = dtype_to_ztype(arr.dtype) cdef zfp_field* field cdef void* pointer = arr.data + + strides = [int(x) / arr.itemsize for x in arr.strides[:ndim]] + if ndim == 1: field = zfp_field_1d(pointer, ztype, shape[0]) + zfp_field_set_stride_1d(field, strides[0]) elif ndim == 2: field = zfp_field_2d(pointer, ztype, shape[0], shape[1]) + zfp_field_set_stride_2d(field, strides[0], strides[1]) elif ndim == 3: field = zfp_field_3d(pointer, ztype, shape[0], shape[1], shape[2]) + zfp_field_set_stride_3d(field, strides[0], strides[1], strides[2]) elif ndim == 4: field = zfp_field_4d(pointer, ztype, shape[0], shape[1], shape[2], shape[3]) + zfp_field_set_stride_4d(field, strides[0], strides[1], strides[2], strides[3]) else: raise RuntimeError("Greater than 4 dimensions not supported") + return field @cython.final @@ -123,10 +131,6 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, raise ValueError("Either tolerance, rate, or precision must be set") elif num_params_set > 1: raise ValueError("Only one of tolerance, rate, or precision can be set") - if not arr.flags['F_CONTIGUOUS']: - # zfp requires a fortran ordered array for optimal compression - # bonus side-effect: we get a contiguous chunk of memory - arr = np.asfortranarray(arr) # Setup zfp structs to begin compression cdef zfp_field* field = _init_field(arr) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index e84ef9940..bc8a05404 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -63,9 +63,8 @@ def test_fixed_precision(self): np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) def test_utils(self): - # TODO: more dimensions - for ndims in [1]: for ztype in [zfp.type_float, zfp.type_double]: + for ndims in range(1, 5): random_array = test_utils.getRandNumpyArray(ndims, ztype) orig_checksum = test_utils.getChecksumOrigArray(ndims, ztype) actual_checksum = test_utils.hashNumpyArray(random_array) From 9106f2fbbf5290768692e6d8fed6196b82833684 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Thu, 14 Mar 2019 07:41:45 -0700 Subject: [PATCH 118/194] tests/python: only use fixed-rate compression on integer types precision and accuracy compression aren't designed for integer types, don't use them in the checksum testing --- tests/python/test_numpy.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index bc8a05404..e1d2173ff 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -13,6 +13,11 @@ def tolerance_round_trip(self, orig_array): decompressed_array = zfp.decompress_numpy(compressed_array) self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1e-3)) + def rate_round_trip(self, orig_array): + compressed_array = zfp.compress_numpy(orig_array, rate=16) + decompressed_array = zfp.decompress_numpy(compressed_array) + self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1)) + def test_large_zeros_array(self): zero_array = np.zeros((1000,1000), dtype=np.float64) self.tolerance_round_trip(zero_array) @@ -39,8 +44,7 @@ def test_different_dtypes(self): for dtype in [np.int32, np.int64]: array = np.random.randint(2**30, size=shape, dtype=dtype) - with self.assertRaises(NotImplementedError): - self.tolerance_round_trip(array) + self.rate_round_trip(array) def test_fixed_rate(self): c_array = np.random.rand(25, 25, 25) @@ -63,8 +67,8 @@ def test_fixed_precision(self): np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) def test_utils(self): - for ztype in [zfp.type_float, zfp.type_double]: for ndims in range(1, 5): + for ztype in [zfp.type_float, zfp.type_double, zfp.type_int32, zfp.type_int64]: random_array = test_utils.getRandNumpyArray(ndims, ztype) orig_checksum = test_utils.getChecksumOrigArray(ndims, ztype) actual_checksum = test_utils.hashNumpyArray(random_array) @@ -72,9 +76,12 @@ def test_utils(self): # TODO: strided arrays for compress_param_num in range(3): - for mode, mode_str in [(zfp.mode_fixed_accuracy, "tolerance"), - (zfp.mode_fixed_precision, "precision"), - (zfp.mode_fixed_rate, "rate")]: + modes = [(zfp.mode_fixed_accuracy, "tolerance"), + (zfp.mode_fixed_precision, "precision"), + (zfp.mode_fixed_rate, "rate")] + if ztype in [zfp.type_int32, zfp.type_int64]: + modes = [modes[-1]] # only fixed-rate is supported for integers + for mode, mode_str in modes: kwargs = { mode_str: test_utils.computeParameterValue(mode, compress_param_num), "write_header" : False, From 5641ce8f28c6ace03922bef985ca0b9bb0c13289 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sat, 23 Mar 2019 19:02:40 -0700 Subject: [PATCH 119/194] python: add decompression into user-supplied buffer --- python/zfp.pxd | 6 ++ python/zfp.pyx | 212 ++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 196 insertions(+), 22 deletions(-) diff --git a/python/zfp.pxd b/python/zfp.pxd index d21114334..6e81ca141 100644 --- a/python/zfp.pxd +++ b/python/zfp.pxd @@ -1,4 +1,5 @@ import cython +cimport libc.stdint as stdint cdef extern from "bitstream.h": cdef struct bitstream: @@ -45,6 +46,8 @@ cdef extern from "zfp.h": cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); + stdint.uint64_t zfp_stream_mode(const zfp_stream* zfp); + zfp_mode zfp_stream_set_mode(zfp_stream* stream, stdint.uint64_t mode); zfp_field* zfp_field_alloc(); zfp_field* zfp_field_1d(void* pointer, zfp_type, cython.uint nx); zfp_field* zfp_field_2d(void* pointer, zfp_type, cython.uint nx, cython.uint ny); @@ -56,9 +59,12 @@ cdef extern from "zfp.h": void zfp_field_set_stride_4d(zfp_field* field, int sx, int sy, int sz, int sw); int zfp_field_stride(const zfp_field* field, int* stride) void zfp_field_free(zfp_field* field); + zfp_type zfp_field_set_type(zfp_field* field, zfp_type type); size_t zfp_compress(zfp_stream* stream, const zfp_field* field); size_t zfp_decompress(zfp_stream* stream, zfp_field* field); size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, cython.uint mask); size_t zfp_read_header(zfp_stream* stream, zfp_field* field, cython.uint mask); void zfp_stream_rewind(zfp_stream* stream); void zfp_field_set_pointer(zfp_field* field, void* pointer); + +cdef gen_padded_int_list(orig_array, pad=*, length=*) diff --git a/python/zfp.pyx b/python/zfp.pyx index 1456c2cb4..3f6762e7a 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -1,11 +1,18 @@ -import cython -from libc.stdlib cimport malloc, free +import six import operator import functools +import cython +from libc.stdlib cimport malloc, free from cython cimport view from cpython cimport array import array +import itertools +if six.PY2: + from itertools import izip_longest as zip_longest +elif six.PY3: + from itertools import zip_longest + cimport zfp import numpy as np @@ -108,6 +115,17 @@ cdef zfp_field* _init_field(np.ndarray arr): return field +cdef gen_padded_int_list(orig_array, pad=0, length=4): + return [int(x) for x in + itertools.islice( + itertools.chain( + orig_array, + itertools.repeat(pad) + ), + length + ) + ] + @cython.final cdef class Memory: cdef void* data @@ -126,7 +144,7 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, # Input validation if arr is None: raise TypeError("Input array cannot be None") - num_params_set = sum([1 for x in [tolerance, rate, precision] if x > -1]) + num_params_set = sum([1 for x in [tolerance, rate, precision] if x >= 0]) if num_params_set == 0: raise ValueError("Either tolerance, rate, or precision must be set") elif num_params_set > 1: @@ -134,17 +152,11 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, # Setup zfp structs to begin compression cdef zfp_field* field = _init_field(arr) - stream = zfp_stream_open(NULL) + cdef zfp_stream* stream = zfp_stream_open(NULL) cdef zfp_type ztype = zfp_type_none; cdef int ndim = arr.ndim; - if tolerance > -1: - zfp_stream_set_accuracy(stream, tolerance) - elif rate > -1: - ztype = dtype_to_ztype(arr.dtype) - zfp_stream_set_rate(stream, rate, ztype, ndim, 0) - elif precision > -1: - zfp_stream_set_precision(stream, precision) + set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) # Allocate space based on the maximum size potentially required by zfp to # store the compressed array @@ -184,27 +196,183 @@ cdef np.ndarray _decompress_with_view(zfp_field* field, zfp_stream* stream): zfp_field_set_pointer(field, pointer) if zfp_decompress(stream, field) == 0: raise RuntimeError("error during zfp decompression") + return decomp_arr + +cdef _decompress_with_user_array( + zfp_field* field, + zfp_stream* stream, + void* out, +): + zfp_field_set_pointer(field, out) + if zfp_decompress(stream, field) == 0: + raise RuntimeError("error during zfp decompression") - return np.asarray(decomp_arr) +cdef set_compression_mode( + zfp_stream *stream, + zfp_type ztype, + int ndim, + double tolerance = -1, + double rate = -1, + int precision = -1, +): + if tolerance >= 0: + zfp_stream_set_accuracy(stream, tolerance) + elif rate >= 0: + zfp_stream_set_rate(stream, rate, ztype, ndim, 0) + elif precision >= 0: + zfp_stream_set_precision(stream, precision) + else: + raise ValueError("Either tolerance, rate, or precision must be set") + +cpdef np.ndarray decompress_numpy( + bytes compressed_data, + out=None, + ztype=type_none, + shape=None, + strides=[0,0,0,0], + double tolerance = -1, + double rate = -1, + int precision = -1, +): -cpdef np.ndarray decompress_numpy(bytes compressed_data): if compressed_data is None: - raise TypeError + raise TypeError("compressed_data cannot be None") + if compressed_data is out: + raise ValueError("Cannot decompress in-place") cdef char* comp_data_pointer = compressed_data cdef bitstream* bstream = stream_open(comp_data_pointer, len(compressed_data)) cdef zfp_field* field = zfp_field_alloc() cdef zfp_stream* stream = zfp_stream_open(bstream) + cdef np.ndarray output - zfp_stream_rewind(stream) - zfp_read_header(stream, field, HEADER_FULL) + try: + zfp_stream_rewind(stream) + if zfp_read_header(stream, field, HEADER_FULL) == 0: + zfp_stream_rewind(stream) + if ztype == type_none or shape is None: + raise ValueError( + "Failed to read zfp header and the ztype/shape/mode " + "were not provided" + ) + try: + if len(shape) > 4: + raise ValueError( + "User-provided shape has too many dimensions " + "(up to 4 supported)" + ) + elif len(shape) <= 0: + raise ValueError( + "User-provided shape needs at least one dimension" + ) + else: # pad the shape with zeros to reach len == 4 + zshape = gen_padded_int_list(shape, pad=0, length=4) + except TypeError: + raise TypeError( + "User-provided shape is not an iterable" + ) + # set the shape, type, and compression mode + # strides are set further down + field[0].nx, field[0].ny, field[0].nz, field[0].nw = zshape + zfp_field_set_type(field, ztype) + ndim = sum([1 for x in zshape if x > 0]) + set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) + else: # Check that user-inputs match the header + if ztype != type_none and ztype is not field[0]._type: + raise ValueError( + "User-provided zfp_type does not match zfp_type in header" + ) + # check that the header and user shapes match + header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = [x for x in header_shape if x > 0] + if shape is not None: + if not all([x == y for x, y in zip_longest(shape, header_shape)]): + raise ValueError( + "User-provided shape does not match shape in header" + ) + # check that setting the compression parameters based on user input + # does not change the stream mode (i.e., the compression parameters + # provided by the user and in the header match) + if tolerance >= 0 or rate >= 0 or precision >= 0: + header_mode = zfp_stream_mode(stream) + ndim = len(header_shape) + set_compression_mode( + stream, + ztype, + ndim, + tolerance, + rate, + precision + ) + mode = zfp_stream_mode(stream) + if mode != mode_null and mode != header_mode: + raise ValueError( + "User-provided zfp_mode {} does not match zfp_mode " + "in header {}".format( + mode, + header_mode, + ) + ) + # check that the shape and strides have the same number of dimensions + if shape is not None and sum(strides) > 0: + stride_dims = sum([1 for x in strides if x > 0]) + shape_dims = sum([1 for x in shape if x > 0]) + if len(strides) != len(shape): + raise ValueError( + "Mis-match in shape and stride lengths" + ) + try: + if len(strides) > 4: + raise ValueError( + "User-provided strides has too many dimensions " + "(up to 4 supported)" + ) + elif len(strides) <= 0: + raise ValueError( + "User-provided strides needs at least one dimension" + ) + else: # pad the shape with zeros to reach len == 4 + strides = gen_padded_int_list(strides, pad=0, length=4) + except TypeError: + raise TypeError( + "User-provided strides is not an iterable" + ) - cdef zfp_type ztype = field[0]._type + field[0].sx, field[0].sy, field[0].sz, field[0].sw = strides - output_arr = _decompress_with_view(field, stream) + if out is None: + output = np.asarray(_decompress_with_view(field, stream)) + else: + header_dtype = ztype_to_dtype(field[0]._type) + header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = [x for x in header_shape if x > 0] + if isinstance(out, np.ndarray): + if out.dtype != header_dtype: + raise ValueError( + "Out ndarray has dtype {} but decompression is using " + "{}".format( + out.dtype, + header_dtype + ) + ) + numpy_shape = [int(x) for x in out.shape[:ndim]] + if not all([x == y for x, y in zip_longest(numpy_shape, header_shape)]): + raise ValueError( + "Out ndarray has shape {} but decompression is using " + "{}".format( + numpy_shape, + header_shape + ) + ) + output = out + else: + output = np.frombuffer(out, dtype=header_dtype) + output = output.reshape(header_shape) - zfp_field_free(field) - zfp_stream_close(stream) - stream_close(bstream) + _decompress_with_user_array(field, stream, output.data) + finally: + zfp_field_free(field) + zfp_stream_close(stream) + stream_close(bstream) - return output_arr + return output From e1704a6d0c104007c2e062646398833e309678c1 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sat, 23 Mar 2019 19:32:21 -0700 Subject: [PATCH 120/194] tests/python: replace ad-hoc round-trip tests with checksum tests --- python/test_utils.pyx | 125 ++++++++++++++++++++++++++-- tests/python/test_numpy.py | 165 ++++++++++++++++++------------------- 2 files changed, 197 insertions(+), 93 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index 3bac1cbae..a68171d66 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -1,7 +1,8 @@ import cython -from libc.stdlib cimport free +from libc.stdlib cimport malloc, free cimport libc.stdint as stdint from cython cimport view +from itertools import islice, repeat, chain import zfp cimport zfp @@ -112,6 +113,13 @@ cdef extern from "zfpHash.h": size_t n[4], int s[4]); +# enums +stride_as_is = AS_IS +stride_permuted = PERMUTED +stride_interleaved = INTERLEAVED +stride_reversed = REVERSED + +# functions cdef validate_num_dimensions(int dims): if dims > 4 or dims < 1: raise ValueError("Unsupported number of dimensions: {}".format(dims)) @@ -279,21 +287,122 @@ cpdef computeParameterValue(zfp.zfp_mode mode, int param): elif mode == zfp.mode_fixed_rate: return computeFixedRateParam(param) +cpdef hashStridedArray( + bytes inarray, + zfp.zfp_type ztype, + shape, + strides, +): + cdef char* array = inarray + cdef size_t[4] padded_shape = zfp.gen_padded_int_list(shape) + cdef int[4] padded_strides = zfp.gen_padded_int_list(strides) + + if ztype == zfp.type_int32 or ztype == zfp.type_float: + return hashStridedArray32(array, padded_shape, padded_strides) + elif ztype == zfp.type_int64 or ztype == zfp.type_double: + return hashStridedArray64(array, padded_shape, padded_strides) + cpdef hashNumpyArray( np.ndarray nparray, + stride_config stride_conf = AS_IS, ): dtype = nparray.dtype - size = nparray.size - # TODO: support strided arrays - if dtype == np.int32 or dtype == np.float32: - return hashArray32(nparray.data, size, 1) - elif dtype == np.int64 or dtype == np.float64: - return hashArray64(nparray.data, size, 1) - else: + if dtype not in [np.int32, np.float32, np.int64, np.float64]: raise ValueError("Unsupported numpy type: {}".format(dtype)) + if stride_conf not in [AS_IS, PERMUTED, INTERLEAVED, REVERSED]: + raise ValueError("Unsupported stride config: {}".format(stride_conf)) + + size = int(nparray.size) + cdef int[4] strides + cdef size_t[4] shape + if stride_conf in [AS_IS, INTERLEAVED]: + stride_width = 1 if stride_conf is AS_IS else 2 + if dtype == np.int32 or dtype == np.float32: + return hashArray32(nparray.data, size, stride_width) + elif dtype == np.int64 or dtype == np.float64: + return hashArray64(nparray.data, size, stride_width) + elif stride_conf in [REVERSED, PERMUTED]: + strides = zfp.gen_padded_int_list( + [x for x in nparray.strides[:nparray.ndim]] + ) + shape = zfp.gen_padded_int_list( + [x for x in nparray.shape[:nparray.ndim]] + ) + if dtype == np.int32 or dtype == np.float32: + return hashStridedArray32(nparray.data, shape, strides) + elif dtype == np.int64 or dtype == np.float64: + return hashStridedArray64(nparray.data, shape, strides) + cpdef hashCompressedArray( bytes array, ): cdef const char* c_array = array return hashBitstream( c_array, len(array)) + + +cpdef generateStridedRandomNumpyArray( + stride_config stride, + np.ndarray randomArray, +): + cdef int ndim = randomArray.ndim + shape = [int(x) for x in randomArray.shape[:ndim]] + dtype = randomArray.dtype + cdef zfp.zfp_type ztype = zfp.dtype_to_ztype(dtype) + cdef int[4] strides = [0, 0, 0, 0] + cdef size_t[4] dims = zfp.gen_padded_int_list(shape) + cdef size_t inputLen = len(randomArray) + cdef void* output_array_ptr = NULL + cdef np.ndarray output_array = None + cdef view.array output_array_view = None + + if stride == AS_IS: + # return an unmodified copy + return randomArray.copy(order='K') + elif stride == PERMUTED: + if ndim == 1: + raise ValueError("Permutation not supported on 1D arrays") + output_array = np.empty_like(randomArray, order='K') + getPermutedStrides(ndim, dims, strides) + strides = [int(x) * (randomArray.itemsize) for x in strides] + ret = permuteSquareArray( + randomArray.data, + output_array.data, + dims[0], + ndim, + ztype + ) + if ret != 0: + raise RuntimeError("Error permuting square array") + + return np.lib.stride_tricks.as_strided( + output_array, + shape=[x for x in dims[:ndim]], + strides=[x for x in strides[:ndim]], + ) + + elif stride == INTERLEAVED: + num_elements = np.prod(shape) + new_shape = [x for x in dims if x > 0] + new_shape[-1] *= 2 + dims = tuple(zfp.gen_padded_int_list(new_shape, pad=0, length=4)) + + output_array = np.empty( + new_shape, + dtype=dtype + ) + interleaveArray( + randomArray.data, + output_array.data, + num_elements, + ztype + ) + getInterleavedStrides(ndim, dims, strides) + strides = [int(x) * (randomArray.itemsize) for x in strides] + return np.lib.stride_tricks.as_strided( + output_array, + shape=shape, + strides=[x for x in strides[:ndim]], + ) + else: + raise ValueError("Unsupported_config: {|}".format(stride_config)) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index e1d2173ff..d585ace8a 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -8,96 +8,91 @@ class TestNumpy(unittest.TestCase): - def tolerance_round_trip(self, orig_array): - compressed_array = zfp.compress_numpy(orig_array, tolerance=1e-4) - decompressed_array = zfp.decompress_numpy(compressed_array) - self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1e-3)) - - def rate_round_trip(self, orig_array): - compressed_array = zfp.compress_numpy(orig_array, rate=16) - decompressed_array = zfp.decompress_numpy(compressed_array) - self.assertIsNone(np.testing.assert_allclose(decompressed_array, orig_array, atol=1)) - - def test_large_zeros_array(self): - zero_array = np.zeros((1000,1000), dtype=np.float64) - self.tolerance_round_trip(zero_array) - - def test_different_dimensions(self): - for dimensions in range(1, 5): - shape = range(5, 5 + dimensions) - - c_array = np.random.rand(*shape) - self.tolerance_round_trip(c_array) - - f_array = np.asfortranarray(c_array) - self.tolerance_round_trip(f_array) - - def test_different_dtypes(self): - shape = (5, 10) - num_elements = 50 - - for dtype in [np.float32, np.float64]: - elements = np.random.random_sample(num_elements) - elements = elements.astype(dtype, casting="same_kind") - array = np.reshape(elements, newshape=shape) - self.tolerance_round_trip(array) - - for dtype in [np.int32, np.int64]: - array = np.random.randint(2**30, size=shape, dtype=dtype) - self.rate_round_trip(array) - - def test_fixed_rate(self): - c_array = np.random.rand(25, 25, 25) - - decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, rate=15)) - self.assertIsNone(np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3)) - - decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, rate=1)) - with self.assertRaises(AssertionError): - np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) - - def test_fixed_precision(self): - c_array = np.random.rand(25, 25, 25) - - decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, precision=24)) - self.assertIsNone(np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3)) - - decompressed_array = zfp.decompress_numpy(zfp.compress_numpy(c_array, precision=1)) - with self.assertRaises(AssertionError): - np.testing.assert_allclose(decompressed_array, c_array, atol=1e-3) - def test_utils(self): for ndims in range(1, 5): - for ztype in [zfp.type_float, zfp.type_double, zfp.type_int32, zfp.type_int64]: - random_array = test_utils.getRandNumpyArray(ndims, ztype) + for ztype, ztype_str in [ + (zfp.type_float, "float"), + (zfp.type_double, "double"), + (zfp.type_int32, "int32"), + (zfp.type_int64, "int64"), + ]: + orig_random_array = test_utils.getRandNumpyArray(ndims, ztype) orig_checksum = test_utils.getChecksumOrigArray(ndims, ztype) - actual_checksum = test_utils.hashNumpyArray(random_array) + actual_checksum = test_utils.hashNumpyArray(orig_random_array) self.assertEqual(orig_checksum, actual_checksum) - # TODO: strided arrays - - for compress_param_num in range(3): - modes = [(zfp.mode_fixed_accuracy, "tolerance"), - (zfp.mode_fixed_precision, "precision"), - (zfp.mode_fixed_rate, "rate")] - if ztype in [zfp.type_int32, zfp.type_int64]: - modes = [modes[-1]] # only fixed-rate is supported for integers - for mode, mode_str in modes: - kwargs = { - mode_str: test_utils.computeParameterValue(mode, compress_param_num), - "write_header" : False, - } - compressed_array = zfp.compress_numpy(random_array, **kwargs) - compressed_checksum = test_utils.getChecksumCompArray(ndims, ztype, mode, compress_param_num) - actual_checksum = test_utils.hashCompressedArray(compressed_array) - self.assertEqual(compressed_checksum, actual_checksum) - - kwargs['write_header'] = True - compressed_array = zfp.compress_numpy(random_array, **kwargs) - decompressed_array = zfp.decompress_numpy(compressed_array) - decompressed_checksum = test_utils.getChecksumDecompArray(ndims, ztype, mode, compress_param_num) - actual_checksum = test_utils.hashNumpyArray(decompressed_array) - self.assertEqual(decompressed_checksum, actual_checksum) + for stride_str, stride_config in [ + ("as_is", test_utils.stride_as_is), + ("permuted", test_utils.stride_permuted), + ("interleaved", test_utils.stride_interleaved), + #("reversed", test_utils.stride_reversed), + ]: + if stride_config == test_utils.stride_permuted and ndims == 1: + continue + random_array = test_utils.generateStridedRandomNumpyArray( + stride_config, + orig_random_array + ) + self.assertTrue(np.equal(orig_random_array, random_array).all()) + + for compress_param_num in range(3): + modes = [(zfp.mode_fixed_accuracy, "tolerance"), + (zfp.mode_fixed_precision, "precision"), + (zfp.mode_fixed_rate, "rate")] + if ztype in [zfp.type_int32, zfp.type_int64]: + modes = [modes[-1]] # only fixed-rate is supported for integers + for mode, mode_str in modes: + # Compression + compression_kwargs = { + mode_str: test_utils.computeParameterValue( + mode, + compress_param_num + ), + } + + compressed_array = zfp.compress_numpy( + random_array, + write_header=False, + **compression_kwargs + ) + compressed_checksum = test_utils.getChecksumCompArray( + ndims, + ztype, + mode, + compress_param_num + ) + actual_checksum = test_utils.hashCompressedArray( + compressed_array + ) + self.assertEqual(compressed_checksum, actual_checksum) + + # Decompression + zshape = [int(x) for x in random_array.shape] + decompression_kwargs = dict( + compression_kwargs, + ztype=ztype, + shape=zshape, + ) + if stride_config == test_utils.stride_permuted: + # test decompressing into a numpy array + # created by the "user" + decompressed_array = np.empty_like(random_array) + decompression_kwargs['out'] = decompressed_array + + decompressed_array = zfp.decompress_numpy( + compressed_array, + **decompression_kwargs + ) + actual_checksum = test_utils.hashNumpyArray( + decompressed_array + ) + decompressed_checksum = test_utils.getChecksumDecompArray( + ndims, + ztype, + mode, + compress_param_num + ) + self.assertEqual(decompressed_checksum, actual_checksum) if __name__ == "__main__": unittest.main(verbosity=2) From 667092b78a43e1b5de99c882d69fddafbe0b641e Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 19:03:59 -0700 Subject: [PATCH 121/194] python: minor formatting tweaks and cleanup --- python/test_utils.pyx | 12 +++++------- python/zfp.pyx | 38 +++++++++++++++++++++++++------------- 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index a68171d66..2c33fe04a 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -143,7 +143,9 @@ cdef validate_mode(zfp.zfp_mode mode): cdef validate_compress_param(int comp_param): if comp_param not in range(3): # i.e., [0, 1, 2] - raise ValueError("Unsupported compression parameter number: {}".format(comp_param)) + raise ValueError( + "Unsupported compression parameter number: {}".format(comp_param) + ) cpdef getRandNumpyArray( int numDims, @@ -160,9 +162,6 @@ cpdef getRandNumpyArray( elif ztype in [zfp.type_int32, zfp.type_int64]: minTotalElements = 4096 - # ztype = zfp.dtype_to_ztype(dtype) - # format_type = zfp.dtype_to_format(dtype) - cdef int64_t* outputArrInt64 = NULL cdef int32_t* outputArrInt32 = NULL cdef float* outputArrFloat = NULL @@ -179,7 +178,6 @@ cpdef getRandNumpyArray( &outputArrInt64, &outputSideLen, &outputTotalLen) - # TODO: all dimensions if numDims == 1: viewArr = outputArrInt64 elif numDims == 2: @@ -237,8 +235,8 @@ cpdef getRandNumpyArray( np_arr = np.asarray(viewArr) return np.lib.stride_tricks.as_strided( - np_arr, - strides=reversed(np_arr.strides) + np_arr, + strides=reversed(np_arr.strides) ) cpdef uint64_t getChecksumOrigArray( diff --git a/python/zfp.pyx b/python/zfp.pyx index 3f6762e7a..68125a7af 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -73,9 +73,7 @@ cpdef ztype_to_dtype(zfp_type ztype): try: return zfp_to_dtype_map[ztype] except KeyError: - # TODO: is this the correct type? - print "Using np.bytes_" - return np.bytes_ + raise ValueError("Unsupported zfp_type {}".format(ztype)) cdef size_t sizeof_ztype(zfp_type ztype): if ztype == zfp_type_int32: @@ -138,9 +136,13 @@ cdef class Memory: def __exit__(self, exc_type, exc_value, exc_tb): free(self.data) -cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, - double rate = -1, int precision = -1, - write_header=True): +cpdef bytes compress_numpy( + np.ndarray arr, + double tolerance = -1, + double rate = -1, + int precision = -1, + write_header=True +): # Input validation if arr is None: raise TypeError("Input array cannot be None") @@ -180,17 +182,20 @@ cpdef bytes compress_numpy(np.ndarray arr, double tolerance = -1, return compress_str -cdef np.ndarray _decompress_with_view(zfp_field* field, zfp_stream* stream): +cdef view.array _decompress_with_view( + zfp_field* field, + zfp_stream* stream, +): cdef zfp_type ztype = field[0]._type dtype = ztype_to_dtype(ztype) format_type = dtype_to_format(dtype) shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) shape = tuple([x for x in shape if x > 0]) - num_elements = functools.reduce(operator.mul, shape) - cdef view.array decomp_arr = view.array(shape, itemsize=sizeof_ztype(ztype), - format=format_type, mode="fortran", + cdef view.array decomp_arr = view.array(shape, + itemsize=sizeof_ztype(ztype), + format=format_type, allocate_buffer=True) cdef void* pointer = decomp_arr.data zfp_field_set_pointer(field, pointer) @@ -227,7 +232,7 @@ cdef set_compression_mode( cpdef np.ndarray decompress_numpy( bytes compressed_data, out=None, - ztype=type_none, + zfp_type ztype=type_none, shape=None, strides=[0,0,0,0], double tolerance = -1, @@ -241,8 +246,11 @@ cpdef np.ndarray decompress_numpy( raise ValueError("Cannot decompress in-place") cdef char* comp_data_pointer = compressed_data - cdef bitstream* bstream = stream_open(comp_data_pointer, len(compressed_data)) cdef zfp_field* field = zfp_field_alloc() + cdef bitstream* bstream = stream_open( + comp_data_pointer, + len(compressed_data) + ) cdef zfp_stream* stream = zfp_stream_open(bstream) cdef np.ndarray output @@ -356,7 +364,11 @@ cpdef np.ndarray decompress_numpy( ) ) numpy_shape = [int(x) for x in out.shape[:ndim]] - if not all([x == y for x, y in zip_longest(numpy_shape, header_shape)]): + if not all( + [x == y for x, y in + zip_longest(numpy_shape, header_shape) + ] + ): raise ValueError( "Out ndarray has shape {} but decompression is using " "{}".format( From 873c0a21b5aeb0473b3c41eca13d89024b59d2ca Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 19:24:56 -0700 Subject: [PATCH 122/194] python: refactor decompress to simplify the top-level function pull input validation out into separate functions --- python/zfp.pyx | 238 ++++++++++++++++++++++++++++--------------------- 1 file changed, 136 insertions(+), 102 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 68125a7af..acac545f3 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -158,7 +158,7 @@ cpdef bytes compress_numpy( cdef zfp_type ztype = zfp_type_none; cdef int ndim = arr.ndim; - set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) + _set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) # Allocate space based on the maximum size potentially required by zfp to # store the compressed array @@ -212,7 +212,7 @@ cdef _decompress_with_user_array( if zfp_decompress(stream, field) == 0: raise RuntimeError("error during zfp decompression") -cdef set_compression_mode( +cdef _set_compression_mode( zfp_stream *stream, zfp_type ztype, int ndim, @@ -229,6 +229,114 @@ cdef set_compression_mode( else: raise ValueError("Either tolerance, rate, or precision must be set") +cdef _validate_4d_list(in_list, list_name): + # Validate that the input list is either a valid list for strides or shape + # Specifically, check it is a list and the length is > 0 and <= 4 + # Throws a TypeError or ValueError if invalid + try: + if len(in_list) > 4: + raise ValueError( + "User-provided {} has too many dimensions " + "(up to 4 supported)" + ) + elif len(in_list) <= 0: + raise ValueError( + "User-provided {} needs at least one dimension" + ) + except TypeError: + raise TypeError( + "User-provided {} is not an iterable" + ) + +cdef _validate_userinput_matches_header( + zfp_field* field, + zfp_stream* stream, + out, + zfp_type ztype, + shape, + strides, + double tolerance, + double rate, + int precision +): + # check that the header and user type matches + if ztype != type_none and ztype is not field[0]._type: + raise ValueError( + "User-provided zfp_type does not match zfp_type in header" + ) + + # check that the header and user shapes match + header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = [x for x in header_shape if x > 0] + if shape is not None: + if not all([x == y for x, y in zip_longest(shape, header_shape)]): + raise ValueError( + "User-provided shape does not match shape in header" + ) + + # check that the shape and strides have the same number of dimensions + if shape is not None and sum(strides) > 0: + stride_dims = sum([1 for x in strides if x > 0]) + shape_dims = sum([1 for x in shape if x > 0]) + if len(strides) != len(shape): + raise ValueError( + "Mis-match in shape and stride lengths" + ) + + # check that setting the compression parameters based on user input + # does not change the stream mode (i.e., the compression parameters + # provided by the user and in the header match) + if tolerance >= 0 or rate >= 0 or precision >= 0: + header_mode = zfp_stream_mode(stream) + ndim = len(header_shape) + _set_compression_mode( + stream, + ztype, + ndim, + tolerance, + rate, + precision + ) + mode = zfp_stream_mode(stream) + if mode != mode_null and mode != header_mode: + raise ValueError( + "User-provided zfp_mode {} does not match zfp_mode " + "in header {}".format( + mode, + header_mode, + ) + ) + + # if the out buffer is a numpy array, check that it's properties match the + # header metadata + if out is not None and isinstance(out, np.ndarray): + # check that numpy and header types match + header_dtype = ztype_to_dtype(field[0]._type) + if out.dtype != header_dtype: + raise ValueError( + "Out ndarray has dtype {} but decompression is using " + "{}".format( + out.dtype, + header_dtype + ) + ) + + # check that numpy and header shape match + numpy_shape = [int(x) for x in out.shape[:ndim]] + if not all( + [x == y for x, y in + zip_longest(numpy_shape, header_shape) + ] + ): + raise ValueError( + "Out ndarray has shape {} but decompression is using " + "{}".format( + numpy_shape, + header_shape + ) + ) + + cpdef np.ndarray decompress_numpy( bytes compressed_data, out=None, @@ -244,6 +352,10 @@ cpdef np.ndarray decompress_numpy( raise TypeError("compressed_data cannot be None") if compressed_data is out: raise ValueError("Cannot decompress in-place") + if shape is not None: + _validate_4d_list(shape, "shape") + if strides is not None: + _validate_4d_list(strides, "strides") cdef char* comp_data_pointer = compressed_data cdef zfp_field* field = zfp_field_alloc() @@ -263,125 +375,47 @@ cpdef np.ndarray decompress_numpy( "Failed to read zfp header and the ztype/shape/mode " "were not provided" ) - try: - if len(shape) > 4: - raise ValueError( - "User-provided shape has too many dimensions " - "(up to 4 supported)" - ) - elif len(shape) <= 0: - raise ValueError( - "User-provided shape needs at least one dimension" - ) - else: # pad the shape with zeros to reach len == 4 - zshape = gen_padded_int_list(shape, pad=0, length=4) - except TypeError: - raise TypeError( - "User-provided shape is not an iterable" - ) + zshape = gen_padded_int_list(shape, pad=0, length=4) # set the shape, type, and compression mode # strides are set further down field[0].nx, field[0].ny, field[0].nz, field[0].nw = zshape zfp_field_set_type(field, ztype) ndim = sum([1 for x in zshape if x > 0]) - set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) - else: # Check that user-inputs match the header - if ztype != type_none and ztype is not field[0]._type: - raise ValueError( - "User-provided zfp_type does not match zfp_type in header" - ) - # check that the header and user shapes match - header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) - header_shape = [x for x in header_shape if x > 0] - if shape is not None: - if not all([x == y for x, y in zip_longest(shape, header_shape)]): - raise ValueError( - "User-provided shape does not match shape in header" - ) - # check that setting the compression parameters based on user input - # does not change the stream mode (i.e., the compression parameters - # provided by the user and in the header match) - if tolerance >= 0 or rate >= 0 or precision >= 0: - header_mode = zfp_stream_mode(stream) - ndim = len(header_shape) - set_compression_mode( - stream, - ztype, - ndim, - tolerance, - rate, - precision - ) - mode = zfp_stream_mode(stream) - if mode != mode_null and mode != header_mode: - raise ValueError( - "User-provided zfp_mode {} does not match zfp_mode " - "in header {}".format( - mode, - header_mode, - ) - ) - # check that the shape and strides have the same number of dimensions - if shape is not None and sum(strides) > 0: - stride_dims = sum([1 for x in strides if x > 0]) - shape_dims = sum([1 for x in shape if x > 0]) - if len(strides) != len(shape): - raise ValueError( - "Mis-match in shape and stride lengths" - ) - try: - if len(strides) > 4: - raise ValueError( - "User-provided strides has too many dimensions " - "(up to 4 supported)" - ) - elif len(strides) <= 0: - raise ValueError( - "User-provided strides needs at least one dimension" - ) - else: # pad the shape with zeros to reach len == 4 - strides = gen_padded_int_list(strides, pad=0, length=4) - except TypeError: - raise TypeError( - "User-provided strides is not an iterable" + _set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) + else: + # zfp_read_header should have taken care of setting the metadata + # correctly, but check that user inputs match the header + _validate_userinput_matches_header( + field, + stream, + out, + ztype, + shape, + strides, + tolerance, + rate, + precision ) + # pad the shape with zeros to reach len == 4 + strides = gen_padded_int_list(strides, pad=0, length=4) field[0].sx, field[0].sy, field[0].sz, field[0].sw = strides if out is None: output = np.asarray(_decompress_with_view(field, stream)) else: - header_dtype = ztype_to_dtype(field[0]._type) - header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) - header_shape = [x for x in header_shape if x > 0] if isinstance(out, np.ndarray): - if out.dtype != header_dtype: - raise ValueError( - "Out ndarray has dtype {} but decompression is using " - "{}".format( - out.dtype, - header_dtype - ) - ) - numpy_shape = [int(x) for x in out.shape[:ndim]] - if not all( - [x == y for x, y in - zip_longest(numpy_shape, header_shape) - ] - ): - raise ValueError( - "Out ndarray has shape {} but decompression is using " - "{}".format( - numpy_shape, - header_shape - ) - ) output = out else: + header_dtype = ztype_to_dtype(field[0]._type) + header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = [x for x in header_shape if x > 0] + output = np.frombuffer(out, dtype=header_dtype) output = output.reshape(header_shape) _decompress_with_user_array(field, stream, output.data) + finally: zfp_field_free(field) zfp_stream_close(stream) From e14206666645c9002797f940a878466b76760e0d Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 19:38:02 -0700 Subject: [PATCH 123/194] python/cmake: include function signatures and docstrings Per @romankarlstetter's suggestion, make sure docstrings and function signatures are included in the compiled bindings. This greatly improves python binding usage in interactive scenarios, like Jupyter Notebooks. --- python/scikit-build-cmake/UseCython.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/scikit-build-cmake/UseCython.cmake b/python/scikit-build-cmake/UseCython.cmake index 809554e11..9a5966488 100644 --- a/python/scikit-build-cmake/UseCython.cmake +++ b/python/scikit-build-cmake/UseCython.cmake @@ -324,9 +324,11 @@ function(add_cython_target _name) endif() set(no_docstrings_arg "") - if(CMAKE_BUILD_TYPE STREQUAL "Release" OR - CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") + set(embed_signature_arg "") + if(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel") set(no_docstrings_arg "--no-docstrings") + else() + set(embed_signature_arg "-Xembedsignature=True") endif() set(cython_debug_arg "") @@ -355,7 +357,7 @@ function(add_cython_target _name) COMMAND ${CYTHON_EXECUTABLE} ARGS ${cxx_arg} ${include_directory_arg} ${py_version_arg} ${embed_arg} ${annotate_arg} ${no_docstrings_arg} - ${cython_debug_arg} ${embed_pos_arg} + ${cython_debug_arg} ${embed_pos_arg} ${embed_signature_arg} ${line_directives_arg} ${CYTHON_FLAGS_LIST} ${pyx_location} --output-file ${generated_file} DEPENDS ${_source_file} From b3f7a1bf04abe4584a8bf35b8ab93e3f92bb6dbf Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 20:31:11 -0700 Subject: [PATCH 124/194] python: use nogil to release GIL when (de-)compressing enables other python threads to execute while executing the computational expensive C functions zfp_compress and zfp_decompress --- python/zfp.pxd | 6 +++--- python/zfp.pyx | 15 ++++++++++----- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/python/zfp.pxd b/python/zfp.pxd index 6e81ca141..f5bafe6d6 100644 --- a/python/zfp.pxd +++ b/python/zfp.pxd @@ -60,11 +60,11 @@ cdef extern from "zfp.h": int zfp_field_stride(const zfp_field* field, int* stride) void zfp_field_free(zfp_field* field); zfp_type zfp_field_set_type(zfp_field* field, zfp_type type); - size_t zfp_compress(zfp_stream* stream, const zfp_field* field); - size_t zfp_decompress(zfp_stream* stream, zfp_field* field); + size_t zfp_compress(zfp_stream* stream, const zfp_field* field) nogil; + size_t zfp_decompress(zfp_stream* stream, zfp_field* field) nogil; size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, cython.uint mask); size_t zfp_read_header(zfp_stream* stream, zfp_field* field, cython.uint mask); void zfp_stream_rewind(zfp_stream* stream); - void zfp_field_set_pointer(zfp_field* field, void* pointer); + void zfp_field_set_pointer(zfp_field* field, void* pointer) nogil; cdef gen_padded_int_list(orig_array, pad=*, length=*) diff --git a/python/zfp.pyx b/python/zfp.pyx index acac545f3..be1c59053 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -172,7 +172,8 @@ cpdef bytes compress_numpy( # decompression if write_header: zfp_write_header(stream, field, HEADER_FULL) - compressed_size = zfp_compress(stream, field) + with nogil: + compressed_size = zfp_compress(stream, field) # copy the compressed data into a perfectly sized bytes object compress_str = (data)[:compressed_size] @@ -198,8 +199,10 @@ cdef view.array _decompress_with_view( format=format_type, allocate_buffer=True) cdef void* pointer = decomp_arr.data - zfp_field_set_pointer(field, pointer) - if zfp_decompress(stream, field) == 0: + with nogil: + zfp_field_set_pointer(field, pointer) + ret = zfp_decompress(stream, field) + if ret == 0: raise RuntimeError("error during zfp decompression") return decomp_arr @@ -208,8 +211,10 @@ cdef _decompress_with_user_array( zfp_stream* stream, void* out, ): - zfp_field_set_pointer(field, out) - if zfp_decompress(stream, field) == 0: + with nogil: + zfp_field_set_pointer(field, out) + ret = zfp_decompress(stream, field) + if ret == 0: raise RuntimeError("error during zfp decompression") cdef _set_compression_mode( From 08d717e09df4056d7f09848824417f896a339c86 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 20:45:41 -0700 Subject: [PATCH 125/194] python: check the return of zfp_write_header raise a RuntimeError if the write failed and the return is 0 --- python/zfp.pyx | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index be1c59053..171da908b 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -164,22 +164,23 @@ cpdef bytes compress_numpy( # store the compressed array cdef bytes compress_str = None cdef size_t maxsize = zfp_stream_maximum_size(stream, field) - with Memory(maxsize) as data: - bstream = stream_open(data, maxsize) - zfp_stream_set_bit_stream(stream, bstream) - zfp_stream_rewind(stream) - # write the full header so we can reconstruct the numpy array on - # decompression - if write_header: - zfp_write_header(stream, field, HEADER_FULL) - with nogil: - compressed_size = zfp_compress(stream, field) - # copy the compressed data into a perfectly sized bytes object - compress_str = (data)[:compressed_size] - - zfp_field_free(field) - zfp_stream_close(stream) - stream_close(bstream) + try: + with Memory(maxsize) as data: + bstream = stream_open(data, maxsize) + zfp_stream_set_bit_stream(stream, bstream) + zfp_stream_rewind(stream) + # write the full header so we can reconstruct the numpy array on + # decompression + if write_header and zfp_write_header(stream, field, HEADER_FULL) == 0: + raise RuntimeError("Failed to write header to stream") + with nogil: + compressed_size = zfp_compress(stream, field) + # copy the compressed data into a perfectly sized bytes object + compress_str = (data)[:compressed_size] + finally: + zfp_field_free(field) + zfp_stream_close(stream) + stream_close(bstream) return compress_str From c225e3abc6fd30455d5f5271c978b0d707caeac8 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 24 Mar 2019 20:46:18 -0700 Subject: [PATCH 126/194] python: remove reference to long long for C89 compliance instead, leverage numpy's itemsize method --- python/zfp.pyx | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 171da908b..d29d008c4 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -75,18 +75,6 @@ cpdef ztype_to_dtype(zfp_type ztype): except KeyError: raise ValueError("Unsupported zfp_type {}".format(ztype)) -cdef size_t sizeof_ztype(zfp_type ztype): - if ztype == zfp_type_int32: - return sizeof(signed int) - elif ztype == zfp_type_int64: - return sizeof(signed long long) - elif ztype == zfp_type_float: - return sizeof(float) - elif ztype == zfp_type_double: - return sizeof(double) - else: - return -1 - cdef zfp_field* _init_field(np.ndarray arr): shape = arr.shape cdef int ndim = arr.ndim @@ -195,10 +183,12 @@ cdef view.array _decompress_with_view( shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) shape = tuple([x for x in shape if x > 0]) - cdef view.array decomp_arr = view.array(shape, - itemsize=sizeof_ztype(ztype), - format=format_type, - allocate_buffer=True) + cdef view.array decomp_arr = view.array( + shape, + itemsize=np.dtype(dtype).itemsize, + format=format_type, + allocate_buffer=True + ) cdef void* pointer = decomp_arr.data with nogil: zfp_field_set_pointer(field, pointer) From ffffa376cf0ffff89bbdf2c9e2d353d79a056dda Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 25 Mar 2019 10:32:41 -0700 Subject: [PATCH 127/194] finalize travis CI config for python testing: default 3.5 over different compilers, plus some 2.7 (osx included) fix python test utils compile error --- .travis.yml | 158 +++++++++++++++++++++++++++++++----------- cmake/travis.cmake | 5 ++ python/test_utils.pyx | 2 +- travis.sh | 16 +++-- 4 files changed, 134 insertions(+), 47 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1fd45ba9b..21e5f6cb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,26 +13,13 @@ matrix: - gcc-6 - g++-6 - gfortran-6 + - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' BUILD_PYTHON='ON' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' COVERAGE='ON' - os: linux - dist: trusty - compiler: gcc-6 - addons: - apt: - sources: ubuntu-toolchain-r-test - packages: - - gcc-6 - - g++-6 - - gfortran-6 - - cython3 - - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' COVERAGE='ON' - - - os: linux - dist: trusty + dist: xenial compiler: clang-3.6 addons: &clang36 apt: @@ -41,7 +28,10 @@ matrix: - clang-3.6 - g++-7 - gfortran-6 - env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -55,10 +45,13 @@ matrix: - clang-4.0 - g++-7 - gfortran-6 - env: CC='clang-4.0' CXX='clang++-4.0' FC='gfortran-6' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='clang-4.0' CXX='clang++-4.0' FC='gfortran-6' PYTHON_VERSION='3.5' - os: linux - dist: trusty + dist: xenial compiler: gcc-4.4 addons: apt: @@ -67,10 +60,13 @@ matrix: - gcc-4.4 - g++-4.4 - gfortran-4.4 - env: CC='gcc-4.4' CXX='g++-4.4' FC='gfortran-4.4' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-4.4' CXX='g++-4.4' FC='gfortran-4.4' PYTHON_VERSION='3.5' - os: linux - dist: trusty + dist: xenial compiler: gcc-4.7 addons: apt: @@ -79,10 +75,13 @@ matrix: - gcc-4.7 - g++-4.7 - gfortran-4.7 - env: CC='gcc-4.7' CXX='g++-4.7' FC='gfortran-4.7' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-4.7' CXX='g++-4.7' FC='gfortran-4.7' PYTHON_VERSION='3.5' - os: linux - dist: trusty + dist: xenial compiler: gcc-4.8 addons: apt: @@ -91,10 +90,13 @@ matrix: - gcc-4.8 - g++-4.8 - gfortran-4.8 - env: CC='gcc-4.8' CXX='g++-4.8' FC='gfortran-4.8' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-4.8' CXX='g++-4.8' FC='gfortran-4.8' PYTHON_VERSION='3.5' - os: linux - dist: trusty + dist: xenial compiler: gcc-4.9 addons: apt: @@ -103,7 +105,10 @@ matrix: - gcc-4.9 - g++-4.9 - gfortran-4.9 - env: CC='gcc-4.9' CXX='g++-4.9' FC='gfortran-4.9' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-4.9' CXX='g++-4.9' FC='gfortran-4.9' PYTHON_VERSION='3.5' - os: linux dist: trusty @@ -115,7 +120,10 @@ matrix: - gcc-5 - g++-5 - gfortran-5 - env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' + - libpython2.7 + - cython + - python-numpy + env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' PYTHON_VERSION='2.7' - os: linux dist: trusty @@ -127,10 +135,13 @@ matrix: - gcc-6 - g++-6 - gfortran-6 - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' C_STANDARD='90' + - libpython2.7 + - cython + - python-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='2.7' - os: linux - dist: trusty + dist: xenial compiler: gcc-6 addons: apt: @@ -139,10 +150,13 @@ matrix: - gcc-6 - g++-6 - gfortran-6 - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' C_STANDARD='11' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' C_STANDARD='90' - os: linux - dist: trusty + dist: xenial compiler: gcc-6 addons: apt: @@ -151,10 +165,13 @@ matrix: - gcc-6 - g++-6 - gfortran-6 - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' CXX_STANDARD='11' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' C_STANDARD='11' - os: linux - dist: trusty + dist: xenial compiler: gcc-6 addons: apt: @@ -163,10 +180,28 @@ matrix: - gcc-6 - g++-6 - gfortran-6 - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' CXX_STANDARD='14' + - libpython3.5-dev + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' CXX_STANDARD='11' - os: linux - dist: trusty + dist: xenial + compiler: gcc-6 + addons: + apt: + sources: ubuntu-toolchain-r-test + packages: + - gcc-6 + - g++-6 + - gfortran-6 + - libpython3.5 + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' CXX_STANDARD='14' + + - os: linux + dist: xenial compiler: gcc-6 addons: apt: @@ -175,29 +210,72 @@ matrix: - gcc-6 - g++-6 - gfortran-6 - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' + - libpython3.5 + - cython3 + - python3-numpy + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' + + - os: linux + dist: xenial + compiler: gcc-7 + addons: + apt: + sources: ubuntu-toolchain-r-test + packages: + - gcc-7 + - g++-7 + - gfortran-7 + - libpython3.5 + - cython3 + - python3-numpy + env: CC='gcc-7' CXX='g++-7' FC='gfortran-7' PYTHON_VERSION='3.5' - os: osx osx_image: xcode7.3 compiler: gcc - env: CC='gcc' CXX='g++' + env: CC='gcc' CXX='g++' PYTHON_VERSION='3.5' - os: osx osx_image: xcode8.3 compiler: gcc - env: CC='gcc' CXX='g++' + env: CC='gcc' CXX='g++' PYTHON_VERSION='2.7' - os: osx osx_image: xcode7.3 compiler: clang - env: CC='clang' CXX='clang++' + env: CC='clang' CXX='clang++' PYTHON_VERSION='3.5' - os: osx osx_image: xcode8.3 compiler: clang - env: CC='clang' CXX='clang++' + env: CC='clang' CXX='clang++' PYTHON_VERSION='2.7' script: + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then pyenv root; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then pyenv install 2.7.12; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then pyenv install 3.5.0; fi + + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/2.7.12/include/python2.7; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_LIBRARY=$(pyenv root)/versions/2.7.12/lib/libpython2.7.dylib; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_BINARY=$(pyenv root)/versions/2.7.12/bin/python2.7; fi + + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/3.5.0/include/python3.5m; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_LIBRARY=$(pyenv root)/versions/3.5.0/lib/libpython3.dylib; fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5; fi + + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install --upgrade pip; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install Cython; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install numpy; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install six; fi + + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PYTHON_BINARY=/usr/bin/python$PYTHON_VERSION; fi + + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_INCLUDE_DIR=/usr/include/python2.7; fi + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_LIBRARY=/usr/lib/libpython2.7.so; fi + + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_INCLUDE_DIR=/usr/include/python3.5m; fi + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_LIBRARY=/usr/lib/libpython3.5m.so; fi + - ./travis.sh after_success: diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 83c005437..9f4cef66e 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -11,6 +11,7 @@ set(cfg_options -DCMAKE_C_STANDARD=${C_STANDARD} -DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DBUILD_CFP=${BUILD_CFP} + -DBUILD_PYTHON=${BUILD_PYTHON} -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_OPENMP=${BUILD_OPENMP} -DZFP_WITH_CUDA=${BUILD_CUDA} @@ -37,6 +38,10 @@ if(BUILD_CFP) endif() endif() +if(BUILD_PYTHON) + set(CTEST_SITE "${CTEST_SITE}_python") +endif() + if(BUILD_ZFORP) set(CTEST_SITE "${CTEST_SITE}_zforp") endif() diff --git a/python/test_utils.pyx b/python/test_utils.pyx index 2c33fe04a..360501157 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -403,4 +403,4 @@ cpdef generateStridedRandomNumpyArray( strides=[x for x in strides[:ndim]], ) else: - raise ValueError("Unsupported_config: {|}".format(stride_config)) + raise ValueError("Unsupported_config: {|}".format(stride)) diff --git a/travis.sh b/travis.sh index 28b84a407..346997ece 100755 --- a/travis.sh +++ b/travis.sh @@ -1,23 +1,27 @@ #!/usr/bin/env sh set -e +# pass additional args in $1 (starting with whitespace character) +run_all () { + run_all_cmd="ctest -V -C Debug -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DPYTHON_VERSION=${PYTHON_VERSION} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_EXECUTABLE=${PYTHON_BINARY} -S \"$TRAVIS_BUILD_DIR/cmake/travis.cmake\"" + eval "${run_all_cmd}$1" +} + mkdir build cd build -CTEST_FLAGS="-V -C \"Debug\" -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DBUILD_PYTHON=${BUILD_PYTHON:-off}" - if [ -n "${COVERAGE}" ]; then # build (linux) - ctest ${CTEST_FLAGS} -DBUILD_CFP=ON -DBUILD_ZFORP=ON -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + run_all " -DBUILD_CFP=ON -DBUILD_PYTHON=ON -DBUILD_ZFORP=ON -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON" else - # build/test without OpenMP, with CFP (and custom namespace), with Fortran (linux only) + # build/test without OpenMP, with CFP (and custom namespace), with zfPy, with Fortran (linux only) if [[ "$OSTYPE" == "darwin"* ]]; then BUILD_ZFORP=OFF else BUILD_ZFORP=ON fi - ctest ${CTEST_FLAGS} -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_PYTHON=ON -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" rm -rf ./* ; @@ -26,6 +30,6 @@ else rm -rf ./* ; # build/test with OpenMP - ctest ${CTEST_FLAGS} -DBUILD_OPENMP=ON -S $TRAVIS_BUILD_DIR/cmake/travis.cmake + run_all " -DBUILD_OPENMP=ON" fi fi From df52af441978a095beb49b4b6ee726bb07713511 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 27 Mar 2019 20:26:17 -0700 Subject: [PATCH 128/194] python: split decomp into simple "public" and complex "private" APIs --- python/zfp.pyx | 7 ++++++- tests/python/test_numpy.py | 32 +++++++++++++++----------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index d29d008c4..e5c21b7e5 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -333,7 +333,7 @@ cdef _validate_userinput_matches_header( ) -cpdef np.ndarray decompress_numpy( +cpdef np.ndarray _decompress( bytes compressed_data, out=None, zfp_type ztype=type_none, @@ -418,3 +418,8 @@ cpdef np.ndarray decompress_numpy( stream_close(bstream) return output + +cpdef np.ndarray decompress_numpy( + bytes compressed_data, +): + return _decompress(compressed_data) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index d585ace8a..aa09757d1 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -27,6 +27,7 @@ def test_utils(self): ("interleaved", test_utils.stride_interleaved), #("reversed", test_utils.stride_reversed), ]: + # permuting a 1D array is not supported if stride_config == test_utils.stride_permuted and ndims == 1: continue random_array = test_utils.generateStridedRandomNumpyArray( @@ -67,32 +68,29 @@ def test_utils(self): self.assertEqual(compressed_checksum, actual_checksum) # Decompression - zshape = [int(x) for x in random_array.shape] - decompression_kwargs = dict( - compression_kwargs, - ztype=ztype, - shape=zshape, + decompressed_checksum = test_utils.getChecksumDecompArray( + ndims, + ztype, + mode, + compress_param_num ) - if stride_config == test_utils.stride_permuted: - # test decompressing into a numpy array - # created by the "user" - decompressed_array = np.empty_like(random_array) - decompression_kwargs['out'] = decompressed_array + # Decompression using the "public" interface + # requires a header, so re-compress with the header + # included in the stream + compressed_array = zfp.compress_numpy( + random_array, + write_header=True, + **compression_kwargs + ) decompressed_array = zfp.decompress_numpy( compressed_array, - **decompression_kwargs ) actual_checksum = test_utils.hashNumpyArray( decompressed_array ) - decompressed_checksum = test_utils.getChecksumDecompArray( - ndims, - ztype, - mode, - compress_param_num - ) self.assertEqual(decompressed_checksum, actual_checksum) + if __name__ == "__main__": unittest.main(verbosity=2) From 4870524615d2b2c20fc83f14947168227a4593ba Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 27 Mar 2019 20:51:18 -0700 Subject: [PATCH 129/194] python: add support for lossless compression --- python/zfp.pxd | 1 + python/zfp.pyx | 6 ++---- tests/python/test_numpy.py | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 4 deletions(-) diff --git a/python/zfp.pxd b/python/zfp.pxd index f5bafe6d6..f812aed6d 100644 --- a/python/zfp.pxd +++ b/python/zfp.pxd @@ -46,6 +46,7 @@ cdef extern from "zfp.h": cython.uint zfp_stream_set_precision(zfp_stream* stream, cython.uint precision); double zfp_stream_set_accuracy(zfp_stream* stream, double tolerance); double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, cython.uint dims, int wra); + void zfp_stream_set_reversible(zfp_stream* stream); stdint.uint64_t zfp_stream_mode(const zfp_stream* zfp); zfp_mode zfp_stream_set_mode(zfp_stream* stream, stdint.uint64_t mode); zfp_field* zfp_field_alloc(); diff --git a/python/zfp.pyx b/python/zfp.pyx index e5c21b7e5..3ab76fc39 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -135,9 +135,7 @@ cpdef bytes compress_numpy( if arr is None: raise TypeError("Input array cannot be None") num_params_set = sum([1 for x in [tolerance, rate, precision] if x >= 0]) - if num_params_set == 0: - raise ValueError("Either tolerance, rate, or precision must be set") - elif num_params_set > 1: + if num_params_set > 1: raise ValueError("Only one of tolerance, rate, or precision can be set") # Setup zfp structs to begin compression @@ -223,7 +221,7 @@ cdef _set_compression_mode( elif precision >= 0: zfp_stream_set_precision(stream, precision) else: - raise ValueError("Either tolerance, rate, or precision must be set") + zfp_stream_set_reversible(stream) cdef _validate_4d_list(in_list, list_name): # Validate that the input list is either a valid list for strides or shape diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index aa09757d1..2d8628f21 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -5,9 +5,46 @@ import zfp import test_utils import numpy as np +try: + from packaging.version import parse as version_parse +except ImportError: + version_parse = None class TestNumpy(unittest.TestCase): + def lossless_round_trip(self, orig_array): + compressed_array = zfp.compress_numpy(orig_array, write_header=True) + decompressed_array = zfp.decompress_numpy(compressed_array) + self.assertIsNone(np.testing.assert_array_equal(decompressed_array, orig_array)) + + def test_different_dimensions(self): + for dimensions in range(1, 5): + shape = [5] * dimensions + + c_array = np.random.rand(*shape) + self.lossless_round_trip(c_array) + + + def test_different_dtypes(self): + shape = (5, 5) + num_elements = shape[0] * shape[1] + + for dtype in [np.float32, np.float64]: + elements = np.random.random_sample(num_elements) + elements = elements.astype(dtype, casting="same_kind") + array = np.reshape(elements, newshape=shape) + self.lossless_round_trip(array) + + if (version_parse is not None and + (version_parse(np.__version__) >= version_parse("1.11.0")) + ): + for dtype in [np.int32, np.int64]: + array = np.random.randint(2**30, size=shape, dtype=dtype) + self.lossless_round_trip(array) + else: + array = np.random.randint(2**30, size=shape) + self.lossless_round_trip(array) + def test_utils(self): for ndims in range(1, 5): for ztype, ztype_str in [ From e361949f6bd9743d4a1259f1250db8451434419c Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 27 Mar 2019 22:11:28 -0700 Subject: [PATCH 130/194] python: reverse stride order to optimize for default C-layout --- python/test_utils.pyx | 6 +----- python/zfp.pyx | 14 +++++++------- tests/python/test_numpy.py | 4 +++- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index 360501157..286699175 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -233,11 +233,7 @@ cpdef getRandNumpyArray( else: raise ValueError("Unknown zfp_type: {}".format(ztype)) - np_arr = np.asarray(viewArr) - return np.lib.stride_tricks.as_strided( - np_arr, - strides=reversed(np_arr.strides) - ) + return np.asarray(viewArr) cpdef uint64_t getChecksumOrigArray( int dims, diff --git a/python/zfp.pyx b/python/zfp.pyx index 3ab76fc39..a89a31fd1 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -88,14 +88,14 @@ cdef zfp_field* _init_field(np.ndarray arr): field = zfp_field_1d(pointer, ztype, shape[0]) zfp_field_set_stride_1d(field, strides[0]) elif ndim == 2: - field = zfp_field_2d(pointer, ztype, shape[0], shape[1]) - zfp_field_set_stride_2d(field, strides[0], strides[1]) + field = zfp_field_2d(pointer, ztype, shape[1], shape[0]) + zfp_field_set_stride_2d(field, strides[1], strides[0]) elif ndim == 3: - field = zfp_field_3d(pointer, ztype, shape[0], shape[1], shape[2]) - zfp_field_set_stride_3d(field, strides[0], strides[1], strides[2]) + field = zfp_field_3d(pointer, ztype, shape[2], shape[1], shape[0]) + zfp_field_set_stride_3d(field, strides[2], strides[1], strides[0]) elif ndim == 4: - field = zfp_field_4d(pointer, ztype, shape[0], shape[1], shape[2], shape[3]) - zfp_field_set_stride_4d(field, strides[0], strides[1], strides[2], strides[3]) + field = zfp_field_4d(pointer, ztype, shape[3], shape[2], shape[1], shape[0]) + zfp_field_set_stride_4d(field, strides[3], strides[2], strides[1], strides[0]) else: raise RuntimeError("Greater than 4 dimensions not supported") @@ -178,7 +178,7 @@ cdef view.array _decompress_with_view( dtype = ztype_to_dtype(ztype) format_type = dtype_to_format(dtype) - shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + shape = (field[0].nw, field[0].nz, field[0].ny, field[0].nx) shape = tuple([x for x in shape if x > 0]) cdef view.array decomp_arr = view.array( diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index 2d8628f21..52cab01e9 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -20,10 +20,12 @@ def lossless_round_trip(self, orig_array): def test_different_dimensions(self): for dimensions in range(1, 5): shape = [5] * dimensions - c_array = np.random.rand(*shape) self.lossless_round_trip(c_array) + shape = range(2, 2 + dimensions) + c_array = np.random.rand(*shape) + self.lossless_round_trip(c_array) def test_different_dtypes(self): shape = (5, 5) From 9f2436fffe264dd3a1bbeece357435810a5cd09e Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sat, 30 Mar 2019 11:29:44 -0700 Subject: [PATCH 131/194] docs: add initial python bindings documentation --- docs/source/index.rst | 1 + docs/source/python.rst | 110 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 111 insertions(+) create mode 100644 docs/source/python.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index 4f6dd42dd..7343a6b04 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -18,6 +18,7 @@ low-level-api bit-stream arrays + python tutorial zfpcmd examples diff --git a/docs/source/python.rst b/docs/source/python.rst new file mode 100644 index 000000000..cf7ff4081 --- /dev/null +++ b/docs/source/python.rst @@ -0,0 +1,110 @@ +.. include:: defs.rst +.. _python: + +Python +======================= + +Dependencies +------------ + +Minimum Tested Versions: + +* Python: Python 2.7 & Python 3.5 +* Cython: 0.23.4 +* Numpy: 1.8.0 + +Installation +------------ + +To build the python bindings, add ``-DBUILD_PYTHON=on`` to the cmake line. Cmake +will attempt to automatically detect the python installation to use. If cmake +finds multiple python installations, it will use the newest one. To specify a +specific python installation to use, set ``PYTHON_LIBRARY`` and +``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: + + cmake -DBUILD_PYTHON=on -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. + +Compression +----------- + +.. py:function:: compress_numpy(arr, tolerance = -1, rate = -1, precision = -1, write_header=True) + +Compression through the python bindings currently requires a numpy array +populated with the data to be compressed. The numpy metadata (i.e., shape, +strides, and type) are used to automatically populate ``zfp_field`` structure. +By default, all that is required to be passed to the compression function is the +numpy array; this will result in a stream that includes a header and is +compressed with the ``reversible`` mode. For example:: + + import zfp + import numpy as np + + my_array = np.arange(1, 20) + compressed_data = zfp.compress_numpy(my_array) + decompressed_array = zfp.decompress_numpy(compressed_data) + + # confirm lossless compression/decompression + np.testing.assert_array_equal(my_array, decompressed_array) + +Using the fixed-accuracy, fixed-rate, or fixed-precision modes simply requires +setting one of the tolerance, rate, or precision arguments, respectively. For example:: + + compressed_data = zfp.compress_numpy(my_array, tolerance=1e-4) + decompressed_array = zfp.decompress_numpy(compressed_data) + + # Note the change from "equal" to "allclose" due to the lossy compression + np.testing.assert_allclose(my_array, decompressed_array, atol=1e-3) + +Since numpy arrays are C-ordered by default and ``zfp_compress`` expects the +fastest changing stride to the first (i.e., Fortran-ordering), +``compress_numpy`` automatically flips the reverses the stride in order to +optimize the compression ratio for C-ordered numpy arrays. Since the +``decompress_numpy`` function also reverses the stride order, data both +compressed and decompressed with the python bindings should have the same shape +before and after. + +.. note:: ``decompress_numpy`` requires a header to decompress properly, so do + not use ``write_header=False`` if you intend to decompress the stream with + the python bindings. + +Decompression +------------- + +.. py:function:: decompress_numpy(compressed_data) + +``decompress_numpy`` consumes a compressed stream that includes a header and +produces a numpy array with metadata populated based on the contents of the +header. Stride information is not stored in the zfp header, so the +``decompress_numpy`` function assumes that the array was compressed with the +fastest changing dimension first (typically referred to as Fortran-ordering). +The returned numpy array is in C-ordering (the default for numpy arrays), so the +shape of the returned array is reversed from that of the shape in the +compression header. For example, if the header declares the array to be of +shape (2, 4, 8), then the returned numpy array will have a shape of (8, 4, 2). +Since the ``compress_numpy`` function also reverses the stride order, data both +compressed and decompressed with the python bindings should have the same shape +before and after. + +.. note:: Decompressing a stream without a header requires using the + internal ``_decompress`` python function (or the C API). + +.. py:function:: _decompress(compressed_data, out=None, ztype=type_none, shape=None, strides=[0,0,0,0], tolerance = -1, rate = -1, precision = -1,) + +.. warning:: ``_decompress`` is a function mainly for internal use within the + zfp library. It does allow decompression of streams without + headers, but providing too small of an output bufffer or + incorrectly specifying the shape or strides can result in + segmentation faults. Use with care. + +Decompresses a compressed stream (with or without a header). If a header is +present in the stream, all user-provided metadata is compared against the stream +header metadata, and an exception is thrown if they disagree. If ``out`` is +specified, the data is decompressed into the ``out`` buffer. ``out`` can be a +numpy array or a pointer to memory large enough to hold the decompressed data. +Regardless if ``out`` is provided or its type, ``_decompress`` always returns a +numpy array. If ``out`` is not provided, the array is allocated for the user, +and if ``out`` is provided, then the returned numpy is just a pointer to or +wrapper around the user-supplied ``out``. If ``strides`` is provided, it is +added to the ``zfp_field`` before decompression, but it is not added to the +output numpy array metadata. ``strides`` should be a zfp-style strides (i.e., +number of elements) rather than a numpy-style strides (i.e., number of bytes). From a1285d23de2c30dbce3714687887da3a47cd1ee5 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Sun, 31 Mar 2019 17:15:02 -0700 Subject: [PATCH 132/194] python: fix checksum tests for permuted and interleaved flipping the strides in the `compress_numpy` function means we have to provide to numpy the reversed of how we actually want the data compressed --- python/test_utils.pyx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/test_utils.pyx b/python/test_utils.pyx index 286699175..e7ed77e06 100644 --- a/python/test_utils.pyx +++ b/python/test_utils.pyx @@ -372,7 +372,7 @@ cpdef generateStridedRandomNumpyArray( return np.lib.stride_tricks.as_strided( output_array, shape=[x for x in dims[:ndim]], - strides=[x for x in strides[:ndim]], + strides=reversed([x for x in strides[:ndim]]), ) elif stride == INTERLEAVED: @@ -396,7 +396,7 @@ cpdef generateStridedRandomNumpyArray( return np.lib.stride_tricks.as_strided( output_array, shape=shape, - strides=[x for x in strides[:ndim]], + strides=reversed([x for x in strides[:ndim]]), ) else: raise ValueError("Unsupported_config: {|}".format(stride)) From fb127f6b6e595a66e8a79f35aa4c93016c902a27 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 1 Apr 2019 11:51:13 -0700 Subject: [PATCH 133/194] python: remove dependency on the 'six' python package --- python/zfp.pyx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index a89a31fd1..7868105fe 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -1,4 +1,4 @@ -import six +import sys import operator import functools import cython @@ -8,9 +8,9 @@ from cpython cimport array import array import itertools -if six.PY2: +if sys.version_info[0] == 2: from itertools import izip_longest as zip_longest -elif six.PY3: +elif sys.version_info[0] == 3: from itertools import zip_longest cimport zfp From 657b140b5cf82b77081f3aa644cc312d08f6b115 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 1 Apr 2019 13:03:45 -0700 Subject: [PATCH 134/194] python: add requirements.txt for py dependencies --- .travis.yml | 4 +--- docs/source/python.rst | 7 ++++++- python/requirements.txt | 3 +++ 3 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 python/requirements.txt diff --git a/.travis.yml b/.travis.yml index 21e5f6cb0..8925f754c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -264,9 +264,7 @@ script: - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5; fi - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install --upgrade pip; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install Cython; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install numpy; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install six; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install -r ${TRAVIS_BUILD_DIR}/python/requirements.txt; fi - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PYTHON_BINARY=/usr/bin/python$PYTHON_VERSION; fi diff --git a/docs/source/python.rst b/docs/source/python.rst index cf7ff4081..64a1c2fe3 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -10,9 +10,14 @@ Dependencies Minimum Tested Versions: * Python: Python 2.7 & Python 3.5 -* Cython: 0.23.4 +* Cython: 0.22 * Numpy: 1.8.0 +You can install the necessary dependencies using ``pip`` and the zfp +``requirements.txt``:: + + pip install -r $ZFP_ROOT/python/requirements.txt + Installation ------------ diff --git a/python/requirements.txt b/python/requirements.txt new file mode 100644 index 000000000..7f3612988 --- /dev/null +++ b/python/requirements.txt @@ -0,0 +1,3 @@ +cython>=0.22 +numpy>=1.8.0 + From 00c813395b9607ff641f1e5e54a175d75cc9eeed Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 1 Apr 2019 14:09:08 -0700 Subject: [PATCH 135/194] travis: attempt to fix python builds --- .travis.yml | 73 ++++++++++++++++++++++++++++++---------------- cmake/travis.cmake | 5 ++++ travis.sh | 2 +- 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8925f754c..3f4f5de17 100644 --- a/.travis.yml +++ b/.travis.yml @@ -121,8 +121,7 @@ matrix: - g++-5 - gfortran-5 - libpython2.7 - - cython - - python-numpy + - python-pip env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' PYTHON_VERSION='2.7' - os: linux @@ -136,8 +135,7 @@ matrix: - g++-6 - gfortran-6 - libpython2.7 - - cython - - python-numpy + - python-pip env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='2.7' - os: linux @@ -251,29 +249,54 @@ matrix: env: CC='clang' CXX='clang++' PYTHON_VERSION='2.7' script: - - if [ "$TRAVIS_OS_NAME" = "osx" ]; then pyenv root; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then pyenv install 2.7.12; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then pyenv install 3.5.0; fi + - if [ "$TRAVIS_OS_NAME" == "osx" ]; then pyenv root; fi + - | + if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then + pyenv install 2.7.12; + export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/2.7.12/include/python2.7; + export PYTHON_LIBRARY=$(pyenv root)/versions/2.7.12/lib/libpython2.7.dylib; + export PYTHON_EXECUTABLE=$(pyenv root)/versions/2.7.12/bin/python2.7; + fi + - | + if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then + pyenv install 3.5.0; + export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/3.5.0/include/python3.5m; + export PYTHON_LIBRARY=$(pyenv root)/versions/3.5.0/lib/libpython3.5m.a; + export PYTHON_EXECUTABLE=$(pyenv root)/versions/3.5.0/bin/python3.5m; + fi + - | + if [ "$TRAVIS_OS_NAME" == "osx" ]; then + $PYTHON_EXECUTABLE -m pip install --upgrade pip; + $PYTHON_EXECUTABLE -m pip install -r ${TRAVIS_BUILD_DIR}/python/requirements.txt; + fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/2.7.12/include/python2.7; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_LIBRARY=$(pyenv root)/versions/2.7.12/lib/libpython2.7.dylib; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_BINARY=$(pyenv root)/versions/2.7.12/bin/python2.7; fi - - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_INCLUDE_DIR=$(pyenv root)/versions/3.5.0/include/python3.5m; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_LIBRARY=$(pyenv root)/versions/3.5.0/lib/libpython3.dylib; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_BINARY=$(pyenv root)/versions/3.5.0/bin/python3.5; fi - - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install --upgrade pip; fi - - if [ "$TRAVIS_OS_NAME" == "osx" ]; then $PYTHON_BINARY -m pip install -r ${TRAVIS_BUILD_DIR}/python/requirements.txt; fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ]; then export PYTHON_BINARY=/usr/bin/python$PYTHON_VERSION; fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_INCLUDE_DIR=/usr/include/python2.7; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "2.7" ]; then export PYTHON_LIBRARY=/usr/lib/libpython2.7.so; fi - - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_INCLUDE_DIR=/usr/include/python3.5m; fi - - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "3.5" ]; then export PYTHON_LIBRARY=/usr/lib/libpython3.5m.so; fi + - | + if [ "$TRAVIS_OS_NAME" = "linux" ]; then + export PYTHON_EXECUTABLE=/usr/bin/python$PYTHON_VERSION; + source /etc/lsb-release; + fi + - | + if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "2.7" ]; then + export PYTHON_INCLUDE_DIR=/usr/include/python2.7; + export PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython2.7.so; + fi + - | + if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$PYTHON_VERSION" = "3.5" ]; then + export PYTHON_INCLUDE_DIR=/usr/include/python3.5m; + export PYTHON_LIBRARY=/usr/lib/x86_64-linux-gnu/libpython3.5m.so; + fi + - | + if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DISTRIB_CODENAME" = "trusty" ] && [ "$PYTHON_VERSION" = "2.7" ]; then + sudo $PYTHON_EXECUTABLE -m pip install --upgrade pip; + sudo $PYTHON_EXECUTABLE -m pip install -r ${TRAVIS_BUILD_DIR}/python/requirements.txt; + fi + - | + if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$DISTRIB_CODENAME" = "trusty" ] && [ "$PYTHON_VERSION" = "3.5" ]; then + echo "Python 3.5 not supported on Ubuntu Trusty"; + exit 1; + fi + - printenv | grep PYTHON - ./travis.sh after_success: diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 9f4cef66e..6d5ab5f7b 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -40,6 +40,11 @@ endif() if(BUILD_PYTHON) set(CTEST_SITE "${CTEST_SITE}_python") + list(APPEND cfg_options + -DPYTHON_INCLUDE_DIR=$ENV{PYTHON_INCLUDE_DIR} + -DPYTHON_LIBRARY=$ENV{PYTHON_LIBRARY} + -DPYTHON_EXECUTABLE=$ENV{PYTHON_EXECUTABLE} + ) endif() if(BUILD_ZFORP) diff --git a/travis.sh b/travis.sh index 346997ece..f71aa9153 100755 --- a/travis.sh +++ b/travis.sh @@ -3,7 +3,7 @@ set -e # pass additional args in $1 (starting with whitespace character) run_all () { - run_all_cmd="ctest -V -C Debug -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -DPYTHON_VERSION=${PYTHON_VERSION} -DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY=${PYTHON_LIBRARY} -DPYTHON_EXECUTABLE=${PYTHON_BINARY} -S \"$TRAVIS_BUILD_DIR/cmake/travis.cmake\"" + run_all_cmd="ctest -V -C Debug -DC_STANDARD=${C_STANDARD:-99} -DCXX_STANDARD=${CXX_STANDARD:-98} -S \"$TRAVIS_BUILD_DIR/cmake/travis.cmake\"" eval "${run_all_cmd}$1" } From 6d68fb3c90066202408044cf4c75106962928d93 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 3 Apr 2019 21:40:08 -0700 Subject: [PATCH 136/194] python: reverse shapes and strides in `_decompress` add unittests for this funcionality --- python/zfp.pyx | 10 +++---- tests/python/test_numpy.py | 61 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/python/zfp.pyx b/python/zfp.pyx index 7868105fe..36f481940 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -260,7 +260,7 @@ cdef _validate_userinput_matches_header( ) # check that the header and user shapes match - header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = (field[0].nw, field[0].nz, field[0].ny, field[0].nx) header_shape = [x for x in header_shape if x > 0] if shape is not None: if not all([x == y for x, y in zip_longest(shape, header_shape)]): @@ -316,7 +316,7 @@ cdef _validate_userinput_matches_header( ) # check that numpy and header shape match - numpy_shape = [int(x) for x in out.shape[:ndim]] + numpy_shape = out.shape if not all( [x == y for x, y in zip_longest(numpy_shape, header_shape) @@ -369,7 +369,7 @@ cpdef np.ndarray _decompress( "Failed to read zfp header and the ztype/shape/mode " "were not provided" ) - zshape = gen_padded_int_list(shape, pad=0, length=4) + zshape = gen_padded_int_list(reversed(shape), pad=0, length=4) # set the shape, type, and compression mode # strides are set further down field[0].nx, field[0].ny, field[0].nz, field[0].nw = zshape @@ -392,7 +392,7 @@ cpdef np.ndarray _decompress( ) # pad the shape with zeros to reach len == 4 - strides = gen_padded_int_list(strides, pad=0, length=4) + strides = gen_padded_int_list(reversed(strides), pad=0, length=4) field[0].sx, field[0].sy, field[0].sz, field[0].sw = strides if out is None: @@ -402,7 +402,7 @@ cpdef np.ndarray _decompress( output = out else: header_dtype = ztype_to_dtype(field[0]._type) - header_shape = (field[0].nx, field[0].ny, field[0].nz, field[0].nw) + header_shape = (field[0].nw, field[0].nz, field[0].ny, field[0].nx) header_shape = [x for x in header_shape if x > 0] output = np.frombuffer(out, dtype=header_dtype) diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index 52cab01e9..8d671a773 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -47,6 +47,67 @@ def test_different_dtypes(self): array = np.random.randint(2**30, size=shape) self.lossless_round_trip(array) + def test_advanced_decompression_checksum(self): + ndims = 2 + ztype = zfp.type_float + random_array = test_utils.getRandNumpyArray(ndims, ztype) + mode = zfp.mode_fixed_accuracy + compress_param_num = 1 + compression_kwargs = { + "tolerance": test_utils.computeParameterValue( + mode, + compress_param_num + ), + } + compressed_array = zfp.compress_numpy( + random_array, + write_header=False, + **compression_kwargs + ) + + # Decompression using the "advanced" interface requires no header, + # but the user must provide all the metadata + decompressed_array = np.empty_like(random_array) + zfp._decompress( + compressed_array, + out=decompressed_array, + ztype=ztype, + shape=random_array.shape, + **compression_kwargs + ) + decompressed_checksum = test_utils.getChecksumDecompArray( + ndims, + ztype, + mode, + compress_param_num + ) + actual_checksum = test_utils.hashNumpyArray( + decompressed_array + ) + self.assertEqual(decompressed_checksum, actual_checksum) + + def test_advanced_decompression_nonsquare(self): + for dimensions in range(1, 5): + shape = range(2, 2 + dimensions) + random_array = np.random.rand(*shape) + + decompressed_array = np.empty_like(random_array) + decompression_kwargs = { + "out": decompressed_array, + "shape": random_array.shape, + "ztype": zfp.dtype_to_ztype(random_array.dtype), + } + for header in [True, False]: + compressed_array = zfp.compress_numpy( + random_array, + write_header=header + ) + zfp._decompress( + compressed_array, + **decompression_kwargs + ) + self.assertIsNone(np.testing.assert_array_equal(decompressed_array, random_array)) + def test_utils(self): for ndims in range(1, 5): for ztype, ztype_str in [ From 90b1d7dca2f0c143e8aaa0cdad6ac15f05c196b7 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 3 Apr 2019 21:54:31 -0700 Subject: [PATCH 137/194] python: throw exception if `zfp_compress` returns 0 --- python/zfp.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/zfp.pyx b/python/zfp.pyx index 36f481940..573645b46 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -161,6 +161,8 @@ cpdef bytes compress_numpy( raise RuntimeError("Failed to write header to stream") with nogil: compressed_size = zfp_compress(stream, field) + if compressed_size == 0: + raise RuntimeError("Failed to write to stream") # copy the compressed data into a perfectly sized bytes object compress_str = (data)[:compressed_size] finally: From 7c11b63a4391d4389c66254c08dda82f630d6803 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Wed, 3 Apr 2019 21:55:07 -0700 Subject: [PATCH 138/194] docs/python: add py:module:: zfp --- docs/source/python.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/python.rst b/docs/source/python.rst index 64a1c2fe3..0a0659d37 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -4,6 +4,8 @@ Python ======================= +.. py:module:: zfp + Dependencies ------------ From 8d612d8b50c845ae5d34a1c3b7860e499a052279 Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 8 Apr 2019 12:42:30 -0700 Subject: [PATCH 139/194] refactor _decompress to assume that no header is present The associated metadata (ztype and shape) are now required arguments. There is no longer an attempt to read the header, and thus there is no validation of user-provided metadata against header metadata. Remove strides since they aren't test and aren't fully working. --- docs/source/python.rst | 38 +++++---- python/zfp.pyx | 161 ++++++++----------------------------- tests/python/test_numpy.py | 34 ++++---- 3 files changed, 67 insertions(+), 166 deletions(-) diff --git a/docs/source/python.rst b/docs/source/python.rst index 0a0659d37..28b5519e8 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -95,23 +95,21 @@ before and after. .. note:: Decompressing a stream without a header requires using the internal ``_decompress`` python function (or the C API). -.. py:function:: _decompress(compressed_data, out=None, ztype=type_none, shape=None, strides=[0,0,0,0], tolerance = -1, rate = -1, precision = -1,) - -.. warning:: ``_decompress`` is a function mainly for internal use within the - zfp library. It does allow decompression of streams without - headers, but providing too small of an output bufffer or - incorrectly specifying the shape or strides can result in - segmentation faults. Use with care. - -Decompresses a compressed stream (with or without a header). If a header is -present in the stream, all user-provided metadata is compared against the stream -header metadata, and an exception is thrown if they disagree. If ``out`` is -specified, the data is decompressed into the ``out`` buffer. ``out`` can be a -numpy array or a pointer to memory large enough to hold the decompressed data. -Regardless if ``out`` is provided or its type, ``_decompress`` always returns a -numpy array. If ``out`` is not provided, the array is allocated for the user, -and if ``out`` is provided, then the returned numpy is just a pointer to or -wrapper around the user-supplied ``out``. If ``strides`` is provided, it is -added to the ``zfp_field`` before decompression, but it is not added to the -output numpy array metadata. ``strides`` should be a zfp-style strides (i.e., -number of elements) rather than a numpy-style strides (i.e., number of bytes). +.. py:function:: _decompress(compressed_data, ztype, shape, out=None, tolerance = -1, rate = -1, precision = -1,) + +.. warning:: ``_decompress`` is an "experimental" function currently used + internally for testing the . It does allow decompression of + streams without headers, but providing too small of an output + bufffer or incorrectly specifying the shape or strides can result + in segmentation faults. Use with care. + +Decompresses a compressed stream without a header. If a header is present in +the stream, it will be incorrectly interpreted as compressed data. ``ztype`` is +a ``zfp_type``, which can be manually specified (e.g., ``zfp.type_int32``) or +generated from a numpy dtype (e.g., ``zfp.dtype_to_ztype(array.dtype)``). If +``out`` is specified, the data is decompressed into the ``out`` buffer. ``out`` +can be a numpy array or a pointer to memory large enough to hold the +decompressed data. Regardless if ``out`` is provided or its type, +``_decompress`` always returns a numpy array. If ``out`` is not provided, the +array is allocated for the user, and if ``out`` is provided, then the returned +numpy is just a pointer to or wrapper around the user-supplied ``out``. diff --git a/python/zfp.pyx b/python/zfp.pyx index 573645b46..e673f6ec5 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -244,101 +244,11 @@ cdef _validate_4d_list(in_list, list_name): "User-provided {} is not an iterable" ) -cdef _validate_userinput_matches_header( - zfp_field* field, - zfp_stream* stream, - out, - zfp_type ztype, - shape, - strides, - double tolerance, - double rate, - int precision -): - # check that the header and user type matches - if ztype != type_none and ztype is not field[0]._type: - raise ValueError( - "User-provided zfp_type does not match zfp_type in header" - ) - - # check that the header and user shapes match - header_shape = (field[0].nw, field[0].nz, field[0].ny, field[0].nx) - header_shape = [x for x in header_shape if x > 0] - if shape is not None: - if not all([x == y for x, y in zip_longest(shape, header_shape)]): - raise ValueError( - "User-provided shape does not match shape in header" - ) - - # check that the shape and strides have the same number of dimensions - if shape is not None and sum(strides) > 0: - stride_dims = sum([1 for x in strides if x > 0]) - shape_dims = sum([1 for x in shape if x > 0]) - if len(strides) != len(shape): - raise ValueError( - "Mis-match in shape and stride lengths" - ) - - # check that setting the compression parameters based on user input - # does not change the stream mode (i.e., the compression parameters - # provided by the user and in the header match) - if tolerance >= 0 or rate >= 0 or precision >= 0: - header_mode = zfp_stream_mode(stream) - ndim = len(header_shape) - _set_compression_mode( - stream, - ztype, - ndim, - tolerance, - rate, - precision - ) - mode = zfp_stream_mode(stream) - if mode != mode_null and mode != header_mode: - raise ValueError( - "User-provided zfp_mode {} does not match zfp_mode " - "in header {}".format( - mode, - header_mode, - ) - ) - - # if the out buffer is a numpy array, check that it's properties match the - # header metadata - if out is not None and isinstance(out, np.ndarray): - # check that numpy and header types match - header_dtype = ztype_to_dtype(field[0]._type) - if out.dtype != header_dtype: - raise ValueError( - "Out ndarray has dtype {} but decompression is using " - "{}".format( - out.dtype, - header_dtype - ) - ) - - # check that numpy and header shape match - numpy_shape = out.shape - if not all( - [x == y for x, y in - zip_longest(numpy_shape, header_shape) - ] - ): - raise ValueError( - "Out ndarray has shape {} but decompression is using " - "{}".format( - numpy_shape, - header_shape - ) - ) - - cpdef np.ndarray _decompress( bytes compressed_data, + zfp_type ztype, + shape, out=None, - zfp_type ztype=type_none, - shape=None, - strides=[0,0,0,0], double tolerance = -1, double rate = -1, int precision = -1, @@ -348,10 +258,7 @@ cpdef np.ndarray _decompress( raise TypeError("compressed_data cannot be None") if compressed_data is out: raise ValueError("Cannot decompress in-place") - if shape is not None: - _validate_4d_list(shape, "shape") - if strides is not None: - _validate_4d_list(strides, "strides") + _validate_4d_list(shape, "shape") cdef char* comp_data_pointer = compressed_data cdef zfp_field* field = zfp_field_alloc() @@ -364,38 +271,17 @@ cpdef np.ndarray _decompress( try: zfp_stream_rewind(stream) - if zfp_read_header(stream, field, HEADER_FULL) == 0: - zfp_stream_rewind(stream) - if ztype == type_none or shape is None: - raise ValueError( - "Failed to read zfp header and the ztype/shape/mode " - "were not provided" - ) - zshape = gen_padded_int_list(reversed(shape), pad=0, length=4) - # set the shape, type, and compression mode - # strides are set further down - field[0].nx, field[0].ny, field[0].nz, field[0].nw = zshape - zfp_field_set_type(field, ztype) - ndim = sum([1 for x in zshape if x > 0]) - _set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) - else: - # zfp_read_header should have taken care of setting the metadata - # correctly, but check that user inputs match the header - _validate_userinput_matches_header( - field, - stream, - out, - ztype, - shape, - strides, - tolerance, - rate, - precision - ) + zshape = gen_padded_int_list(reversed(shape), pad=0, length=4) + # set the shape, type, and compression mode + # strides are set further down + field[0].nx, field[0].ny, field[0].nz, field[0].nw = zshape + zfp_field_set_type(field, ztype) + ndim = sum([1 for x in zshape if x > 0]) + _set_compression_mode(stream, ztype, ndim, tolerance, rate, precision) # pad the shape with zeros to reach len == 4 - strides = gen_padded_int_list(reversed(strides), pad=0, length=4) - field[0].sx, field[0].sy, field[0].sz, field[0].sw = strides + # strides = gen_padded_int_list(reversed(strides), pad=0, length=4) + # field[0].sx, field[0].sy, field[0].sz, field[0].sw = strides if out is None: output = np.asarray(_decompress_with_view(field, stream)) @@ -422,4 +308,25 @@ cpdef np.ndarray _decompress( cpdef np.ndarray decompress_numpy( bytes compressed_data, ): - return _decompress(compressed_data) + if compressed_data is None: + raise TypeError("compressed_data cannot be None") + + cdef char* comp_data_pointer = compressed_data + cdef zfp_field* field = zfp_field_alloc() + cdef bitstream* bstream = stream_open( + comp_data_pointer, + len(compressed_data) + ) + cdef zfp_stream* stream = zfp_stream_open(bstream) + cdef np.ndarray output + + try: + if zfp_read_header(stream, field, HEADER_FULL) == 0: + raise ValueError("Failed to read required zfp header") + output = np.asarray(_decompress_with_view(field, stream)) + finally: + zfp_field_free(field) + zfp_stream_close(stream) + stream_close(bstream) + + return output diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index 8d671a773..4443e76ba 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -65,14 +65,14 @@ def test_advanced_decompression_checksum(self): **compression_kwargs ) - # Decompression using the "advanced" interface requires no header, - # but the user must provide all the metadata + # Decompression using the "advanced" interface which enforces no header, + # and the user must provide all the metadata decompressed_array = np.empty_like(random_array) zfp._decompress( compressed_array, + ztype, + random_array.shape, out=decompressed_array, - ztype=ztype, - shape=random_array.shape, **compression_kwargs ) decompressed_checksum = test_utils.getChecksumDecompArray( @@ -92,21 +92,17 @@ def test_advanced_decompression_nonsquare(self): random_array = np.random.rand(*shape) decompressed_array = np.empty_like(random_array) - decompression_kwargs = { - "out": decompressed_array, - "shape": random_array.shape, - "ztype": zfp.dtype_to_ztype(random_array.dtype), - } - for header in [True, False]: - compressed_array = zfp.compress_numpy( - random_array, - write_header=header - ) - zfp._decompress( - compressed_array, - **decompression_kwargs - ) - self.assertIsNone(np.testing.assert_array_equal(decompressed_array, random_array)) + compressed_array = zfp.compress_numpy( + random_array, + write_header=False, + ) + zfp._decompress( + compressed_array, + zfp.dtype_to_ztype(random_array.dtype), + random_array.shape, + out= decompressed_array, + ) + self.assertIsNone(np.testing.assert_array_equal(decompressed_array, random_array)) def test_utils(self): for ndims in range(1, 5): From 8d64d049ba3e2f612d8b5206e1e43f2b00de277f Mon Sep 17 00:00:00 2001 From: Stephen Herbein Date: Mon, 8 Apr 2019 15:42:40 -0700 Subject: [PATCH 140/194] python: re-add comparison of output metadata against user-provided --- docs/source/python.rst | 6 +++++- python/zfp.pyx | 35 +++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/docs/source/python.rst b/docs/source/python.rst index 28b5519e8..0806ff10d 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -112,4 +112,8 @@ can be a numpy array or a pointer to memory large enough to hold the decompressed data. Regardless if ``out`` is provided or its type, ``_decompress`` always returns a numpy array. If ``out`` is not provided, the array is allocated for the user, and if ``out`` is provided, then the returned -numpy is just a pointer to or wrapper around the user-supplied ``out``. +numpy is just a pointer to or wrapper around the user-supplied ``out``. If +``out`` is a numpy array, then the shape and type of the numpy array must match +the required arguments ``shape`` and ``ztype``. If you want to avoid this +constraint check, use ``out=ndarray.data`` rather than ``out=ndarray`` when +calling ``_decompress``. diff --git a/python/zfp.pyx b/python/zfp.pyx index e673f6ec5..d0e4f3305 100644 --- a/python/zfp.pyx +++ b/python/zfp.pyx @@ -286,15 +286,38 @@ cpdef np.ndarray _decompress( if out is None: output = np.asarray(_decompress_with_view(field, stream)) else: + dtype = zfp.ztype_to_dtype(ztype) if isinstance(out, np.ndarray): output = out - else: - header_dtype = ztype_to_dtype(field[0]._type) - header_shape = (field[0].nw, field[0].nz, field[0].ny, field[0].nx) - header_shape = [x for x in header_shape if x > 0] - output = np.frombuffer(out, dtype=header_dtype) - output = output.reshape(header_shape) + # check that numpy and user-provided types match + if out.dtype != dtype: + raise ValueError( + "Out ndarray has dtype {} but decompression is using " + "{}. Use out=ndarray.data to avoid this check.".format( + out.dtype, + dtype + ) + ) + + # check that numpy and user-provided shape match + numpy_shape = out.shape + user_shape = [x for x in shape if x > 0] + if not all( + [x == y for x, y in + zip_longest(numpy_shape, user_shape) + ] + ): + raise ValueError( + "Out ndarray has shape {} but decompression is using " + "{}. Use out=ndarray.data to avoid this check.".format( + numpy_shape, + user_shape + ) + ) + else: + output = np.frombuffer(out, dtype=dtype) + output = output.reshape(shape) _decompress_with_user_array(field, stream, output.data) From 76beb76d0ead9a613204acf9ddea82d6ebb17686 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 31 Mar 2019 17:27:43 -0700 Subject: [PATCH 141/194] Update documentation for 0.5.5 release --- LICENSE | 4 ++-- README.md | 24 +++++++++++++----------- VERSIONS.md | 20 ++++++++++++++++++++ docs/source/algorithm.rst | 32 +++++++++++++++++++------------- docs/source/conf.py | 2 +- docs/source/disclaimer.inc | 8 ++++++++ docs/source/execution.rst | 25 ++++++++++++++++--------- docs/source/high-level-api.rst | 15 +++++++++++++++ docs/source/introduction.rst | 4 +++- docs/source/license.rst | 4 ++-- docs/source/limitations.rst | 13 ++++++++++--- docs/source/tutorial.rst | 28 +++++++++++++++++----------- docs/source/versions.rst | 23 ++++++++++++++++++++++- docs/source/zfpcmd.rst | 25 +++++++++++++------------ 14 files changed, 161 insertions(+), 66 deletions(-) create mode 100644 docs/source/disclaimer.inc diff --git a/LICENSE b/LICENSE index 7945102e8..093449a33 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ -Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC. Produced at the Lawrence Livermore National Laboratory. -Written by Peter Lindstrom, Markus Salasoo, and Matt Larsen. +Written by Peter Lindstrom, Markus Salasoo, Matt Larsen, and Stephen Herbein. LLNL-CODE-663824. All rights reserved. diff --git a/README.md b/README.md index b84e777c8..761bf8d0c 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ zfp is an open source C/C++ library for compressed numerical arrays that support high throughput read and write random access. zfp also supports streaming compression of integer and floating-point data, e.g., for applications that read and write large data sets to and from disk. +zfp is primarily written in C and C++ but also includes Python and +Fortran bindings. zfp was developed at Lawrence Livermore National Laboratory and is loosely based on the algorithm described in the following paper: @@ -21,12 +23,11 @@ based on the algorithm described in the following paper: doi:10.1109/TVCG.2014.2346458 zfp was originally designed for floating-point arrays only, but has been -extended to also support integer data, and could for instance be used to +extended to also support integer data and could for instance be used to compress images and quantized volumetric data. To achieve high compression -ratios, zfp uses lossy but optionally error-bounded compression. Although -bit-for-bit lossless compression of floating-point data is not always -possible, zfp is usually accurate to within machine epsilon in near-lossless -mode. +ratios, zfp generally uses lossy but optionally error-bounded compression. +Bit-for-bit lossless compression is also possible through one of zfp's +compression modes. zfp works best for 2D and 3D arrays that exhibit spatial correlation, such as continuous fields from physics simulations, images, regularly sampled terrain @@ -34,7 +35,8 @@ surfaces, etc. Although zfp also provides a 1D array class that can be used for 1D signals such as audio, or even unstructured floating-point streams, the compression scheme has not been well optimized for this use case, and rate and quality may not be competitive with floating-point compressors -designed specifically for 1D streams. +designed specifically for 1D streams. zfp also supports compression of +4D arrays. zfp is freely available as open source under a BSD license, as outlined in the file 'LICENSE'. For more information on zfp and comparisons with other @@ -48,9 +50,9 @@ DOCUMENTATION ------------- Full -[documentation](http://zfp.readthedocs.io/en/release0.5.4/) +[documentation](http://zfp.readthedocs.io/en/release0.5.5/) is available online via Read the Docs. A -[PDF](http://readthedocs.org/projects/zfp/downloads/pdf/release0.5.4/) +[PDF](http://readthedocs.org/projects/zfp/downloads/pdf/release0.5.5/) version is also available. @@ -77,14 +79,14 @@ zfp has successfully been built and tested using these compilers: MinGW version 5.3.0 Visual Studio versions 14 (2015), 15 (2017) -zfp conforms to various language standards, including C89, C99, C++98, -C++11, and C++14. +zfp conforms to various language standards, including C89, C99, C11, +C++98, C++11, and C++14. NOTE: zfp requires 64-bit compiler and operating system support. ## GNU builds -To compile zfp using gcc, type +To build zfp using gcc, type make diff --git a/VERSIONS.md b/VERSIONS.md index 1a33ff9aa..e4d781aa3 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,5 +1,25 @@ # zfp Release Notes +## 0.5.5 (March 31, 2019) + +- Added support for reversible (lossless) compression of floating-point and + integer data. + +- Added methods for serializing and deserializing zfp's compressed arrays. + +- Added Python bindings for compressing numpy arrays. + +- Added Fortran bindings to zfp's high-level C API. + +- Bug fixes: + - Incorrect handling of execution policy in zfp utility. + - Incorrect handling of decompression via header in zfp utility. + - Tests for failing mallocs. + - CMake installation of CFP when built. + - zfp\_write\_header and zfp\_field\_metadata now fail if array dimensions + are too large to fit in header. + + ## 0.5.4 (October 1, 2018) - Added support for CUDA fixed-rate compression and decompression. diff --git a/docs/source/algorithm.rst b/docs/source/algorithm.rst index abd4388f9..5c8b80f3a 100644 --- a/docs/source/algorithm.rst +++ b/docs/source/algorithm.rst @@ -61,8 +61,13 @@ purposes): 5. The two's complement signed integers are converted to their negabinary (base negative two) representation using one addition and one bit-wise - exclusive or per integer. Because negabinary has no dedicated single - sign bit, these integers are subsequently treated as unsigned. + exclusive or per integer. Because negabinary has no single dedicated + sign bit, these integers are subsequently treated as unsigned. Unlike + sign-magnitude representations, the leftmost one-bit in negabinary + simultaneously encodes the sign and approximate magnitude of a number. + Moreover, unlike two's complement, numbers small in magnitude have many + leading zeros in negabinary regardless of sign, which facilitates + encoding. 6. The bits that represent the list of |4powd| integers are transposed so that instead of being ordered by coefficient they are ordered by bit @@ -75,23 +80,24 @@ purposes): 7. The transform coefficients are compressed losslessly using embedded coding by exploiting the property that the coefficients tend to have many leading zeros that need not be encoded explicitly. Each bit plane is - encoded in two parts, from lowest to highest bit. First the *n* lowest - bits are emitted verbatim, where *n* depends on previous bit planes and - is initially zero. Then a variable-length representation of the remaining - |4powd| |minus| *n* bits, *x*, is encoded. For such an integer *x*, a single - bit is emitted to indicate if *x* = 0, in which case we are done with the - current bit plane. If not, then bits of *x* are emitted, starting from - the lowest bit, until a one-bit is emitted. This triggers another test - whether this is the highest set bit of *x*, and the result of this test - is output as a single bit. If not, then the procedure repeats until all - *m* of *x*'s value bits have been output, where + encoded in two parts, from lowest to highest bit. First, the *n* lowest + bits are emitted verbatim, where *n* is the smallest number such that + the |4powd| |minus| *n* highest bits in all previous bit planes are all + zero. Initially, *n* = 0. Then, a variable-length representation of the + remaining |4powd| |minus| *n* bits, *x*, is encoded. For such an integer + *x*, a single bit is emitted to indicate if *x* = 0, in which case we are + done with the current bit plane. If not, then bits of *x* are emitted, + starting from the lowest bit, until a one-bit is emitted. This triggers + another test whether this is the highest set bit of *x*, and the result + of this test is output as a single bit. If not, then the procedure + repeats until all *m* of *x*'s value bits have been output, where 2\ :sup:`m-1` |leq| *x* < 2\ :sup:`m`. This can be thought of as a run-length encoding of the zeros of *x*, where the run lengths are expressed in unary. The total number of value bits, *n*, in this bit plane is then incremented by *m* before being passed to the next bit plane, which is encoded by first emitting its *n* lowest bits. The assumption is that these bits correspond to *n* coefficients whose most - significant bits have already been output, i.e. these *n* bits are + significant bits have already been output, i.e., these *n* bits are essentially random and not compressible. Following this, the remaining |4powd| |minus| *n* bits of the bit plane are run-length encoded as described above, which potentially results in *n* being increased. diff --git a/docs/source/conf.py b/docs/source/conf.py index 8d008b064..6d31521be 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -56,7 +56,7 @@ # The short X.Y version. version = u'0.5' # The full version, including alpha/beta/rc tags. -release = u'0.5.4' +release = u'0.5.5' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/source/disclaimer.inc b/docs/source/disclaimer.inc new file mode 100644 index 000000000..4745f5edc --- /dev/null +++ b/docs/source/disclaimer.inc @@ -0,0 +1,8 @@ +.. note:: + In multidimensional arrays, the order in which dimensions are specified + is important. In |zfp|, the memory layout convention is such that *x* + varies faster than *y*, which varies faster than *z*, and hence *x* should + map to the innermost (rightmost) array dimension in a C array and to the + leftmost dimension in a Fortran array. Getting the order of dimensions + right is crucial for good compression and accuracy. See the discussion of + :ref:`dimensions and strides ` for further information. diff --git a/docs/source/execution.rst b/docs/source/execution.rst index bb93dd066..1137a3ee5 100644 --- a/docs/source/execution.rst +++ b/docs/source/execution.rst @@ -222,11 +222,14 @@ The source code for the |zfpcmd| command-line tool includes further examples on how to set the execution policy. To use parallel compression and decompression in this tool, see the :option:`-x` command-line option. -Note: As of |zfp| |cudarelease|, the execution policy refers to both -compression and decompression. The OpenMP implementation does not -yet support decompression, and hence :c:func:`zfp_decompress` will -fail if the execution policy is not reset to :code:`zfp_exec_serial` -before calling the decompressor. +.. note:: + As of |zfp| |cudarelease|, the execution policy refers to both + compression and decompression. The OpenMP implementation does not + yet support decompression, and hence :c:func:`zfp_decompress` will + fail if the execution policy is not reset to :code:`zfp_exec_serial` + before calling the decompressor. Similarly, the CUDA implementation + supports only fixed-rate mode and will fail if other compression modes + are specified. The following table summarizes which execution policies are supported with which :ref:`compression modes `: @@ -236,15 +239,19 @@ with which :ref:`compression modes `: +===============+=================+========+========+======+ | | fixed rate | x | x | x | | +-----------------+--------+--------+------+ - | compression | fixed precision | x | x | | - | +-----------------+--------+--------+------+ + | | fixed precision | x | x | | + | compression +-----------------+--------+--------+------+ | | fixed accuracy | x | x | | + | +-----------------+--------+--------+------+ + | | reversible | x | x | | +---------------+-----------------+--------+--------+------+ | | fixed rate | x | | x | | +-----------------+--------+--------+------+ - | decompression | fixed precision | x | | | - | +-----------------+--------+--------+------+ + | | fixed precision | x | | | + | decompression +-----------------+--------+--------+------+ | | fixed accuracy | x | | | + | +-----------------+--------+--------+------+ + | | reversible | x | | | +---------------+-----------------+--------+--------+------+ :c:func:`zfp_compress` and :c:func:`zfp_decompress` both return zero if the diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index effaf1767..3d32c495c 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -239,6 +239,21 @@ Types where :code:`data` is a pointer to the first array element. +.. _indexing: +.. index:: + single: C order + single: Fortran order +.. warning:: + It is paramount that the field dimensions, *nx*, *ny*, *nz*, and *nw*, + and strides, *sx*, *sy*, *sz*, and *sw*, be correctly mapped to how the + uncompressed array is laid out in memory. Although compression will + still succeed if array dimensions are accidentally transposed, compression + ratio and/or accuracy may suffer greatly. Since the leftmost index, *x*, + is assumed to vary fastest, |zfp| can be thought of as assuming + Fortran ordering. For C ordered arrays, the user should transpose + the dimensions or specify strides to properly describe the memory layout. + See this :ref:`discussion ` for further details. + .. _hl-data: Constants diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index ef70f6833..90a0d4a88 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -4,10 +4,12 @@ Introduction ============ -|zfp| is an open source C/C++ library for compressed numerical arrays that +|zfp| is an open source library for compressed numerical arrays that support high throughput read and write random access. |zfp| also supports streaming compression of integer and floating-point data, e.g., for applications that read and write large data sets to and from disk. +|zfp| is primarily written in C and C++ but also includes Python and +Fortran bindings. |zfp| was developed at `Lawrence Livermore National Laboratory `_ and is diff --git a/docs/source/license.rst b/docs/source/license.rst index df1275679..6b5074fa7 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -3,9 +3,9 @@ License ======= -| Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +| Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC. | Produced at the Lawrence Livermore National Laboratory. -| Written by Peter Lindstrom, Markus Salasoo, and Matt Larsen. +| Written by Peter Lindstrom, Markus Salasoo, Matt Larsen, and Stephen Herbein. | LLNL-CODE-663824. | All rights reserved. diff --git a/docs/source/limitations.rst b/docs/source/limitations.rst index 68f9b39fa..88a7c3e62 100644 --- a/docs/source/limitations.rst +++ b/docs/source/limitations.rst @@ -21,9 +21,12 @@ that will address some of these limitations. minor effort. - The optional |zfp| :ref:`header ` supports arrays with at - most 2\ :sup:`48` elements. Each dimension is limited to 2\ :sup:`48/d` - elements in a *d*-dimensional array, i.e., 2\ :sup:`48`, 2\ :sup:`24`, - 2\ :sup:`16`, and 2\ :sup:`12` for 1D through 4D arrays, respectively. + most 2\ :sup:`48` elements. The |zfp| header limits each dimension + to 2\ :sup:`48/d` elements in a *d*-dimensional array, i.e., + 2\ :sup:`48`, 2\ :sup:`24`, 2\ :sup:`16`, and 2\ :sup:`12` for 1D through + 4D arrays, respectively. Note that this limitation applies only to + the header; array dimensions are otherwise limited only by the size + of an unsigned integer. - Conventional pointers and references to individual array elements are not available. That is, constructions like :code:`double* ptr = &a[i];` @@ -71,3 +74,7 @@ that will address some of these limitations. - The :ref:`C wrappers ` for |zfp|'s compressed arrays support only basic array accesses. There is currently no C interface for proxy references, pointers, iterators, or views. + +- The Python and Fortran bindings do not yet support compressed arrays. + Moreover, only a select subset of the :ref:`high-level API ` + is available via Python. diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index e044fd5d6..012fddab5 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -41,10 +41,13 @@ Consider compressing the 3D C/C++ array // define an uncompressed array double a[nz][ny][nx]; -where *nx*, *ny*, and *nz* can be any positive dimensions. To invoke the -|libzfp| compressor, the dimensions and type must first be specified in a -:c:type:`zfp_field` parameter object that encapsulates the type, size, and -memory layout of the array:: +where *nx*, *ny*, and *nz* can be any positive dimensions. + +.. include:: disclaimer.inc + +To invoke the |libzfp| compressor, the dimensions and type must first be +specified in a :c:type:`zfp_field` parameter object that encapsulates the +type, size, and memory layout of the array:: // allocate metadata for the 3D array a[nz][ny][nx] uint dims = 3; @@ -328,13 +331,16 @@ or using STL vectors but with the user specifying the amount of storage used via the *rate* parameter. (A predefined type :cpp:type:`array3d` also exists, while -the suffix 'f' is used for floats.) Note that the array dimensions can -be arbitrary, and need not be multiples of four (see above for a discussion -of incomplete blocks). The *rate* argument specifies how many bits per -value (amortized) to store in the compressed representation. By default -the block size is restricted to a multiple of 64 bits, and therefore the -rate argument can be specified in increments of 64 / |4powd| bits in *d* -dimensions, i.e. +the suffix 'f' is used for floats.) + +.. include:: disclaimer.inc + +Note that the array dimensions can be arbitrary, and need not be multiples +of four (see above for a discussion of incomplete blocks). The *rate* +argument specifies how many bits per value (amortized) to store in the +compressed representation. By default the block size is restricted to a +multiple of 64 bits, and therefore the rate argument can be specified in +increments of 64 / |4powd| bits in *d* dimensions, i.e. :: 1D arrays: 16-bit granularity diff --git a/docs/source/versions.rst b/docs/source/versions.rst index 6f7e646b8..60c547a2f 100644 --- a/docs/source/versions.rst +++ b/docs/source/versions.rst @@ -3,6 +3,27 @@ Release Notes ============= +zfp 0.5.5, March 31, 2019 + + - Added support for reversible (lossless) compression of floating-point and + integer data. + + - Added methods for serializing and deserializing zfp's compressed arrays. + + - Added Python bindings for compressing numpy arrays. + + - Added Fortran bindings to zfp's high-level C API. + + - Bug fixes: + + - Incorrect handling of execution policy in zfp utility. + - Incorrect handling of decompression via header in zfp utility. + - Tests for failing mallocs. + - CMake installation of CFP when built. + - zfp_write_header and zfp_field_metadata now fail if array dimensions + are too large to fit in header. + + zfp 0.5.4, October 1, 2018 - Added support for CUDA fixed-rate compression and decompression. @@ -23,7 +44,7 @@ zfp 0.5.4, October 1, 2018 - Bug fixes: - Handling of negative strides. - - Command line tool handling of arrays with more than 2^32 elements. + - Command line tool handling of arrays with more than 2\ :sup:`32` elements. - bitstream C++ compatibility. - Respect minimum cache size request. diff --git a/docs/source/zfpcmd.rst b/docs/source/zfpcmd.rst index 6216780c7..1ec32761f 100644 --- a/docs/source/zfpcmd.rst +++ b/docs/source/zfpcmd.rst @@ -50,18 +50,19 @@ varies faster than *z*, and so on. That is, a 4D input file corresponding to a flattened C array :code:`a[nw][nz][ny][nx]` is specified as :code:`-4 nx ny nz nw`. -Note that :code:`-2 nx ny` is not equivalent to :code:`-3 nx ny 1`, even -though the same number of values are compressed. One invokes the 2D codec, -while the other uses the 3D codec, which in this example has to pad the -input to an *nx* |times| *ny* |times| 4 array since arrays are partitioned -into blocks of dimensions |4powd|. Such padding usually negatively impacts -compression. - -Moreover, :code:`-2 nx ny` is not equivalent to :code:`-2 ny nx`, i.e., with -the dimensions transposed. It is crucial for accuracy and compression ratio -that the array dimensions are listed in the order expected by |zfpcmd| so -that the array layout is correctly interpreted. See this -:ref:`discussion ` for more details. +.. note:: + Note that :code:`-2 nx ny` is not equivalent to :code:`-3 nx ny 1`, even + though the same number of values are compressed. One invokes the 2D codec, + while the other uses the 3D codec, which in this example has to pad the + input to an *nx* |times| *ny* |times| 4 array since arrays are partitioned + into blocks of dimensions |4powd|. Such padding usually negatively impacts + compression. + +In addition to ensuring correct dimensionality, the order of dimensions +also matters. For instance, :code:`-2 nx ny` is not equivalent to +:code:`-2 ny nx`, i.e., with the dimensions transposed. + +.. include:: disclaimer.inc Using :option:`-h`, the array dimensions and type are stored in a header of the compressed stream so that they do not have to be specified on the command From 60fc6afc23d96628bf4e06adac22be3c5ba3161c Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 2 Apr 2019 16:05:51 -0700 Subject: [PATCH 142/194] Require CHAR_BIT=8 --- tests/testzfp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/testzfp.cpp b/tests/testzfp.cpp index 194b1d8af..7469358f0 100644 --- a/tests/testzfp.cpp +++ b/tests/testzfp.cpp @@ -985,6 +985,10 @@ common_tests() failures++; } // ensure integer type sizes are correct + if (CHAR_BIT != 8) { + std::cout << "byte type is not 8 bits wide" << std::endl; + failures++; + } if (sizeof(int8) != 1u || sizeof(uint8) != 1u) { std::cout << "8-bit integer type is not one byte wide" << std::endl; failures++; From 5d2d0ce3387fec0010d751e064439ffc180e093c Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 16 Apr 2019 15:09:31 -0700 Subject: [PATCH 143/194] Update FAQ and other docs to reflect reversible compression --- README.md | 8 +++++--- docs/source/arrays.rst | 9 ++++++++- docs/source/contributors.rst | 9 +++++---- docs/source/faq.rst | 16 +++++++++++----- docs/source/introduction.rst | 4 +++- docs/source/modes.rst | 9 +++++++-- 6 files changed, 39 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 761bf8d0c..764767a4e 100644 --- a/README.md +++ b/README.md @@ -40,9 +40,11 @@ designed specifically for 1D streams. zfp also supports compression of zfp is freely available as open source under a BSD license, as outlined in the file 'LICENSE'. For more information on zfp and comparisons with other -compressors, please see the zfp -[website](https://computation.llnl.gov/projects/floating-point-compression). -For questions, comments, requests, and bug reports, please contact +compressors, please see the +[zfp website](https://computation.llnl.gov/projects/floating-point-compression). +For bug reports, please consult the +[GitHub issue tracker](https://github.com/LLNL/zfp/issues). +For questions, comments, and requests, please contact [Peter Lindstrom](mailto:pl@llnl.gov). diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index 7d55fcfa8..8608766e5 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -203,7 +203,14 @@ type is ommitted for readability, e.g., .. cpp:function:: array2::array2() .. cpp:function:: array3::array3() - Default constructor. Creates an empty array. + Default constructor. Creates an empty array whose size and rate are both + zero. + +.. note:: + The default constructor is useful when the array size or rate is not known at + time of construction. Before the array can become usable, however, it must + be :ref:`resized ` and its rate must be set via + :cpp:func:`array::set_rate`. These two tasks can be performed in either order. .. _array_ctor: .. cpp:function:: array1::array1(uint n, double rate, const Scalar* p = 0, size_t csize = 0) diff --git a/docs/source/contributors.rst b/docs/source/contributors.rst index aa8350ee6..8ed309bc9 100644 --- a/docs/source/contributors.rst +++ b/docs/source/contributors.rst @@ -6,10 +6,11 @@ Contributors * LLNL |zfp| team - - Peter Lindstrom (Project Lead and original developer) - - Matt Larsen (CUDA port) - - Mark Miller (`HDF5 plugin `_) - - Markus Salasoo (testing, backwards compatibility, language bindings) + - Peter Lindstrom + - Markus Salasoo + - Matt Larsen + - Stephen Herbein + - Mark Miller * External contributors diff --git a/docs/source/faq.rst b/docs/source/faq.rst index cfabca22e..8c9165cdd 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -452,11 +452,17 @@ and :code:`&out[1][0][0]`. Q17: *Why does zfp sometimes not respect my error tolerance?* -A: |zfp| does not store each floating-point value independently, but represents -a group of values (4, 16, 64, or 256 values, depending on dimensionality) as -linear combinations like averages by evaluating arithmetic expressions. Just -like in uncompressed IEEE floating-point arithmetic, both representation error -and roundoff error in the least significant bit(s) often occur. +A: First, |zfp| does not support +:ref:`fixed-accuracy mode ` for integer data and +will ignore any tolerance requested via :c:func:`zfp_stream_set_accuracy` +or associated :ref:`expert mode ` parameter settings. + +For floating-point data, |zfp| does not store each scalar value independently +but represents a group of values (4, 16, 64, or 256 values, depending on +dimensionality) as linear combinations like averages by evaluating arithmetic +expressions. Just like in uncompressed IEEE floating-point arithmetic, both +representation error and roundoff error in the least significant bit(s) often +occur. To illustrate this, consider compressing the following 1D array of four floats:: diff --git a/docs/source/introduction.rst b/docs/source/introduction.rst index 90a0d4a88..655171132 100644 --- a/docs/source/introduction.rst +++ b/docs/source/introduction.rst @@ -44,5 +44,7 @@ supports compression of 4D arrays. For more information on |zfp| and comparisons with other compressors, please see the |zfp| `website `_. -For questions, comments, requests, and bug reports, please contact +For bug reports, please consult the +`GitHub issue tracker `_. +For questions, comments, and requests, please contact `Peter Lindstrom `__. diff --git a/docs/source/modes.rst b/docs/source/modes.rst index 515be06f6..81db2802c 100644 --- a/docs/source/modes.rst +++ b/docs/source/modes.rst @@ -77,8 +77,9 @@ the block. The four constraints are as follows: .. c:member:: int zfp_stream.minexp - The smallest absolute bit plane number encoded. The place value of each - transform coefficient bit depends on the common floating-point exponent, + The smallest absolute bit plane number encoded (applies to floating-point + data only; this parameter is ignored for integer data). The place value of + each transform coefficient bit depends on the common floating-point exponent, *e*, that scales the integer coefficients. If the most significant coefficient bit has place value 2\ :sup:`e`, then the number of bit planes encoded is (one plus) the difference between *e* and @@ -212,6 +213,10 @@ lossless compression). Fixed-accuracy mode gives the highest quality (in terms of absolute error) for a given compression rate, and is preferable when random access is not needed. +.. note:: + Fixed-accuracy mode is available for floating-point (not integer) data + only. + .. index:: single: Compression mode; Reversible mode single: Lossless compression From 2189c937bf55bbcadb020456ee7d703965a15f78 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 18 Apr 2019 16:03:50 -0700 Subject: [PATCH 144/194] Add compressed array header documentation --- docs/source/array-factory.inc | 32 ++++++++++++++++++++++++++++++++ docs/source/arrays.rst | 30 ++++++++++++++++++++++++++++++ docs/source/exceptions.inc | 19 +++++++++++++++++++ docs/source/header.inc | 22 ++++++++++++++++++++++ 4 files changed, 103 insertions(+) create mode 100644 docs/source/array-factory.inc create mode 100644 docs/source/exceptions.inc create mode 100644 docs/source/header.inc diff --git a/docs/source/array-factory.inc b/docs/source/array-factory.inc new file mode 100644 index 000000000..0957f74b4 --- /dev/null +++ b/docs/source/array-factory.inc @@ -0,0 +1,32 @@ +.. index:: + single: array-factory +.. _array_factory: + +Serializing and Deserializing Compressed Arrays +----------------------------------------------- + +|zfp|'s compressed arrays can be written to disk and recovered back into an +object. A header is generated through :cpp:func:`get_header`. Also record the +compressed-data (blocks) using :cpp:func:`compressed_data`, having length +:cpp:func:`compressed_size` (in bytes). + +There are two ways to construct a compressed array object from memory. The +first is to use the correct array type's constructor, which accepts a +:cpp:type:`zfp::array::header`, optional *buffer*, and optional *buffer_size*. +If the wrong array type is used, then :cpp:class:`zfp::array::header::exception` +is thrown. + +The second method is useful when the serialized array type is unknown, but +described in the header. Include zfpfactory.h after including the 1, 2, and/or 3 +dimensional compressed array headers, and use (static) +:cpp:func:`zfp::array::construct`, listed below. This function also accepts a +*header*, optional *buffer*, and optional *buffer_size*. + +.. cpp:function:: static array* zfp::array::construct(const zfp::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) + + Construct the correct compressed array object from what the header describes, + returning a pointer to the base class upon success, otherwise throwing a + :cpp:class:`zfp::array::header::exception`. Just as with the constructor, + :cpp:type:`zfp::array::header` holds the header and optional *buffer* points to the + compressed data. Optional *buffer_size_bytes* argument specifies *buffer* + length, in bytes. diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index 8608766e5..fbcf42a1b 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -43,6 +43,9 @@ iterators, and views. The following sections are available: * :ref:`array_classes` +* :ref:`header` +* :ref:`exceptions` +* :ref:`array_factory` * :ref:`caching` * :ref:`references` * :ref:`pointers` @@ -107,6 +110,19 @@ Base Class Return pointer to compressed data for read or write access. The size of the buffer is given by :cpp:func:`compressed_size`. +.. cpp:function:: uint array::dimensionality() const + + Return the dimensionality of the compressed array. + +.. cpp:function:: zfp_type array::scalar_type() const + + Return the underlying :c:type:`zfp_type` of the compressed array. + +.. cpp:function:: zfp::array::header array::get_header() const + + Write a header describing this compressed array into struct + :cpp:type:`header`, and return it. + Common Methods ^^^^^^^^^^^^^^ @@ -222,6 +238,17 @@ type is ommitted for readability, e.g., *csize* bytes of cache, and optionally initialized from flat, uncompressed array *p*. If *csize* is zero, a default cache size is chosen. +.. cpp:function:: array1::array1(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) +.. cpp:function:: array2::array2(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) +.. cpp:function:: array3::array3(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) + + Constructor of array from previously-serialized compressed array. Struct + :cpp:type:`zfp::array::header` contains header information, while optional + *buffer* points to the compressed-data. Optional *buffer_size_bytes* argument + specifies *buffer* length in case header describes a longer array. Throws + :cpp:class:`zfp::array::header::exception` if unable to construct. Omitting a + buffer will construct the object with its entries allocated (ready for use). + .. cpp:function:: array1::array1(const array1& a) .. cpp:function:: array2::array2(const array2& a) .. cpp:function:: array3::array3(const array3& a) @@ -274,6 +301,9 @@ type is ommitted for readability, e.g., Return :ref:`proxy reference ` to scalar stored at multi-dimensional index given by *i*, *j*, and *k* (mutator). +.. include:: header.inc +.. include:: exceptions.inc +.. include:: array-factory.inc .. include:: caching.inc .. include:: references.inc .. include:: pointers.inc diff --git a/docs/source/exceptions.inc b/docs/source/exceptions.inc new file mode 100644 index 000000000..bb2c22f1c --- /dev/null +++ b/docs/source/exceptions.inc @@ -0,0 +1,19 @@ +.. index:: + single: Exceptions +.. _exceptions: + +Exceptions +---------- + +.. cpp:namespace:: zfp::array::header + +.. + .. cpp:class:: exception : public std::runtime_error + +.. cpp:class:: exception : public std::runtime_error + + Compressed arrays can throw this exception when calling the constructor taking + a :cpp:type:`zfp::array::header` and buffer. This exception will be thrown if + the header is invalid or describes compressed data that is incompatible with + this compressed-array. Also note this exception lies in the :cpp:any:`zfp` + namespace. diff --git a/docs/source/header.inc b/docs/source/header.inc new file mode 100644 index 000000000..50c806ba6 --- /dev/null +++ b/docs/source/header.inc @@ -0,0 +1,22 @@ +.. index:: + single: Header +.. _header: + +Header +------ + +.. cpp:namespace:: zfp::array + +.. + .. cpp:class:: header + +.. cpp:class:: header + + This struct stores information needed to describe a compressed-array, should + a user want to serialize it. Compressed-arrays always have 96 bit headers, + stored in the buffer array. This header is fully compatible with the C API. + :: + + class header { + uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BYTES)]; + }; From a348041fa3a2e59f61d0a146912fcb605865a373 Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 23 Apr 2019 10:17:39 -0700 Subject: [PATCH 145/194] Update serialization documentation --- docs/source/array-factory.inc | 32 --------- docs/source/arrays.rst | 54 +++++++++------ docs/source/conf.py | 2 +- docs/source/exceptions.inc | 19 ------ docs/source/header.inc | 22 ------ docs/source/serialization.inc | 123 ++++++++++++++++++++++++++++++++++ 6 files changed, 158 insertions(+), 94 deletions(-) delete mode 100644 docs/source/array-factory.inc delete mode 100644 docs/source/exceptions.inc delete mode 100644 docs/source/header.inc create mode 100644 docs/source/serialization.inc diff --git a/docs/source/array-factory.inc b/docs/source/array-factory.inc deleted file mode 100644 index 0957f74b4..000000000 --- a/docs/source/array-factory.inc +++ /dev/null @@ -1,32 +0,0 @@ -.. index:: - single: array-factory -.. _array_factory: - -Serializing and Deserializing Compressed Arrays ------------------------------------------------ - -|zfp|'s compressed arrays can be written to disk and recovered back into an -object. A header is generated through :cpp:func:`get_header`. Also record the -compressed-data (blocks) using :cpp:func:`compressed_data`, having length -:cpp:func:`compressed_size` (in bytes). - -There are two ways to construct a compressed array object from memory. The -first is to use the correct array type's constructor, which accepts a -:cpp:type:`zfp::array::header`, optional *buffer*, and optional *buffer_size*. -If the wrong array type is used, then :cpp:class:`zfp::array::header::exception` -is thrown. - -The second method is useful when the serialized array type is unknown, but -described in the header. Include zfpfactory.h after including the 1, 2, and/or 3 -dimensional compressed array headers, and use (static) -:cpp:func:`zfp::array::construct`, listed below. This function also accepts a -*header*, optional *buffer*, and optional *buffer_size*. - -.. cpp:function:: static array* zfp::array::construct(const zfp::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) - - Construct the correct compressed array object from what the header describes, - returning a pointer to the base class upon success, otherwise throwing a - :cpp:class:`zfp::array::header::exception`. Just as with the constructor, - :cpp:type:`zfp::array::header` holds the header and optional *buffer* points to the - compressed data. Optional *buffer_size_bytes* argument specifies *buffer* - length, in bytes. diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index fbcf42a1b..08904cd5d 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -43,10 +43,8 @@ iterators, and views. The following sections are available: * :ref:`array_classes` -* :ref:`header` -* :ref:`exceptions` -* :ref:`array_factory` * :ref:`caching` +* :ref:`serialization` * :ref:`references` * :ref:`pointers` * :ref:`iterators` @@ -112,16 +110,31 @@ Base Class .. cpp:function:: uint array::dimensionality() const - Return the dimensionality of the compressed array. + Return the dimensionality (1, 2, or 3) of the array. .. cpp:function:: zfp_type array::scalar_type() const - Return the underlying :c:type:`zfp_type` of the compressed array. + Return the underlying scalar type (:c:type:`zfp_type`) of the array. -.. cpp:function:: zfp::array::header array::get_header() const +.. cpp:function:: array::header array::get_header() const - Write a header describing this compressed array into struct - :cpp:type:`header`, and return it. + Return a short :ref:`header
` describing the scalar type, + dimensions, and rate associated with the array. + A :cpp:class:`array::header::exception` is thrown if the header cannot + describe the array. + +.. _array_factory: +.. cpp:function:: static array* array::construct(const array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) + + Construct a compressed-array object whose scalar type, dimensions, and rate + are given by the header *h*. Return a pointer to the base class upon + success. The optional *buffer* points to compressed data that, when passed, + is copied into the array. If *buffer* is absent, the array is default + intialized with all zeroes. The optional *buffer_size_bytes* argument + specifies the buffer length in bytes. When passed, a comparison is made to + ensure that the buffer size is at least as large as the size implied by + the header. If this function fails for any reason, an + :cpp:class:`array::header::exception` is thrown. Common Methods ^^^^^^^^^^^^^^ @@ -238,16 +251,19 @@ type is ommitted for readability, e.g., *csize* bytes of cache, and optionally initialized from flat, uncompressed array *p*. If *csize* is zero, a default cache size is chosen. -.. cpp:function:: array1::array1(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) -.. cpp:function:: array2::array2(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) -.. cpp:function:: array3::array3(const zfp::array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) +.. _array_ctor_header: +.. cpp:function:: array1::array1(const array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) +.. cpp:function:: array2::array2(const array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) +.. cpp:function:: array3::array3(const array::header& h, const uchar* buffer = 0, size_t buffer_size_bytes = 0) - Constructor of array from previously-serialized compressed array. Struct - :cpp:type:`zfp::array::header` contains header information, while optional - *buffer* points to the compressed-data. Optional *buffer_size_bytes* argument - specifies *buffer* length in case header describes a longer array. Throws - :cpp:class:`zfp::array::header::exception` if unable to construct. Omitting a - buffer will construct the object with its entries allocated (ready for use). + Constructor from previously :ref:`serialized ` compressed + array. Struct :cpp:type:`array::header` contains array metadata, while + optional *buffer* points to the compressed data that is to be copied to + the array. The optional *buffer_size_bytes* argument specifies the + *buffer* length. If the constructor fails, an + :cpp:class:`array::header::exception` is thrown. + See :cpp:func:`array::construct` for further details on the *buffer* and + *buffer_size_bytes* arguments. .. cpp:function:: array1::array1(const array1& a) .. cpp:function:: array2::array2(const array2& a) @@ -301,10 +317,8 @@ type is ommitted for readability, e.g., Return :ref:`proxy reference ` to scalar stored at multi-dimensional index given by *i*, *j*, and *k* (mutator). -.. include:: header.inc -.. include:: exceptions.inc -.. include:: array-factory.inc .. include:: caching.inc +.. include:: serialization.inc .. include:: references.inc .. include:: pointers.inc .. include:: iterators.inc diff --git a/docs/source/conf.py b/docs/source/conf.py index 6d31521be..93104a18c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -146,7 +146,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'zfp.tex', u'zfp Documentation', - u'Peter Lindstrom', 'manual'), + u'\shortstack{Peter Lindstrom\\\\Markus Salasoo}', 'manual'), ] diff --git a/docs/source/exceptions.inc b/docs/source/exceptions.inc deleted file mode 100644 index bb2c22f1c..000000000 --- a/docs/source/exceptions.inc +++ /dev/null @@ -1,19 +0,0 @@ -.. index:: - single: Exceptions -.. _exceptions: - -Exceptions ----------- - -.. cpp:namespace:: zfp::array::header - -.. - .. cpp:class:: exception : public std::runtime_error - -.. cpp:class:: exception : public std::runtime_error - - Compressed arrays can throw this exception when calling the constructor taking - a :cpp:type:`zfp::array::header` and buffer. This exception will be thrown if - the header is invalid or describes compressed data that is incompatible with - this compressed-array. Also note this exception lies in the :cpp:any:`zfp` - namespace. diff --git a/docs/source/header.inc b/docs/source/header.inc deleted file mode 100644 index 50c806ba6..000000000 --- a/docs/source/header.inc +++ /dev/null @@ -1,22 +0,0 @@ -.. index:: - single: Header -.. _header: - -Header ------- - -.. cpp:namespace:: zfp::array - -.. - .. cpp:class:: header - -.. cpp:class:: header - - This struct stores information needed to describe a compressed-array, should - a user want to serialize it. Compressed-arrays always have 96 bit headers, - stored in the buffer array. This header is fully compatible with the C API. - :: - - class header { - uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BYTES)]; - }; diff --git a/docs/source/serialization.inc b/docs/source/serialization.inc new file mode 100644 index 000000000..0b06ec609 --- /dev/null +++ b/docs/source/serialization.inc @@ -0,0 +1,123 @@ +.. index:: + single: Serialization +.. _serialization: + +Serialization +------------- + +.. cpp:namespace:: zfp + +|zfp|'s compressed arrays can be serialized to sequential, contiguous +storage and later recovered back into an object, for example, to support +I/O of compressed-array objects. Two pieces of information are needed +to describe a |zfp| array: the raw compressed data, obtained via +:cpp:func:`array::compressed_data` and :cpp:func:`array::compressed_size`, +and a :ref:`header
` that describes the array scalar type, +dimensions, and rate, obtained via :cpp:func:`array::get_header`. +The user may concatenate the header and compressed data to form a +fixed-rate byte stream that can be read by the |zfp| +:ref:`command-line tool `. + +There are two primary ways to construct a compressed-array object from +compressed data: via array-specific :ref:`constructors ` +and via a generic :ref:`factory function `: + +- When the array scalar type (i.e., :code:`float` or :code:`double`) and + dimensionality (i.e., 1D, 2D, or 3D) are already known, the corresponding + array :ref:`constructor ` may be used. If the + scalar type and dimensionality stored in the header do not match + the array class, then an :ref:`exception ` is thrown. + +- |zfp| provides a :ref:`factory function ` that can be used + when the serialized array type is unknown but described in the header. + This function returns a pointer to the abstract base class, + :cpp:class:`array`, which the caller should dynamically cast to the + corresponding derived array, e.g., by examining + :cpp:func:`array::scalar_type` and :cpp:func:`array::dimensionality`. + + The (static) factory function is made available by including + :file:`zfpfactory.h`. This header must be included *after* first + including the header files associated with the compressed arrays, i.e., + :file:`zfparray1.h`, :file:`zfparray2.h`, and :file:`zfparray3.h`. + Only those arrays whose header files are included can be constructed by + the factory function. This design decouples the array classes so that + they may be included independently, for example, to reduce compilation + time. + +Both types of deserialization functions accept an :cpp:class:`array::header`, +an optional buffer holding compressed data, and an optional buffer size. +If this buffer is provided, then a separate copy of the compressed data it +holds is made, which is used to initialize the array. If the optional buffer +size is also provided, then these functions throw an exception if the size +is not at least as large as is expected from the metadata stored in the +header. This safeguard is implemented to avoid accessing memory beyond the +end of the buffer. If no buffer is provided, then all array elements are +default initialized to zero. The array may later be initialized by directly +reading/copying data into the space pointed to by +:cpp:func:`array::compressed_data`. + +Below is a simple example of serialization of a 3D compressed array of doubles +(error checking has been omitted for clarity):: + + zfp::array3d a(nx, ny, nz, rate); + zfp::array::header h = a.get_header(); + fwrite(&h, sizeof(h), 1, file); + fwrite(a.compressed_data(), a.compressed_size(), 1, file); + +We may then deserialize this array using the factory function. The following +example reads the compressed data directly into the array without making a +copy:: + + zfp::array::header h; + fread(&h, sizeof(h), 1, file); + zfp::array* p = zfp::array::construct(h); + fread(p->compressed_data(), p->compressed_size(), 1, file); + assert(p->dimensionality() == 3 && p->scalar_type() == zfp_type_double); + zfp::array3d& a = *dynamic_cast(p); + +.. index:: + single: Header + single: Exceptions + +.. _header: + +Header +^^^^^^ + +.. cpp:namespace:: zfp + +Short 12-byte headers are used to describe array metadata and compression +parameters when serializing a compressed array. This header is the same as +supported by the :c:func:`zfp_read_header` and :c:func:`zfp_write_header` +functions, using :c:macro:`ZFP_HEADER_FULL` to indicate that complete metadata +is to be stored in the header. The header is also compatible with the |zfp| +:ref:`command-line tool `. Processing of the header may result in an +:ref:`exception ` being thrown. + +.. cpp:class:: array::header + + The header stores information such as scalar type, array dimensions, and + rate. Compressed-array headers are always 96 bits long. These bits are + stored in the :code:`header::buffer` field, the only field represented + in the header. + :: + + struct header { + uchar buffer[BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)]; + }; + +.. _exception: +.. cpp:class:: array::header::exception : public std::runtime_error + + Compressed arrays can throw this exception upon serialization, when forming + a header via :cpp:func:`get_header`, or deserialization, when constructing + a compressed array via its :ref:`constructor ` or + :ref:`factory function `. + +.. note:: + Compressed-array headers use |zfp|'s most concise representation of only + 96 bits. Such short headers support compressed blocks up to 2048 bits long. + This implies that the highest rate for 3D arrays is 2048/4\ :sup:`3` = 32 + bits/value. 3D arrays whose rate exceeds 32 cannot be serialized using + :cpp:func:`array::get_header`, which for such arrays throws an exception. + 1D and 2D arrays do not suffer from this limitation. From 78678b0b562d8d26462fca182e4418a8f2a8c20d Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 19 Apr 2019 17:31:56 -0700 Subject: [PATCH 146/194] force fortran integers 8 bytes where appropriate --- fortran/zfp.f | 20 ++++++++++---------- tests/fortran/testFortran.f | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/fortran/zfp.f b/fortran/zfp.f index c7cf86b89..4d40dcf34 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -585,7 +585,7 @@ function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) bind(c, na implicit none type(zFORp_bitstream_type) :: bitstream type(c_ptr), intent(in) :: buffer - integer, intent(in) :: bytes + integer (kind=8), intent(in) :: bytes bitstream%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) end function zFORp_bitstream_stream_open @@ -642,7 +642,7 @@ end function zFORp_stream_mode subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") type(zFORp_stream_type), intent(in) :: zfp_stream - integer, intent(inout) :: minbits, maxbits, maxprec, minexp + integer (kind=8), intent(inout) :: minbits, maxbits, maxprec, minexp call zfp_stream_params(zfp_stream%object, & int(minbits, c_int), & int(maxbits, c_int), & @@ -653,7 +653,7 @@ end subroutine zFORp_stream_params function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, name="zforp_stream_compressed_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream - integer compressed_size + integer (kind=8) compressed_size compressed_size = zfp_stream_compressed_size(zfp_stream%object) end function zFORp_stream_compressed_size @@ -661,7 +661,7 @@ function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) bind( implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field - integer max_size + integer (kind=8) max_size max_size = zfp_stream_maximum_size(zfp_stream%object, zfp_field%object) end function zFORp_stream_maximum_size @@ -738,7 +738,7 @@ end function zFORp_stream_omp_threads function zFORp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) bind(c, name="zforp_stream_omp_chunk_size") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream - integer chunk_size_blocks + integer (kind=8) chunk_size_blocks chunk_size_blocks = zfp_stream_omp_chunk_size(zfp_stream%object) end function zFORp_stream_omp_chunk_size @@ -852,7 +852,7 @@ function zFORp_field_size(zfp_field, size_arr) result(total_size) bind(c, name=" implicit none type(zFORp_field_type), intent(in) :: zfp_field integer, dimension(4), target, intent(inout) :: size_arr - integer total_size + integer (kind=8) total_size total_size = zfp_field_size(zfp_field%object, c_loc(size_arr)) end function zFORp_field_size @@ -947,7 +947,7 @@ function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bi implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field - integer bitstream_offset_bytes + integer (kind=8) bitstream_offset_bytes bitstream_offset_bytes = zfp_compress(zfp_stream%object, zfp_field%object) end function zFORp_compress @@ -955,7 +955,7 @@ function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) implicit none type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field - integer bitstream_offset_bytes + integer (kind=8) bitstream_offset_bytes bitstream_offset_bytes = zfp_decompress(zfp_stream%object, zfp_field%object) end function zFORp_decompress @@ -964,7 +964,7 @@ function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: mask - integer num_bits_written + integer (kind=8) num_bits_written num_bits_written = zfp_write_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) end function zFORp_write_header @@ -973,7 +973,7 @@ function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bi type(zFORp_stream_type), intent(in) :: zfp_stream type(zFORp_field_type), intent(in) :: zfp_field integer, intent(in) :: mask - integer num_bits_read + integer (kind=8) num_bits_read num_bits_read = zfp_read_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) end function zFORp_read_header diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index b37518ffa..fe959e633 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -18,7 +18,7 @@ program main ! bitstream character, dimension(:), allocatable, target :: buffer type(c_ptr) :: buffer_c_ptr - integer buffer_size_bytes, bitstream_offset_bytes + integer (kind=8) buffer_size_bytes, bitstream_offset_bytes type(zFORp_bitstream_type) :: bitstream, queried_bitstream ! zfp_stream From 2dd26a35923ec5833e694a9044b766ebabdfbd63 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 23 Apr 2019 14:44:46 -0700 Subject: [PATCH 147/194] add zforp documentation --- docs/source/cfp.inc | 3 +- docs/source/conf.py | 2 +- docs/source/defs.rst | 1 - docs/source/index.rst | 1 + docs/source/requirements.txt | 3 + docs/source/setup.py | 3 + docs/source/zforp.rst | 617 +++++++++++++++++++++++++++++++++++ 7 files changed, 626 insertions(+), 4 deletions(-) create mode 100644 docs/source/requirements.txt create mode 100644 docs/source/setup.py create mode 100644 docs/source/zforp.rst diff --git a/docs/source/cfp.inc b/docs/source/cfp.inc index cb2dd01bb..1f7f1e382 100644 --- a/docs/source/cfp.inc +++ b/docs/source/cfp.inc @@ -8,8 +8,7 @@ C bindings .. cpp:namespace:: zfp |zfp| |cfprelease| adds |cfp|: C language bindings for compressed arrays -via wrappers around the C++ classes. Future releases will add |zfpy| and -|zforp| for Python and Fortan bindings. +via wrappers around the C++ classes. The C API has been designed to facilitate working with compressed arrays without the benefits of C++ operator overloading and self-aware objects, diff --git a/docs/source/conf.py b/docs/source/conf.py index 93104a18c..6fba0cd4f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -30,7 +30,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.imgmath'] +extensions = ['sphinx.ext.imgmath', 'sphinxfortran.fortran_domain'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] diff --git a/docs/source/defs.rst b/docs/source/defs.rst index 641e01bea..a555acdcd 100644 --- a/docs/source/defs.rst +++ b/docs/source/defs.rst @@ -5,7 +5,6 @@ .. |zfp| replace:: zfp .. |cfp| replace:: cfp .. |zfpy| replace:: zfPy -.. |zforp| replace:: zFORp .. |libzfp| replace:: :file:`libzfp` .. |libcfp| replace:: :file:`libcfp` .. |zfpcmd| replace:: :program:`zfp` diff --git a/docs/source/index.rst b/docs/source/index.rst index 7343a6b04..a552e387b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -19,6 +19,7 @@ bit-stream arrays python + zforp tutorial zfpcmd examples diff --git a/docs/source/requirements.txt b/docs/source/requirements.txt new file mode 100644 index 000000000..28fdfbfff --- /dev/null +++ b/docs/source/requirements.txt @@ -0,0 +1,3 @@ +# force older sphinx version for readthedocs build +sphinx==1.6.7 +sphinx-fortran diff --git a/docs/source/setup.py b/docs/source/setup.py new file mode 100644 index 000000000..606849326 --- /dev/null +++ b/docs/source/setup.py @@ -0,0 +1,3 @@ +from setuptools import setup + +setup() diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst new file mode 100644 index 000000000..f3735aa42 --- /dev/null +++ b/docs/source/zforp.rst @@ -0,0 +1,617 @@ +.. index:: + single: zforp +.. _zforp: + +Fortran bindings +---------------- + +.. cpp:namespace:: zfp + +ZFP 0.5.5 adds zFORp: A Fortran API providing wrappers around the high-level C +API. Wrappers for compressed arrays will arrive in a future release. + +Every high-level C API function can be called from a Fortran wrapper function. +C structs are wrapped as Fortran derived types, each containing a single C +pointer to the C struct in memory. The wrapper functions accept and return +these Fortran types, so users should never need to touch the C pointers. + +In addition to the high-level C API, some other functions are necessary to be +able to completely compress or decompress data. These include opening and +closing a bitstream, and rewinding a bitstream. See example code +tests/fortran/testFortran.f for how the Fortran API is used to compress and +decompress data. + +Types +----- + + .. f:type:: zFORp_bitstream_type + + :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` + + .. f:type:: zFORp_stream_type + + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` + + .. f:type:: zFORp_field_type + + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` + +Constants +--------- + + Enums wrapping :c:type:`zfp_type` + + .. f:variable:: integer zFORp_type_none + .. f:variable:: integer zFORp_type_int32 + .. f:variable:: integer zFORp_type_int64 + .. f:variable:: integer zFORp_type_float + .. f:variable:: integer zFORp_type_double + + Enums wrapping :c:type:`zfp_mode` + + .. f:variable:: integer zFORp_mode_null + .. f:variable:: integer zFORp_mode_expert + .. f:variable:: integer zFORp_mode_fixed_rate + .. f:variable:: integer zFORp_mode_fixed_precision + .. f:variable:: integer zFORp_mode_fixed_accuracy + + Enums wrapping :c:type:`zfp_exec_policy` + + .. f:variable:: integer zFORp_exec_serial + .. f:variable:: integer zFORp_exec_omp + .. f:variable:: integer zFORp_exec_cuda + + Non-enum constants + + .. f:variable:: integer zFORp_version_major + + Wraps :c:macro:`ZFP_VERSION_MAJOR` + + .. f:variable:: integer zFORp_version_minor + + Wraps :c:macro:`ZFP_VERSION_MINOR` + + .. f:variable:: integer zFORp_version_patch + + Wraps :c:macro:`ZFP_VERSION_PATCH` + + .. f:variable:: integer zFORp_codec_version + + Wraps :c:data:`zfp_codec_version` + + .. f:variable:: integer zFORp_library_version + + Wraps :c:data:`zfp_library_version` + + .. f:variable:: character(len=36) zFORp_version_string + + Wraps :c:macro:`ZFP_VERSION_STRING` + + .. f:variable:: integer zFORp_min_bits + + Wraps :c:macro:`ZFP_MIN_BITS` + + .. f:variable:: integer zFORp_max_bits + + Wraps :c:macro:`ZFP_MAX_BITS` + + .. f:variable:: integer zFORp_max_prec + + Wraps :c:macro:`ZFP_MAX_PREC` + + .. f:variable:: integer zFORp_min_exp + + Wraps :c:macro:`ZFP_MIN_EXP` + + .. f:variable:: integer zFORp_header_magic + + Wraps :c:macro:`ZFP_HEADER_MAGIC` + + .. f:variable:: integer zFORp_header_meta + + Wraps :c:macro:`ZFP_HEADER_META` + + .. f:variable:: integer zFORp_header_mode + + Wraps :c:macro:`ZFP_HEADER_MODE` + + .. f:variable:: integer zFORp_header_full + + Wraps :c:macro:`ZFP_HEADER_FULL` + + .. f:variable:: integer zFORp_meta_null + + Wraps :c:macro:`ZFP_META_NULL` + + .. f:variable:: integer zFORp_magic_bits + + Wraps :c:macro:`ZFP_MAGIC_BITS` + + .. f:variable:: integer zFORp_meta_bits + + Wraps :c:macro:`ZFP_META_BITS` + + .. f:variable:: integer zFORp_mode_short_bits + + Wraps :c:macro:`ZFP_MODE_SHORT_BITS` + + .. f:variable:: integer zFORp_mode_long_bits + + Wraps :c:macro:`ZFP_MODE_LONG_BITS` + + .. f:variable:: integer zFORp_header_max_bits + + Wraps :c:macro:`ZFP_HEADER_MAX_BITS` + + .. f:variable:: integer zFORp_mode_short_max + + Wraps :c:macro:`ZFP_MODE_SHORT_MAX` + +Bitstream function wrappers +--------------------------- + + .. f:function:: zFORp_bitstream_stream_open(buffer, bytes) + + Wrapper for :c:func:`stream_open` + + :p type(c_ptr) buffer [in]: Bitstream buffer + :p integer (kind=8) bytes [in]: Buffer size, in bytes + :r bitstream: Bitstream + :rtype bitstream: zFORp_bitstream_type + + .. f:subroutine:: zFORp_bitstream_stream_close(bitstream) + + Wrapper for :c:func:`stream_close` + + :p zFORp_bitstream_type bitstream [inout]: Bitstream + +High-level API utility function wrappers +---------------------------------------- + + .. f:function:: zFORp_type_size(zfp_type) + + Wrapper for :c:func:`zfp_type_size` + + :p integer zfp_type [in]: zFORp_type enum. + :r type_size: Size of described zfp_type, in bytes, from C-language perspective. + :rtype type_size: integer + + .. f:function:: zFORp_stream_open(bitstream) + + Wrapper for :c:func:`zfp_stream_open` + + :p type(zFORp_bitstream_type) bitstream [in]: Bitstream + :r zfp_stream: Newly allocated zfp_stream + :rtype zfp_stream: zFORp_stream_type + + .. f:subroutine:: zFORp_stream_close(zfp_stream) + + Wrapper for :c:func:`zfp_stream_close` + + :p type(zFORp_stream_type) zfp_stream [inout]: Zfp_stream + + .. f:function:: zFORp_stream_bit_stream(zfp_stream) + + Wrapper for :c:func:`zfp_stream_bit_stream` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r bitstream: Bitstream + :rtype bitstream: zFORp_bitstream_type + + .. f:function:: zFORp_stream_compression_mode(zfp_stream) + + Wrapper for :c:func:`zfp_stream_compression_mode` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r zfp_mode: zFORp_mode enum + :rtype zfp_mode: integer + + .. f:function:: zFORp_stream_mode(zfp_stream) + + Wrapper for :c:func:`zfp_stream_mode` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r encoded_mode: 64 bit encoded mode + :rtype encoded_mode: integer (kind=8) + + .. f:subroutine:: zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) + + Wrapper for :c:func:`zfp_stream_params` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer (kind=8) minbits [inout]: minbits + :p integer (kind=8) maxbits [inout]: maxbits + :p integer (kind=8) maxprec [inout]: maxprec + :p integer (kind=8) minexp [inout]: minexp + + .. f:function:: zFORp_stream_compressed_size(zfp_stream) + + Wrapper for :c:func:`zfp_stream_compressed_size` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r compressed_size: compressed size + :rtype compressed_size: integer (kind=8) + + .. f:function:: zFORp_stream_maximum_size(zfp_stream, zfp_field) + + Wrapper for :c:func:`zfp_stream_maximum_size` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :r max_size: maximum size + :rtype max_size: integer (kind=8) + + .. f:subroutine:: zFORp_stream_set_bit_stream(zfp_stream, bitstream) + + Wrapper for :c:func:`zfp_stream_set_bit_stream` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_bitstream_type bitstream [in]: bitstream + + .. f:function:: zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) + + Wrapper for :c:func:`zfp_stream_set_rate` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p real rate [in]: desired rate + :p integer zfp_type [in]: enum zfp_type + :p integer dims [in]: dimensions + :p integer wra [in]: use write random access? + :r rate_result: actual set rate + :rtype rate_result: real + + .. f:function:: zFORp_stream_set_precision(zfp_stream, prec) + + Wrapper for :c:func:`zfp_stream_set_precision` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer prec [in]: desired precision + :r prec_result: actual set precision + :rtype prec_result: integer + + .. f:function:: zFORp_stream_set_accuracy(zfp_stream, acc) + + Wrapper for :c:func:`zfp_stream_set_accuracy()` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p real acc: desired accuracy (kind=8) + :r acc_result: actual set accuracy + :rtype acc_result: real (kind=8) + + .. f:function:: zFORp_stream_set_mode(zfp_stream, encoded_mode) + + Wrapper for :c:func:`zfp_stream_set_mode` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer encoded_mode [in]: encoded mode parameter + :r mode_result: newly set zfp_mode enum on zfp_stream + :rtype mode_result: integer + + .. f:function:: zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) + + Wrapper for :c:func:`zfp_stream_set_params` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer minbits [in]: min num of bits + :p integer maxbits [in]: max num of bits + :p integer maxprec [in]: max precision + :p integer minexp [in]: min exponent + :r is_success: indicate whether parameters were successfully set (1) or not (0) + :rtype is_success: integer + +High-level API: execution policy function wrappers +-------------------------------------------------- + + .. f:function:: zFORp_stream_execution(zfp_stream) + + Wrapper for :c:func:`zfp_stream_execution` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r execution_policy: enum of active execution policy + :rtype execution_policy: integer + + .. f:function:: zFORp_stream_omp_threads(zfp_stream) + + Wrapper for :c:func:`zfp_stream_omp_threads` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r thread_count: number of threads to use upon execution + :rtype thread_count: integer + + .. f:function:: zFORp_stream_omp_chunk_size(zfp_stream) + + Wrapper for :c:func:`zfp_stream_omp_chunk_size` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r chunk_size_blocks: specified chunk size, in blocks + :rtype chunk_size_blocks: integer (kind=8) + + .. f:function:: zFORp_stream_set_execution(zfp_stream, execution_policy) + + Wrapper for :c:func:`zfp_stream_set_execution` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer execution_policy [in]: desired execution policy (enum) + :r is_success: indicate whether execution policy was successfully set or not + :rtype is_success: integer + + .. f:function:: zFORp_stream_set_omp_threads(zfp_stream, thread_count) + + Wrapper for :c:func:`zfp_stream_set_omp_threads` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer thread_count [in]: desired number of threads + :r is_success: indicate whether number of threads successfully set or not + :rtype is_success: integer + + .. f:function:: zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) + + Wrapper for :c:func:`zfp_stream_set_omp_chunk_size` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer chunk_size [in]: desired chunk size, in blocks + :r is_success: indicate whether chunk size successfully set or not + :rtype is_success: integer + +High-level API: zfp_field function wrappers +------------------------------------------- + + .. f:function:: zFORp_field_alloc() + + Wrapper for :c:func:`zfp_field_alloc` + + :r zfp_field: newly allocated zfp field + :rtype zfp_field: zFORp_field_type + + .. f:function:: zFORp_field_1d(uncompressed_ptr, zfp_type, nx) + + Wrapper for :c:func:`zfp_field_1d` + + :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data + :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer nx [in]: number of elements in uncompressed data array + :r zfp_field: newly allocated zfp field + :rtype zfp_field: zFORp_field_type + + .. f:function:: zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) + + Wrapper for :c:func:`zfp_field_2d` + + :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data + :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer nx [in]: number of elements in uncompressed data array's x dimension + :p integer ny [in]: number of elements in uncompressed data array's y dimension + :r zfp_field: newly allocated zfp field + :rtype zfp_field: zFORp_field_type + + .. f:function:: zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) + + Wrapper for :c:func:`zfp_field_3d` + + :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data + :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer nx [in]: number of elements in uncompressed data array's x dimension + :p integer ny [in]: number of elements in uncompressed data array's y dimension + :p integer nz [in]: number of elements in uncompressed data array's z dimension + :r zfp_field: newly allocated zfp field + :rtype zfp_field: zFORp_field_type + + .. f:function:: zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) + + Wrapper for :c:func:`zfp_field_4d` + + :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data + :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer nx [in]: number of elements in uncompressed data array's x dimension + :p integer ny [in]: number of elements in uncompressed data array's y dimension + :p integer nz [in]: number of elements in uncompressed data array's z dimension + :p integer nw [in]: number of elements in uncompressed data array's w dimension + :r zfp_field: newly allocated zfp field + :rtype zfp_field: zFORp_field_type + + .. f:subroutine:: zFORp_field_free(zfp_field) + + Wrapper for :c:func:`zfp_field_free` + + :p zFORp_field_type zfp_field [inout]: Zfp_field + + .. f:function:: zFORp_field_pointer(zfp_field) + + Wrapper for :c:func:`zfp_field_pointer` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :r arr_ptr: pointer to raw (uncompressed/decompressed) array + :rtype arr_ptr: type(c_ptr) + + .. f:function:: zFORp_field_scalar_type(zfp_field) + + Wrapper for :c:func:`zfp_field_type` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :r zfp_type: zfp_type enum describing field data + :rtype zfp_type: integer + + .. f:function:: zFORp_field_precision(zfp_field) + + Wrapper for :c:func:`zfp_field_precision` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :r prec: type precision describing field data + :rtype prec: integer + + .. f:function:: zFORp_field_dimensionality(zfp_field) + + Wrapper for :c:func:`zfp_field_dimensionality` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :r dims: dimensionality of field data + :rtype dims: integer + + .. f:function:: zFORp_field_size(zfp_field, size_arr) + + Wrapper for :c:func:`zfp_field_size` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer size_arr [inout]: integer array to write field dimensions into + :r total_size: total number of elements in field + :rtype total_size: integer (kind=8) + + .. f:function:: zFORp_field_stride(zfp_field, stride_arr) + + Wrapper for :c:func:`zfp_field_stride` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer stride_arr [inout]: integer array to write strides into + :r is_strided: indicate whether field is strided or not + :rtype is_strided: integer + + .. f:function:: zFORp_field_metadata(zfp_field) + + Wrapper for :c:func:`zfp_field_metadata` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :r encoded_metadata: encoded metadata of field + :rtype encoded_metadata: integer (kind=8) + + .. f:subroutine:: zFORp_field_set_pointer(zfp_field, arr_ptr) + + Wrapper for :c:func:`zfp_field_set_pointer` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p type(c_ptr) arr_ptr [in]: pointer to raw array + + .. f:function:: zFORp_field_set_type(zfp_field, zfp_type) + + Wrapper for :c:func:`zfp_field_set_type` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer zfp_type: desired zfp_type enum + :r zfp_type_result: new zfp_type on the field + :rtype zfp_type_result: integer + + .. f:subroutine:: zFORp_field_set_size_1d(zfp_field, nx) + + Wrapper for :c:func:`zfp_field_set_size_1d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer nx [in]: number of elements in data array + + .. f:subroutine:: zFORp_field_set_size_2d(zfp_field, nx, ny) + + Wrapper for :c:func:`zfp_field_set_size_2d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer nx [in]: number of elements in data array's x dimension + :p integer ny [in]: number of elements in data array's y dimension + + .. f:subroutine:: zFORp_field_set_size_3d(zfp_field, nx, ny, nz) + + Wrapper for :c:func:`zfp_field_set_size_3d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer nx [in]: number of elements in data array's x dimension + :p integer ny [in]: number of elements in data array's y dimension + :p integer nz [in]: number of elements in data array's z dimension + + .. f:subroutine:: zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) + + Wrapper for :c:func:`zfp_field_set_size_4d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer nx [in]: number of elements in data array's x dimension + :p integer ny [in]: number of elements in data array's y dimension + :p integer nz [in]: number of elements in data array's z dimension + :p integer nw [in]: number of elements in data array's w dimension + + .. f:subroutine:: zFORp_field_set_stride_1d(zfp_field, sx) + + Wrapper for :c:func:`zfp_field_set_stride_1d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer sx [in]: stride of data array's x dimension + + .. f:subroutine:: zFORp_field_set_stride_2d(zfp_field, sx, sy) + + Wrapper for :c:func:`zfp_field_set_stride_2d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer sx [in]: stride of data array's x dimension + :p integer sy [in]: stride of data array's y dimension + + .. f:subroutine:: zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) + + Wrapper for :c:func:`zfp_field_set_stride_3d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer sx [in]: stride of data array's x dimension + :p integer sy [in]: stride of data array's y dimension + :p integer sz [in]: stride of data array's z dimension + + .. f:subroutine:: zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) + + Wrapper for :c:func:`zfp_field_set_stride_4d` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer sx [in]: stride of data array's x dimension + :p integer sy [in]: stride of data array's y dimension + :p integer sz [in]: stride of data array's z dimension + :p integer sw [in]: stride of data array's w dimension + + .. f:function:: zFORp_field_set_metadata(zfp_field, encoded_metadata) + + Wrapper for :c:func:`zfp_field_set_metadata` + + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer encoded_metadata [in]: encoded metadata (kind=8) + :r is_success: indicate whether metadata successfully set on field or not + :rtype is_success: integer + +High-level API: compression, decompression, header wrappers +----------------------------------------------------------- + + .. f:function:: zFORp_compress(zfp_stream, zfp_field) + + Wrapper for :c:func:`zfp_compress` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :r bitstream_offset_bytes: bitstream offset after compression, in bytes + :rtype bitstream_offset_bytes: integer (kind=8) + + .. f:function:: zFORp_decompress(zfp_stream, zfp_field) + + Wrapper for :c:func:`zfp_decompress` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :r bitstream_offset_bytes: bitstream offset after decompression, in bytes + :rtype bitstream_offset_bytes: integer (kind=8) + + .. f:function:: zFORp_write_header(zfp_stream, zfp_field, mask) + + Wrapper for :c:func:`zfp_write_header` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer mask [in]: indicates header level of detail + :r num_bits_written: number of bits successfully written in header + :rtype num_bits_written: integer (kind=8) + + .. f:function:: zFORp_read_header(zfp_stream, zfp_field, mask) + + Wrapper for :c:func:`zfp_read_header` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :p integer mask [in]: indicates header level of detail + :r num_bits_read: number of bits successfully read in header + :rtype num_bits_read: integer (kind=8) + +Low-level API: stream manipulation wrappers +------------------------------------------- + + .. f:subroutine:: zFORp_stream_rewind(zfp_stream) + + Wrapper for :c:func:`zfp_stream_rewind` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream From d9a355ea87316df89fe5896237e1b421b8e63ec2 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 25 Apr 2019 14:44:02 -0700 Subject: [PATCH 148/194] add fortran code coverage flags --- cmake/travis.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 6d5ab5f7b..7d600dbc4 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -55,6 +55,7 @@ if(WITH_COVERAGE) list(APPEND cfg_options -DCMAKE_C_FLAGS=-coverage -DCMAKE_CXX_FLAGS=-coverage + -DCMAKE_Fortran_FLAGS=-coverage ) set(CTEST_SITE "${CTEST_SITE}_coverage") endif() From 8dd161a7ba98dd27625f5af6dfc5994014b927e1 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 25 Apr 2019 15:13:51 -0700 Subject: [PATCH 149/194] add reversible mode bindings to Fortran API --- docs/source/zforp.rst | 15 +++++++++++++++ fortran/zfp.f | 28 +++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index f3735aa42..5648a86b2 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -54,6 +54,7 @@ Constants .. f:variable:: integer zFORp_mode_fixed_rate .. f:variable:: integer zFORp_mode_fixed_precision .. f:variable:: integer zFORp_mode_fixed_accuracy + .. f:variable:: integer zFORp_mode_reversible Enums wrapping :c:type:`zfp_exec_policy` @@ -198,6 +199,14 @@ High-level API utility function wrappers :r bitstream: Bitstream :rtype bitstream: zFORp_bitstream_type + .. f:function:: zFORp_stream_is_reversible(zfp_stream) + + Wrapper for :c:func:`zfp_stream_is_reversible` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r is_reversible: indicate whether reversible mode active (1) or not (0) + :rtype is_reversible: integer + .. f:function:: zFORp_stream_compression_mode(zfp_stream) Wrapper for :c:func:`zfp_stream_compression_mode` @@ -248,6 +257,12 @@ High-level API utility function wrappers :p zFORp_stream_type zfp_stream [in]: Zfp_stream :p zFORp_bitstream_type bitstream [in]: bitstream + .. f:subroutine:: zFORp_stream_set_reversible(zfp_stream) + + Wrapper for :c:func:`zfp_stream_set_reversible` + + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + .. f:function:: zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) Wrapper for :c:func:`zfp_stream_set_rate` diff --git a/fortran/zfp.f b/fortran/zfp.f index 4d40dcf34..7494d56d4 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -33,7 +33,8 @@ module zFORp_module zFORp_mode_expert = 1, & zFORp_mode_fixed_rate = 2, & zFORp_mode_fixed_precision = 3, & - zFORp_mode_fixed_accuracy = 4 + zFORp_mode_fixed_accuracy = 4, & + zFORp_mode_reversible = 5 end enum enum, bind(c) @@ -159,6 +160,12 @@ function zfp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zfp_s type(c_ptr) :: bitstream end function + function zfp_stream_is_reversible(zfp_stream) result(is_reversible) bind(c, name="zfp_stream_is_reversible") + import + type(c_ptr), value :: zfp_stream + integer(c_int) :: is_reversible + end function + function zfp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zfp_stream_compression_mode") import type(c_ptr), value :: zfp_stream @@ -194,6 +201,11 @@ subroutine zfp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zfp_st type(c_ptr), value :: zfp_stream, bitstream end subroutine + subroutine zfp_stream_set_reversible(zfp_stream) bind(c, name="zfp_stream_set_reversible") + import + type(c_ptr), value :: zfp_stream + end subroutine + function zfp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") import type(c_ptr), value :: zfp_stream @@ -519,12 +531,14 @@ subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") public :: zFORp_stream_open, & zFORp_stream_close, & zFORp_stream_bit_stream, & + zFORp_stream_is_reversible, & zFORp_stream_compression_mode, & zFORp_stream_mode, & zFORp_stream_params, & zFORp_stream_compressed_size, & zFORp_stream_maximum_size, & zFORp_stream_set_bit_stream, & + zFORp_stream_set_reversible, & zFORp_stream_set_rate, & zFORp_stream_set_precision, & zFORp_stream_set_accuracy, & @@ -626,6 +640,13 @@ function zFORp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zfo bitstream%object = zfp_stream_bit_stream(zfp_stream%object) end function zFORp_stream_bit_stream + function zFORp_stream_is_reversible(zfp_stream) result(is_reversible) bind(c, name="zforp_stream_is_reversible") + implicit none + type(zFORp_stream_type), intent(in) :: zfp_stream + integer is_reversible + is_reversible = zfp_stream_is_reversible(zfp_stream%object) + end function zFORp_stream_is_reversible + function zFORp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream @@ -671,6 +692,11 @@ subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zfor call zfp_stream_set_bit_stream(zfp_stream%object, bitstream%object) end subroutine zFORp_stream_set_bit_stream + subroutine zFORp_stream_set_reversible(zfp_stream) bind(c, name="zforp_stream_set_reversible") + type(zFORp_stream_type), intent(in) :: zfp_stream + call zfp_stream_set_reversible(zfp_stream%object) + end subroutine zFORp_stream_set_reversible + function zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") implicit none type(zFORp_stream_type), intent(in) :: zfp_stream From d529fad81dbc12012cd31dfc6ad7553c811a6ec4 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 24 Apr 2019 15:27:55 -0700 Subject: [PATCH 150/194] fix docs typos: remove type() when zFORp inside --- docs/source/zforp.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 5648a86b2..f602e24ec 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -181,7 +181,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_open` - :p type(zFORp_bitstream_type) bitstream [in]: Bitstream + :p zFORp_bitstream_type bitstream [in]: Bitstream :r zfp_stream: Newly allocated zfp_stream :rtype zfp_stream: zFORp_stream_type @@ -189,7 +189,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_close` - :p type(zFORp_stream_type) zfp_stream [inout]: Zfp_stream + :p zFORp_stream_type zfp_stream [inout]: Zfp_stream .. f:function:: zFORp_stream_bit_stream(zfp_stream) From 216a2b808b43efa71ba03dbcfcc14d2990d203dc Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 25 Apr 2019 23:36:22 -0700 Subject: [PATCH 151/194] fix fortran documentation referencing zfp constant --- docs/source/zforp.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index f602e24ec..73fe99f12 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -86,7 +86,7 @@ Constants .. f:variable:: character(len=36) zFORp_version_string - Wraps :c:macro:`ZFP_VERSION_STRING` + Wraps :c:data:`zfp_version_string` .. f:variable:: integer zFORp_min_bits From 69fb52905511a8bb621a8c3119f77da2d8a4a240 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 26 Apr 2019 00:26:57 -0700 Subject: [PATCH 152/194] remove indentation in fortran docs --- docs/source/zforp.rst | 338 +++++++++++++++++++++--------------------- 1 file changed, 169 insertions(+), 169 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 73fe99f12..4e74d5a2c 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -24,295 +24,295 @@ decompress data. Types ----- - .. f:type:: zFORp_bitstream_type +.. f:type:: zFORp_bitstream_type - :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` + :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` - .. f:type:: zFORp_stream_type +.. f:type:: zFORp_stream_type - :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` - .. f:type:: zFORp_field_type +.. f:type:: zFORp_field_type - :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` Constants --------- - Enums wrapping :c:type:`zfp_type` +Enums wrapping :c:type:`zfp_type` - .. f:variable:: integer zFORp_type_none - .. f:variable:: integer zFORp_type_int32 - .. f:variable:: integer zFORp_type_int64 - .. f:variable:: integer zFORp_type_float - .. f:variable:: integer zFORp_type_double + .. f:variable:: integer zFORp_type_none + .. f:variable:: integer zFORp_type_int32 + .. f:variable:: integer zFORp_type_int64 + .. f:variable:: integer zFORp_type_float + .. f:variable:: integer zFORp_type_double - Enums wrapping :c:type:`zfp_mode` +Enums wrapping :c:type:`zfp_mode` - .. f:variable:: integer zFORp_mode_null - .. f:variable:: integer zFORp_mode_expert - .. f:variable:: integer zFORp_mode_fixed_rate - .. f:variable:: integer zFORp_mode_fixed_precision - .. f:variable:: integer zFORp_mode_fixed_accuracy - .. f:variable:: integer zFORp_mode_reversible + .. f:variable:: integer zFORp_mode_null + .. f:variable:: integer zFORp_mode_expert + .. f:variable:: integer zFORp_mode_fixed_rate + .. f:variable:: integer zFORp_mode_fixed_precision + .. f:variable:: integer zFORp_mode_fixed_accuracy + .. f:variable:: integer zFORp_mode_reversible - Enums wrapping :c:type:`zfp_exec_policy` +Enums wrapping :c:type:`zfp_exec_policy` - .. f:variable:: integer zFORp_exec_serial - .. f:variable:: integer zFORp_exec_omp - .. f:variable:: integer zFORp_exec_cuda + .. f:variable:: integer zFORp_exec_serial + .. f:variable:: integer zFORp_exec_omp + .. f:variable:: integer zFORp_exec_cuda - Non-enum constants +Non-enum constants - .. f:variable:: integer zFORp_version_major + .. f:variable:: integer zFORp_version_major - Wraps :c:macro:`ZFP_VERSION_MAJOR` + Wraps :c:macro:`ZFP_VERSION_MAJOR` - .. f:variable:: integer zFORp_version_minor + .. f:variable:: integer zFORp_version_minor - Wraps :c:macro:`ZFP_VERSION_MINOR` + Wraps :c:macro:`ZFP_VERSION_MINOR` - .. f:variable:: integer zFORp_version_patch + .. f:variable:: integer zFORp_version_patch - Wraps :c:macro:`ZFP_VERSION_PATCH` + Wraps :c:macro:`ZFP_VERSION_PATCH` - .. f:variable:: integer zFORp_codec_version + .. f:variable:: integer zFORp_codec_version - Wraps :c:data:`zfp_codec_version` + Wraps :c:data:`zfp_codec_version` - .. f:variable:: integer zFORp_library_version + .. f:variable:: integer zFORp_library_version - Wraps :c:data:`zfp_library_version` + Wraps :c:data:`zfp_library_version` - .. f:variable:: character(len=36) zFORp_version_string + .. f:variable:: character(len=36) zFORp_version_string - Wraps :c:data:`zfp_version_string` + Wraps :c:data:`zfp_version_string` - .. f:variable:: integer zFORp_min_bits + .. f:variable:: integer zFORp_min_bits - Wraps :c:macro:`ZFP_MIN_BITS` + Wraps :c:macro:`ZFP_MIN_BITS` - .. f:variable:: integer zFORp_max_bits + .. f:variable:: integer zFORp_max_bits - Wraps :c:macro:`ZFP_MAX_BITS` + Wraps :c:macro:`ZFP_MAX_BITS` - .. f:variable:: integer zFORp_max_prec + .. f:variable:: integer zFORp_max_prec - Wraps :c:macro:`ZFP_MAX_PREC` + Wraps :c:macro:`ZFP_MAX_PREC` - .. f:variable:: integer zFORp_min_exp + .. f:variable:: integer zFORp_min_exp - Wraps :c:macro:`ZFP_MIN_EXP` + Wraps :c:macro:`ZFP_MIN_EXP` - .. f:variable:: integer zFORp_header_magic + .. f:variable:: integer zFORp_header_magic - Wraps :c:macro:`ZFP_HEADER_MAGIC` + Wraps :c:macro:`ZFP_HEADER_MAGIC` - .. f:variable:: integer zFORp_header_meta + .. f:variable:: integer zFORp_header_meta - Wraps :c:macro:`ZFP_HEADER_META` + Wraps :c:macro:`ZFP_HEADER_META` - .. f:variable:: integer zFORp_header_mode + .. f:variable:: integer zFORp_header_mode - Wraps :c:macro:`ZFP_HEADER_MODE` + Wraps :c:macro:`ZFP_HEADER_MODE` - .. f:variable:: integer zFORp_header_full + .. f:variable:: integer zFORp_header_full - Wraps :c:macro:`ZFP_HEADER_FULL` + Wraps :c:macro:`ZFP_HEADER_FULL` - .. f:variable:: integer zFORp_meta_null + .. f:variable:: integer zFORp_meta_null - Wraps :c:macro:`ZFP_META_NULL` + Wraps :c:macro:`ZFP_META_NULL` - .. f:variable:: integer zFORp_magic_bits + .. f:variable:: integer zFORp_magic_bits - Wraps :c:macro:`ZFP_MAGIC_BITS` + Wraps :c:macro:`ZFP_MAGIC_BITS` - .. f:variable:: integer zFORp_meta_bits + .. f:variable:: integer zFORp_meta_bits - Wraps :c:macro:`ZFP_META_BITS` + Wraps :c:macro:`ZFP_META_BITS` - .. f:variable:: integer zFORp_mode_short_bits + .. f:variable:: integer zFORp_mode_short_bits - Wraps :c:macro:`ZFP_MODE_SHORT_BITS` + Wraps :c:macro:`ZFP_MODE_SHORT_BITS` - .. f:variable:: integer zFORp_mode_long_bits + .. f:variable:: integer zFORp_mode_long_bits - Wraps :c:macro:`ZFP_MODE_LONG_BITS` + Wraps :c:macro:`ZFP_MODE_LONG_BITS` - .. f:variable:: integer zFORp_header_max_bits + .. f:variable:: integer zFORp_header_max_bits - Wraps :c:macro:`ZFP_HEADER_MAX_BITS` + Wraps :c:macro:`ZFP_HEADER_MAX_BITS` - .. f:variable:: integer zFORp_mode_short_max + .. f:variable:: integer zFORp_mode_short_max - Wraps :c:macro:`ZFP_MODE_SHORT_MAX` + Wraps :c:macro:`ZFP_MODE_SHORT_MAX` Bitstream function wrappers --------------------------- - .. f:function:: zFORp_bitstream_stream_open(buffer, bytes) +.. f:function:: zFORp_bitstream_stream_open(buffer, bytes) - Wrapper for :c:func:`stream_open` + Wrapper for :c:func:`stream_open` - :p type(c_ptr) buffer [in]: Bitstream buffer - :p integer (kind=8) bytes [in]: Buffer size, in bytes - :r bitstream: Bitstream - :rtype bitstream: zFORp_bitstream_type + :p type(c_ptr) buffer [in]: Bitstream buffer + :p integer (kind=8) bytes [in]: Buffer size, in bytes + :r bitstream: Bitstream + :rtype bitstream: zFORp_bitstream_type - .. f:subroutine:: zFORp_bitstream_stream_close(bitstream) +.. f:subroutine:: zFORp_bitstream_stream_close(bitstream) - Wrapper for :c:func:`stream_close` + Wrapper for :c:func:`stream_close` - :p zFORp_bitstream_type bitstream [inout]: Bitstream + :p zFORp_bitstream_type bitstream [inout]: Bitstream High-level API utility function wrappers ---------------------------------------- - .. f:function:: zFORp_type_size(zfp_type) +.. f:function:: zFORp_type_size(zfp_type) - Wrapper for :c:func:`zfp_type_size` + Wrapper for :c:func:`zfp_type_size` - :p integer zfp_type [in]: zFORp_type enum. - :r type_size: Size of described zfp_type, in bytes, from C-language perspective. - :rtype type_size: integer + :p integer zfp_type [in]: zFORp_type enum. + :r type_size: Size of described zfp_type, in bytes, from C-language perspective. + :rtype type_size: integer - .. f:function:: zFORp_stream_open(bitstream) +.. f:function:: zFORp_stream_open(bitstream) - Wrapper for :c:func:`zfp_stream_open` + Wrapper for :c:func:`zfp_stream_open` - :p zFORp_bitstream_type bitstream [in]: Bitstream - :r zfp_stream: Newly allocated zfp_stream - :rtype zfp_stream: zFORp_stream_type + :p zFORp_bitstream_type bitstream [in]: Bitstream + :r zfp_stream: Newly allocated zfp_stream + :rtype zfp_stream: zFORp_stream_type - .. f:subroutine:: zFORp_stream_close(zfp_stream) +.. f:subroutine:: zFORp_stream_close(zfp_stream) - Wrapper for :c:func:`zfp_stream_close` + Wrapper for :c:func:`zfp_stream_close` - :p zFORp_stream_type zfp_stream [inout]: Zfp_stream + :p zFORp_stream_type zfp_stream [inout]: Zfp_stream - .. f:function:: zFORp_stream_bit_stream(zfp_stream) +.. f:function:: zFORp_stream_bit_stream(zfp_stream) - Wrapper for :c:func:`zfp_stream_bit_stream` + Wrapper for :c:func:`zfp_stream_bit_stream` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r bitstream: Bitstream - :rtype bitstream: zFORp_bitstream_type + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r bitstream: Bitstream + :rtype bitstream: zFORp_bitstream_type - .. f:function:: zFORp_stream_is_reversible(zfp_stream) +.. f:function:: zFORp_stream_is_reversible(zfp_stream) - Wrapper for :c:func:`zfp_stream_is_reversible` + Wrapper for :c:func:`zfp_stream_is_reversible` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r is_reversible: indicate whether reversible mode active (1) or not (0) - :rtype is_reversible: integer + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r is_reversible: indicate whether reversible mode active (1) or not (0) + :rtype is_reversible: integer - .. f:function:: zFORp_stream_compression_mode(zfp_stream) +.. f:function:: zFORp_stream_compression_mode(zfp_stream) - Wrapper for :c:func:`zfp_stream_compression_mode` + Wrapper for :c:func:`zfp_stream_compression_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r zfp_mode: zFORp_mode enum - :rtype zfp_mode: integer + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r zfp_mode: zFORp_mode enum + :rtype zfp_mode: integer - .. f:function:: zFORp_stream_mode(zfp_stream) +.. f:function:: zFORp_stream_mode(zfp_stream) - Wrapper for :c:func:`zfp_stream_mode` + Wrapper for :c:func:`zfp_stream_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r encoded_mode: 64 bit encoded mode - :rtype encoded_mode: integer (kind=8) + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r encoded_mode: 64 bit encoded mode + :rtype encoded_mode: integer (kind=8) - .. f:subroutine:: zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) +.. f:subroutine:: zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) - Wrapper for :c:func:`zfp_stream_params` + Wrapper for :c:func:`zfp_stream_params` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p integer (kind=8) minbits [inout]: minbits - :p integer (kind=8) maxbits [inout]: maxbits - :p integer (kind=8) maxprec [inout]: maxprec - :p integer (kind=8) minexp [inout]: minexp + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer (kind=8) minbits [inout]: minbits + :p integer (kind=8) maxbits [inout]: maxbits + :p integer (kind=8) maxprec [inout]: maxprec + :p integer (kind=8) minexp [inout]: minexp - .. f:function:: zFORp_stream_compressed_size(zfp_stream) +.. f:function:: zFORp_stream_compressed_size(zfp_stream) - Wrapper for :c:func:`zfp_stream_compressed_size` + Wrapper for :c:func:`zfp_stream_compressed_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r compressed_size: compressed size - :rtype compressed_size: integer (kind=8) + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :r compressed_size: compressed size + :rtype compressed_size: integer (kind=8) - .. f:function:: zFORp_stream_maximum_size(zfp_stream, zfp_field) +.. f:function:: zFORp_stream_maximum_size(zfp_stream, zfp_field) - Wrapper for :c:func:`zfp_stream_maximum_size` + Wrapper for :c:func:`zfp_stream_maximum_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field - :r max_size: maximum size - :rtype max_size: integer (kind=8) + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_field_type zfp_field [in]: Zfp_field + :r max_size: maximum size + :rtype max_size: integer (kind=8) - .. f:subroutine:: zFORp_stream_set_bit_stream(zfp_stream, bitstream) +.. f:subroutine:: zFORp_stream_set_bit_stream(zfp_stream, bitstream) - Wrapper for :c:func:`zfp_stream_set_bit_stream` + Wrapper for :c:func:`zfp_stream_set_bit_stream` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_bitstream_type bitstream [in]: bitstream + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_bitstream_type bitstream [in]: bitstream - .. f:subroutine:: zFORp_stream_set_reversible(zfp_stream) +.. f:subroutine:: zFORp_stream_set_reversible(zfp_stream) - Wrapper for :c:func:`zfp_stream_set_reversible` + Wrapper for :c:func:`zfp_stream_set_reversible` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type zfp_stream [in]: Zfp_stream - .. f:function:: zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) +.. f:function:: zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) - Wrapper for :c:func:`zfp_stream_set_rate` + Wrapper for :c:func:`zfp_stream_set_rate` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p real rate [in]: desired rate - :p integer zfp_type [in]: enum zfp_type - :p integer dims [in]: dimensions - :p integer wra [in]: use write random access? - :r rate_result: actual set rate - :rtype rate_result: real + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p real rate [in]: desired rate + :p integer zfp_type [in]: enum zfp_type + :p integer dims [in]: dimensions + :p integer wra [in]: use write random access? + :r rate_result: actual set rate + :rtype rate_result: real - .. f:function:: zFORp_stream_set_precision(zfp_stream, prec) +.. f:function:: zFORp_stream_set_precision(zfp_stream, prec) - Wrapper for :c:func:`zfp_stream_set_precision` + Wrapper for :c:func:`zfp_stream_set_precision` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p integer prec [in]: desired precision - :r prec_result: actual set precision - :rtype prec_result: integer + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer prec [in]: desired precision + :r prec_result: actual set precision + :rtype prec_result: integer - .. f:function:: zFORp_stream_set_accuracy(zfp_stream, acc) +.. f:function:: zFORp_stream_set_accuracy(zfp_stream, acc) - Wrapper for :c:func:`zfp_stream_set_accuracy()` + Wrapper for :c:func:`zfp_stream_set_accuracy()` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p real acc: desired accuracy (kind=8) - :r acc_result: actual set accuracy - :rtype acc_result: real (kind=8) + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p real acc: desired accuracy (kind=8) + :r acc_result: actual set accuracy + :rtype acc_result: real (kind=8) - .. f:function:: zFORp_stream_set_mode(zfp_stream, encoded_mode) +.. f:function:: zFORp_stream_set_mode(zfp_stream, encoded_mode) - Wrapper for :c:func:`zfp_stream_set_mode` + Wrapper for :c:func:`zfp_stream_set_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p integer encoded_mode [in]: encoded mode parameter - :r mode_result: newly set zfp_mode enum on zfp_stream - :rtype mode_result: integer + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer encoded_mode [in]: encoded mode parameter + :r mode_result: newly set zfp_mode enum on zfp_stream + :rtype mode_result: integer - .. f:function:: zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) +.. f:function:: zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) - Wrapper for :c:func:`zfp_stream_set_params` + Wrapper for :c:func:`zfp_stream_set_params` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p integer minbits [in]: min num of bits - :p integer maxbits [in]: max num of bits - :p integer maxprec [in]: max precision - :p integer minexp [in]: min exponent - :r is_success: indicate whether parameters were successfully set (1) or not (0) - :rtype is_success: integer + :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p integer minbits [in]: min num of bits + :p integer maxbits [in]: max num of bits + :p integer maxprec [in]: max precision + :p integer minexp [in]: min exponent + :r is_success: indicate whether parameters were successfully set (1) or not (0) + :rtype is_success: integer High-level API: execution policy function wrappers -------------------------------------------------- From d36f8ac2f5078c9143207c59646bdb515062d743 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 26 Apr 2019 00:52:26 -0700 Subject: [PATCH 153/194] change fortran parameter names to match C API --- docs/source/zforp.rst | 232 +++++++++--------- fortran/zfp.f | 556 +++++++++++++++++++++--------------------- 2 files changed, 394 insertions(+), 394 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 4e74d5a2c..32be04869 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -157,14 +157,14 @@ Bitstream function wrappers :p type(c_ptr) buffer [in]: Bitstream buffer :p integer (kind=8) bytes [in]: Buffer size, in bytes - :r bitstream: Bitstream - :rtype bitstream: zFORp_bitstream_type + :r bs: Bitstream + :rtype bs: zFORp_bitstream_type -.. f:subroutine:: zFORp_bitstream_stream_close(bitstream) +.. f:subroutine:: zFORp_bitstream_stream_close(bs) Wrapper for :c:func:`stream_close` - :p zFORp_bitstream_type bitstream [inout]: Bitstream + :p zFORp_bitstream_type bs [inout]: Bitstream High-level API utility function wrappers ---------------------------------------- @@ -177,97 +177,97 @@ High-level API utility function wrappers :r type_size: Size of described zfp_type, in bytes, from C-language perspective. :rtype type_size: integer -.. f:function:: zFORp_stream_open(bitstream) +.. f:function:: zFORp_stream_open(bs) Wrapper for :c:func:`zfp_stream_open` - :p zFORp_bitstream_type bitstream [in]: Bitstream - :r zfp_stream: Newly allocated zfp_stream - :rtype zfp_stream: zFORp_stream_type + :p zFORp_bitstream_type bs [in]: Bitstream + :r stream: Newly allocated zfp_stream + :rtype stream: zFORp_stream_type -.. f:subroutine:: zFORp_stream_close(zfp_stream) +.. f:subroutine:: zFORp_stream_close(stream) Wrapper for :c:func:`zfp_stream_close` - :p zFORp_stream_type zfp_stream [inout]: Zfp_stream + :p zFORp_stream_type stream [inout]: Zfp_stream -.. f:function:: zFORp_stream_bit_stream(zfp_stream) +.. f:function:: zFORp_stream_bit_stream(stream) Wrapper for :c:func:`zfp_stream_bit_stream` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :r bitstream: Bitstream - :rtype bitstream: zFORp_bitstream_type + :p zFORp_stream_type stream [in]: Zfp_stream + :r bs: Bitstream + :rtype bs: zFORp_bitstream_type -.. f:function:: zFORp_stream_is_reversible(zfp_stream) +.. f:function:: zFORp_stream_is_reversible(stream) Wrapper for :c:func:`zfp_stream_is_reversible` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r is_reversible: indicate whether reversible mode active (1) or not (0) :rtype is_reversible: integer -.. f:function:: zFORp_stream_compression_mode(zfp_stream) +.. f:function:: zFORp_stream_compression_mode(stream) Wrapper for :c:func:`zfp_stream_compression_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r zfp_mode: zFORp_mode enum :rtype zfp_mode: integer -.. f:function:: zFORp_stream_mode(zfp_stream) +.. f:function:: zFORp_stream_mode(stream) Wrapper for :c:func:`zfp_stream_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r encoded_mode: 64 bit encoded mode :rtype encoded_mode: integer (kind=8) -.. f:subroutine:: zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) +.. f:subroutine:: zFORp_stream_params(stream, minbits, maxbits, maxprec, minexp) Wrapper for :c:func:`zfp_stream_params` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer (kind=8) minbits [inout]: minbits :p integer (kind=8) maxbits [inout]: maxbits :p integer (kind=8) maxprec [inout]: maxprec :p integer (kind=8) minexp [inout]: minexp -.. f:function:: zFORp_stream_compressed_size(zfp_stream) +.. f:function:: zFORp_stream_compressed_size(stream) Wrapper for :c:func:`zfp_stream_compressed_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r compressed_size: compressed size :rtype compressed_size: integer (kind=8) -.. f:function:: zFORp_stream_maximum_size(zfp_stream, zfp_field) +.. f:function:: zFORp_stream_maximum_size(stream, field) Wrapper for :c:func:`zfp_stream_maximum_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_field_type field [in]: Zfp_field :r max_size: maximum size :rtype max_size: integer (kind=8) -.. f:subroutine:: zFORp_stream_set_bit_stream(zfp_stream, bitstream) +.. f:subroutine:: zFORp_stream_set_bit_stream(stream, bs) Wrapper for :c:func:`zfp_stream_set_bit_stream` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_bitstream_type bitstream [in]: bitstream + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_bitstream_type bs [in]: bitstream -.. f:subroutine:: zFORp_stream_set_reversible(zfp_stream) +.. f:subroutine:: zFORp_stream_set_reversible(stream) Wrapper for :c:func:`zfp_stream_set_reversible` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream -.. f:function:: zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) +.. f:function:: zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) Wrapper for :c:func:`zfp_stream_set_rate` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p real rate [in]: desired rate :p integer zfp_type [in]: enum zfp_type :p integer dims [in]: dimensions @@ -275,38 +275,38 @@ High-level API utility function wrappers :r rate_result: actual set rate :rtype rate_result: real -.. f:function:: zFORp_stream_set_precision(zfp_stream, prec) +.. f:function:: zFORp_stream_set_precision(stream, prec) Wrapper for :c:func:`zfp_stream_set_precision` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer prec [in]: desired precision :r prec_result: actual set precision :rtype prec_result: integer -.. f:function:: zFORp_stream_set_accuracy(zfp_stream, acc) +.. f:function:: zFORp_stream_set_accuracy(stream, acc) Wrapper for :c:func:`zfp_stream_set_accuracy()` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p real acc: desired accuracy (kind=8) :r acc_result: actual set accuracy :rtype acc_result: real (kind=8) -.. f:function:: zFORp_stream_set_mode(zfp_stream, encoded_mode) +.. f:function:: zFORp_stream_set_mode(stream, encoded_mode) Wrapper for :c:func:`zfp_stream_set_mode` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer encoded_mode [in]: encoded mode parameter :r mode_result: newly set zfp_mode enum on zfp_stream :rtype mode_result: integer -.. f:function:: zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) +.. f:function:: zFORp_stream_set_params(stream, minbits, maxbits, maxprec, minexp) Wrapper for :c:func:`zfp_stream_set_params` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer minbits [in]: min num of bits :p integer maxbits [in]: max num of bits :p integer maxprec [in]: max precision @@ -317,53 +317,53 @@ High-level API utility function wrappers High-level API: execution policy function wrappers -------------------------------------------------- - .. f:function:: zFORp_stream_execution(zfp_stream) + .. f:function:: zFORp_stream_execution(stream) Wrapper for :c:func:`zfp_stream_execution` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r execution_policy: enum of active execution policy :rtype execution_policy: integer - .. f:function:: zFORp_stream_omp_threads(zfp_stream) + .. f:function:: zFORp_stream_omp_threads(stream) Wrapper for :c:func:`zfp_stream_omp_threads` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r thread_count: number of threads to use upon execution :rtype thread_count: integer - .. f:function:: zFORp_stream_omp_chunk_size(zfp_stream) + .. f:function:: zFORp_stream_omp_chunk_size(stream) Wrapper for :c:func:`zfp_stream_omp_chunk_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :r chunk_size_blocks: specified chunk size, in blocks :rtype chunk_size_blocks: integer (kind=8) - .. f:function:: zFORp_stream_set_execution(zfp_stream, execution_policy) + .. f:function:: zFORp_stream_set_execution(stream, execution_policy) Wrapper for :c:func:`zfp_stream_set_execution` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer execution_policy [in]: desired execution policy (enum) :r is_success: indicate whether execution policy was successfully set or not :rtype is_success: integer - .. f:function:: zFORp_stream_set_omp_threads(zfp_stream, thread_count) + .. f:function:: zFORp_stream_set_omp_threads(stream, thread_count) Wrapper for :c:func:`zfp_stream_set_omp_threads` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer thread_count [in]: desired number of threads :r is_success: indicate whether number of threads successfully set or not :rtype is_success: integer - .. f:function:: zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) + .. f:function:: zFORp_stream_set_omp_chunk_size(stream, chunk_size) Wrapper for :c:func:`zfp_stream_set_omp_chunk_size` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream :p integer chunk_size [in]: desired chunk size, in blocks :r is_success: indicate whether chunk size successfully set or not :rtype is_success: integer @@ -375,8 +375,8 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_alloc` - :r zfp_field: newly allocated zfp field - :rtype zfp_field: zFORp_field_type + :r field: newly allocated zfp_field + :rtype field: zFORp_field_type .. f:function:: zFORp_field_1d(uncompressed_ptr, zfp_type, nx) @@ -385,8 +385,8 @@ High-level API: zfp_field function wrappers :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data :p integer zfp_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array - :r zfp_field: newly allocated zfp field - :rtype zfp_field: zFORp_field_type + :r field: newly allocated zfp_field + :rtype field: zFORp_field_type .. f:function:: zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) @@ -396,8 +396,8 @@ High-level API: zfp_field function wrappers :p integer zfp_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension - :r zfp_field: newly allocated zfp field - :rtype zfp_field: zFORp_field_type + :r field: newly allocated zfp_field + :rtype field: zFORp_field_type .. f:function:: zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) @@ -408,8 +408,8 @@ High-level API: zfp_field function wrappers :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension :p integer nz [in]: number of elements in uncompressed data array's z dimension - :r zfp_field: newly allocated zfp field - :rtype zfp_field: zFORp_field_type + :r field: newly allocated zfp_field + :rtype field: zFORp_field_type .. f:function:: zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) @@ -421,162 +421,162 @@ High-level API: zfp_field function wrappers :p integer ny [in]: number of elements in uncompressed data array's y dimension :p integer nz [in]: number of elements in uncompressed data array's z dimension :p integer nw [in]: number of elements in uncompressed data array's w dimension - :r zfp_field: newly allocated zfp field - :rtype zfp_field: zFORp_field_type + :r field: newly allocated zfp_field + :rtype field: zFORp_field_type - .. f:subroutine:: zFORp_field_free(zfp_field) + .. f:subroutine:: zFORp_field_free(field) Wrapper for :c:func:`zfp_field_free` - :p zFORp_field_type zfp_field [inout]: Zfp_field + :p zFORp_field_type field [inout]: Zfp_field - .. f:function:: zFORp_field_pointer(zfp_field) + .. f:function:: zFORp_field_pointer(field) Wrapper for :c:func:`zfp_field_pointer` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :r arr_ptr: pointer to raw (uncompressed/decompressed) array :rtype arr_ptr: type(c_ptr) - .. f:function:: zFORp_field_scalar_type(zfp_field) + .. f:function:: zFORp_field_scalar_type(field) Wrapper for :c:func:`zfp_field_type` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :r zfp_type: zfp_type enum describing field data :rtype zfp_type: integer - .. f:function:: zFORp_field_precision(zfp_field) + .. f:function:: zFORp_field_precision(field) Wrapper for :c:func:`zfp_field_precision` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :r prec: type precision describing field data :rtype prec: integer - .. f:function:: zFORp_field_dimensionality(zfp_field) + .. f:function:: zFORp_field_dimensionality(field) Wrapper for :c:func:`zfp_field_dimensionality` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :r dims: dimensionality of field data :rtype dims: integer - .. f:function:: zFORp_field_size(zfp_field, size_arr) + .. f:function:: zFORp_field_size(field, size_arr) Wrapper for :c:func:`zfp_field_size` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer size_arr [inout]: integer array to write field dimensions into :r total_size: total number of elements in field :rtype total_size: integer (kind=8) - .. f:function:: zFORp_field_stride(zfp_field, stride_arr) + .. f:function:: zFORp_field_stride(field, stride_arr) Wrapper for :c:func:`zfp_field_stride` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer stride_arr [inout]: integer array to write strides into :r is_strided: indicate whether field is strided or not :rtype is_strided: integer - .. f:function:: zFORp_field_metadata(zfp_field) + .. f:function:: zFORp_field_metadata(field) Wrapper for :c:func:`zfp_field_metadata` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :r encoded_metadata: encoded metadata of field :rtype encoded_metadata: integer (kind=8) - .. f:subroutine:: zFORp_field_set_pointer(zfp_field, arr_ptr) + .. f:subroutine:: zFORp_field_set_pointer(field, arr_ptr) Wrapper for :c:func:`zfp_field_set_pointer` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p type(c_ptr) arr_ptr [in]: pointer to raw array - .. f:function:: zFORp_field_set_type(zfp_field, zfp_type) + .. f:function:: zFORp_field_set_type(field, zfp_type) Wrapper for :c:func:`zfp_field_set_type` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer zfp_type: desired zfp_type enum :r zfp_type_result: new zfp_type on the field :rtype zfp_type_result: integer - .. f:subroutine:: zFORp_field_set_size_1d(zfp_field, nx) + .. f:subroutine:: zFORp_field_set_size_1d(field, nx) Wrapper for :c:func:`zfp_field_set_size_1d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer nx [in]: number of elements in data array - .. f:subroutine:: zFORp_field_set_size_2d(zfp_field, nx, ny) + .. f:subroutine:: zFORp_field_set_size_2d(field, nx, ny) Wrapper for :c:func:`zfp_field_set_size_2d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension - .. f:subroutine:: zFORp_field_set_size_3d(zfp_field, nx, ny, nz) + .. f:subroutine:: zFORp_field_set_size_3d(field, nx, ny, nz) Wrapper for :c:func:`zfp_field_set_size_3d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension :p integer nz [in]: number of elements in data array's z dimension - .. f:subroutine:: zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) + .. f:subroutine:: zFORp_field_set_size_4d(field, nx, ny, nz, nw) Wrapper for :c:func:`zfp_field_set_size_4d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension :p integer nz [in]: number of elements in data array's z dimension :p integer nw [in]: number of elements in data array's w dimension - .. f:subroutine:: zFORp_field_set_stride_1d(zfp_field, sx) + .. f:subroutine:: zFORp_field_set_stride_1d(field, sx) Wrapper for :c:func:`zfp_field_set_stride_1d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension - .. f:subroutine:: zFORp_field_set_stride_2d(zfp_field, sx, sy) + .. f:subroutine:: zFORp_field_set_stride_2d(field, sx, sy) Wrapper for :c:func:`zfp_field_set_stride_2d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension - .. f:subroutine:: zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) + .. f:subroutine:: zFORp_field_set_stride_3d(field, sx, sy, sz) Wrapper for :c:func:`zfp_field_set_stride_3d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension :p integer sz [in]: stride of data array's z dimension - .. f:subroutine:: zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) + .. f:subroutine:: zFORp_field_set_stride_4d(field, sx, sy, sz, sw) Wrapper for :c:func:`zfp_field_set_stride_4d` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension :p integer sz [in]: stride of data array's z dimension :p integer sw [in]: stride of data array's w dimension - .. f:function:: zFORp_field_set_metadata(zfp_field, encoded_metadata) + .. f:function:: zFORp_field_set_metadata(field, encoded_metadata) Wrapper for :c:func:`zfp_field_set_metadata` - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_field_type field [in]: Zfp_field :p integer encoded_metadata [in]: encoded metadata (kind=8) :r is_success: indicate whether metadata successfully set on field or not :rtype is_success: integer @@ -584,40 +584,40 @@ High-level API: zfp_field function wrappers High-level API: compression, decompression, header wrappers ----------------------------------------------------------- - .. f:function:: zFORp_compress(zfp_stream, zfp_field) + .. f:function:: zFORp_compress(stream, field) Wrapper for :c:func:`zfp_compress` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_field_type field [in]: Zfp_field :r bitstream_offset_bytes: bitstream offset after compression, in bytes :rtype bitstream_offset_bytes: integer (kind=8) - .. f:function:: zFORp_decompress(zfp_stream, zfp_field) + .. f:function:: zFORp_decompress(stream, field) Wrapper for :c:func:`zfp_decompress` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_field_type field [in]: Zfp_field :r bitstream_offset_bytes: bitstream offset after decompression, in bytes :rtype bitstream_offset_bytes: integer (kind=8) - .. f:function:: zFORp_write_header(zfp_stream, zfp_field, mask) + .. f:function:: zFORp_write_header(stream, field, mask) Wrapper for :c:func:`zfp_write_header` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_field_type field [in]: Zfp_field :p integer mask [in]: indicates header level of detail :r num_bits_written: number of bits successfully written in header :rtype num_bits_written: integer (kind=8) - .. f:function:: zFORp_read_header(zfp_stream, zfp_field, mask) + .. f:function:: zFORp_read_header(stream, field, mask) Wrapper for :c:func:`zfp_read_header` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream - :p zFORp_field_type zfp_field [in]: Zfp_field + :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_field_type field [in]: Zfp_field :p integer mask [in]: indicates header level of detail :r num_bits_read: number of bits successfully read in header :rtype num_bits_read: integer (kind=8) @@ -625,8 +625,8 @@ High-level API: compression, decompression, header wrappers Low-level API: stream manipulation wrappers ------------------------------------------- - .. f:subroutine:: zFORp_stream_rewind(zfp_stream) + .. f:subroutine:: zFORp_stream_rewind(stream) Wrapper for :c:func:`zfp_stream_rewind` - :p zFORp_stream_type zfp_stream [in]: Zfp_stream + :p zFORp_stream_type stream [in]: Zfp_stream diff --git a/fortran/zfp.f b/fortran/zfp.f index 7494d56d4..223e05f9d 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -121,16 +121,16 @@ module zFORp_module ! minimal bitstream API - function zfp_bitstream_stream_open(buffer, bytes) result(bitstream) bind(c, name="stream_open") + function zfp_bitstream_stream_open(buffer, bytes) result(bs) bind(c, name="stream_open") import type(c_ptr), value :: buffer integer(c_size_t), value :: bytes - type(c_ptr) :: bitstream + type(c_ptr) :: bs end function zfp_bitstream_stream_open - subroutine zfp_bitstream_stream_close(bitstream) bind(c, name="stream_close") + subroutine zfp_bitstream_stream_close(bs) bind(c, name="stream_close") import - type(c_ptr), value :: bitstream + type(c_ptr), value :: bs end subroutine ! high-level API: utility functions @@ -143,72 +143,72 @@ function zfp_type_size(zfp_type) result(type_size) bind(c, name="zfp_type_size") ! high-level API: zfp_stream functions - function zfp_stream_open(bitstream) result(zfp_stream) bind(c, name="zfp_stream_open") + function zfp_stream_open(bs) result(stream) bind(c, name="zfp_stream_open") import - type(c_ptr), value :: bitstream - type(c_ptr) :: zfp_stream + type(c_ptr), value :: bs + type(c_ptr) :: stream end function zfp_stream_open - subroutine zfp_stream_close(zfp_stream) bind(c, name="zfp_stream_close") + subroutine zfp_stream_close(stream) bind(c, name="zfp_stream_close") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream end subroutine - function zfp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zfp_stream_bit_stream") + function zfp_stream_bit_stream(stream) result(bs) bind(c, name="zfp_stream_bit_stream") import - type(c_ptr), value :: zfp_stream - type(c_ptr) :: bitstream + type(c_ptr), value :: stream + type(c_ptr) :: bs end function - function zfp_stream_is_reversible(zfp_stream) result(is_reversible) bind(c, name="zfp_stream_is_reversible") + function zfp_stream_is_reversible(stream) result(is_reversible) bind(c, name="zfp_stream_is_reversible") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) :: is_reversible end function - function zfp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zfp_stream_compression_mode") + function zfp_stream_compression_mode(stream) result(zfp_mode) bind(c, name="zfp_stream_compression_mode") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) :: zfp_mode end function - function zfp_stream_mode(zfp_stream) result(encoded_mode) bind(c, name="zfp_stream_mode") + function zfp_stream_mode(stream) result(encoded_mode) bind(c, name="zfp_stream_mode") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int64_t) encoded_mode end function - subroutine zfp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) bind(c, name="zfp_stream_params") + subroutine zfp_stream_params(stream, minbits, maxbits, maxprec, minexp) bind(c, name="zfp_stream_params") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) :: minbits, maxbits, maxprec, minexp end subroutine - function zfp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, name="zfp_stream_compressed_size") + function zfp_stream_compressed_size(stream) result(compressed_size) bind(c, name="zfp_stream_compressed_size") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_size_t) compressed_size end function - function zfp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) bind(c, name="zfp_stream_maximum_size") + function zfp_stream_maximum_size(stream, field) result(max_size) bind(c, name="zfp_stream_maximum_size") import - type(c_ptr), value :: zfp_stream, zfp_field + type(c_ptr), value :: stream, field integer(c_size_t) max_size end function - subroutine zfp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zfp_stream_set_bit_stream") + subroutine zfp_stream_set_bit_stream(stream, bs) bind(c, name="zfp_stream_set_bit_stream") import - type(c_ptr), value :: zfp_stream, bitstream + type(c_ptr), value :: stream, bs end subroutine - subroutine zfp_stream_set_reversible(zfp_stream) bind(c, name="zfp_stream_set_reversible") + subroutine zfp_stream_set_reversible(stream) bind(c, name="zfp_stream_set_reversible") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream end subroutine - function zfp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") + function zfp_stream_set_rate(stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream real(c_double), value :: rate integer(c_int), value :: zfp_type ! no unsigned int in Fortran @@ -216,253 +216,253 @@ function zfp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_ real(c_double) :: rate_result end function - function zfp_stream_set_precision(zfp_stream, prec) result(prec_result) bind(c, name="zfp_stream_set_precision") + function zfp_stream_set_precision(stream, prec) result(prec_result) bind(c, name="zfp_stream_set_precision") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int), value :: prec integer(c_int) prec_result end function - function zfp_stream_set_accuracy(zfp_stream, acc) result(acc_result) bind(c, name="zfp_stream_set_accuracy") + function zfp_stream_set_accuracy(stream, acc) result(acc_result) bind(c, name="zfp_stream_set_accuracy") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream real(c_double), value :: acc real(c_double) acc_result end function - function zfp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) bind(c, name="zfp_stream_set_mode") + function zfp_stream_set_mode(stream, encoded_mode) result(mode_result) bind(c, name="zfp_stream_set_mode") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int64_t), value :: encoded_mode integer(c_int) mode_result end function - function zfp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) & + function zfp_stream_set_params(stream, minbits, maxbits, maxprec, minexp) & result(is_success) bind(c, name="zfp_stream_set_params") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int), value :: minbits, maxbits, maxprec, minexp integer(c_int) is_success end function ! high-level API: execution policy functions - function zfp_stream_execution(zfp_stream) result(execution_policy) bind(c, name="zfp_stream_execution") + function zfp_stream_execution(stream) result(execution_policy) bind(c, name="zfp_stream_execution") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) execution_policy end function - function zfp_stream_omp_threads(zfp_stream) result(num_threads) bind(c, name="zfp_stream_omp_threads") + function zfp_stream_omp_threads(stream) result(num_threads) bind(c, name="zfp_stream_omp_threads") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) num_threads end function - function zfp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) bind(c, name="zfp_stream_omp_chunk_size") + function zfp_stream_omp_chunk_size(stream) result(chunk_size_blocks) bind(c, name="zfp_stream_omp_chunk_size") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) chunk_size_blocks end function - function zfp_stream_set_execution(zfp_stream, execution_policy) result(is_success) bind(c, name="zfp_stream_set_execution") + function zfp_stream_set_execution(stream, execution_policy) result(is_success) bind(c, name="zfp_stream_set_execution") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) execution_policy, is_success end function - function zfp_stream_set_omp_threads(zfp_stream, threads) result(is_success) bind(c, name="zfp_stream_set_omp_threads") + function zfp_stream_set_omp_threads(stream, threads) result(is_success) bind(c, name="zfp_stream_set_omp_threads") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) threads, is_success end function - function zfp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) bind(c, name="zfp_stream_set_omp_chunk_size") + function zfp_stream_set_omp_chunk_size(stream, chunk_size) result(is_success) bind(c, name="zfp_stream_set_omp_chunk_size") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream integer(c_int) chunk_size, is_success end function ! high-level API: zfp_field functions - function zfp_field_alloc() result(zfp_field) bind(c, name="zfp_field_alloc") + function zfp_field_alloc() result(field) bind(c, name="zfp_field_alloc") import - type(c_ptr) :: zfp_field + type(c_ptr) :: field end function - function zfp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) bind(c, name="zfp_field_1d") + function zfp_field_1d(uncompressed_ptr, zfp_type, nx) result(field) bind(c, name="zfp_field_1d") import type(c_ptr), value :: uncompressed_ptr - type(c_ptr) :: zfp_field + type(c_ptr) :: field integer(c_int), value :: zfp_type, nx end function - function zfp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) bind(c, name="zfp_field_2d") + function zfp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(field) bind(c, name="zfp_field_2d") import type(c_ptr), value :: uncompressed_ptr - type(c_ptr) :: zfp_field + type(c_ptr) :: field integer(c_int), value :: zfp_type, nx, ny end function - function zfp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) bind(c, name="zfp_field_3d") + function zfp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(field) bind(c, name="zfp_field_3d") import type(c_ptr), value :: uncompressed_ptr - type(c_ptr) :: zfp_field + type(c_ptr) :: field integer(c_int), value :: zfp_type, nx, ny, nz end function - function zfp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) bind(c, name="zfp_field_4d") + function zfp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(field) bind(c, name="zfp_field_4d") import type(c_ptr), value :: uncompressed_ptr - type(c_ptr) :: zfp_field + type(c_ptr) :: field integer(c_int), value :: zfp_type, nx, ny, nz, nw end function - subroutine zfp_field_free(zfp_field) bind(c, name="zfp_field_free") + subroutine zfp_field_free(field) bind(c, name="zfp_field_free") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field end subroutine - function zfp_field_pointer(zfp_field) result(arr_ptr) bind(c, name="zfp_field_pointer") + function zfp_field_pointer(field) result(arr_ptr) bind(c, name="zfp_field_pointer") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field type(c_ptr) :: arr_ptr end function - function zfp_field_scalar_type(zfp_field) result(zfp_type) bind(c, name="zfp_field_type") + function zfp_field_scalar_type(field) result(zfp_type) bind(c, name="zfp_field_type") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) zfp_type end function - function zfp_field_precision(zfp_field) result(prec) bind(c, name="zfp_field_precision") + function zfp_field_precision(field) result(prec) bind(c, name="zfp_field_precision") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) prec end function - function zfp_field_dimensionality(zfp_field) result(dims) bind(c, name="zfp_field_dimensionality") + function zfp_field_dimensionality(field) result(dims) bind(c, name="zfp_field_dimensionality") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) dims end function - function zfp_field_size(zfp_field, size_arr) result(total_size) bind(c, name="zfp_field_size") + function zfp_field_size(field, size_arr) result(total_size) bind(c, name="zfp_field_size") import - type(c_ptr), value :: zfp_field, size_arr + type(c_ptr), value :: field, size_arr integer(c_size_t) total_size end function - function zfp_field_stride(zfp_field, stride_arr) result(is_strided) bind(c, name="zfp_field_stride") + function zfp_field_stride(field, stride_arr) result(is_strided) bind(c, name="zfp_field_stride") import - type(c_ptr), value :: zfp_field, stride_arr + type(c_ptr), value :: field, stride_arr integer(c_int) is_strided end function - function zfp_field_metadata(zfp_field) result(encoded_metadata) bind(c, name="zfp_field_metadata") + function zfp_field_metadata(field) result(encoded_metadata) bind(c, name="zfp_field_metadata") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int64_t) encoded_metadata end function - subroutine zfp_field_set_pointer(zfp_field, arr_ptr) bind(c, name="zfp_field_set_pointer") + subroutine zfp_field_set_pointer(field, arr_ptr) bind(c, name="zfp_field_set_pointer") import - type(c_ptr), value :: zfp_field, arr_ptr + type(c_ptr), value :: field, arr_ptr end subroutine - function zfp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) bind(c, name="zfp_field_set_type") + function zfp_field_set_type(field, zfp_type) result(zfp_type_result) bind(c, name="zfp_field_set_type") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) zfp_type, zfp_type_result end function - subroutine zfp_field_set_size_1d(zfp_field, nx) bind(c, name="zfp_field_set_size_1d") + subroutine zfp_field_set_size_1d(field, nx) bind(c, name="zfp_field_set_size_1d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) nx end subroutine - subroutine zfp_field_set_size_2d(zfp_field, nx, ny) bind(c, name="zfp_field_set_size_2d") + subroutine zfp_field_set_size_2d(field, nx, ny) bind(c, name="zfp_field_set_size_2d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) nx, ny end subroutine - subroutine zfp_field_set_size_3d(zfp_field, nx, ny, nz) bind(c, name="zfp_field_set_size_3d") + subroutine zfp_field_set_size_3d(field, nx, ny, nz) bind(c, name="zfp_field_set_size_3d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) nx, ny, nz end subroutine - subroutine zfp_field_set_size_4d(zfp_field, nx, ny, nz, nw) bind(c, name="zfp_field_set_size_4d") + subroutine zfp_field_set_size_4d(field, nx, ny, nz, nw) bind(c, name="zfp_field_set_size_4d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) nx, ny, nz, nw end subroutine - subroutine zfp_field_set_stride_1d(zfp_field, sx) bind(c, name="zfp_field_set_stride_1d") + subroutine zfp_field_set_stride_1d(field, sx) bind(c, name="zfp_field_set_stride_1d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) sx end subroutine - subroutine zfp_field_set_stride_2d(zfp_field, sx, sy) bind(c, name="zfp_field_set_stride_2d") + subroutine zfp_field_set_stride_2d(field, sx, sy) bind(c, name="zfp_field_set_stride_2d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) sx, sy end subroutine - subroutine zfp_field_set_stride_3d(zfp_field, sx, sy, sz) bind(c, name="zfp_field_set_stride_3d") + subroutine zfp_field_set_stride_3d(field, sx, sy, sz) bind(c, name="zfp_field_set_stride_3d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) sx, sy, sz end subroutine - subroutine zfp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) bind(c, name="zfp_field_set_stride_4d") + subroutine zfp_field_set_stride_4d(field, sx, sy, sz, sw) bind(c, name="zfp_field_set_stride_4d") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int) sx, sy, sz, sw end subroutine - function zfp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) bind(c, name="zfp_field_set_metadata") + function zfp_field_set_metadata(field, encoded_metadata) result(is_success) bind(c, name="zfp_field_set_metadata") import - type(c_ptr), value :: zfp_field + type(c_ptr), value :: field integer(c_int64_t) :: encoded_metadata integer(c_int) is_success end function ! high-level API: compression and decompression - function zfp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zfp_compress") + function zfp_compress(stream, field) result(bitstream_offset_bytes) bind(c, name="zfp_compress") import - type(c_ptr), value :: zfp_stream, zfp_field + type(c_ptr), value :: stream, field integer(c_size_t) :: bitstream_offset_bytes end function - function zfp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zfp_decompress") + function zfp_decompress(stream, field) result(bitstream_offset_bytes) bind(c, name="zfp_decompress") import - type(c_ptr), value :: zfp_stream, zfp_field + type(c_ptr), value :: stream, field integer(c_size_t) :: bitstream_offset_bytes end function - function zfp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) bind(c, name="zfp_write_header") + function zfp_write_header(stream, field, mask) result(num_bits_written) bind(c, name="zfp_write_header") import - type(c_ptr), value :: zfp_stream, zfp_field + type(c_ptr), value :: stream, field integer(c_int) mask integer(c_size_t) num_bits_written end function - function zfp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind(c, name="zfp_read_header") + function zfp_read_header(stream, field, mask) result(num_bits_read) bind(c, name="zfp_read_header") import - type(c_ptr), value :: zfp_stream, zfp_field + type(c_ptr), value :: stream, field integer(c_int) mask integer(c_size_t) num_bits_read end function ! low-level API: stream manipulation - subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") + subroutine zfp_stream_rewind(stream) bind(c, name="zfp_stream_rewind") import - type(c_ptr), value :: zfp_stream + type(c_ptr), value :: stream end subroutine end interface @@ -595,18 +595,18 @@ subroutine zfp_stream_rewind(zfp_stream) bind(c, name="zfp_stream_rewind") ! minimal bitstream API - function zFORp_bitstream_stream_open(buffer, bytes) result(bitstream) bind(c, name="zforp_bitstream_stream_open") + function zFORp_bitstream_stream_open(buffer, bytes) result(bs) bind(c, name="zforp_bitstream_stream_open") implicit none - type(zFORp_bitstream_type) :: bitstream + type(zFORp_bitstream_type) :: bs type(c_ptr), intent(in) :: buffer integer (kind=8), intent(in) :: bytes - bitstream%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) + bs%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) end function zFORp_bitstream_stream_open - subroutine zFORp_bitstream_stream_close(bitstream) bind(c, name="zforp_bitstream_stream_close") - type(zFORp_bitstream_type), intent(inout) :: bitstream - call zfp_bitstream_stream_close(bitstream%object) - bitstream%object = c_null_ptr + subroutine zFORp_bitstream_stream_close(bs) bind(c, name="zforp_bitstream_stream_close") + type(zFORp_bitstream_type), intent(inout) :: bs + call zfp_bitstream_stream_close(bs%object) + bs%object = c_null_ptr end subroutine zFORp_bitstream_stream_close ! high-level API: utility functions @@ -620,125 +620,125 @@ end function zFORp_type_size ! high-level API: zfp_stream functions - function zFORp_stream_open(bitstream) result(zfp_stream) bind(c, name="zforp_stream_open") + function zFORp_stream_open(bs) result(stream) bind(c, name="zforp_stream_open") implicit none - type(zFORp_bitstream_type), intent(in) :: bitstream - type(zFORp_stream_type) :: zfp_stream - zfp_stream%object = zfp_stream_open(bitstream%object) + type(zFORp_bitstream_type), intent(in) :: bs + type(zFORp_stream_type) :: stream + stream%object = zfp_stream_open(bs%object) end function zFORp_stream_open - subroutine zFORp_stream_close(zfp_stream) bind(c, name="zforp_stream_close") - type(zFORp_stream_type), intent(inout) :: zfp_stream - call zfp_stream_close(zfp_stream%object) - zfp_stream%object = c_null_ptr + subroutine zFORp_stream_close(stream) bind(c, name="zforp_stream_close") + type(zFORp_stream_type), intent(inout) :: stream + call zfp_stream_close(stream%object) + stream%object = c_null_ptr end subroutine zFORp_stream_close - function zFORp_stream_bit_stream(zfp_stream) result(bitstream) bind(c, name="zforp_stream_bit_stream") + function zFORp_stream_bit_stream(stream) result(bs) bind(c, name="zforp_stream_bit_stream") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_bitstream_type) :: bitstream - bitstream%object = zfp_stream_bit_stream(zfp_stream%object) + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_bitstream_type) :: bs + bs%object = zfp_stream_bit_stream(stream%object) end function zFORp_stream_bit_stream - function zFORp_stream_is_reversible(zfp_stream) result(is_reversible) bind(c, name="zforp_stream_is_reversible") + function zFORp_stream_is_reversible(stream) result(is_reversible) bind(c, name="zforp_stream_is_reversible") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer is_reversible - is_reversible = zfp_stream_is_reversible(zfp_stream%object) + is_reversible = zfp_stream_is_reversible(stream%object) end function zFORp_stream_is_reversible - function zFORp_stream_compression_mode(zfp_stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") + function zFORp_stream_compression_mode(stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer zfp_mode - zfp_mode = zfp_stream_compression_mode(zfp_stream%object) + zfp_mode = zfp_stream_compression_mode(stream%object) end function zFORp_stream_compression_mode - function zFORp_stream_mode(zfp_stream) result(encoded_mode) bind(c, name="zforp_stream_mode") + function zFORp_stream_mode(stream) result(encoded_mode) bind(c, name="zforp_stream_mode") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer (kind=8) encoded_mode - encoded_mode = zfp_stream_mode(zfp_stream%object) + encoded_mode = zfp_stream_mode(stream%object) end function zFORp_stream_mode - subroutine zFORp_stream_params(zfp_stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") - type(zFORp_stream_type), intent(in) :: zfp_stream + subroutine zFORp_stream_params(stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") + type(zFORp_stream_type), intent(in) :: stream integer (kind=8), intent(inout) :: minbits, maxbits, maxprec, minexp - call zfp_stream_params(zfp_stream%object, & + call zfp_stream_params(stream%object, & int(minbits, c_int), & int(maxbits, c_int), & int(maxprec, c_int), & int(minexp, c_int)) end subroutine zFORp_stream_params - function zFORp_stream_compressed_size(zfp_stream) result(compressed_size) bind(c, name="zforp_stream_compressed_size") + function zFORp_stream_compressed_size(stream) result(compressed_size) bind(c, name="zforp_stream_compressed_size") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer (kind=8) compressed_size - compressed_size = zfp_stream_compressed_size(zfp_stream%object) + compressed_size = zfp_stream_compressed_size(stream%object) end function zFORp_stream_compressed_size - function zFORp_stream_maximum_size(zfp_stream, zfp_field) result(max_size) bind(c, name="zforp_stream_maximum_size") + function zFORp_stream_maximum_size(stream, field) result(max_size) bind(c, name="zforp_stream_maximum_size") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_field_type), intent(in) :: field integer (kind=8) max_size - max_size = zfp_stream_maximum_size(zfp_stream%object, zfp_field%object) + max_size = zfp_stream_maximum_size(stream%object, field%object) end function zFORp_stream_maximum_size - subroutine zFORp_stream_set_bit_stream(zfp_stream, bitstream) bind(c, name="zforp_stream_set_bit_stream") - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_bitstream_type), intent(in) :: bitstream - call zfp_stream_set_bit_stream(zfp_stream%object, bitstream%object) + subroutine zFORp_stream_set_bit_stream(stream, bs) bind(c, name="zforp_stream_set_bit_stream") + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_bitstream_type), intent(in) :: bs + call zfp_stream_set_bit_stream(stream%object, bs%object) end subroutine zFORp_stream_set_bit_stream - subroutine zFORp_stream_set_reversible(zfp_stream) bind(c, name="zforp_stream_set_reversible") - type(zFORp_stream_type), intent(in) :: zfp_stream - call zfp_stream_set_reversible(zfp_stream%object) + subroutine zFORp_stream_set_reversible(stream) bind(c, name="zforp_stream_set_reversible") + type(zFORp_stream_type), intent(in) :: stream + call zfp_stream_set_reversible(stream%object) end subroutine zFORp_stream_set_reversible - function zFORp_stream_set_rate(zfp_stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") + function zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream real (kind=8), intent(in) :: rate integer, intent(in) :: zfp_type integer, intent(in) :: dims, wra real (kind=8) :: rate_result - rate_result = zfp_stream_set_rate(zfp_stream%object, real(rate, c_double), & + rate_result = zfp_stream_set_rate(stream%object, real(rate, c_double), & int(zfp_type, c_int), int(dims, c_int), int(wra, c_int)) end function zFORp_stream_set_rate - function zFORp_stream_set_precision(zfp_stream, prec) result(prec_result) bind(c, name="zforp_stream_set_precision") + function zFORp_stream_set_precision(stream, prec) result(prec_result) bind(c, name="zforp_stream_set_precision") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer, intent(in) :: prec integer prec_result - prec_result = zfp_stream_set_precision(zfp_stream%object, int(prec, c_int)) + prec_result = zfp_stream_set_precision(stream%object, int(prec, c_int)) end function zFORp_stream_set_precision - function zFORp_stream_set_accuracy(zfp_stream, acc) result(acc_result) bind(c, name="zforp_stream_set_accuracy") + function zFORp_stream_set_accuracy(stream, acc) result(acc_result) bind(c, name="zforp_stream_set_accuracy") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream real (kind=8), intent(in) :: acc real (kind=8) acc_result - acc_result = zfp_stream_set_accuracy(zfp_stream%object, real(acc, c_double)) + acc_result = zfp_stream_set_accuracy(stream%object, real(acc, c_double)) end function zFORp_stream_set_accuracy - function zFORp_stream_set_mode(zfp_stream, encoded_mode) result(mode_result) bind(c, name="zforp_stream_set_mode") + function zFORp_stream_set_mode(stream, encoded_mode) result(mode_result) bind(c, name="zforp_stream_set_mode") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer (kind=8), intent(in) :: encoded_mode integer mode_result - mode_result = zfp_stream_set_mode(zfp_stream%object, int(encoded_mode, c_int64_t)) + mode_result = zfp_stream_set_mode(stream%object, int(encoded_mode, c_int64_t)) end function zFORp_stream_set_mode - function zFORp_stream_set_params(zfp_stream, minbits, maxbits, maxprec, minexp) result(is_success) & + function zFORp_stream_set_params(stream, minbits, maxbits, maxprec, minexp) result(is_success) & bind(c, name="zforp_stream_set_params") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer, intent(in) :: minbits, maxbits, maxprec, minexp integer is_success - is_success = zfp_stream_set_params(zfp_stream%object, & + is_success = zfp_stream_set_params(stream%object, & int(minbits, c_int), & int(maxbits, c_int), & int(maxprec, c_int), & @@ -747,267 +747,267 @@ end function zFORp_stream_set_params ! high-level API: execution policy functions - function zFORp_stream_execution(zfp_stream) result(execution_policy) bind(c, name="zforp_stream_execution") + function zFORp_stream_execution(stream) result(execution_policy) bind(c, name="zforp_stream_execution") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer execution_policy - execution_policy = zfp_stream_execution(zfp_stream%object) + execution_policy = zfp_stream_execution(stream%object) end function zFORp_stream_execution - function zFORp_stream_omp_threads(zfp_stream) result(thread_count) bind(c, name="zforp_stream_omp_threads") + function zFORp_stream_omp_threads(stream) result(thread_count) bind(c, name="zforp_stream_omp_threads") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer thread_count - thread_count = zfp_stream_omp_threads(zfp_stream%object) + thread_count = zfp_stream_omp_threads(stream%object) end function zFORp_stream_omp_threads - function zFORp_stream_omp_chunk_size(zfp_stream) result(chunk_size_blocks) bind(c, name="zforp_stream_omp_chunk_size") + function zFORp_stream_omp_chunk_size(stream) result(chunk_size_blocks) bind(c, name="zforp_stream_omp_chunk_size") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer (kind=8) chunk_size_blocks - chunk_size_blocks = zfp_stream_omp_chunk_size(zfp_stream%object) + chunk_size_blocks = zfp_stream_omp_chunk_size(stream%object) end function zFORp_stream_omp_chunk_size - function zFORp_stream_set_execution(zfp_stream, execution_policy) result(is_success) bind(c, name="zforp_stream_set_execution") + function zFORp_stream_set_execution(stream, execution_policy) result(is_success) bind(c, name="zforp_stream_set_execution") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer, intent(in) :: execution_policy integer is_success - is_success = zfp_stream_set_execution(zfp_stream%object, int(execution_policy, c_int)) + is_success = zfp_stream_set_execution(stream%object, int(execution_policy, c_int)) end function zFORp_stream_set_execution - function zFORp_stream_set_omp_threads(zfp_stream, thread_count) result(is_success) bind(c, name="zforp_stream_set_omp_threads") + function zFORp_stream_set_omp_threads(stream, thread_count) result(is_success) bind(c, name="zforp_stream_set_omp_threads") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer, intent(in) :: thread_count integer is_success - is_success = zfp_stream_set_omp_threads(zfp_stream%object, int(thread_count, c_int)) + is_success = zfp_stream_set_omp_threads(stream%object, int(thread_count, c_int)) end function zFORp_stream_set_omp_threads - function zFORp_stream_set_omp_chunk_size(zfp_stream, chunk_size) result(is_success) & + function zFORp_stream_set_omp_chunk_size(stream, chunk_size) result(is_success) & bind(c, name="zforp_stream_set_omp_chunk_size") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream + type(zFORp_stream_type), intent(in) :: stream integer, intent(in) :: chunk_size integer is_success - is_success = zfp_stream_set_omp_chunk_size(zfp_stream%object, int(chunk_size, c_int)) + is_success = zfp_stream_set_omp_chunk_size(stream%object, int(chunk_size, c_int)) end function zFORp_stream_set_omp_chunk_size ! high-level API: zfp_field functions - function zFORp_field_alloc() result(zfp_field) bind(c, name="zforp_field_alloc") + function zFORp_field_alloc() result(field) bind(c, name="zforp_field_alloc") implicit none - type(zFORp_field_type) zfp_field - zfp_field%object = zfp_field_alloc() + type(zFORp_field_type) field + field%object = zfp_field_alloc() end function zFORp_field_alloc - function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(zfp_field) bind(c, name="zforp_field_1d") + function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(field) bind(c, name="zforp_field_1d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx - type(zFORp_field_type) zfp_field - zfp_field%object = zfp_field_1d(uncompressed_ptr, int(zfp_type, c_int), & + type(zFORp_field_type) field + field%object = zfp_field_1d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int)) end function zFORp_field_1d - function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(zfp_field) bind(c, name="zforp_field_2d") + function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(field) bind(c, name="zforp_field_2d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny - type(zFORp_field_type) zfp_field - zfp_field%object = zfp_field_2d(uncompressed_ptr, int(zfp_type, c_int), & + type(zFORp_field_type) field + field%object = zfp_field_2d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int)) end function zFORp_field_2d - function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(zfp_field) bind(c, name="zforp_field_3d") + function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(field) bind(c, name="zforp_field_3d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz - type(zFORp_field_type) zfp_field - zfp_field%object = zfp_field_3d(uncompressed_ptr, int(zfp_type, c_int), & + type(zFORp_field_type) field + field%object = zfp_field_3d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int)) end function zFORp_field_3d - function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(zfp_field) bind(c, name="zforp_field_4d") + function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(field) bind(c, name="zforp_field_4d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz, nw - type(zFORp_field_type) zfp_field - zfp_field%object = zfp_field_4d(uncompressed_ptr, int(zfp_type, c_int), & + type(zFORp_field_type) field + field%object = zfp_field_4d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int), int(nw, c_int)) end function zFORp_field_4d - subroutine zFORp_field_free(zfp_field) bind(c, name="zforp_field_free") - type(zFORp_field_type), intent(inout) :: zfp_field - call zfp_field_free(zfp_field%object) - zfp_field%object = c_null_ptr + subroutine zFORp_field_free(field) bind(c, name="zforp_field_free") + type(zFORp_field_type), intent(inout) :: field + call zfp_field_free(field%object) + field%object = c_null_ptr end subroutine zFORp_field_free - function zFORp_field_pointer(zfp_field) result(arr_ptr) bind(c, name="zforp_field_pointer") + function zFORp_field_pointer(field) result(arr_ptr) bind(c, name="zforp_field_pointer") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field type(c_ptr) arr_ptr - arr_ptr = zfp_field_pointer(zfp_field%object) + arr_ptr = zfp_field_pointer(field%object) end function zFORp_field_pointer ! added "scalar" to name to avoid clash with zfp_field_type - function zFORp_field_scalar_type(zfp_field) result(zfp_type) bind(c, name="zforp_field_scalar_type") + function zFORp_field_scalar_type(field) result(zfp_type) bind(c, name="zforp_field_scalar_type") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer zfp_type - zfp_type = zfp_field_scalar_type(zfp_field%object) + zfp_type = zfp_field_scalar_type(field%object) end function zFORp_field_scalar_type - function zFORp_field_precision(zfp_field) result(prec) bind(c, name="zforp_field_precision") + function zFORp_field_precision(field) result(prec) bind(c, name="zforp_field_precision") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer prec - prec = zfp_field_precision(zfp_field%object) + prec = zfp_field_precision(field%object) end function zFORp_field_precision - function zFORp_field_dimensionality(zfp_field) result(dims) bind(c, name="zforp_field_dimensionality") + function zFORp_field_dimensionality(field) result(dims) bind(c, name="zforp_field_dimensionality") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer dims - dims = zfp_field_dimensionality(zfp_field%object) + dims = zfp_field_dimensionality(field%object) end function zFORp_field_dimensionality - function zFORp_field_size(zfp_field, size_arr) result(total_size) bind(c, name="zforp_field_size") + function zFORp_field_size(field, size_arr) result(total_size) bind(c, name="zforp_field_size") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer, dimension(4), target, intent(inout) :: size_arr integer (kind=8) total_size - total_size = zfp_field_size(zfp_field%object, c_loc(size_arr)) + total_size = zfp_field_size(field%object, c_loc(size_arr)) end function zFORp_field_size - function zFORp_field_stride(zfp_field, stride_arr) result(is_strided) bind(c, name="zforp_field_stride") + function zFORp_field_stride(field, stride_arr) result(is_strided) bind(c, name="zforp_field_stride") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer, dimension(4), target, intent(inout) :: stride_arr integer is_strided - is_strided = zfp_field_stride(zfp_field%object, c_loc(stride_arr)) + is_strided = zfp_field_stride(field%object, c_loc(stride_arr)) end function zFORp_field_stride - function zFORp_field_metadata(zfp_field) result(encoded_metadata) bind(c, name="zforp_field_metadata") + function zFORp_field_metadata(field) result(encoded_metadata) bind(c, name="zforp_field_metadata") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer (kind=8) encoded_metadata - encoded_metadata = zfp_field_metadata(zfp_field%object) + encoded_metadata = zfp_field_metadata(field%object) end function zFORp_field_metadata - subroutine zFORp_field_set_pointer(zfp_field, arr_ptr) bind(c, name="zforp_field_set_pointer") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_pointer(field, arr_ptr) bind(c, name="zforp_field_set_pointer") + type(zFORp_field_type), intent(in) :: field type(c_ptr), intent(in) :: arr_ptr - call zfp_field_set_pointer(zfp_field%object, arr_ptr) + call zfp_field_set_pointer(field%object, arr_ptr) end subroutine zFORp_field_set_pointer - function zFORp_field_set_type(zfp_field, zfp_type) result(zfp_type_result) bind(c, name="zforp_field_set_type") + function zFORp_field_set_type(field, zfp_type) result(zfp_type_result) bind(c, name="zforp_field_set_type") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: zfp_type integer zfp_type_result - zfp_type_result = zfp_field_set_type(zfp_field%object, int(zfp_type, c_int)) + zfp_type_result = zfp_field_set_type(field%object, int(zfp_type, c_int)) end function zFORp_field_set_type - subroutine zFORp_field_set_size_1d(zfp_field, nx) bind(c, name="zforp_field_set_size_1d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_size_1d(field, nx) bind(c, name="zforp_field_set_size_1d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: nx - call zfp_field_set_size_1d(zfp_field%object, int(nx, c_int)) + call zfp_field_set_size_1d(field%object, int(nx, c_int)) end subroutine zFORp_field_set_size_1d - subroutine zFORp_field_set_size_2d(zfp_field, nx, ny) bind(c, name="zforp_field_set_size_2d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_size_2d(field, nx, ny) bind(c, name="zforp_field_set_size_2d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: nx, ny - call zfp_field_set_size_2d(zfp_field%object, int(nx, c_int), int(ny, c_int)) + call zfp_field_set_size_2d(field%object, int(nx, c_int), int(ny, c_int)) end subroutine zFORp_field_set_size_2d - subroutine zFORp_field_set_size_3d(zfp_field, nx, ny, nz) bind(c, name="zforp_field_set_size_3d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_size_3d(field, nx, ny, nz) bind(c, name="zforp_field_set_size_3d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: nx, ny, nz - call zfp_field_set_size_3d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int)) + call zfp_field_set_size_3d(field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int)) end subroutine zFORp_field_set_size_3d - subroutine zFORp_field_set_size_4d(zfp_field, nx, ny, nz, nw) bind(c, name="zforp_field_set_size_4d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_size_4d(field, nx, ny, nz, nw) bind(c, name="zforp_field_set_size_4d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: nx, ny, nz, nw - call zfp_field_set_size_4d(zfp_field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int), int(nw, c_int)) + call zfp_field_set_size_4d(field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int), int(nw, c_int)) end subroutine zFORp_field_set_size_4d - subroutine zFORp_field_set_stride_1d(zfp_field, sx) bind(c, name="zforp_field_set_stride_1d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_stride_1d(field, sx) bind(c, name="zforp_field_set_stride_1d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: sx - call zfp_field_set_stride_1d(zfp_field%object, int(sx, c_int)) + call zfp_field_set_stride_1d(field%object, int(sx, c_int)) end subroutine zFORp_field_set_stride_1d - subroutine zFORp_field_set_stride_2d(zfp_field, sx, sy) bind(c, name="zforp_field_set_stride_2d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_stride_2d(field, sx, sy) bind(c, name="zforp_field_set_stride_2d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: sx, sy - call zfp_field_set_stride_2d(zfp_field%object, int(sx, c_int), int(sy, c_int)) + call zfp_field_set_stride_2d(field%object, int(sx, c_int), int(sy, c_int)) end subroutine zFORp_field_set_stride_2d - subroutine zFORp_field_set_stride_3d(zfp_field, sx, sy, sz) bind(c, name="zforp_field_set_stride_3d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_stride_3d(field, sx, sy, sz) bind(c, name="zforp_field_set_stride_3d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: sx, sy, sz - call zfp_field_set_stride_3d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int)) + call zfp_field_set_stride_3d(field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int)) end subroutine zFORp_field_set_stride_3d - subroutine zFORp_field_set_stride_4d(zfp_field, sx, sy, sz, sw) bind(c, name="zforp_field_set_stride_4d") - type(zFORp_field_type), intent(in) :: zfp_field + subroutine zFORp_field_set_stride_4d(field, sx, sy, sz, sw) bind(c, name="zforp_field_set_stride_4d") + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: sx, sy, sz, sw - call zfp_field_set_stride_4d(zfp_field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int), int(sw, c_int)) + call zfp_field_set_stride_4d(field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int), int(sw, c_int)) end subroutine zFORp_field_set_stride_4d - function zFORp_field_set_metadata(zfp_field, encoded_metadata) result(is_success) bind(c, name="zforp_field_set_metadata") + function zFORp_field_set_metadata(field, encoded_metadata) result(is_success) bind(c, name="zforp_field_set_metadata") implicit none - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_field_type), intent(in) :: field integer (kind=8), intent(in) :: encoded_metadata integer is_success - is_success = zfp_field_set_metadata(zfp_field%object, int(encoded_metadata, c_int64_t)) + is_success = zfp_field_set_metadata(field%object, int(encoded_metadata, c_int64_t)) end function zFORp_field_set_metadata ! high-level API: compression and decompression - function zFORp_compress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zforp_compress") + function zFORp_compress(stream, field) result(bitstream_offset_bytes) bind(c, name="zforp_compress") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_field_type), intent(in) :: field integer (kind=8) bitstream_offset_bytes - bitstream_offset_bytes = zfp_compress(zfp_stream%object, zfp_field%object) + bitstream_offset_bytes = zfp_compress(stream%object, field%object) end function zFORp_compress - function zFORp_decompress(zfp_stream, zfp_field) result(bitstream_offset_bytes) bind(c, name="zforp_decompress") + function zFORp_decompress(stream, field) result(bitstream_offset_bytes) bind(c, name="zforp_decompress") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_field_type), intent(in) :: field integer (kind=8) bitstream_offset_bytes - bitstream_offset_bytes = zfp_decompress(zfp_stream%object, zfp_field%object) + bitstream_offset_bytes = zfp_decompress(stream%object, field%object) end function zFORp_decompress - function zFORp_write_header(zfp_stream, zfp_field, mask) result(num_bits_written) bind(c, name="zforp_write_header") + function zFORp_write_header(stream, field, mask) result(num_bits_written) bind(c, name="zforp_write_header") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: mask integer (kind=8) num_bits_written - num_bits_written = zfp_write_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) + num_bits_written = zfp_write_header(stream%object, field%object, int(mask, c_int)) end function zFORp_write_header - function zFORp_read_header(zfp_stream, zfp_field, mask) result(num_bits_read) bind(c, name="zforp_read_header") + function zFORp_read_header(stream, field, mask) result(num_bits_read) bind(c, name="zforp_read_header") implicit none - type(zFORp_stream_type), intent(in) :: zfp_stream - type(zFORp_field_type), intent(in) :: zfp_field + type(zFORp_stream_type), intent(in) :: stream + type(zFORp_field_type), intent(in) :: field integer, intent(in) :: mask integer (kind=8) num_bits_read - num_bits_read = zfp_read_header(zfp_stream%object, zfp_field%object, int(mask, c_int)) + num_bits_read = zfp_read_header(stream%object, field%object, int(mask, c_int)) end function zFORp_read_header ! low-level API: stream manipulation - subroutine zFORp_stream_rewind(zfp_stream) bind(c, name="zforp_stream_rewind") - type(zFORp_stream_type), intent(in) :: zfp_stream - call zfp_stream_rewind(zfp_stream%object) + subroutine zFORp_stream_rewind(stream) bind(c, name="zforp_stream_rewind") + type(zFORp_stream_type), intent(in) :: stream + call zfp_stream_rewind(stream%object) end subroutine zFORp_stream_rewind end module zFORp_module From 81d7306d167f7febd88090ccf9554aa52a9f4c3e Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 26 Apr 2019 00:54:47 -0700 Subject: [PATCH 154/194] change fortran derived type names to more closely match C API --- docs/source/zforp.rst | 128 ++++++++++++++++----------------- fortran/zfp.f | 140 ++++++++++++++++++------------------ tests/fortran/testFortran.f | 26 +++---- 3 files changed, 147 insertions(+), 147 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 32be04869..7a9e9dbe3 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -24,15 +24,15 @@ decompress data. Types ----- -.. f:type:: zFORp_bitstream_type +.. f:type:: zFORp_bitstream :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` -.. f:type:: zFORp_stream_type +.. f:type:: zFORp_stream :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` -.. f:type:: zFORp_field_type +.. f:type:: zFORp_field :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` @@ -158,13 +158,13 @@ Bitstream function wrappers :p type(c_ptr) buffer [in]: Bitstream buffer :p integer (kind=8) bytes [in]: Buffer size, in bytes :r bs: Bitstream - :rtype bs: zFORp_bitstream_type + :rtype bs: zFORp_bitstream .. f:subroutine:: zFORp_bitstream_stream_close(bs) Wrapper for :c:func:`stream_close` - :p zFORp_bitstream_type bs [inout]: Bitstream + :p zFORp_bitstream bs [inout]: Bitstream High-level API utility function wrappers ---------------------------------------- @@ -181,29 +181,29 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_open` - :p zFORp_bitstream_type bs [in]: Bitstream + :p zFORp_bitstream bs [in]: Bitstream :r stream: Newly allocated zfp_stream - :rtype stream: zFORp_stream_type + :rtype stream: zFORp_stream .. f:subroutine:: zFORp_stream_close(stream) Wrapper for :c:func:`zfp_stream_close` - :p zFORp_stream_type stream [inout]: Zfp_stream + :p zFORp_stream stream [inout]: Zfp_stream .. f:function:: zFORp_stream_bit_stream(stream) Wrapper for :c:func:`zfp_stream_bit_stream` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r bs: Bitstream - :rtype bs: zFORp_bitstream_type + :rtype bs: zFORp_bitstream .. f:function:: zFORp_stream_is_reversible(stream) Wrapper for :c:func:`zfp_stream_is_reversible` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r is_reversible: indicate whether reversible mode active (1) or not (0) :rtype is_reversible: integer @@ -211,7 +211,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_compression_mode` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r zfp_mode: zFORp_mode enum :rtype zfp_mode: integer @@ -219,7 +219,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_mode` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r encoded_mode: 64 bit encoded mode :rtype encoded_mode: integer (kind=8) @@ -227,7 +227,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_params` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer (kind=8) minbits [inout]: minbits :p integer (kind=8) maxbits [inout]: maxbits :p integer (kind=8) maxprec [inout]: maxprec @@ -237,7 +237,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_compressed_size` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r compressed_size: compressed size :rtype compressed_size: integer (kind=8) @@ -245,8 +245,8 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_maximum_size` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_field field [in]: Zfp_field :r max_size: maximum size :rtype max_size: integer (kind=8) @@ -254,20 +254,20 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_set_bit_stream` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_bitstream_type bs [in]: bitstream + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_bitstream bs [in]: bitstream .. f:subroutine:: zFORp_stream_set_reversible(stream) Wrapper for :c:func:`zfp_stream_set_reversible` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream .. f:function:: zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) Wrapper for :c:func:`zfp_stream_set_rate` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p real rate [in]: desired rate :p integer zfp_type [in]: enum zfp_type :p integer dims [in]: dimensions @@ -279,7 +279,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_set_precision` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer prec [in]: desired precision :r prec_result: actual set precision :rtype prec_result: integer @@ -288,7 +288,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_set_accuracy()` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p real acc: desired accuracy (kind=8) :r acc_result: actual set accuracy :rtype acc_result: real (kind=8) @@ -297,7 +297,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_set_mode` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer encoded_mode [in]: encoded mode parameter :r mode_result: newly set zfp_mode enum on zfp_stream :rtype mode_result: integer @@ -306,7 +306,7 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_set_params` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer minbits [in]: min num of bits :p integer maxbits [in]: max num of bits :p integer maxprec [in]: max precision @@ -321,7 +321,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_execution` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r execution_policy: enum of active execution policy :rtype execution_policy: integer @@ -329,7 +329,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_omp_threads` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r thread_count: number of threads to use upon execution :rtype thread_count: integer @@ -337,7 +337,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_omp_chunk_size` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :r chunk_size_blocks: specified chunk size, in blocks :rtype chunk_size_blocks: integer (kind=8) @@ -345,7 +345,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_set_execution` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer execution_policy [in]: desired execution policy (enum) :r is_success: indicate whether execution policy was successfully set or not :rtype is_success: integer @@ -354,7 +354,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_set_omp_threads` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer thread_count [in]: desired number of threads :r is_success: indicate whether number of threads successfully set or not :rtype is_success: integer @@ -363,7 +363,7 @@ High-level API: execution policy function wrappers Wrapper for :c:func:`zfp_stream_set_omp_chunk_size` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream :p integer chunk_size [in]: desired chunk size, in blocks :r is_success: indicate whether chunk size successfully set or not :rtype is_success: integer @@ -376,7 +376,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_alloc` :r field: newly allocated zfp_field - :rtype field: zFORp_field_type + :rtype field: zFORp_field .. f:function:: zFORp_field_1d(uncompressed_ptr, zfp_type, nx) @@ -386,7 +386,7 @@ High-level API: zfp_field function wrappers :p integer zfp_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array :r field: newly allocated zfp_field - :rtype field: zFORp_field_type + :rtype field: zFORp_field .. f:function:: zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) @@ -397,7 +397,7 @@ High-level API: zfp_field function wrappers :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension :r field: newly allocated zfp_field - :rtype field: zFORp_field_type + :rtype field: zFORp_field .. f:function:: zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) @@ -409,7 +409,7 @@ High-level API: zfp_field function wrappers :p integer ny [in]: number of elements in uncompressed data array's y dimension :p integer nz [in]: number of elements in uncompressed data array's z dimension :r field: newly allocated zfp_field - :rtype field: zFORp_field_type + :rtype field: zFORp_field .. f:function:: zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) @@ -422,19 +422,19 @@ High-level API: zfp_field function wrappers :p integer nz [in]: number of elements in uncompressed data array's z dimension :p integer nw [in]: number of elements in uncompressed data array's w dimension :r field: newly allocated zfp_field - :rtype field: zFORp_field_type + :rtype field: zFORp_field .. f:subroutine:: zFORp_field_free(field) Wrapper for :c:func:`zfp_field_free` - :p zFORp_field_type field [inout]: Zfp_field + :p zFORp_field field [inout]: Zfp_field .. f:function:: zFORp_field_pointer(field) Wrapper for :c:func:`zfp_field_pointer` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :r arr_ptr: pointer to raw (uncompressed/decompressed) array :rtype arr_ptr: type(c_ptr) @@ -442,7 +442,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_type` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :r zfp_type: zfp_type enum describing field data :rtype zfp_type: integer @@ -450,7 +450,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_precision` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :r prec: type precision describing field data :rtype prec: integer @@ -458,7 +458,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_dimensionality` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :r dims: dimensionality of field data :rtype dims: integer @@ -466,7 +466,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_size` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer size_arr [inout]: integer array to write field dimensions into :r total_size: total number of elements in field :rtype total_size: integer (kind=8) @@ -475,7 +475,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_stride` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer stride_arr [inout]: integer array to write strides into :r is_strided: indicate whether field is strided or not :rtype is_strided: integer @@ -484,7 +484,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_metadata` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :r encoded_metadata: encoded metadata of field :rtype encoded_metadata: integer (kind=8) @@ -492,14 +492,14 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_pointer` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p type(c_ptr) arr_ptr [in]: pointer to raw array .. f:function:: zFORp_field_set_type(field, zfp_type) Wrapper for :c:func:`zfp_field_set_type` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer zfp_type: desired zfp_type enum :r zfp_type_result: new zfp_type on the field :rtype zfp_type_result: integer @@ -508,14 +508,14 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_size_1d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer nx [in]: number of elements in data array .. f:subroutine:: zFORp_field_set_size_2d(field, nx, ny) Wrapper for :c:func:`zfp_field_set_size_2d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension @@ -523,7 +523,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_size_3d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension :p integer nz [in]: number of elements in data array's z dimension @@ -532,7 +532,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_size_4d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer nx [in]: number of elements in data array's x dimension :p integer ny [in]: number of elements in data array's y dimension :p integer nz [in]: number of elements in data array's z dimension @@ -542,14 +542,14 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_stride_1d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension .. f:subroutine:: zFORp_field_set_stride_2d(field, sx, sy) Wrapper for :c:func:`zfp_field_set_stride_2d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension @@ -557,7 +557,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_stride_3d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension :p integer sz [in]: stride of data array's z dimension @@ -566,7 +566,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_stride_4d` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer sx [in]: stride of data array's x dimension :p integer sy [in]: stride of data array's y dimension :p integer sz [in]: stride of data array's z dimension @@ -576,7 +576,7 @@ High-level API: zfp_field function wrappers Wrapper for :c:func:`zfp_field_set_metadata` - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_field field [in]: Zfp_field :p integer encoded_metadata [in]: encoded metadata (kind=8) :r is_success: indicate whether metadata successfully set on field or not :rtype is_success: integer @@ -588,8 +588,8 @@ High-level API: compression, decompression, header wrappers Wrapper for :c:func:`zfp_compress` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_field field [in]: Zfp_field :r bitstream_offset_bytes: bitstream offset after compression, in bytes :rtype bitstream_offset_bytes: integer (kind=8) @@ -597,8 +597,8 @@ High-level API: compression, decompression, header wrappers Wrapper for :c:func:`zfp_decompress` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_field field [in]: Zfp_field :r bitstream_offset_bytes: bitstream offset after decompression, in bytes :rtype bitstream_offset_bytes: integer (kind=8) @@ -606,8 +606,8 @@ High-level API: compression, decompression, header wrappers Wrapper for :c:func:`zfp_write_header` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_field field [in]: Zfp_field :p integer mask [in]: indicates header level of detail :r num_bits_written: number of bits successfully written in header :rtype num_bits_written: integer (kind=8) @@ -616,8 +616,8 @@ High-level API: compression, decompression, header wrappers Wrapper for :c:func:`zfp_read_header` - :p zFORp_stream_type stream [in]: Zfp_stream - :p zFORp_field_type field [in]: Zfp_field + :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_field field [in]: Zfp_field :p integer mask [in]: indicates header level of detail :r num_bits_read: number of bits successfully read in header :rtype num_bits_read: integer (kind=8) @@ -629,4 +629,4 @@ Low-level API: stream manipulation wrappers Wrapper for :c:func:`zfp_stream_rewind` - :p zFORp_stream_type stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Zfp_stream diff --git a/fortran/zfp.f b/fortran/zfp.f index 223e05f9d..a30cc00f6 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -5,20 +5,20 @@ module zFORp_module private ! bind(c) on types, enums because tests written in C need to reference them - type, bind(c) :: zFORp_bitstream_type + type, bind(c) :: zFORp_bitstream private type(c_ptr) :: object = c_null_ptr - end type zFORp_bitstream_type + end type zFORp_bitstream - type, bind(c) :: zFORp_stream_type + type, bind(c) :: zFORp_stream private type(c_ptr) :: object = c_null_ptr - end type zFORp_stream_type + end type zFORp_stream - type, bind(c) :: zFORp_field_type + type, bind(c) :: zFORp_field private type(c_ptr) :: object = c_null_ptr - end type zFORp_field_type + end type zFORp_field enum, bind(c) enumerator :: zFORp_type_none = 0, & @@ -469,9 +469,9 @@ subroutine zfp_stream_rewind(stream) bind(c, name="zfp_stream_rewind") ! types - public :: zFORp_bitstream_type, & - zFORp_stream_type, & - zFORp_field_type + public :: zFORp_bitstream, & + zFORp_stream, & + zFORp_field ! enums @@ -597,14 +597,14 @@ subroutine zfp_stream_rewind(stream) bind(c, name="zfp_stream_rewind") function zFORp_bitstream_stream_open(buffer, bytes) result(bs) bind(c, name="zforp_bitstream_stream_open") implicit none - type(zFORp_bitstream_type) :: bs + type(zFORp_bitstream) :: bs type(c_ptr), intent(in) :: buffer integer (kind=8), intent(in) :: bytes bs%object = zfp_bitstream_stream_open(buffer, int(bytes, c_size_t)) end function zFORp_bitstream_stream_open subroutine zFORp_bitstream_stream_close(bs) bind(c, name="zforp_bitstream_stream_close") - type(zFORp_bitstream_type), intent(inout) :: bs + type(zFORp_bitstream), intent(inout) :: bs call zfp_bitstream_stream_close(bs%object) bs%object = c_null_ptr end subroutine zFORp_bitstream_stream_close @@ -622,47 +622,47 @@ end function zFORp_type_size function zFORp_stream_open(bs) result(stream) bind(c, name="zforp_stream_open") implicit none - type(zFORp_bitstream_type), intent(in) :: bs - type(zFORp_stream_type) :: stream + type(zFORp_bitstream), intent(in) :: bs + type(zFORp_stream) :: stream stream%object = zfp_stream_open(bs%object) end function zFORp_stream_open subroutine zFORp_stream_close(stream) bind(c, name="zforp_stream_close") - type(zFORp_stream_type), intent(inout) :: stream + type(zFORp_stream), intent(inout) :: stream call zfp_stream_close(stream%object) stream%object = c_null_ptr end subroutine zFORp_stream_close function zFORp_stream_bit_stream(stream) result(bs) bind(c, name="zforp_stream_bit_stream") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_bitstream_type) :: bs + type(zFORp_stream), intent(in) :: stream + type(zFORp_bitstream) :: bs bs%object = zfp_stream_bit_stream(stream%object) end function zFORp_stream_bit_stream function zFORp_stream_is_reversible(stream) result(is_reversible) bind(c, name="zforp_stream_is_reversible") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer is_reversible is_reversible = zfp_stream_is_reversible(stream%object) end function zFORp_stream_is_reversible function zFORp_stream_compression_mode(stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer zfp_mode zfp_mode = zfp_stream_compression_mode(stream%object) end function zFORp_stream_compression_mode function zFORp_stream_mode(stream) result(encoded_mode) bind(c, name="zforp_stream_mode") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer (kind=8) encoded_mode encoded_mode = zfp_stream_mode(stream%object) end function zFORp_stream_mode subroutine zFORp_stream_params(stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer (kind=8), intent(inout) :: minbits, maxbits, maxprec, minexp call zfp_stream_params(stream%object, & int(minbits, c_int), & @@ -673,33 +673,33 @@ end subroutine zFORp_stream_params function zFORp_stream_compressed_size(stream) result(compressed_size) bind(c, name="zforp_stream_compressed_size") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer (kind=8) compressed_size compressed_size = zfp_stream_compressed_size(stream%object) end function zFORp_stream_compressed_size function zFORp_stream_maximum_size(stream, field) result(max_size) bind(c, name="zforp_stream_maximum_size") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_field_type), intent(in) :: field + type(zFORp_stream), intent(in) :: stream + type(zFORp_field), intent(in) :: field integer (kind=8) max_size max_size = zfp_stream_maximum_size(stream%object, field%object) end function zFORp_stream_maximum_size subroutine zFORp_stream_set_bit_stream(stream, bs) bind(c, name="zforp_stream_set_bit_stream") - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_bitstream_type), intent(in) :: bs + type(zFORp_stream), intent(in) :: stream + type(zFORp_bitstream), intent(in) :: bs call zfp_stream_set_bit_stream(stream%object, bs%object) end subroutine zFORp_stream_set_bit_stream subroutine zFORp_stream_set_reversible(stream) bind(c, name="zforp_stream_set_reversible") - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream call zfp_stream_set_reversible(stream%object) end subroutine zFORp_stream_set_reversible function zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream real (kind=8), intent(in) :: rate integer, intent(in) :: zfp_type integer, intent(in) :: dims, wra @@ -710,7 +710,7 @@ end function zFORp_stream_set_rate function zFORp_stream_set_precision(stream, prec) result(prec_result) bind(c, name="zforp_stream_set_precision") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer, intent(in) :: prec integer prec_result prec_result = zfp_stream_set_precision(stream%object, int(prec, c_int)) @@ -718,7 +718,7 @@ end function zFORp_stream_set_precision function zFORp_stream_set_accuracy(stream, acc) result(acc_result) bind(c, name="zforp_stream_set_accuracy") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream real (kind=8), intent(in) :: acc real (kind=8) acc_result acc_result = zfp_stream_set_accuracy(stream%object, real(acc, c_double)) @@ -726,7 +726,7 @@ end function zFORp_stream_set_accuracy function zFORp_stream_set_mode(stream, encoded_mode) result(mode_result) bind(c, name="zforp_stream_set_mode") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer (kind=8), intent(in) :: encoded_mode integer mode_result mode_result = zfp_stream_set_mode(stream%object, int(encoded_mode, c_int64_t)) @@ -735,7 +735,7 @@ end function zFORp_stream_set_mode function zFORp_stream_set_params(stream, minbits, maxbits, maxprec, minexp) result(is_success) & bind(c, name="zforp_stream_set_params") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer, intent(in) :: minbits, maxbits, maxprec, minexp integer is_success is_success = zfp_stream_set_params(stream%object, & @@ -749,28 +749,28 @@ end function zFORp_stream_set_params function zFORp_stream_execution(stream) result(execution_policy) bind(c, name="zforp_stream_execution") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer execution_policy execution_policy = zfp_stream_execution(stream%object) end function zFORp_stream_execution function zFORp_stream_omp_threads(stream) result(thread_count) bind(c, name="zforp_stream_omp_threads") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer thread_count thread_count = zfp_stream_omp_threads(stream%object) end function zFORp_stream_omp_threads function zFORp_stream_omp_chunk_size(stream) result(chunk_size_blocks) bind(c, name="zforp_stream_omp_chunk_size") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer (kind=8) chunk_size_blocks chunk_size_blocks = zfp_stream_omp_chunk_size(stream%object) end function zFORp_stream_omp_chunk_size function zFORp_stream_set_execution(stream, execution_policy) result(is_success) bind(c, name="zforp_stream_set_execution") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer, intent(in) :: execution_policy integer is_success is_success = zfp_stream_set_execution(stream%object, int(execution_policy, c_int)) @@ -778,7 +778,7 @@ end function zFORp_stream_set_execution function zFORp_stream_set_omp_threads(stream, thread_count) result(is_success) bind(c, name="zforp_stream_set_omp_threads") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer, intent(in) :: thread_count integer is_success is_success = zfp_stream_set_omp_threads(stream%object, int(thread_count, c_int)) @@ -787,7 +787,7 @@ end function zFORp_stream_set_omp_threads function zFORp_stream_set_omp_chunk_size(stream, chunk_size) result(is_success) & bind(c, name="zforp_stream_set_omp_chunk_size") implicit none - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream integer, intent(in) :: chunk_size integer is_success is_success = zfp_stream_set_omp_chunk_size(stream%object, int(chunk_size, c_int)) @@ -797,7 +797,7 @@ end function zFORp_stream_set_omp_chunk_size function zFORp_field_alloc() result(field) bind(c, name="zforp_field_alloc") implicit none - type(zFORp_field_type) field + type(zFORp_field) field field%object = zfp_field_alloc() end function zFORp_field_alloc @@ -805,7 +805,7 @@ function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(field) bind(c, na implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx - type(zFORp_field_type) field + type(zFORp_field) field field%object = zfp_field_1d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int)) end function zFORp_field_1d @@ -814,7 +814,7 @@ function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(field) bind(c implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny - type(zFORp_field_type) field + type(zFORp_field) field field%object = zfp_field_2d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int)) end function zFORp_field_2d @@ -823,7 +823,7 @@ function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(field) bi implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz - type(zFORp_field_type) field + type(zFORp_field) field field%object = zfp_field_3d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int)) @@ -833,21 +833,21 @@ function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(field implicit none type(c_ptr), intent(in) :: uncompressed_ptr integer, intent(in) :: zfp_type, nx, ny, nz, nw - type(zFORp_field_type) field + type(zFORp_field) field field%object = zfp_field_4d(uncompressed_ptr, int(zfp_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int), int(nw, c_int)) end function zFORp_field_4d subroutine zFORp_field_free(field) bind(c, name="zforp_field_free") - type(zFORp_field_type), intent(inout) :: field + type(zFORp_field), intent(inout) :: field call zfp_field_free(field%object) field%object = c_null_ptr end subroutine zFORp_field_free function zFORp_field_pointer(field) result(arr_ptr) bind(c, name="zforp_field_pointer") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field type(c_ptr) arr_ptr arr_ptr = zfp_field_pointer(field%object) end function zFORp_field_pointer @@ -855,28 +855,28 @@ end function zFORp_field_pointer ! added "scalar" to name to avoid clash with zfp_field_type function zFORp_field_scalar_type(field) result(zfp_type) bind(c, name="zforp_field_scalar_type") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer zfp_type zfp_type = zfp_field_scalar_type(field%object) end function zFORp_field_scalar_type function zFORp_field_precision(field) result(prec) bind(c, name="zforp_field_precision") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer prec prec = zfp_field_precision(field%object) end function zFORp_field_precision function zFORp_field_dimensionality(field) result(dims) bind(c, name="zforp_field_dimensionality") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer dims dims = zfp_field_dimensionality(field%object) end function zFORp_field_dimensionality function zFORp_field_size(field, size_arr) result(total_size) bind(c, name="zforp_field_size") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, dimension(4), target, intent(inout) :: size_arr integer (kind=8) total_size total_size = zfp_field_size(field%object, c_loc(size_arr)) @@ -884,7 +884,7 @@ end function zFORp_field_size function zFORp_field_stride(field, stride_arr) result(is_strided) bind(c, name="zforp_field_stride") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, dimension(4), target, intent(inout) :: stride_arr integer is_strided is_strided = zfp_field_stride(field%object, c_loc(stride_arr)) @@ -892,76 +892,76 @@ end function zFORp_field_stride function zFORp_field_metadata(field) result(encoded_metadata) bind(c, name="zforp_field_metadata") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer (kind=8) encoded_metadata encoded_metadata = zfp_field_metadata(field%object) end function zFORp_field_metadata subroutine zFORp_field_set_pointer(field, arr_ptr) bind(c, name="zforp_field_set_pointer") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field type(c_ptr), intent(in) :: arr_ptr call zfp_field_set_pointer(field%object, arr_ptr) end subroutine zFORp_field_set_pointer function zFORp_field_set_type(field, zfp_type) result(zfp_type_result) bind(c, name="zforp_field_set_type") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: zfp_type integer zfp_type_result zfp_type_result = zfp_field_set_type(field%object, int(zfp_type, c_int)) end function zFORp_field_set_type subroutine zFORp_field_set_size_1d(field, nx) bind(c, name="zforp_field_set_size_1d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: nx call zfp_field_set_size_1d(field%object, int(nx, c_int)) end subroutine zFORp_field_set_size_1d subroutine zFORp_field_set_size_2d(field, nx, ny) bind(c, name="zforp_field_set_size_2d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: nx, ny call zfp_field_set_size_2d(field%object, int(nx, c_int), int(ny, c_int)) end subroutine zFORp_field_set_size_2d subroutine zFORp_field_set_size_3d(field, nx, ny, nz) bind(c, name="zforp_field_set_size_3d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: nx, ny, nz call zfp_field_set_size_3d(field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int)) end subroutine zFORp_field_set_size_3d subroutine zFORp_field_set_size_4d(field, nx, ny, nz, nw) bind(c, name="zforp_field_set_size_4d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: nx, ny, nz, nw call zfp_field_set_size_4d(field%object, int(nx, c_int), int(ny, c_int), int(nz, c_int), int(nw, c_int)) end subroutine zFORp_field_set_size_4d subroutine zFORp_field_set_stride_1d(field, sx) bind(c, name="zforp_field_set_stride_1d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: sx call zfp_field_set_stride_1d(field%object, int(sx, c_int)) end subroutine zFORp_field_set_stride_1d subroutine zFORp_field_set_stride_2d(field, sx, sy) bind(c, name="zforp_field_set_stride_2d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: sx, sy call zfp_field_set_stride_2d(field%object, int(sx, c_int), int(sy, c_int)) end subroutine zFORp_field_set_stride_2d subroutine zFORp_field_set_stride_3d(field, sx, sy, sz) bind(c, name="zforp_field_set_stride_3d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: sx, sy, sz call zfp_field_set_stride_3d(field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int)) end subroutine zFORp_field_set_stride_3d subroutine zFORp_field_set_stride_4d(field, sx, sy, sz, sw) bind(c, name="zforp_field_set_stride_4d") - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer, intent(in) :: sx, sy, sz, sw call zfp_field_set_stride_4d(field%object, int(sx, c_int), int(sy, c_int), int(sz, c_int), int(sw, c_int)) end subroutine zFORp_field_set_stride_4d function zFORp_field_set_metadata(field, encoded_metadata) result(is_success) bind(c, name="zforp_field_set_metadata") implicit none - type(zFORp_field_type), intent(in) :: field + type(zFORp_field), intent(in) :: field integer (kind=8), intent(in) :: encoded_metadata integer is_success is_success = zfp_field_set_metadata(field%object, int(encoded_metadata, c_int64_t)) @@ -971,24 +971,24 @@ end function zFORp_field_set_metadata function zFORp_compress(stream, field) result(bitstream_offset_bytes) bind(c, name="zforp_compress") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_field_type), intent(in) :: field + type(zFORp_stream), intent(in) :: stream + type(zFORp_field), intent(in) :: field integer (kind=8) bitstream_offset_bytes bitstream_offset_bytes = zfp_compress(stream%object, field%object) end function zFORp_compress function zFORp_decompress(stream, field) result(bitstream_offset_bytes) bind(c, name="zforp_decompress") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_field_type), intent(in) :: field + type(zFORp_stream), intent(in) :: stream + type(zFORp_field), intent(in) :: field integer (kind=8) bitstream_offset_bytes bitstream_offset_bytes = zfp_decompress(stream%object, field%object) end function zFORp_decompress function zFORp_write_header(stream, field, mask) result(num_bits_written) bind(c, name="zforp_write_header") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_field_type), intent(in) :: field + type(zFORp_stream), intent(in) :: stream + type(zFORp_field), intent(in) :: field integer, intent(in) :: mask integer (kind=8) num_bits_written num_bits_written = zfp_write_header(stream%object, field%object, int(mask, c_int)) @@ -996,8 +996,8 @@ end function zFORp_write_header function zFORp_read_header(stream, field, mask) result(num_bits_read) bind(c, name="zforp_read_header") implicit none - type(zFORp_stream_type), intent(in) :: stream - type(zFORp_field_type), intent(in) :: field + type(zFORp_stream), intent(in) :: stream + type(zFORp_field), intent(in) :: field integer, intent(in) :: mask integer (kind=8) num_bits_read num_bits_read = zfp_read_header(stream%object, field%object, int(mask, c_int)) @@ -1006,7 +1006,7 @@ end function zFORp_read_header ! low-level API: stream manipulation subroutine zFORp_stream_rewind(stream) bind(c, name="zforp_stream_rewind") - type(zFORp_stream_type), intent(in) :: stream + type(zFORp_stream), intent(in) :: stream call zfp_stream_rewind(stream%object) end subroutine zFORp_stream_rewind diff --git a/tests/fortran/testFortran.f b/tests/fortran/testFortran.f index fe959e633..1576420b6 100644 --- a/tests/fortran/testFortran.f +++ b/tests/fortran/testFortran.f @@ -13,16 +13,16 @@ program main integer error, max_abs_error ! zfp_field - type(zFORp_field_type) :: zfp_field + type(zFORp_field) :: field ! bitstream character, dimension(:), allocatable, target :: buffer type(c_ptr) :: buffer_c_ptr integer (kind=8) buffer_size_bytes, bitstream_offset_bytes - type(zFORp_bitstream_type) :: bitstream, queried_bitstream + type(zFORp_bitstream) :: bitstream, queried_bitstream ! zfp_stream - type(zFORp_stream_type) :: zfp_stream + type(zFORp_stream) :: stream real (kind=8) :: desired_rate, rate_result integer :: dims, wra integer :: zfp_type @@ -42,7 +42,7 @@ program main ! setup zfp_field array_c_ptr = c_loc(input_array) zfp_type = zFORp_type_int32 - zfp_field = zFORp_field_2d(array_c_ptr, zfp_type, xLen, yLen) + field = zFORp_field_2d(array_c_ptr, zfp_type, xLen, yLen) ! setup bitstream buffer_size_bytes = 256 @@ -51,27 +51,27 @@ program main bitstream = zFORp_bitstream_stream_open(buffer_c_ptr, buffer_size_bytes) ! setup zfp_stream - zfp_stream = zFORp_stream_open(bitstream) + stream = zFORp_stream_open(bitstream) desired_rate = 8.0 dims = 2 wra = 0 zfp_type = zFORp_type_float - rate_result = zFORp_stream_set_rate(zfp_stream, desired_rate, zfp_type, dims, wra) + rate_result = zFORp_stream_set_rate(stream, desired_rate, zfp_type, dims, wra) - queried_bitstream = zFORp_stream_bit_stream(zfp_stream) + queried_bitstream = zFORp_stream_bit_stream(stream) ! compress - bitstream_offset_bytes = zFORp_compress(zfp_stream, zfp_field) + bitstream_offset_bytes = zFORp_compress(stream, field) write(*, *) "After compression, bitstream offset at " write(*, *) bitstream_offset_bytes ! decompress - call zFORp_stream_rewind(zfp_stream) + call zFORp_stream_rewind(stream) array_c_ptr = c_loc(decompressed_array) - call zFORp_field_set_pointer(zfp_field, array_c_ptr) + call zFORp_field_set_pointer(field, array_c_ptr) - bitstream_offset_bytes = zFORp_decompress(zfp_stream, zfp_field) + bitstream_offset_bytes = zFORp_decompress(stream, field) write(*, *) "After decompression, bitstream offset at " write(*, *) bitstream_offset_bytes @@ -93,9 +93,9 @@ program main write(*, *) zFORp_meta_null ! deallocations - call zFORp_stream_close(zfp_stream) + call zFORp_stream_close(stream) call zFORp_bitstream_stream_close(queried_bitstream) - call zFORp_field_free(zfp_field) + call zFORp_field_free(field) deallocate(buffer) deallocate(input_array) From adfef293e9fcf2efc3f314e515e96b36753b1955 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 26 Apr 2019 00:56:05 -0700 Subject: [PATCH 155/194] fortran: rename function params `zfp_type` to `scalar_type`, function zFORp_field_scalar_type() to zFORp_field_type(), and unwiden compression parameters --- docs/source/zforp.rst | 46 +++++++++++----------- fortran/zfp.f | 89 +++++++++++++++++++++---------------------- 2 files changed, 67 insertions(+), 68 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 7a9e9dbe3..02dc5002f 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -169,11 +169,11 @@ Bitstream function wrappers High-level API utility function wrappers ---------------------------------------- -.. f:function:: zFORp_type_size(zfp_type) +.. f:function:: zFORp_type_size(scalar_type) Wrapper for :c:func:`zfp_type_size` - :p integer zfp_type [in]: zFORp_type enum. + :p integer scalar_type [in]: zFORp_type enum. :r type_size: Size of described zfp_type, in bytes, from C-language perspective. :rtype type_size: integer @@ -228,10 +228,10 @@ High-level API utility function wrappers Wrapper for :c:func:`zfp_stream_params` :p zFORp_stream stream [in]: Zfp_stream - :p integer (kind=8) minbits [inout]: minbits - :p integer (kind=8) maxbits [inout]: maxbits - :p integer (kind=8) maxprec [inout]: maxprec - :p integer (kind=8) minexp [inout]: minexp + :p integer minbits [inout]: minbits + :p integer maxbits [inout]: maxbits + :p integer maxprec [inout]: maxprec + :p integer minexp [inout]: minexp .. f:function:: zFORp_stream_compressed_size(stream) @@ -263,13 +263,13 @@ High-level API utility function wrappers :p zFORp_stream stream [in]: Zfp_stream -.. f:function:: zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) +.. f:function:: zFORp_stream_set_rate(stream, rate, scalar_type, dims, wra) Wrapper for :c:func:`zfp_stream_set_rate` :p zFORp_stream stream [in]: Zfp_stream :p real rate [in]: desired rate - :p integer zfp_type [in]: enum zfp_type + :p integer scalar_type [in]: enum zfp_type :p integer dims [in]: dimensions :p integer wra [in]: use write random access? :r rate_result: actual set rate @@ -378,45 +378,45 @@ High-level API: zfp_field function wrappers :r field: newly allocated zfp_field :rtype field: zFORp_field - .. f:function:: zFORp_field_1d(uncompressed_ptr, zfp_type, nx) + .. f:function:: zFORp_field_1d(uncompressed_ptr, scalar_type, nx) Wrapper for :c:func:`zfp_field_1d` :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer scalar_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array :r field: newly allocated zfp_field :rtype field: zFORp_field - .. f:function:: zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) + .. f:function:: zFORp_field_2d(uncompressed_ptr, scalar_type, nx, ny) Wrapper for :c:func:`zfp_field_2d` :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer scalar_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension :r field: newly allocated zfp_field :rtype field: zFORp_field - .. f:function:: zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) + .. f:function:: zFORp_field_3d(uncompressed_ptr, scalar_type, nx, ny, nz) Wrapper for :c:func:`zfp_field_3d` :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer scalar_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension :p integer nz [in]: number of elements in uncompressed data array's z dimension :r field: newly allocated zfp_field :rtype field: zFORp_field - .. f:function:: zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) + .. f:function:: zFORp_field_4d(uncompressed_ptr, scalar_type, nx, ny, nz, nw) Wrapper for :c:func:`zfp_field_4d` :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer zfp_type [in]: zfp_type enum describing uncompressed data type + :p integer scalar_type [in]: zfp_type enum describing uncompressed data type :p integer nx [in]: number of elements in uncompressed data array's x dimension :p integer ny [in]: number of elements in uncompressed data array's y dimension :p integer nz [in]: number of elements in uncompressed data array's z dimension @@ -438,13 +438,13 @@ High-level API: zfp_field function wrappers :r arr_ptr: pointer to raw (uncompressed/decompressed) array :rtype arr_ptr: type(c_ptr) - .. f:function:: zFORp_field_scalar_type(field) + .. f:function:: zFORp_field_type(field) Wrapper for :c:func:`zfp_field_type` :p zFORp_field field [in]: Zfp_field - :r zfp_type: zfp_type enum describing field data - :rtype zfp_type: integer + :r scalar_type: zfp_type enum describing field data + :rtype scalar_type: integer .. f:function:: zFORp_field_precision(field) @@ -495,14 +495,14 @@ High-level API: zfp_field function wrappers :p zFORp_field field [in]: Zfp_field :p type(c_ptr) arr_ptr [in]: pointer to raw array - .. f:function:: zFORp_field_set_type(field, zfp_type) + .. f:function:: zFORp_field_set_type(field, scalar_type) Wrapper for :c:func:`zfp_field_set_type` :p zFORp_field field [in]: Zfp_field - :p integer zfp_type: desired zfp_type enum - :r zfp_type_result: new zfp_type on the field - :rtype zfp_type_result: integer + :p integer scalar_type: desired zfp_type enum + :r scalar_type_result: new zfp_type on the field + :rtype scalar_type_result: integer .. f:subroutine:: zFORp_field_set_size_1d(field, nx) diff --git a/fortran/zfp.f b/fortran/zfp.f index a30cc00f6..83f1d57db 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -135,9 +135,9 @@ subroutine zfp_bitstream_stream_close(bs) bind(c, name="stream_close") ! high-level API: utility functions - function zfp_type_size(zfp_type) result(type_size) bind(c, name="zfp_type_size") + function zfp_type_size(scalar_type) result(type_size) bind(c, name="zfp_type_size") import - integer(c_int) zfp_type + integer(c_int) scalar_type integer(c_size_t) type_size end function @@ -206,11 +206,11 @@ subroutine zfp_stream_set_reversible(stream) bind(c, name="zfp_stream_set_revers type(c_ptr), value :: stream end subroutine - function zfp_stream_set_rate(stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") + function zfp_stream_set_rate(stream, rate, scalar_type, dims, wra) result(rate_result) bind(c, name="zfp_stream_set_rate") import type(c_ptr), value :: stream real(c_double), value :: rate - integer(c_int), value :: zfp_type + integer(c_int), value :: scalar_type ! no unsigned int in Fortran integer(c_int), value :: dims, wra real(c_double) :: rate_result @@ -290,32 +290,32 @@ function zfp_field_alloc() result(field) bind(c, name="zfp_field_alloc") type(c_ptr) :: field end function - function zfp_field_1d(uncompressed_ptr, zfp_type, nx) result(field) bind(c, name="zfp_field_1d") + function zfp_field_1d(uncompressed_ptr, scalar_type, nx) result(field) bind(c, name="zfp_field_1d") import type(c_ptr), value :: uncompressed_ptr type(c_ptr) :: field - integer(c_int), value :: zfp_type, nx + integer(c_int), value :: scalar_type, nx end function - function zfp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(field) bind(c, name="zfp_field_2d") + function zfp_field_2d(uncompressed_ptr, scalar_type, nx, ny) result(field) bind(c, name="zfp_field_2d") import type(c_ptr), value :: uncompressed_ptr type(c_ptr) :: field - integer(c_int), value :: zfp_type, nx, ny + integer(c_int), value :: scalar_type, nx, ny end function - function zfp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(field) bind(c, name="zfp_field_3d") + function zfp_field_3d(uncompressed_ptr, scalar_type, nx, ny, nz) result(field) bind(c, name="zfp_field_3d") import type(c_ptr), value :: uncompressed_ptr type(c_ptr) :: field - integer(c_int), value :: zfp_type, nx, ny, nz + integer(c_int), value :: scalar_type, nx, ny, nz end function - function zfp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(field) bind(c, name="zfp_field_4d") + function zfp_field_4d(uncompressed_ptr, scalar_type, nx, ny, nz, nw) result(field) bind(c, name="zfp_field_4d") import type(c_ptr), value :: uncompressed_ptr type(c_ptr) :: field - integer(c_int), value :: zfp_type, nx, ny, nz, nw + integer(c_int), value :: scalar_type, nx, ny, nz, nw end function subroutine zfp_field_free(field) bind(c, name="zfp_field_free") @@ -329,10 +329,10 @@ function zfp_field_pointer(field) result(arr_ptr) bind(c, name="zfp_field_pointe type(c_ptr) :: arr_ptr end function - function zfp_field_scalar_type(field) result(zfp_type) bind(c, name="zfp_field_type") + function zfp_field_type(field) result(scalar_type) bind(c, name="zfp_field_type") import type(c_ptr), value :: field - integer(c_int) zfp_type + integer(c_int) scalar_type end function function zfp_field_precision(field) result(prec) bind(c, name="zfp_field_precision") @@ -370,10 +370,10 @@ subroutine zfp_field_set_pointer(field, arr_ptr) bind(c, name="zfp_field_set_poi type(c_ptr), value :: field, arr_ptr end subroutine - function zfp_field_set_type(field, zfp_type) result(zfp_type_result) bind(c, name="zfp_field_set_type") + function zfp_field_set_type(field, scalar_type) result(scalar_type_result) bind(c, name="zfp_field_set_type") import type(c_ptr), value :: field - integer(c_int) zfp_type, zfp_type_result + integer(c_int) scalar_type, scalar_type_result end function subroutine zfp_field_set_size_1d(field, nx) bind(c, name="zfp_field_set_size_1d") @@ -562,7 +562,7 @@ subroutine zfp_stream_rewind(stream) bind(c, name="zfp_stream_rewind") zFORp_field_4d, & zFORp_field_free, & zFORp_field_pointer, & - zFORp_field_scalar_type, & + zFORp_field_type, & zFORp_field_precision, & zFORp_field_dimensionality, & zFORp_field_size, & @@ -611,11 +611,11 @@ end subroutine zFORp_bitstream_stream_close ! high-level API: utility functions - function zFORp_type_size(zfp_type) result(type_size) bind(c, name="zforp_type_size") + function zFORp_type_size(scalar_type) result(type_size) bind(c, name="zforp_type_size") implicit none - integer, intent(in) :: zfp_type + integer, intent(in) :: scalar_type integer type_size - type_size = zfp_type_size(int(zfp_type, c_int)) + type_size = zfp_type_size(int(scalar_type, c_int)) end function zFORp_type_size ! high-level API: zfp_stream functions @@ -663,7 +663,7 @@ end function zFORp_stream_mode subroutine zFORp_stream_params(stream, minbits, maxbits, maxprec, minexp) bind(c, name="zforp_stream_params") type(zFORp_stream), intent(in) :: stream - integer (kind=8), intent(inout) :: minbits, maxbits, maxprec, minexp + integer, intent(inout) :: minbits, maxbits, maxprec, minexp call zfp_stream_params(stream%object, & int(minbits, c_int), & int(maxbits, c_int), & @@ -697,15 +697,15 @@ subroutine zFORp_stream_set_reversible(stream) bind(c, name="zforp_stream_set_re call zfp_stream_set_reversible(stream%object) end subroutine zFORp_stream_set_reversible - function zFORp_stream_set_rate(stream, rate, zfp_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") + function zFORp_stream_set_rate(stream, rate, scalar_type, dims, wra) result(rate_result) bind(c, name="zforp_stream_set_rate") implicit none type(zFORp_stream), intent(in) :: stream real (kind=8), intent(in) :: rate - integer, intent(in) :: zfp_type + integer, intent(in) :: scalar_type integer, intent(in) :: dims, wra real (kind=8) :: rate_result rate_result = zfp_stream_set_rate(stream%object, real(rate, c_double), & - int(zfp_type, c_int), int(dims, c_int), int(wra, c_int)) + int(scalar_type, c_int), int(dims, c_int), int(wra, c_int)) end function zFORp_stream_set_rate function zFORp_stream_set_precision(stream, prec) result(prec_result) bind(c, name="zforp_stream_set_precision") @@ -801,40 +801,40 @@ function zFORp_field_alloc() result(field) bind(c, name="zforp_field_alloc") field%object = zfp_field_alloc() end function zFORp_field_alloc - function zFORp_field_1d(uncompressed_ptr, zfp_type, nx) result(field) bind(c, name="zforp_field_1d") + function zFORp_field_1d(uncompressed_ptr, scalar_type, nx) result(field) bind(c, name="zforp_field_1d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr - integer, intent(in) :: zfp_type, nx + integer, intent(in) :: scalar_type, nx type(zFORp_field) field - field%object = zfp_field_1d(uncompressed_ptr, int(zfp_type, c_int), & + field%object = zfp_field_1d(uncompressed_ptr, int(scalar_type, c_int), & int(nx, c_int)) end function zFORp_field_1d - function zFORp_field_2d(uncompressed_ptr, zfp_type, nx, ny) result(field) bind(c, name="zforp_field_2d") + function zFORp_field_2d(uncompressed_ptr, scalar_type, nx, ny) result(field) bind(c, name="zforp_field_2d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr - integer, intent(in) :: zfp_type, nx, ny + integer, intent(in) :: scalar_type, nx, ny type(zFORp_field) field - field%object = zfp_field_2d(uncompressed_ptr, int(zfp_type, c_int), & + field%object = zfp_field_2d(uncompressed_ptr, int(scalar_type, c_int), & int(nx, c_int), int(ny, c_int)) end function zFORp_field_2d - function zFORp_field_3d(uncompressed_ptr, zfp_type, nx, ny, nz) result(field) bind(c, name="zforp_field_3d") + function zFORp_field_3d(uncompressed_ptr, scalar_type, nx, ny, nz) result(field) bind(c, name="zforp_field_3d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr - integer, intent(in) :: zfp_type, nx, ny, nz + integer, intent(in) :: scalar_type, nx, ny, nz type(zFORp_field) field - field%object = zfp_field_3d(uncompressed_ptr, int(zfp_type, c_int), & + field%object = zfp_field_3d(uncompressed_ptr, int(scalar_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int)) end function zFORp_field_3d - function zFORp_field_4d(uncompressed_ptr, zfp_type, nx, ny, nz, nw) result(field) bind(c, name="zforp_field_4d") + function zFORp_field_4d(uncompressed_ptr, scalar_type, nx, ny, nz, nw) result(field) bind(c, name="zforp_field_4d") implicit none type(c_ptr), intent(in) :: uncompressed_ptr - integer, intent(in) :: zfp_type, nx, ny, nz, nw + integer, intent(in) :: scalar_type, nx, ny, nz, nw type(zFORp_field) field - field%object = zfp_field_4d(uncompressed_ptr, int(zfp_type, c_int), & + field%object = zfp_field_4d(uncompressed_ptr, int(scalar_type, c_int), & int(nx, c_int), int(ny, c_int), & int(nz, c_int), int(nw, c_int)) end function zFORp_field_4d @@ -852,13 +852,12 @@ function zFORp_field_pointer(field) result(arr_ptr) bind(c, name="zforp_field_po arr_ptr = zfp_field_pointer(field%object) end function zFORp_field_pointer - ! added "scalar" to name to avoid clash with zfp_field_type - function zFORp_field_scalar_type(field) result(zfp_type) bind(c, name="zforp_field_scalar_type") + function zFORp_field_type(field) result(scalar_type) bind(c, name="zforp_field_type") implicit none type(zFORp_field), intent(in) :: field - integer zfp_type - zfp_type = zfp_field_scalar_type(field%object) - end function zFORp_field_scalar_type + integer scalar_type + scalar_type = zfp_field_type(field%object) + end function zFORp_field_type function zFORp_field_precision(field) result(prec) bind(c, name="zforp_field_precision") implicit none @@ -903,12 +902,12 @@ subroutine zFORp_field_set_pointer(field, arr_ptr) bind(c, name="zforp_field_set call zfp_field_set_pointer(field%object, arr_ptr) end subroutine zFORp_field_set_pointer - function zFORp_field_set_type(field, zfp_type) result(zfp_type_result) bind(c, name="zforp_field_set_type") + function zFORp_field_set_type(field, scalar_type) result(scalar_type_result) bind(c, name="zforp_field_set_type") implicit none type(zFORp_field), intent(in) :: field - integer, intent(in) :: zfp_type - integer zfp_type_result - zfp_type_result = zfp_field_set_type(field%object, int(zfp_type, c_int)) + integer, intent(in) :: scalar_type + integer scalar_type_result + scalar_type_result = zfp_field_set_type(field%object, int(scalar_type, c_int)) end function zFORp_field_set_type subroutine zFORp_field_set_size_1d(field, nx) bind(c, name="zforp_field_set_size_1d") From 496350363a9bfa66e7a77956a8077c75ff3b1382 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 25 Apr 2019 16:51:56 -0700 Subject: [PATCH 156/194] move zfpy test utils to tests/python/ --- python/CMakeLists.txt | 8 -------- tests/python/CMakeLists.txt | 22 ++++++++++++++++++++++ {python => tests/python}/test_utils.pyx | 0 3 files changed, 22 insertions(+), 8 deletions(-) rename {python => tests/python}/test_utils.pyx (100%) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 429fd8fe7..c43aab12b 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -27,11 +27,3 @@ set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) # Install to the typical python module directory set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) - -include_directories(${ZFP_SOURCE_DIR}/tests/utils) -include_directories(${ZFP_SOURCE_DIR}) -add_cython_target(test_utils test_utils.pyx C) -add_library(test_utils MODULE ${test_utils}) -target_link_libraries(test_utils zfp genSmoothRandNumsLib stridedOperationsLib zfpCompressionParamsLib zfpChecksumsLib zfpHashLib) -python_extension_module(test_utils) -set_target_properties(test_utils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index 163a95d16..36a867d9d 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -1,3 +1,25 @@ +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/python/scikit-build-cmake) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/python/eyescale-cmake) + +find_package(PythonInterp REQUIRED) +find_package(PythonLibs REQUIRED) +find_package(PythonExtensions REQUIRED) +find_package(Cython REQUIRED) +find_package(NumPy REQUIRED) + +include_directories(${ZFP_SOURCE_DIR}/include) +include_directories(${ZFP_SOURCE_DIR}/python) +include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) + +include_directories(${ZFP_SOURCE_DIR}/tests/python) +include_directories(${ZFP_SOURCE_DIR}/tests/utils) +include_directories(${ZFP_SOURCE_DIR}) +add_cython_target(test_utils test_utils.pyx C) +add_library(test_utils MODULE ${test_utils}) +target_link_libraries(test_utils zfp genSmoothRandNumsLib stridedOperationsLib zfpCompressionParamsLib zfpChecksumsLib zfpHashLib) +python_extension_module(test_utils) +set_target_properties(test_utils PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) + add_test(NAME test_numpy COMMAND ${PYTHON_EXECUTABLE} test_numpy.py WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/python/test_utils.pyx b/tests/python/test_utils.pyx similarity index 100% rename from python/test_utils.pyx rename to tests/python/test_utils.pyx From 891f528754e8084da9287cbf49386b91868b0f1b Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 29 Apr 2019 15:01:27 -0700 Subject: [PATCH 157/194] rename python library from zfp to zfpy, rename build parameter from BUILD_PYTHON to BUILD_ZFPY --- CMakeLists.txt | 4 +- cmake/travis.cmake | 6 +-- docs/source/python.rst | 20 +++---- python/CMakeLists.txt | 15 +++--- python/{zfp.pxd => zfpy.pxd} | 0 python/{zfp.pyx => zfpy.pyx} | 4 +- tests/python/test_numpy.py | 42 +++++++-------- tests/python/test_utils.pyx | 100 +++++++++++++++++------------------ travis.sh | 4 +- 9 files changed, 96 insertions(+), 99 deletions(-) rename python/{zfp.pxd => zfpy.pxd} (100%) rename python/{zfp.pyx => zfpy.pyx} (99%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c05c8875b..5021d3fbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -232,8 +232,8 @@ if(BUILD_UTILITIES) add_subdirectory(utils) endif() -option(BUILD_PYTHON "Build python bindings for zfp" OFF) -if(BUILD_PYTHON) +option(BUILD_ZFPY "Build python bindings for zfp" OFF) +if(BUILD_ZFPY) add_subdirectory(python) endif() diff --git a/cmake/travis.cmake b/cmake/travis.cmake index 7d600dbc4..aeb31a4bd 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -11,7 +11,7 @@ set(cfg_options -DCMAKE_C_STANDARD=${C_STANDARD} -DCMAKE_CXX_STANDARD=${CXX_STANDARD} -DBUILD_CFP=${BUILD_CFP} - -DBUILD_PYTHON=${BUILD_PYTHON} + -DBUILD_ZFPY=${BUILD_ZFPY} -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_OPENMP=${BUILD_OPENMP} -DZFP_WITH_CUDA=${BUILD_CUDA} @@ -38,8 +38,8 @@ if(BUILD_CFP) endif() endif() -if(BUILD_PYTHON) - set(CTEST_SITE "${CTEST_SITE}_python") +if(BUILD_ZFPY) + set(CTEST_SITE "${CTEST_SITE}_zfpy") list(APPEND cfg_options -DPYTHON_INCLUDE_DIR=$ENV{PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY=$ENV{PYTHON_LIBRARY} diff --git a/docs/source/python.rst b/docs/source/python.rst index 0806ff10d..703271c1c 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -4,7 +4,7 @@ Python ======================= -.. py:module:: zfp +.. py:module:: zfpy Dependencies ------------ @@ -23,13 +23,13 @@ You can install the necessary dependencies using ``pip`` and the zfp Installation ------------ -To build the python bindings, add ``-DBUILD_PYTHON=on`` to the cmake line. Cmake +To build the python bindings, add ``-DBUILD_ZFPY=ON`` to the cmake line. Cmake will attempt to automatically detect the python installation to use. If cmake finds multiple python installations, it will use the newest one. To specify a specific python installation to use, set ``PYTHON_LIBRARY`` and ``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: - cmake -DBUILD_PYTHON=on -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. + cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. Compression ----------- @@ -43,12 +43,12 @@ By default, all that is required to be passed to the compression function is the numpy array; this will result in a stream that includes a header and is compressed with the ``reversible`` mode. For example:: - import zfp + import zfpy import numpy as np my_array = np.arange(1, 20) - compressed_data = zfp.compress_numpy(my_array) - decompressed_array = zfp.decompress_numpy(compressed_data) + compressed_data = zfpy.compress_numpy(my_array) + decompressed_array = zfpy.decompress_numpy(compressed_data) # confirm lossless compression/decompression np.testing.assert_array_equal(my_array, decompressed_array) @@ -56,8 +56,8 @@ compressed with the ``reversible`` mode. For example:: Using the fixed-accuracy, fixed-rate, or fixed-precision modes simply requires setting one of the tolerance, rate, or precision arguments, respectively. For example:: - compressed_data = zfp.compress_numpy(my_array, tolerance=1e-4) - decompressed_array = zfp.decompress_numpy(compressed_data) + compressed_data = zfpy.compress_numpy(my_array, tolerance=1e-4) + decompressed_array = zfpy.decompress_numpy(compressed_data) # Note the change from "equal" to "allclose" due to the lossy compression np.testing.assert_allclose(my_array, decompressed_array, atol=1e-3) @@ -105,8 +105,8 @@ before and after. Decompresses a compressed stream without a header. If a header is present in the stream, it will be incorrectly interpreted as compressed data. ``ztype`` is -a ``zfp_type``, which can be manually specified (e.g., ``zfp.type_int32``) or -generated from a numpy dtype (e.g., ``zfp.dtype_to_ztype(array.dtype)``). If +a ``zfp_type``, which can be manually specified (e.g., ``zfpy.type_int32``) or +generated from a numpy dtype (e.g., ``zfpy.dtype_to_ztype(array.dtype)``). If ``out`` is specified, the data is decompressed into the ``out`` buffer. ``out`` can be a numpy array or a pointer to memory large enough to hold the decompressed data. Regardless if ``out`` is provided or its type, diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index c43aab12b..905dc97eb 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -13,17 +13,14 @@ find_package(NumPy REQUIRED) include_directories(${ZFP_SOURCE_DIR}/include) include_directories(${PYTHON_NUMPY_INCLUDE_DIR}) -# cannot reuse the zfp target, use _zfp instead -add_cython_target(_zfp zfp.pyx C) -add_library(_zfp MODULE ${_zfp}) -target_link_libraries(_zfp zfp) -python_extension_module(_zfp) +add_cython_target(zfpy zfpy.pyx C) +add_library(zfpy MODULE ${zfpy}) +target_link_libraries(zfpy zfp) +python_extension_module(zfpy) # Build to the currrent binary dir to avoid conflicts with other libraries named zfp set(PYLIB_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/lib" CACHE PATH "Directory where zfp python library will be built") -set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) -# Make sure the final library is called zfp (rather than _zfp) -set_target_properties(_zfp PROPERTIES LIBRARY_OUTPUT_NAME zfp) +set_target_properties(zfpy PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PYLIB_BUILD_DIR}) # Install to the typical python module directory set(python_install_lib_dir "lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/site-packages/") -install(TARGETS _zfp LIBRARY DESTINATION ${python_install_lib_dir}) +install(TARGETS zfpy LIBRARY DESTINATION ${python_install_lib_dir}) diff --git a/python/zfp.pxd b/python/zfpy.pxd similarity index 100% rename from python/zfp.pxd rename to python/zfpy.pxd diff --git a/python/zfp.pyx b/python/zfpy.pyx similarity index 99% rename from python/zfp.pyx rename to python/zfpy.pyx index d0e4f3305..1f38697f2 100644 --- a/python/zfp.pyx +++ b/python/zfpy.pyx @@ -13,7 +13,7 @@ if sys.version_info[0] == 2: elif sys.version_info[0] == 3: from itertools import zip_longest -cimport zfp +cimport zfpy import numpy as np cimport numpy as np @@ -286,7 +286,7 @@ cpdef np.ndarray _decompress( if out is None: output = np.asarray(_decompress_with_view(field, stream)) else: - dtype = zfp.ztype_to_dtype(ztype) + dtype = zfpy.ztype_to_dtype(ztype) if isinstance(out, np.ndarray): output = out diff --git a/tests/python/test_numpy.py b/tests/python/test_numpy.py index 4443e76ba..a6c8176d6 100644 --- a/tests/python/test_numpy.py +++ b/tests/python/test_numpy.py @@ -2,7 +2,7 @@ import unittest -import zfp +import zfpy import test_utils import numpy as np try: @@ -13,8 +13,8 @@ class TestNumpy(unittest.TestCase): def lossless_round_trip(self, orig_array): - compressed_array = zfp.compress_numpy(orig_array, write_header=True) - decompressed_array = zfp.decompress_numpy(compressed_array) + compressed_array = zfpy.compress_numpy(orig_array, write_header=True) + decompressed_array = zfpy.decompress_numpy(compressed_array) self.assertIsNone(np.testing.assert_array_equal(decompressed_array, orig_array)) def test_different_dimensions(self): @@ -49,9 +49,9 @@ def test_different_dtypes(self): def test_advanced_decompression_checksum(self): ndims = 2 - ztype = zfp.type_float + ztype = zfpy.type_float random_array = test_utils.getRandNumpyArray(ndims, ztype) - mode = zfp.mode_fixed_accuracy + mode = zfpy.mode_fixed_accuracy compress_param_num = 1 compression_kwargs = { "tolerance": test_utils.computeParameterValue( @@ -59,7 +59,7 @@ def test_advanced_decompression_checksum(self): compress_param_num ), } - compressed_array = zfp.compress_numpy( + compressed_array = zfpy.compress_numpy( random_array, write_header=False, **compression_kwargs @@ -68,7 +68,7 @@ def test_advanced_decompression_checksum(self): # Decompression using the "advanced" interface which enforces no header, # and the user must provide all the metadata decompressed_array = np.empty_like(random_array) - zfp._decompress( + zfpy._decompress( compressed_array, ztype, random_array.shape, @@ -92,13 +92,13 @@ def test_advanced_decompression_nonsquare(self): random_array = np.random.rand(*shape) decompressed_array = np.empty_like(random_array) - compressed_array = zfp.compress_numpy( + compressed_array = zfpy.compress_numpy( random_array, write_header=False, ) - zfp._decompress( + zfpy._decompress( compressed_array, - zfp.dtype_to_ztype(random_array.dtype), + zfpy.dtype_to_ztype(random_array.dtype), random_array.shape, out= decompressed_array, ) @@ -107,10 +107,10 @@ def test_advanced_decompression_nonsquare(self): def test_utils(self): for ndims in range(1, 5): for ztype, ztype_str in [ - (zfp.type_float, "float"), - (zfp.type_double, "double"), - (zfp.type_int32, "int32"), - (zfp.type_int64, "int64"), + (zfpy.type_float, "float"), + (zfpy.type_double, "double"), + (zfpy.type_int32, "int32"), + (zfpy.type_int64, "int64"), ]: orig_random_array = test_utils.getRandNumpyArray(ndims, ztype) orig_checksum = test_utils.getChecksumOrigArray(ndims, ztype) @@ -133,10 +133,10 @@ def test_utils(self): self.assertTrue(np.equal(orig_random_array, random_array).all()) for compress_param_num in range(3): - modes = [(zfp.mode_fixed_accuracy, "tolerance"), - (zfp.mode_fixed_precision, "precision"), - (zfp.mode_fixed_rate, "rate")] - if ztype in [zfp.type_int32, zfp.type_int64]: + modes = [(zfpy.mode_fixed_accuracy, "tolerance"), + (zfpy.mode_fixed_precision, "precision"), + (zfpy.mode_fixed_rate, "rate")] + if ztype in [zfpy.type_int32, zfpy.type_int64]: modes = [modes[-1]] # only fixed-rate is supported for integers for mode, mode_str in modes: # Compression @@ -147,7 +147,7 @@ def test_utils(self): ), } - compressed_array = zfp.compress_numpy( + compressed_array = zfpy.compress_numpy( random_array, write_header=False, **compression_kwargs @@ -174,12 +174,12 @@ def test_utils(self): # Decompression using the "public" interface # requires a header, so re-compress with the header # included in the stream - compressed_array = zfp.compress_numpy( + compressed_array = zfpy.compress_numpy( random_array, write_header=True, **compression_kwargs ) - decompressed_array = zfp.decompress_numpy( + decompressed_array = zfpy.decompress_numpy( compressed_array, ) actual_checksum = test_utils.hashNumpyArray( diff --git a/tests/python/test_utils.pyx b/tests/python/test_utils.pyx index e7ed77e06..6069609f0 100644 --- a/tests/python/test_utils.pyx +++ b/tests/python/test_utils.pyx @@ -4,8 +4,8 @@ cimport libc.stdint as stdint from cython cimport view from itertools import islice, repeat, chain -import zfp -cimport zfp +import zfpy +cimport zfpy import numpy as np cimport numpy as np @@ -50,16 +50,16 @@ cdef extern from "stridedOperations.h": void reverseArray(void* inputArr, void* outputArr, size_t inputArrLen, - zfp.zfp_type zfpType); + zfpy.zfp_type zfpType); void interleaveArray(void* inputArr, void* outputArr, size_t inputArrLen, - zfp.zfp_type zfpType); + zfpy.zfp_type zfpType); int permuteSquareArray(void* inputArr, void* outputArr, size_t sideLen, int dims, - zfp.zfp_type zfpType); + zfpy.zfp_type zfpType); void getReversedStrides(int dims, size_t n[4], int s[4]); @@ -77,24 +77,24 @@ cdef extern from "zfpCompressionParams.h": cdef extern from "zfpChecksums.h": uint64_t getChecksumOriginalDataBlock(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumEncodedBlock(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumEncodedPartialBlock(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumDecodedBlock(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumDecodedPartialBlock(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumOriginalDataArray(int dims, - zfp.zfp_type type); + zfpy.zfp_type type); uint64_t getChecksumCompressedBitstream(int dims, - zfp.zfp_type type, - zfp.zfp_mode mode, + zfpy.zfp_type type, + zfpy.zfp_mode mode, int compressParamNum); uint64_t getChecksumDecompressedArray(int dims, - zfp.zfp_type type, - zfp.zfp_mode mode, + zfpy.zfp_type type, + zfpy.zfp_mode mode, int compressParamNum); cdef extern from "zfpHash.h": @@ -124,20 +124,20 @@ cdef validate_num_dimensions(int dims): if dims > 4 or dims < 1: raise ValueError("Unsupported number of dimensions: {}".format(dims)) -cdef validate_ztype(zfp.zfp_type ztype): +cdef validate_ztype(zfpy.zfp_type ztype): if ztype not in [ - zfp.type_float, - zfp.type_double, - zfp.type_int32, - zfp.type_int64 + zfpy.type_float, + zfpy.type_double, + zfpy.type_int32, + zfpy.type_int64 ]: raise ValueError("Unsupported ztype: {}".format(ztype)) -cdef validate_mode(zfp.zfp_mode mode): +cdef validate_mode(zfpy.zfp_mode mode): if mode not in [ - zfp.mode_fixed_rate, - zfp.mode_fixed_precision, - zfp.mode_fixed_accuracy, + zfpy.mode_fixed_rate, + zfpy.mode_fixed_precision, + zfpy.mode_fixed_accuracy, ]: raise ValueError("Unsupported mode: {}".format(mode)) @@ -149,7 +149,7 @@ cdef validate_compress_param(int comp_param): cpdef getRandNumpyArray( int numDims, - zfp.zfp_type ztype, + zfpy.zfp_type ztype, ): validate_num_dimensions(numDims) validate_ztype(ztype) @@ -157,9 +157,9 @@ cpdef getRandNumpyArray( cdef size_t minTotalElements = 0 cdef int amplitudeExp = 0 - if ztype in [zfp.type_float, zfp.type_double]: + if ztype in [zfpy.type_float, zfpy.type_double]: minTotalElements = 1000000 - elif ztype in [zfp.type_int32, zfp.type_int64]: + elif ztype in [zfpy.type_int32, zfpy.type_int64]: minTotalElements = 4096 cdef int64_t* outputArrInt64 = NULL @@ -170,7 +170,7 @@ cpdef getRandNumpyArray( cdef size_t outputTotalLen = 0 cdef view.array viewArr = None - if ztype == zfp.type_int64: + if ztype == zfpy.type_int64: amplitudeExp = 64 - 2 generateSmoothRandInts64(minTotalElements, numDims, @@ -186,7 +186,7 @@ cpdef getRandNumpyArray( viewArr = outputArrInt64 elif numDims == 4: viewArr = outputArrInt64 - elif ztype == zfp.type_int32: + elif ztype == zfpy.type_int32: amplitudeExp = 32 - 2 generateSmoothRandInts32(minTotalElements, numDims, @@ -202,7 +202,7 @@ cpdef getRandNumpyArray( viewArr = outputArrInt32 elif numDims == 4: viewArr = outputArrInt32 - elif ztype == zfp.type_float: + elif ztype == zfpy.type_float: generateSmoothRandFloats(minTotalElements, numDims, &outputArrFloat, @@ -216,7 +216,7 @@ cpdef getRandNumpyArray( viewArr = outputArrFloat elif numDims == 4: viewArr = outputArrFloat - elif ztype == zfp.type_double: + elif ztype == zfpy.type_double: generateSmoothRandDoubles(minTotalElements, numDims, &outputArrDouble, @@ -237,7 +237,7 @@ cpdef getRandNumpyArray( cpdef uint64_t getChecksumOrigArray( int dims, - zfp.zfp_type ztype + zfpy.zfp_type ztype ): validate_num_dimensions(dims) validate_ztype(ztype) @@ -246,8 +246,8 @@ cpdef uint64_t getChecksumOrigArray( cpdef uint64_t getChecksumCompArray( int dims, - zfp.zfp_type ztype, - zfp.zfp_mode mode, + zfpy.zfp_type ztype, + zfpy.zfp_mode mode, int compressParamNum ): validate_num_dimensions(dims) @@ -259,8 +259,8 @@ cpdef uint64_t getChecksumCompArray( cpdef uint64_t getChecksumDecompArray( int dims, - zfp.zfp_type ztype, - zfp.zfp_mode mode, + zfpy.zfp_type ztype, + zfpy.zfp_mode mode, int compressParamNum ): validate_num_dimensions(dims) @@ -270,30 +270,30 @@ cpdef uint64_t getChecksumDecompArray( return getChecksumDecompressedArray(dims, ztype, mode, compressParamNum) -cpdef computeParameterValue(zfp.zfp_mode mode, int param): +cpdef computeParameterValue(zfpy.zfp_mode mode, int param): validate_mode(mode) validate_compress_param(param) - if mode == zfp.mode_fixed_accuracy: + if mode == zfpy.mode_fixed_accuracy: return computeFixedAccuracyParam(param) - elif mode == zfp.mode_fixed_precision: + elif mode == zfpy.mode_fixed_precision: return computeFixedPrecisionParam(param) - elif mode == zfp.mode_fixed_rate: + elif mode == zfpy.mode_fixed_rate: return computeFixedRateParam(param) cpdef hashStridedArray( bytes inarray, - zfp.zfp_type ztype, + zfpy.zfp_type ztype, shape, strides, ): cdef char* array = inarray - cdef size_t[4] padded_shape = zfp.gen_padded_int_list(shape) - cdef int[4] padded_strides = zfp.gen_padded_int_list(strides) + cdef size_t[4] padded_shape = zfpy.gen_padded_int_list(shape) + cdef int[4] padded_strides = zfpy.gen_padded_int_list(strides) - if ztype == zfp.type_int32 or ztype == zfp.type_float: + if ztype == zfpy.type_int32 or ztype == zfpy.type_float: return hashStridedArray32(array, padded_shape, padded_strides) - elif ztype == zfp.type_int64 or ztype == zfp.type_double: + elif ztype == zfpy.type_int64 or ztype == zfpy.type_double: return hashStridedArray64(array, padded_shape, padded_strides) cpdef hashNumpyArray( @@ -316,10 +316,10 @@ cpdef hashNumpyArray( elif dtype == np.int64 or dtype == np.float64: return hashArray64(nparray.data, size, stride_width) elif stride_conf in [REVERSED, PERMUTED]: - strides = zfp.gen_padded_int_list( + strides = zfpy.gen_padded_int_list( [x for x in nparray.strides[:nparray.ndim]] ) - shape = zfp.gen_padded_int_list( + shape = zfpy.gen_padded_int_list( [x for x in nparray.shape[:nparray.ndim]] ) if dtype == np.int32 or dtype == np.float32: @@ -342,9 +342,9 @@ cpdef generateStridedRandomNumpyArray( cdef int ndim = randomArray.ndim shape = [int(x) for x in randomArray.shape[:ndim]] dtype = randomArray.dtype - cdef zfp.zfp_type ztype = zfp.dtype_to_ztype(dtype) + cdef zfpy.zfp_type ztype = zfpy.dtype_to_ztype(dtype) cdef int[4] strides = [0, 0, 0, 0] - cdef size_t[4] dims = zfp.gen_padded_int_list(shape) + cdef size_t[4] dims = zfpy.gen_padded_int_list(shape) cdef size_t inputLen = len(randomArray) cdef void* output_array_ptr = NULL cdef np.ndarray output_array = None @@ -379,7 +379,7 @@ cpdef generateStridedRandomNumpyArray( num_elements = np.prod(shape) new_shape = [x for x in dims if x > 0] new_shape[-1] *= 2 - dims = tuple(zfp.gen_padded_int_list(new_shape, pad=0, length=4)) + dims = tuple(zfpy.gen_padded_int_list(new_shape, pad=0, length=4)) output_array = np.empty( new_shape, diff --git a/travis.sh b/travis.sh index f71aa9153..623a76e29 100755 --- a/travis.sh +++ b/travis.sh @@ -12,7 +12,7 @@ cd build if [ -n "${COVERAGE}" ]; then # build (linux) - run_all " -DBUILD_CFP=ON -DBUILD_PYTHON=ON -DBUILD_ZFORP=ON -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON" + run_all " -DBUILD_CFP=ON -DBUILD_ZFPY=ON -DBUILD_ZFORP=ON -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON" else # build/test without OpenMP, with CFP (and custom namespace), with zfPy, with Fortran (linux only) if [[ "$OSTYPE" == "darwin"* ]]; then @@ -21,7 +21,7 @@ else BUILD_ZFORP=ON fi - run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_PYTHON=ON -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" + run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_ZFPY=ON -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" rm -rf ./* ; From f0d73baac0e8fd7777b1f86e065f07408a5fff86 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 29 Apr 2019 17:26:34 -0700 Subject: [PATCH 158/194] move python installation info to general installation section (documentation) --- docs/source/defs.rst | 1 + docs/source/installation.rst | 32 ++++++++++++++++++++++++++++++++ docs/source/python.rst | 25 ------------------------- 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/docs/source/defs.rst b/docs/source/defs.rst index a555acdcd..1b51bc8be 100644 --- a/docs/source/defs.rst +++ b/docs/source/defs.rst @@ -7,6 +7,7 @@ .. |zfpy| replace:: zfPy .. |libzfp| replace:: :file:`libzfp` .. |libcfp| replace:: :file:`libcfp` +.. |libzforp| replace:: :file:`libzforp` .. |zfpcmd| replace:: :program:`zfp` .. |testzfp| replace:: :program:`testzfp` .. |4powd| replace:: 4\ :sup:`d` diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 0edd62060..02d4c9958 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -125,6 +125,24 @@ Regardless of the settings below, |libzfp| will always be built. Build |libcfp| for C bindings to compressed arrays. Default: off. +.. c:macro:: BUILD_ZFPY + + Build |zfpy| for Python bindings to the C API. + + Cmake will attempt to automatically detect the python installation to use. If cmake + finds multiple python installations, it will use the newest one. To specify a + specific python installation to use, set ``PYTHON_LIBRARY`` and + ``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: + + cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. + + Default: off. + +.. c:macro:: BUILD_ZFORP + + Build |libzforp| for Fortran bindings to the C API. + Default: off. + .. c:macro:: BUILD_UTILITIES Build |zfpcmd| command-line utility for compressing binary files. @@ -247,3 +265,17 @@ in the same manner that :ref:`build targets ` are specified, e.g., Macro for renaming the outermost |cfp| namespace, e.g., to avoid name clashes. Default: cfp. + +Python Dependencies +------------------- + +Minimum Tested Versions: + +* Python: Python 2.7 & Python 3.5 +* Cython: 0.22 +* Numpy: 1.8.0 + +You can install the necessary dependencies using ``pip`` and the zfp +``requirements.txt``:: + + pip install -r $ZFP_ROOT/python/requirements.txt diff --git a/docs/source/python.rst b/docs/source/python.rst index 703271c1c..25a444e4f 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -6,31 +6,6 @@ Python .. py:module:: zfpy -Dependencies ------------- - -Minimum Tested Versions: - -* Python: Python 2.7 & Python 3.5 -* Cython: 0.22 -* Numpy: 1.8.0 - -You can install the necessary dependencies using ``pip`` and the zfp -``requirements.txt``:: - - pip install -r $ZFP_ROOT/python/requirements.txt - -Installation ------------- - -To build the python bindings, add ``-DBUILD_ZFPY=ON`` to the cmake line. Cmake -will attempt to automatically detect the python installation to use. If cmake -finds multiple python installations, it will use the newest one. To specify a -specific python installation to use, set ``PYTHON_LIBRARY`` and -``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: - - cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. - Compression ----------- From 5337de3eec50d800c5966ebc8795d63ad43b316b Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Mon, 29 Apr 2019 17:36:28 -0700 Subject: [PATCH 159/194] add Fortran standard information to installation documentation --- docs/source/installation.rst | 3 +++ fortran/CMakeLists.txt | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 02d4c9958..46a46e23b 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -141,6 +141,9 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_ZFORP Build |libzforp| for Fortran bindings to the C API. + + Requires Fortran standard 2003 and later. + Default: off. .. c:macro:: BUILD_UTILITIES diff --git a/fortran/CMakeLists.txt b/fortran/CMakeLists.txt index 978eae1d5..22381df45 100644 --- a/fortran/CMakeLists.txt +++ b/fortran/CMakeLists.txt @@ -1,11 +1,11 @@ enable_language(Fortran) if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU") - set(dialect "-ffree-form -std=f2008 -fimplicit-none") + set(dialect "-ffree-form -fimplicit-none") set(bounds "-fbounds-check") endif() if(CMAKE_Fortran_COMPILER_ID MATCHES "Intel") - set(dialect "-stand f08 -free -implicitnone") + set(dialect "-stand -free -implicitnone") set(bounds "-check bounds") endif() From 6c9e74cc3f5c6c425628da5eec1b9e9c1b4369f0 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 30 Apr 2019 16:20:22 -0700 Subject: [PATCH 160/194] add python version to cdash site. Remove trailing whitespaces from added compressed array header code --- array/zfp/header.h | 2 +- array/zfparray.h | 2 +- cmake/travis.cmake | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/array/zfp/header.h b/array/zfp/header.h index 0ba5011cb..ad6433cf1 100644 --- a/array/zfp/header.h +++ b/array/zfp/header.h @@ -3,7 +3,7 @@ class header { class exception : public std::runtime_error { public: exception(const std::string& msg) : runtime_error(msg) {} - + virtual ~exception() throw (){} }; diff --git a/array/zfparray.h b/array/zfparray.h index b60b2419d..9842bcefa 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -87,7 +87,7 @@ class array { deep_copy(a); return *this; } - + public: // public virtual destructor (can delete array through base class pointer) virtual ~array() diff --git a/cmake/travis.cmake b/cmake/travis.cmake index aeb31a4bd..eedcc92a0 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -39,7 +39,7 @@ if(BUILD_CFP) endif() if(BUILD_ZFPY) - set(CTEST_SITE "${CTEST_SITE}_zfpy") + set(CTEST_SITE "${CTEST_SITE}_zfpy$ENV{PYTHON_VERSION}") list(APPEND cfg_options -DPYTHON_INCLUDE_DIR=$ENV{PYTHON_INCLUDE_DIR} -DPYTHON_LIBRARY=$ENV{PYTHON_LIBRARY} From 7bf5803575ad9ea855796d59a918d76454842f13 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 30 Apr 2019 16:31:10 -0700 Subject: [PATCH 161/194] add README badges for CIs and Readthedocs --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 764767a4e..2fd5fa328 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ ZFP === - -[![codecov](https://codecov.io/gh/LLNL/zfp/branch/develop/graph/badge.svg)](https://codecov.io/gh/LLNL/zfp) +[![Travis CI Build Status](https://travis-ci.org/LLNL/zfp.svg?branch=develop)](https://travis-ci.org/LLNL/zfp) +[![Appveyor Build Status](https://ci.appveyor.com/api/projects/status/github/LLNL/zfp?branch=develop&svg=true)](https://ci.appveyor.com/project/salasoom/zfp) +[![Documentation Status](https://readthedocs.org/projects/zfp/badge/?version=release0.5.5)](https://zfp.readthedocs.io/en/release0.5.5/?badge=release0.5.5) +[![Codecov](https://codecov.io/gh/LLNL/zfp/branch/develop/graph/badge.svg)](https://codecov.io/gh/LLNL/zfp) INTRODUCTION ------------ From 94363e0b0b70abd5e39d99e8212854da24aa0076 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Tue, 30 Apr 2019 17:27:01 -0700 Subject: [PATCH 162/194] add Fortran 2003, 2008 to CI. Specify standard in cdash site name --- .travis.yml | 30 +++++++++++++++--------------- cmake/travis.cmake | 5 ++++- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3f4f5de17..402876885 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' COVERAGE='ON' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' COVERAGE='ON' - os: linux dist: xenial @@ -31,7 +31,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' PYTHON_VERSION='3.5' + env: CC='clang-3.6' CXX='clang++-3.6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -48,7 +48,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='clang-4.0' CXX='clang++-4.0' FC='gfortran-6' PYTHON_VERSION='3.5' + env: CC='clang-4.0' CXX='clang++-4.0' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -63,7 +63,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-4.4' CXX='g++-4.4' FC='gfortran-4.4' PYTHON_VERSION='3.5' + env: CC='gcc-4.4' CXX='g++-4.4' FC='gfortran-4.4' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -78,7 +78,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-4.7' CXX='g++-4.7' FC='gfortran-4.7' PYTHON_VERSION='3.5' + env: CC='gcc-4.7' CXX='g++-4.7' FC='gfortran-4.7' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -93,7 +93,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-4.8' CXX='g++-4.8' FC='gfortran-4.8' PYTHON_VERSION='3.5' + env: CC='gcc-4.8' CXX='g++-4.8' FC='gfortran-4.8' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -108,7 +108,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-4.9' CXX='g++-4.9' FC='gfortran-4.9' PYTHON_VERSION='3.5' + env: CC='gcc-4.9' CXX='g++-4.9' FC='gfortran-4.9' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' - os: linux dist: trusty @@ -122,7 +122,7 @@ matrix: - gfortran-5 - libpython2.7 - python-pip - env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' PYTHON_VERSION='2.7' + env: CC='gcc-5' CXX='g++-5' FC='gfortran-5' FORTRAN_STANDARD='2003' PYTHON_VERSION='2.7' - os: linux dist: trusty @@ -136,7 +136,7 @@ matrix: - gfortran-6 - libpython2.7 - python-pip - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='2.7' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='2.7' - os: linux dist: xenial @@ -151,7 +151,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' C_STANDARD='90' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' C_STANDARD='90' - os: linux dist: xenial @@ -166,7 +166,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' C_STANDARD='11' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' C_STANDARD='11' - os: linux dist: xenial @@ -181,7 +181,7 @@ matrix: - libpython3.5-dev - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' CXX_STANDARD='11' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' CXX_STANDARD='11' - os: linux dist: xenial @@ -196,7 +196,7 @@ matrix: - libpython3.5 - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' CXX_STANDARD='14' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2003' PYTHON_VERSION='3.5' CXX_STANDARD='14' - os: linux dist: xenial @@ -211,7 +211,7 @@ matrix: - libpython3.5 - cython3 - python3-numpy - env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' PYTHON_VERSION='3.5' + env: CC='gcc-6' CXX='g++-6' FC='gfortran-6' FORTRAN_STANDARD='2008' PYTHON_VERSION='3.5' - os: linux dist: xenial @@ -226,7 +226,7 @@ matrix: - libpython3.5 - cython3 - python3-numpy - env: CC='gcc-7' CXX='g++-7' FC='gfortran-7' PYTHON_VERSION='3.5' + env: CC='gcc-7' CXX='g++-7' FC='gfortran-7' FORTRAN_STANDARD='2008' PYTHON_VERSION='3.5' - os: osx osx_image: xcode7.3 diff --git a/cmake/travis.cmake b/cmake/travis.cmake index eedcc92a0..f2bf844b7 100644 --- a/cmake/travis.cmake +++ b/cmake/travis.cmake @@ -48,7 +48,10 @@ if(BUILD_ZFPY) endif() if(BUILD_ZFORP) - set(CTEST_SITE "${CTEST_SITE}_zforp") + set(CTEST_SITE "${CTEST_SITE}_zforp$ENV{FORTRAN_STANDARD}") + list(APPEND cfg_options + -DCMAKE_FORTRAN_FLAGS='-std=f$ENV{FORTRAN_STANDARD}' + ) endif() if(WITH_COVERAGE) From ec87822d6f6615e74468b8ae5d8ec50dbe024929 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 1 May 2019 14:08:22 -0700 Subject: [PATCH 163/194] refactor CI build scripts, always build utilities & examples --- appveyor.sh | 21 +++++++++++++++++++-- travis.sh | 31 ++++++++++++++++++++++++++++--- 2 files changed, 47 insertions(+), 5 deletions(-) diff --git a/appveyor.sh b/appveyor.sh index a00271ba7..31d7194ae 100644 --- a/appveyor.sh +++ b/appveyor.sh @@ -11,8 +11,18 @@ run_all () { mkdir build cd build +# technically, flags are passed on to cmake/* and actually set there # config without OpenMP, with CFP (and custom namespace), with aligned allocations (compressed arrays) -run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_ZFORP=OFF -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" +BUILD_FLAGS="" +BUILD_FLAGS="$BUILD_FLAGS -DBUILD_UTILITIES=ON" +BUILD_FLAGS="$BUILD_FLAGS -DBUILD_EXAMPLES=ON" +BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CFP=ON" +BUILD_FLAGS="$BUILD_FLAGS -DCFP_NAMESPACE=cfp2" +BUILD_FLAGS="$BUILD_FLAGS -DZFP_WITH_ALIGNED_ALLOC=ON" +BUILD_FLAGS="$BUILD_FLAGS -DBUILD_OPENMP=OFF" +BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CUDA=OFF" + +run_all "$BUILD_FLAGS" # build empty project requiring OpenMP, in a temp directory that ZFP is oblivious to mkdir tmpBuild @@ -33,7 +43,14 @@ if [ $? -eq 0 ]; then rm CMakeCache.txt # only run tests not run in previous build, due to appveyor time limit (1 hour) - run_all " -DBUILD_OPENMP=ON -DOMP_TESTS_ONLY=1" + # but continue to build utilities & examples because some support OpenMP + BUILD_FLAGS="" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_UTILITIES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_EXAMPLES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_OPENMP=ON" + BUILD_FLAGS="$BUILD_FLAGS -DOMP_TESTS_ONLY=ON" + + run_all "$BUILD_FLAGS" else echo "OpenMP not found, build completed." fi diff --git a/travis.sh b/travis.sh index 623a76e29..e73383cde 100755 --- a/travis.sh +++ b/travis.sh @@ -10,9 +10,23 @@ run_all () { mkdir build cd build +# technically, flags are passed on to cmake/* and actually set there +BUILD_FLAGS="" + if [ -n "${COVERAGE}" ]; then # build (linux) - run_all " -DBUILD_CFP=ON -DBUILD_ZFPY=ON -DBUILD_ZFORP=ON -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=ON -DBUILD_CUDA=OFF -DWITH_COVERAGE=ON" + + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_UTILITIES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_EXAMPLES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CFP=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_ZFPY=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_ZFORP=ON" + BUILD_FLAGS="$BUILD_FLAGS -DZFP_WITH_ALIGNED_ALLOC=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_OPENMP=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CUDA=OFF" + BUILD_FLAGS="$BUILD_FLAGS -DWITH_COVERAGE=ON" + + run_all "$BUILD_FLAGS" else # build/test without OpenMP, with CFP (and custom namespace), with zfPy, with Fortran (linux only) if [[ "$OSTYPE" == "darwin"* ]]; then @@ -21,7 +35,16 @@ else BUILD_ZFORP=ON fi - run_all " -DBUILD_CFP=ON -DCFP_NAMESPACE=cfp2 -DBUILD_ZFPY=ON -DBUILD_ZFORP=${BUILD_ZFORP} -DZFP_WITH_ALIGNED_ALLOC=1 -DBUILD_OPENMP=OFF -DBUILD_CUDA=OFF" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_UTILITIES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_EXAMPLES=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CFP=ON" + BUILD_FLAGS="$BUILD_FLAGS -DCFP_NAMESPACE=cfp2" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_ZFPY=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_ZFORP=$BUILD_ZFORP" + BUILD_FLAGS="$BUILD_FLAGS -DZFP_WITH_ALIGNED_ALLOC=ON" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_OPENMP=OFF" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_CUDA=OFF" + run_all "$BUILD_FLAGS" rm -rf ./* ; @@ -30,6 +53,8 @@ else rm -rf ./* ; # build/test with OpenMP - run_all " -DBUILD_OPENMP=ON" + BUILD_FLAGS="" + BUILD_FLAGS="$BUILD_FLAGS -DBUILD_OPENMP=ON" + run_all "$BUILD_FLAGS" fi fi From 805c096a2e0ff217b23c32742381ba041000a42e Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Wed, 1 May 2019 15:26:30 -0700 Subject: [PATCH 164/194] add CMake BUILD_ALL option, to build all subdirectories. Fix missed BUILD_PYTHON -> BUILD_ZFPY in tests/CMakeLists.txt --- CMakeLists.txt | 19 ++++++++++++++----- docs/source/installation.rst | 5 +++++ tests/CMakeLists.txt | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5021d3fbf..47179fd81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,6 +217,15 @@ mark_as_advanced(ZFP_LIBRARY_PREFIX) add_subdirectory(src) +option(BUILD_ALL "Build all subdirectories" OFF) +if(BUILD_ALL) + set(BUILD_CFP ON CACHE BOOL "Build CFP arrays library" FORCE) + set(BUILD_ZFORP ON CACHE BOOL "Build Fortran library" FORCE) + set(BUILD_ZFPY ON CACHE BOOL "Build python bindings for zfp" FORCE) + set(BUILD_UTILITIES ON CACHE BOOL "Build command line utilities for zfp" FORCE) + set(BUILD_EXAMPLES ON CACHE BOOL "Build Examples" FORCE) +endif() + option(BUILD_CFP "Build CFP arrays library" OFF) if(BUILD_CFP) add_subdirectory(cfp) @@ -227,16 +236,16 @@ if(BUILD_ZFORP) add_subdirectory(fortran) endif() -option(BUILD_UTILITIES "Build command line utilities for zfp" ON) -if(BUILD_UTILITIES) - add_subdirectory(utils) -endif() - option(BUILD_ZFPY "Build python bindings for zfp" OFF) if(BUILD_ZFPY) add_subdirectory(python) endif() +option(BUILD_UTILITIES "Build command line utilities for zfp" ON) +if(BUILD_UTILITIES) + add_subdirectory(utils) +endif() + option(BUILD_EXAMPLES "Build Examples" OFF) if(BUILD_EXAMPLES) add_subdirectory(examples) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 46a46e23b..93deb531c 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -120,6 +120,11 @@ or using CMake Regardless of the settings below, |libzfp| will always be built. +.. c:macro:: BUILD_ALL + + Build all subdirectories; enable all options (except BUILD_SHARED_LIBS). + Default: off. + .. c:macro:: BUILD_CFP Build |libcfp| for C bindings to compressed arrays. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f39f775bb..45abf2d91 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -129,6 +129,6 @@ if(ZFP_BUILD_TESTING_LARGE) endforeach() endif() -if(BUILD_PYTHON) +if(BUILD_ZFPY) add_subdirectory(python) endif() From 3d651dd725282bb3d6e0608c5f530dba818ed063 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Thu, 2 May 2019 18:32:27 -0700 Subject: [PATCH 165/194] fix cuda version bug --- src/cuda_zfp/pointers.cuh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cuda_zfp/pointers.cuh b/src/cuda_zfp/pointers.cuh index 63538f0ce..ad963f8c8 100644 --- a/src/cuda_zfp/pointers.cuh +++ b/src/cuda_zfp/pointers.cuh @@ -16,7 +16,7 @@ bool is_gpu_ptr(const void *ptr) // clear last error so other error checking does // not pick it up cudaError_t error = cudaGetLastError(); -#if CUDART_VERSION >= 1000 +#if CUDART_VERSION >= 10000 return perr == cudaSuccess && (atts.type == cudaMemoryTypeDevice || atts.type == cudaMemoryTypeManaged); From e36405baab25632a3fe8970d10981ed91eb6468f Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 28 Apr 2019 08:35:21 -0700 Subject: [PATCH 166/194] Fix cleanup of incorrect pointer in CUDA decompress --- src/cuda_zfp/cuZFP.cu | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/cuda_zfp/cuZFP.cu b/src/cuda_zfp/cuZFP.cu index 46815a6ac..ffbb99337 100644 --- a/src/cuda_zfp/cuZFP.cu +++ b/src/cuda_zfp/cuZFP.cu @@ -434,7 +434,7 @@ cuda_decompress(zfp_stream *stream, zfp_field *field) } size_t bytes = type_size * field_size; - internal::cleanup_device_ptr(stream->stream, d_stream,0, 0, field->type); + internal::cleanup_device_ptr(stream->stream->begin, d_stream, 0, 0, field->type); internal::cleanup_device_ptr(field->data, d_data, bytes, offset, field->type); // this is how zfp determins if this was a success @@ -442,6 +442,4 @@ cuda_decompress(zfp_stream *stream, zfp_field *field) stream->stream->bits = wsize; // set stream pointer to end of stream stream->stream->ptr = stream->stream->begin + words_read; - } - From 5da62def064e34ed6e6a384dc03e11533e27681e Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 28 Apr 2019 08:37:26 -0700 Subject: [PATCH 167/194] Update release number and copyright year --- include/zfp.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/include/zfp.h b/include/zfp.h index 94034d9bb..be070303b 100644 --- a/include/zfp.h +++ b/include/zfp.h @@ -1,7 +1,7 @@ /* -** Copyright (c) 2014-2018, Lawrence Livermore National Security, LLC. +** Copyright (c) 2014-2019, Lawrence Livermore National Security, LLC. ** Produced at the Lawrence Livermore National Laboratory. -** Authors: Peter Lindstrom, Markus Salasoo, Matt Larsen. +** Authors: Peter Lindstrom, Markus Salasoo, Matt Larsen, Stephen Herbein. ** LLNL-CODE-663824. ** All rights reserved. ** @@ -74,7 +74,7 @@ /* library version information */ #define ZFP_VERSION_MAJOR 0 /* library major version number */ #define ZFP_VERSION_MINOR 5 /* library minor version number */ -#define ZFP_VERSION_PATCH 4 /* library patch version number */ +#define ZFP_VERSION_PATCH 5 /* library patch version number */ #define ZFP_VERSION_RELEASE ZFP_VERSION_PATCH /* codec version number (see also zfp_codec_version) */ @@ -216,21 +216,21 @@ zfp_stream_bit_stream( const zfp_stream* stream /* compressed stream */ ); -int /* nonzero if lossless compression is enabled */ +int /* nonzero if lossless compression is enabled */ zfp_stream_is_reversible( - const zfp_stream* zfp /* compressed stream */ + const zfp_stream* stream /* compressed stream */ ); /* returns enum of compression mode */ -zfp_mode /* enum for compression mode */ +zfp_mode /* enum for compression mode */ zfp_stream_compression_mode( - const zfp_stream* zfp /* compressed stream */ + const zfp_stream* stream /* compressed stream */ ); /* get all compression parameters in a compact representation */ -uint64 /* 12- or 64-bit encoding of parameters */ +uint64 /* 12- or 64-bit encoding of parameters */ zfp_stream_mode( - const zfp_stream* zfp /* compressed stream */ + const zfp_stream* stream /* compressed stream */ ); /* get all compression parameters (pointers may be NULL) */ @@ -277,7 +277,7 @@ zfp_stream_set_rate( zfp_stream* stream, /* compressed stream */ double rate, /* desired rate in compressed bits/scalar */ zfp_type type, /* scalar type to compress */ - uint dims, /* array dimensionality (1, 2, or 3) */ + uint dims, /* array dimensionality (1, 2, 3, or 4) */ int wra /* nonzero if write random access is needed */ ); From a4df3d0bbd79fb7b19adac130ab07c20825c1bc9 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 28 Apr 2019 08:40:23 -0700 Subject: [PATCH 168/194] Add missing reversible mode to documentation, correct parameter names --- docs/source/high-level-api.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 3d32c495c..f972cf325 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -180,7 +180,8 @@ Types zfp_mode_expert = 1, // expert mode (4 params set manually) zfp_mode_fixed_rate = 2, // fixed rate mode zfp_mode_fixed_precision = 3, // fixed precision mode - zfp_mode_fixed_accuracy = 4 // fixed accuracy mode + zfp_mode_fixed_accuracy = 4, // fixed accuracy mode + zfp_mode_reversible = 5 // reversible (lossless) mode } zfp_mode; .. c:type:: zfp_type @@ -308,12 +309,12 @@ Compressed Stream Return bit stream associated with compressed stream. -.. c:function:: zfp_mode zfp_stream_compression_mode(const zfp_stream* zfp) +.. c:function:: zfp_mode zfp_stream_compression_mode(const zfp_stream* stream) Return compression mode associated with compression parameters. Returns :code:`zfp_mode_null` when compression parameters are invalid. -.. c:function:: uint64 zfp_stream_mode(const zfp_stream* zfp) +.. c:function:: uint64 zfp_stream_mode(const zfp_stream* stream) Return compact encoding of compression parameters. If the return value is no larger than :c:macro:`ZFP_MODE_SHORT_MAX`, then the least significant From df36b06cbdab7237a10c5a3f23ebfc6b5d010bab Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 28 Apr 2019 08:50:01 -0700 Subject: [PATCH 169/194] Associate zfp_stream_rewind with high-level interface --- include/zfp.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/zfp.h b/include/zfp.h index be070303b..a7b067213 100644 --- a/include/zfp.h +++ b/include/zfp.h @@ -258,6 +258,12 @@ zfp_stream_maximum_size( /* high-level API: initialization of compressed stream parameters ---------- */ +/* rewind bit stream to beginning for compression or decompression */ +void +zfp_stream_rewind( + zfp_stream* stream /* compressed bit stream */ +); + /* associate bit stream with compressed stream */ void zfp_stream_set_bit_stream( @@ -587,12 +593,6 @@ zfp_stream_align( zfp_stream* stream /* compressed bit stream */ ); -/* rewind bit stream to beginning for compression or decompression */ -void -zfp_stream_rewind( - zfp_stream* stream /* compressed bit stream */ -); - /* low-level API: encoder -------------------------------------------------- */ /* From 59873e2035be6a1354bf2989934f214ebff6cb7a Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 30 Apr 2019 17:21:37 -0700 Subject: [PATCH 170/194] Change default compressed-array cache size --- VERSIONS.md | 7 ++++++- array/zfparray.h | 9 +++++++++ array/zfparray1.h | 2 +- array/zfparray2.h | 2 +- array/zfparray3.h | 2 +- docs/source/caching.inc | 6 ++++-- docs/source/defs.rst | 5 +++++ docs/source/faq.rst | 16 +++++++++++----- docs/source/tutorial.rst | 4 +++- docs/source/versions.rst | 7 ++++++- 10 files changed, 47 insertions(+), 13 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index e4d781aa3..e0a5c1023 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,6 +1,6 @@ # zfp Release Notes -## 0.5.5 (March 31, 2019) +## 0.5.5 (April ??, 2019) - Added support for reversible (lossless) compression of floating-point and integer data. @@ -11,9 +11,14 @@ - Added Fortran bindings to zfp's high-level C API. +- Change: + - The default compressed-array cache size is now a function of the total + number of array elements, irrespective of array shape. + - Bug fixes: - Incorrect handling of execution policy in zfp utility. - Incorrect handling of decompression via header in zfp utility. + - Incorrect cleanup of device memory in CUDA decompress. - Tests for failing mallocs. - CMake installation of CFP when built. - zfp\_write\_header and zfp\_field\_metadata now fail if array dimensions diff --git a/array/zfparray.h b/array/zfparray.h index 9842bcefa..2ddbde426 100644 --- a/array/zfparray.h +++ b/array/zfparray.h @@ -255,6 +255,15 @@ class array { blkbits = zfp->maxbits; } + // default number of cache lines for array with n blocks + static uint lines(size_t n) + { + // compute m = O(sqrt(n)) + size_t m; + for (m = 1; m * m < n; m *= 2); + return static_cast(m); + } + uint dims; // array dimensionality (1, 2, or 3) zfp_type type; // scalar type uint nx, ny, nz; // array dimensions diff --git a/array/zfparray1.h b/array/zfparray1.h index d102d2c5a..3080850c0 100644 --- a/array/zfparray1.h +++ b/array/zfparray1.h @@ -281,7 +281,7 @@ class array1 : public array { // number of cache lines corresponding to size (or suggested size if zero) static uint lines(size_t size, uint n) { - n = uint(((size ? size : 8 * sizeof(Scalar)) + sizeof(CacheLine) - 1) / sizeof(CacheLine)); + n = size ? (size + sizeof(CacheLine) - 1) / sizeof(CacheLine) : array::lines(size_t((n + 3) / 4)); return std::max(n, 1u); } diff --git a/array/zfparray2.h b/array/zfparray2.h index 62804ecc0..4ccfd0ced 100644 --- a/array/zfparray2.h +++ b/array/zfparray2.h @@ -308,7 +308,7 @@ class array2 : public array { // number of cache lines corresponding to size (or suggested size if zero) static uint lines(size_t size, uint nx, uint ny) { - uint n = uint(((size ? size : 8 * nx * sizeof(Scalar)) + sizeof(CacheLine) - 1) / sizeof(CacheLine)); + uint n = size ? uint((size + sizeof(CacheLine) - 1) / sizeof(CacheLine)) : array::lines(size_t((nx + 3) / 4) * size_t((ny + 3) / 4)); return std::max(n, 1u); } diff --git a/array/zfparray3.h b/array/zfparray3.h index 5fb11a8f3..e8ad92528 100644 --- a/array/zfparray3.h +++ b/array/zfparray3.h @@ -322,7 +322,7 @@ class array3 : public array { // number of cache lines corresponding to size (or suggested size if zero) static uint lines(size_t size, uint nx, uint ny, uint nz) { - uint n = uint(((size ? size : 8 * nx * ny * sizeof(Scalar)) + sizeof(CacheLine) - 1) / sizeof(CacheLine)); + uint n = size ? (size + sizeof(CacheLine) - 1) / sizeof(CacheLine) : array::lines(size_t((nx + 3) / 4) * size_t((ny + 3) / 4) * size_t((nz + 3) / 4)); return std::max(n, 1u); } diff --git a/docs/source/caching.inc b/docs/source/caching.inc index 12aff3dd3..c70021590 100644 --- a/docs/source/caching.inc +++ b/docs/source/caching.inc @@ -1,3 +1,4 @@ +.. include:: defs.rst .. _caching: Caching @@ -17,8 +18,9 @@ at least two "layers" of blocks, e.g. 2 |times| (*nx* / 4) |times| (*ny* / 4) blocks for 3D arrays, for applications that stream through the array and perform stencil computations such as gathering data from neighboring elements. This allows limiting the cache misses to compulsory ones. If the *csize* -parameter provided to the constructor is set to zero bytes, then this default -of two layers is used. +parameter provided to the constructor is set to zero bytes, then a default +cache size of |sqrt|\ *n* blocks is used, where *n* is the total number of +blocks contained in the array. The cache size can be set during construction, or can be set at a later time via :cpp:func:`array::set_cache_size`. Note that if *csize* = 0, then diff --git a/docs/source/defs.rst b/docs/source/defs.rst index 1b51bc8be..c89d458ec 100644 --- a/docs/source/defs.rst +++ b/docs/source/defs.rst @@ -2,8 +2,10 @@ .. |minus| unicode:: 0x2212 .. |leq| unicode:: 0x2264 .. |geq| unicode:: 0x2265 +.. |sqrt| unicode:: 0x221a .. |zfp| replace:: zfp .. |cfp| replace:: cfp +.. |zforp| replace:: zFORp .. |zfpy| replace:: zfPy .. |libzfp| replace:: :file:`libzfp` .. |libcfp| replace:: :file:`libcfp` @@ -21,3 +23,6 @@ .. |cudarelease| replace:: 0.5.4 .. |cfprelease| replace:: 0.5.4 .. |revrelease| replace:: 0.5.5 +.. |zforprelease| replace:: 0.5.5 +.. |zfpyrelease| replace:: 0.5.5 +.. |csizerelease| replace:: 0.5.5 diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 8c9165cdd..8fef7417c 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -892,11 +892,17 @@ to offset the overhead of setting up parallel compression. Q26: *Why are 1D compressed arrays so slow?* -A: This is likely due to the use of a very small cache. All arrays use -two 'layers' of blocks as default cache size, which is reasonable for -2D and higher-dimensional arrays. In 1D, this implies that the cache -holds only two blocks, which is likely to cause excessive thrashing. -Experiment with larger cache sizes of at least a few KB. +A: This is likely due to the use of a very small cache. Prior to |zfp| +|csizerelease|, all arrays used two 'layers' of blocks as default cache +size, which is reasonable for 2D and higher-dimensional arrays (as long +as they are not too 'skinny'). In 1D, however, this implies that the +cache holds only two blocks, which is likely to cause excessive thrashing. + +As of version |csizerelease|, the default cache size is roughly proportional +to the square root of the total number of array elements, regardless of +array dimensionality. While this tends to reduce thrashing, we suggest +experimenting with larger cache sizes of at least a few KB to ensure +acceptable performance. ------------------------------------------------------------------------------- diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index 012fddab5..04056e404 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -580,7 +580,9 @@ at least two layers of blocks (2 |times| (*nx* / 4) |times| (*ny* / 4) blocks) for applications that stream through the array and perform stencil computations such as gathering data from neighboring elements. This allows limiting the cache misses to compulsory ones. If the *cache_size* parameter -is set to zero bytes, then this default of two layers is used. +is set to zero bytes, then a default size of |sqrt|\ *n* blocks is used, +where *n* is the total number of blocks in the array. + The cache size can be set during construction, or can be set at a later time via diff --git a/docs/source/versions.rst b/docs/source/versions.rst index 60c547a2f..f9d7c8c0f 100644 --- a/docs/source/versions.rst +++ b/docs/source/versions.rst @@ -3,7 +3,7 @@ Release Notes ============= -zfp 0.5.5, March 31, 2019 +zfp 0.5.5, April ??, 2019 - Added support for reversible (lossless) compression of floating-point and integer data. @@ -14,6 +14,11 @@ zfp 0.5.5, March 31, 2019 - Added Fortran bindings to zfp's high-level C API. + - Change: + + - The default compressed-array cache size is now a function of the total + number of array elements, irrespective of array shape. + - Bug fixes: - Incorrect handling of execution policy in zfp utility. From 7620a0eb8ab388b4b9100f510d3f0f3a5d545ee8 Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 30 Apr 2019 17:34:30 -0700 Subject: [PATCH 171/194] Update copyright year for documentation --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6fba0cd4f..a75db83c7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -46,7 +46,7 @@ # General information about the project. project = u'zfp' -copyright = u'2014-2018, LLNL-CODE-663824' +copyright = u'2014-2019, LLNL-CODE-663824' author = u'Peter Lindstrom' # The version info for the project you're documenting, acts as replacement for From f1f4dd70d846a9a77c6346beb3def7e77fc9c15d Mon Sep 17 00:00:00 2001 From: lindstro Date: Tue, 30 Apr 2019 20:39:18 -0700 Subject: [PATCH 172/194] Initial pass over Fortran documentation --- docs/source/zforp.rst | 779 ++++++++++++++++++++++-------------------- 1 file changed, 404 insertions(+), 375 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 02dc5002f..f246f189d 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -1,632 +1,661 @@ +.. include:: defs.rst + .. index:: single: zforp .. _zforp: -Fortran bindings ----------------- +Fortran Bindings +================ .. cpp:namespace:: zfp -ZFP 0.5.5 adds zFORp: A Fortran API providing wrappers around the high-level C -API. Wrappers for compressed arrays will arrive in a future release. +|zfp| |zforprelease| adds |zforp|: a Fortran API providing wrappers around +the :ref:`high-level C API `. Wrappers for +:ref:`compressed arrays ` will arrive in a future release. +The |zforp| implementation is based on the standard :code:`iso_c_binding` +module available since Fortran 2003. Every high-level C API function can be called from a Fortran wrapper function. C structs are wrapped as Fortran derived types, each containing a single C pointer to the C struct in memory. The wrapper functions accept and return these Fortran types, so users should never need to touch the C pointers. +In addition to the high-level C API, two essential functions from the +:ref:`bit stream API ` for opening and closing bit streams are +available. -In addition to the high-level C API, some other functions are necessary to be -able to completely compress or decompress data. These include opening and -closing a bitstream, and rewinding a bitstream. See example code -tests/fortran/testFortran.f for how the Fortran API is used to compress and -decompress data. +See example code :file:`tests/fortran/testFortran.f` for how the +Fortran API is used to compress and decompress data. Types ----- .. f:type:: zFORp_bitstream - :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` + :f c_ptr object: A C pointer to the instance of :c:type:`bitstream` .. f:type:: zFORp_stream - :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_stream` .. f:type:: zFORp_field - :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` + :f c_ptr object: A C pointer to the instance of :c:type:`zfp_field` Constants --------- -Enums wrapping :c:type:`zfp_type` +Enumerations +^^^^^^^^^^^^ + +.. _zforp_type: +.. f:variable:: integer zFORp_type_none +.. f:variable:: integer zFORp_type_int32 +.. f:variable:: integer zFORp_type_int64 +.. f:variable:: integer zFORp_type_float +.. f:variable:: integer zFORp_type_double + + Enums wrapping :c:type:`zfp_type` + +.. _zforp_mode: +.. f:variable:: integer zFORp_mode_null +.. f:variable:: integer zFORp_mode_expert +.. f:variable:: integer zFORp_mode_fixed_rate +.. f:variable:: integer zFORp_mode_fixed_precision +.. f:variable:: integer zFORp_mode_fixed_accuracy +.. f:variable:: integer zFORp_mode_reversible + + Enums wrapping :c:type:`zfp_mode` - .. f:variable:: integer zFORp_type_none - .. f:variable:: integer zFORp_type_int32 - .. f:variable:: integer zFORp_type_int64 - .. f:variable:: integer zFORp_type_float - .. f:variable:: integer zFORp_type_double +.. _zforp_exec: +.. f:variable:: integer zFORp_exec_serial +.. f:variable:: integer zFORp_exec_omp +.. f:variable:: integer zFORp_exec_cuda -Enums wrapping :c:type:`zfp_mode` + Enums wrapping :c:type:`zfp_exec_policy` - .. f:variable:: integer zFORp_mode_null - .. f:variable:: integer zFORp_mode_expert - .. f:variable:: integer zFORp_mode_fixed_rate - .. f:variable:: integer zFORp_mode_fixed_precision - .. f:variable:: integer zFORp_mode_fixed_accuracy - .. f:variable:: integer zFORp_mode_reversible -Enums wrapping :c:type:`zfp_exec_policy` +Non-Enum Constants +^^^^^^^^^^^^^^^^^^ - .. f:variable:: integer zFORp_exec_serial - .. f:variable:: integer zFORp_exec_omp - .. f:variable:: integer zFORp_exec_cuda +.. f:variable:: integer zFORp_version_major -Non-enum constants + Wraps :c:macro:`ZFP_VERSION_MAJOR` - .. f:variable:: integer zFORp_version_major +.. f:variable:: integer zFORp_version_minor - Wraps :c:macro:`ZFP_VERSION_MAJOR` + Wraps :c:macro:`ZFP_VERSION_MINOR` - .. f:variable:: integer zFORp_version_minor +.. f:variable:: integer zFORp_version_patch - Wraps :c:macro:`ZFP_VERSION_MINOR` + Wraps :c:macro:`ZFP_VERSION_PATCH` - .. f:variable:: integer zFORp_version_patch +.. f:variable:: integer zFORp_codec_version - Wraps :c:macro:`ZFP_VERSION_PATCH` + Wraps :c:data:`zfp_codec_version` - .. f:variable:: integer zFORp_codec_version +.. f:variable:: integer zFORp_library_version - Wraps :c:data:`zfp_codec_version` + Wraps :c:data:`zfp_library_version` - .. f:variable:: integer zFORp_library_version +.. f:variable:: character(len=36) zFORp_version_string - Wraps :c:data:`zfp_library_version` + Wraps :c:data:`zfp_version_string` - .. f:variable:: character(len=36) zFORp_version_string +.. f:variable:: integer zFORp_min_bits - Wraps :c:data:`zfp_version_string` + Wraps :c:macro:`ZFP_MIN_BITS` - .. f:variable:: integer zFORp_min_bits +.. f:variable:: integer zFORp_max_bits - Wraps :c:macro:`ZFP_MIN_BITS` + Wraps :c:macro:`ZFP_MAX_BITS` - .. f:variable:: integer zFORp_max_bits +.. f:variable:: integer zFORp_max_prec - Wraps :c:macro:`ZFP_MAX_BITS` + Wraps :c:macro:`ZFP_MAX_PREC` - .. f:variable:: integer zFORp_max_prec +.. f:variable:: integer zFORp_min_exp - Wraps :c:macro:`ZFP_MAX_PREC` + Wraps :c:macro:`ZFP_MIN_EXP` - .. f:variable:: integer zFORp_min_exp +.. _zforp_header: +.. f:variable:: integer zFORp_header_magic - Wraps :c:macro:`ZFP_MIN_EXP` + Wraps :c:macro:`ZFP_HEADER_MAGIC` - .. f:variable:: integer zFORp_header_magic +.. f:variable:: integer zFORp_header_meta - Wraps :c:macro:`ZFP_HEADER_MAGIC` + Wraps :c:macro:`ZFP_HEADER_META` - .. f:variable:: integer zFORp_header_meta +.. f:variable:: integer zFORp_header_mode - Wraps :c:macro:`ZFP_HEADER_META` + Wraps :c:macro:`ZFP_HEADER_MODE` - .. f:variable:: integer zFORp_header_mode +.. f:variable:: integer zFORp_header_full - Wraps :c:macro:`ZFP_HEADER_MODE` + Wraps :c:macro:`ZFP_HEADER_FULL` - .. f:variable:: integer zFORp_header_full +.. f:variable:: integer zFORp_meta_null - Wraps :c:macro:`ZFP_HEADER_FULL` + Wraps :c:macro:`ZFP_META_NULL` - .. f:variable:: integer zFORp_meta_null +.. f:variable:: integer zFORp_magic_bits - Wraps :c:macro:`ZFP_META_NULL` + Wraps :c:macro:`ZFP_MAGIC_BITS` - .. f:variable:: integer zFORp_magic_bits +.. f:variable:: integer zFORp_meta_bits - Wraps :c:macro:`ZFP_MAGIC_BITS` + Wraps :c:macro:`ZFP_META_BITS` - .. f:variable:: integer zFORp_meta_bits +.. f:variable:: integer zFORp_mode_short_bits - Wraps :c:macro:`ZFP_META_BITS` + Wraps :c:macro:`ZFP_MODE_SHORT_BITS` - .. f:variable:: integer zFORp_mode_short_bits +.. f:variable:: integer zFORp_mode_long_bits - Wraps :c:macro:`ZFP_MODE_SHORT_BITS` + Wraps :c:macro:`ZFP_MODE_LONG_BITS` - .. f:variable:: integer zFORp_mode_long_bits +.. f:variable:: integer zFORp_header_max_bits - Wraps :c:macro:`ZFP_MODE_LONG_BITS` + Wraps :c:macro:`ZFP_HEADER_MAX_BITS` - .. f:variable:: integer zFORp_header_max_bits +.. f:variable:: integer zFORp_mode_short_max - Wraps :c:macro:`ZFP_HEADER_MAX_BITS` + Wraps :c:macro:`ZFP_MODE_SHORT_MAX` - .. f:variable:: integer zFORp_mode_short_max - Wraps :c:macro:`ZFP_MODE_SHORT_MAX` +Functions and Subroutines +------------------------- -Bitstream function wrappers ---------------------------- +Each of the functions included here wraps a corresponding C function. Please +consult the C documentation for detailed descriptions of the functions, their +parameters, and their return values. + +Bit Stream +^^^^^^^^^^ .. f:function:: zFORp_bitstream_stream_open(buffer, bytes) - Wrapper for :c:func:`stream_open` + Wrapper for :c:func:`stream_open` - :p type(c_ptr) buffer [in]: Bitstream buffer - :p integer (kind=8) bytes [in]: Buffer size, in bytes - :r bs: Bitstream - :rtype bs: zFORp_bitstream + :p c_ptr buffer [in]: Memory buffer + :p bytes [in]: Buffer size in bytes + :ptype bytes: integer (kind=8) + :r bs: Bit stream + :rtype bs: zFORp_bitstream .. f:subroutine:: zFORp_bitstream_stream_close(bs) - Wrapper for :c:func:`stream_close` + Wrapper for :c:func:`stream_close` + + :p zFORp_bitstream bs [inout]: Bit stream - :p zFORp_bitstream bs [inout]: Bitstream -High-level API utility function wrappers ----------------------------------------- +Utility Functions +^^^^^^^^^^^^^^^^^ .. f:function:: zFORp_type_size(scalar_type) - Wrapper for :c:func:`zfp_type_size` + Wrapper for :c:func:`zfp_type_size` + + :p integer scalar_type [in]: :ref:`zFORp_type ` enum + :r type_size: Size of described :c:type:`zfp_type`, in bytes, from C-language perspective + :rtype type_size: integer + - :p integer scalar_type [in]: zFORp_type enum. - :r type_size: Size of described zfp_type, in bytes, from C-language perspective. - :rtype type_size: integer +Compressed Stream +^^^^^^^^^^^^^^^^^ .. f:function:: zFORp_stream_open(bs) - Wrapper for :c:func:`zfp_stream_open` + Wrapper for :c:func:`zfp_stream_open` - :p zFORp_bitstream bs [in]: Bitstream - :r stream: Newly allocated zfp_stream - :rtype stream: zFORp_stream + :p zFORp_bitstream bs [in]: Bit stream + :r stream: Newly allocated compressed stream + :rtype stream: zFORp_stream .. f:subroutine:: zFORp_stream_close(stream) - Wrapper for :c:func:`zfp_stream_close` + Wrapper for :c:func:`zfp_stream_close` - :p zFORp_stream stream [inout]: Zfp_stream + :p zFORp_stream stream [inout]: Compressed stream .. f:function:: zFORp_stream_bit_stream(stream) - Wrapper for :c:func:`zfp_stream_bit_stream` + Wrapper for :c:func:`zfp_stream_bit_stream` - :p zFORp_stream stream [in]: Zfp_stream - :r bs: Bitstream - :rtype bs: zFORp_bitstream - -.. f:function:: zFORp_stream_is_reversible(stream) - - Wrapper for :c:func:`zfp_stream_is_reversible` - - :p zFORp_stream stream [in]: Zfp_stream - :r is_reversible: indicate whether reversible mode active (1) or not (0) - :rtype is_reversible: integer + :p zFORp_stream stream [in]: Compressed stream + :r bs: Bit stream + :rtype bs: zFORp_bitstream .. f:function:: zFORp_stream_compression_mode(stream) - Wrapper for :c:func:`zfp_stream_compression_mode` + Wrapper for :c:func:`zfp_stream_compression_mode` - :p zFORp_stream stream [in]: Zfp_stream - :r zfp_mode: zFORp_mode enum - :rtype zfp_mode: integer + :p zFORp_stream stream [in]: Compressed stream + :r mode: :ref:`zFORp_mode ` enum + :rtype mode: integer .. f:function:: zFORp_stream_mode(stream) - Wrapper for :c:func:`zfp_stream_mode` + Wrapper for :c:func:`zfp_stream_mode` - :p zFORp_stream stream [in]: Zfp_stream - :r encoded_mode: 64 bit encoded mode - :rtype encoded_mode: integer (kind=8) + :p zFORp_stream stream [in]: Compressed stream + :r mode: 64-bit encoded mode + :rtype mode: integer (kind=8) .. f:subroutine:: zFORp_stream_params(stream, minbits, maxbits, maxprec, minexp) - Wrapper for :c:func:`zfp_stream_params` + Wrapper for :c:func:`zfp_stream_params` - :p zFORp_stream stream [in]: Zfp_stream - :p integer minbits [inout]: minbits - :p integer maxbits [inout]: maxbits - :p integer maxprec [inout]: maxprec - :p integer minexp [inout]: minexp + :p zFORp_stream stream [in]: Compressed stream + :p integer minbits [inout]: Minimum number of bits per block + :p integer maxbits [inout]: Maximum number of bits per block + :p integer maxprec [inout]: Maximum precision + :p integer minexp [inout]: Minimum bit plane number encoded .. f:function:: zFORp_stream_compressed_size(stream) - Wrapper for :c:func:`zfp_stream_compressed_size` + Wrapper for :c:func:`zfp_stream_compressed_size` - :p zFORp_stream stream [in]: Zfp_stream - :r compressed_size: compressed size - :rtype compressed_size: integer (kind=8) + :p zFORp_stream stream [in]: Compressed stream + :r compressed_size: Compressed size in bytes + :rtype compressed_size: integer (kind=8) .. f:function:: zFORp_stream_maximum_size(stream, field) - Wrapper for :c:func:`zfp_stream_maximum_size` + Wrapper for :c:func:`zfp_stream_maximum_size` - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_field field [in]: Zfp_field - :r max_size: maximum size - :rtype max_size: integer (kind=8) + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_field field [in]: Field metadata + :r max_size: Maximum possible compressed size in bytes + :rtype max_size: integer (kind=8) .. f:subroutine:: zFORp_stream_set_bit_stream(stream, bs) - Wrapper for :c:func:`zfp_stream_set_bit_stream` + Wrapper for :c:func:`zfp_stream_set_bit_stream` + + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_bitstream bs [in]: Bit stream + +.. f:subroutine:: zFORp_stream_rewind(stream) - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_bitstream bs [in]: bitstream + Wrapper for :c:func:`zfp_stream_rewind` + + :p zFORp_stream stream [in]: Compressed stream + + +Compression Parameters +^^^^^^^^^^^^^^^^^^^^^^ .. f:subroutine:: zFORp_stream_set_reversible(stream) - Wrapper for :c:func:`zfp_stream_set_reversible` + Wrapper for :c:func:`zfp_stream_set_reversible` - :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Compressed stream .. f:function:: zFORp_stream_set_rate(stream, rate, scalar_type, dims, wra) - Wrapper for :c:func:`zfp_stream_set_rate` + Wrapper for :c:func:`zfp_stream_set_rate` - :p zFORp_stream stream [in]: Zfp_stream - :p real rate [in]: desired rate - :p integer scalar_type [in]: enum zfp_type - :p integer dims [in]: dimensions - :p integer wra [in]: use write random access? - :r rate_result: actual set rate - :rtype rate_result: real + :p zFORp_stream stream [in]: Compressed stream + :p real rate [in]: Desired rate + :p integer scalar_type [in]: :ref:`zFORp_type ` enum + :p integer dims [in]: Number of dimensions + :p integer wra [in]: Use write random access? + :r rate_result: Actual set rate in bits/scalar + :rtype rate_result: real .. f:function:: zFORp_stream_set_precision(stream, prec) - Wrapper for :c:func:`zfp_stream_set_precision` + Wrapper for :c:func:`zfp_stream_set_precision` - :p zFORp_stream stream [in]: Zfp_stream - :p integer prec [in]: desired precision - :r prec_result: actual set precision - :rtype prec_result: integer + :p zFORp_stream stream [in]: Compressed stream + :p integer prec [in]: Desired precision + :r prec_result: Actual set precision + :rtype prec_result: integer -.. f:function:: zFORp_stream_set_accuracy(stream, acc) +.. f:function:: zFORp_stream_set_accuracy(stream, tolerance) - Wrapper for :c:func:`zfp_stream_set_accuracy()` + Wrapper for :c:func:`zfp_stream_set_accuracy()` - :p zFORp_stream stream [in]: Zfp_stream - :p real acc: desired accuracy (kind=8) - :r acc_result: actual set accuracy - :rtype acc_result: real (kind=8) + :p zFORp_stream stream [in]: Compressed stream + :p tolerance [in]: Desired error tolerance + :ptype tolerance: real (kind=8) + :r tol_result: Actual set tolerance + :rtype tol_result: real (kind=8) -.. f:function:: zFORp_stream_set_mode(stream, encoded_mode) +.. f:function:: zFORp_stream_set_mode(stream, mode) - Wrapper for :c:func:`zfp_stream_set_mode` + Wrapper for :c:func:`zfp_stream_set_mode` - :p zFORp_stream stream [in]: Zfp_stream - :p integer encoded_mode [in]: encoded mode parameter - :r mode_result: newly set zfp_mode enum on zfp_stream - :rtype mode_result: integer + :p zFORp_stream stream [in]: Compressed stream + :p mode [in]: Compact encoding of compression parameters + :ptype mode: integer (kind=8) + :r mode_result: Newly set :ref:`zFORp_mode ` enum + :rtype mode_result: integer .. f:function:: zFORp_stream_set_params(stream, minbits, maxbits, maxprec, minexp) - Wrapper for :c:func:`zfp_stream_set_params` - - :p zFORp_stream stream [in]: Zfp_stream - :p integer minbits [in]: min num of bits - :p integer maxbits [in]: max num of bits - :p integer maxprec [in]: max precision - :p integer minexp [in]: min exponent - :r is_success: indicate whether parameters were successfully set (1) or not (0) - :rtype is_success: integer + Wrapper for :c:func:`zfp_stream_set_params` -High-level API: execution policy function wrappers --------------------------------------------------- + :p zFORp_stream stream [in]: Compressed stream + :p integer minbits [in]: Minimum number of bits per block + :p integer maxbits [in]: Maximum number of bits per block + :p integer maxprec [in]: Maximum precision + :p integer minexp [in]: Minimum bit plane number encoded + :r is_success: Indicate whether parameters were successfully set (1) or not (0) + :rtype is_success: integer - .. f:function:: zFORp_stream_execution(stream) - Wrapper for :c:func:`zfp_stream_execution` +Execution Policy +^^^^^^^^^^^^^^^^ - :p zFORp_stream stream [in]: Zfp_stream - :r execution_policy: enum of active execution policy - :rtype execution_policy: integer +.. f:function:: zFORp_stream_execution(stream) - .. f:function:: zFORp_stream_omp_threads(stream) + Wrapper for :c:func:`zfp_stream_execution` - Wrapper for :c:func:`zfp_stream_omp_threads` + :p zFORp_stream stream [in]: Compressed stream + :r execution_policy: :ref:`zFORp_exec ` enum indicating active execution policy + :rtype execution_policy: integer - :p zFORp_stream stream [in]: Zfp_stream - :r thread_count: number of threads to use upon execution - :rtype thread_count: integer +.. f:function:: zFORp_stream_omp_threads(stream) - .. f:function:: zFORp_stream_omp_chunk_size(stream) + Wrapper for :c:func:`zfp_stream_omp_threads` - Wrapper for :c:func:`zfp_stream_omp_chunk_size` + :p zFORp_stream stream [in]: Compressed stream + :r thread_count: Number of OpenMP threads to use upon execution + :rtype thread_count: integer - :p zFORp_stream stream [in]: Zfp_stream - :r chunk_size_blocks: specified chunk size, in blocks - :rtype chunk_size_blocks: integer (kind=8) +.. f:function:: zFORp_stream_omp_chunk_size(stream) - .. f:function:: zFORp_stream_set_execution(stream, execution_policy) + Wrapper for :c:func:`zfp_stream_omp_chunk_size` - Wrapper for :c:func:`zfp_stream_set_execution` + :p zFORp_stream stream [in]: Compressed stream + :r chunk_size_blocks: Specified chunk size, in blocks + :rtype chunk_size_blocks: integer (kind=8) - :p zFORp_stream stream [in]: Zfp_stream - :p integer execution_policy [in]: desired execution policy (enum) - :r is_success: indicate whether execution policy was successfully set or not - :rtype is_success: integer +.. f:function:: zFORp_stream_set_execution(stream, execution_policy) - .. f:function:: zFORp_stream_set_omp_threads(stream, thread_count) + Wrapper for :c:func:`zfp_stream_set_execution` - Wrapper for :c:func:`zfp_stream_set_omp_threads` + :p zFORp_stream stream [in]: Compressed stream + :p integer execution_policy [in]: :ref:`zFORp_exec ` enum indicating desired execution policy + :r is_success: Indicate whether execution policy was successfully set (1) or not (0) + :rtype is_success: integer - :p zFORp_stream stream [in]: Zfp_stream - :p integer thread_count [in]: desired number of threads - :r is_success: indicate whether number of threads successfully set or not - :rtype is_success: integer +.. f:function:: zFORp_stream_set_omp_threads(stream, thread_count) - .. f:function:: zFORp_stream_set_omp_chunk_size(stream, chunk_size) + Wrapper for :c:func:`zfp_stream_set_omp_threads` - Wrapper for :c:func:`zfp_stream_set_omp_chunk_size` + :p zFORp_stream stream [in]: Compressed stream + :p integer thread_count [in]: Desired number of OpenMP threads + :r is_success: Indicate whether number of threads was successfully set (1) or not (0) + :rtype is_success: integer - :p zFORp_stream stream [in]: Zfp_stream - :p integer chunk_size [in]: desired chunk size, in blocks - :r is_success: indicate whether chunk size successfully set or not - :rtype is_success: integer +.. f:function:: zFORp_stream_set_omp_chunk_size(stream, chunk_size) -High-level API: zfp_field function wrappers -------------------------------------------- + Wrapper for :c:func:`zfp_stream_set_omp_chunk_size` - .. f:function:: zFORp_field_alloc() + :p zFORp_stream stream [in]: Compressed stream + :p integer chunk_size [in]: Desired chunk size, in blocks + :r is_success: Indicate whether chunk size was successfully set (1) or not (0) + :rtype is_success: integer - Wrapper for :c:func:`zfp_field_alloc` - :r field: newly allocated zfp_field - :rtype field: zFORp_field +Array Metadata +^^^^^^^^^^^^^^ - .. f:function:: zFORp_field_1d(uncompressed_ptr, scalar_type, nx) +.. f:function:: zFORp_field_alloc() - Wrapper for :c:func:`zfp_field_1d` + Wrapper for :c:func:`zfp_field_alloc` - :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer scalar_type [in]: zfp_type enum describing uncompressed data type - :p integer nx [in]: number of elements in uncompressed data array - :r field: newly allocated zfp_field - :rtype field: zFORp_field + :r field: Newly allocated field + :rtype field: zFORp_field - .. f:function:: zFORp_field_2d(uncompressed_ptr, scalar_type, nx, ny) +.. f:function:: zFORp_field_1d(uncompressed_ptr, scalar_type, nx) - Wrapper for :c:func:`zfp_field_2d` + Wrapper for :c:func:`zfp_field_1d` - :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer scalar_type [in]: zfp_type enum describing uncompressed data type - :p integer nx [in]: number of elements in uncompressed data array's x dimension - :p integer ny [in]: number of elements in uncompressed data array's y dimension - :r field: newly allocated zfp_field - :rtype field: zFORp_field + :p c_ptr uncompressed_ptr [in]: Pointer to uncompressed data + :p integer scalar_type [in]: :ref:`zFORp_type ` enum describing uncompressed scalar type + :p integer nx [in]: Number of array elements + :r field: Newly allocated field + :rtype field: zFORp_field - .. f:function:: zFORp_field_3d(uncompressed_ptr, scalar_type, nx, ny, nz) +.. f:function:: zFORp_field_2d(uncompressed_ptr, scalar_type, nx, ny) - Wrapper for :c:func:`zfp_field_3d` + Wrapper for :c:func:`zfp_field_2d` - :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer scalar_type [in]: zfp_type enum describing uncompressed data type - :p integer nx [in]: number of elements in uncompressed data array's x dimension - :p integer ny [in]: number of elements in uncompressed data array's y dimension - :p integer nz [in]: number of elements in uncompressed data array's z dimension - :r field: newly allocated zfp_field - :rtype field: zFORp_field + :p c_ptr uncompressed_ptr [in]: Pointer to uncompressed data + :p integer scalar_type [in]: :ref:`zFORp_type ` enum describing uncompressed scalar type + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension + :r field: Newly allocated field + :rtype field: zFORp_field - .. f:function:: zFORp_field_4d(uncompressed_ptr, scalar_type, nx, ny, nz, nw) +.. f:function:: zFORp_field_3d(uncompressed_ptr, scalar_type, nx, ny, nz) - Wrapper for :c:func:`zfp_field_4d` + Wrapper for :c:func:`zfp_field_3d` - :p type(c_ptr) uncompressed_ptr [in]: pointer to uncompressed data - :p integer scalar_type [in]: zfp_type enum describing uncompressed data type - :p integer nx [in]: number of elements in uncompressed data array's x dimension - :p integer ny [in]: number of elements in uncompressed data array's y dimension - :p integer nz [in]: number of elements in uncompressed data array's z dimension - :p integer nw [in]: number of elements in uncompressed data array's w dimension - :r field: newly allocated zfp_field - :rtype field: zFORp_field + :p c_ptr uncompressed_ptr [in]: Pointer to uncompressed data + :p integer scalar_type [in]: :ref:`zFORp_type ` enum describing uncompressed scalar type + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension + :p integer nz [in]: Number of array elements in *z* dimension + :r field: Newly allocated field + :rtype field: zFORp_field - .. f:subroutine:: zFORp_field_free(field) +.. f:function:: zFORp_field_4d(uncompressed_ptr, scalar_type, nx, ny, nz, nw) - Wrapper for :c:func:`zfp_field_free` + Wrapper for :c:func:`zfp_field_4d` - :p zFORp_field field [inout]: Zfp_field + :p c_ptr uncompressed_ptr [in]: Pointer to uncompressed data + :p integer scalar_type [in]: :ref:`zFORp_type ` enum describing uncompressed scalar type + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension + :p integer nz [in]: Number of array elements in *z* dimension + :p integer nw [in]: Number of array elements in *w* dimension + :r field: Newly allocated field + :rtype field: zFORp_field - .. f:function:: zFORp_field_pointer(field) +.. f:subroutine:: zFORp_field_free(field) - Wrapper for :c:func:`zfp_field_pointer` + Wrapper for :c:func:`zfp_field_free` - :p zFORp_field field [in]: Zfp_field - :r arr_ptr: pointer to raw (uncompressed/decompressed) array - :rtype arr_ptr: type(c_ptr) + :p zFORp_field field [inout]: Field metadata - .. f:function:: zFORp_field_type(field) +.. f:function:: zFORp_field_pointer(field) - Wrapper for :c:func:`zfp_field_type` + Wrapper for :c:func:`zfp_field_pointer` - :p zFORp_field field [in]: Zfp_field - :r scalar_type: zfp_type enum describing field data - :rtype scalar_type: integer + :p zFORp_field field [in]: Field metadata + :r arr_ptr: Pointer to raw (uncompressed/decompressed) array + :rtype arr_ptr: c_ptr - .. f:function:: zFORp_field_precision(field) +.. f:function:: zFORp_field_scalar_type(field) - Wrapper for :c:func:`zfp_field_precision` + Wrapper for :c:func:`zfp_field_type` - :p zFORp_field field [in]: Zfp_field - :r prec: type precision describing field data - :rtype prec: integer + :p zFORp_field field [in]: Field metadata + :r scalar_type: :ref:`zFORp_type ` enum describing uncompressed scalar type + :rtype scalar_type: integer - .. f:function:: zFORp_field_dimensionality(field) +.. f:function:: zFORp_field_precision(field) - Wrapper for :c:func:`zfp_field_dimensionality` + Wrapper for :c:func:`zfp_field_precision` - :p zFORp_field field [in]: Zfp_field - :r dims: dimensionality of field data - :rtype dims: integer + :p zFORp_field field [in]: Field metadata + :r prec: Scalar type precision in number of bits + :rtype prec: integer - .. f:function:: zFORp_field_size(field, size_arr) +.. f:function:: zFORp_field_dimensionality(field) - Wrapper for :c:func:`zfp_field_size` + Wrapper for :c:func:`zfp_field_dimensionality` - :p zFORp_field field [in]: Zfp_field - :p integer size_arr [inout]: integer array to write field dimensions into - :r total_size: total number of elements in field - :rtype total_size: integer (kind=8) + :p zFORp_field field [in]: Field metadata + :r dims: Dimensionality of array + :rtype dims: integer - .. f:function:: zFORp_field_stride(field, stride_arr) +.. f:function:: zFORp_field_size(field, size_arr) - Wrapper for :c:func:`zfp_field_stride` + Wrapper for :c:func:`zfp_field_size` - :p zFORp_field field [in]: Zfp_field - :p integer stride_arr [inout]: integer array to write strides into - :r is_strided: indicate whether field is strided or not - :rtype is_strided: integer + :p zFORp_field field [in]: Field metadata + :p size_arr [inout]: Integer array to write field dimensions into + :ptype size_arr: integer,dimension(4),target + :r total_size: Total number of array elements + :rtype total_size: integer (kind=8) - .. f:function:: zFORp_field_metadata(field) +.. f:function:: zFORp_field_stride(field, stride_arr) - Wrapper for :c:func:`zfp_field_metadata` + Wrapper for :c:func:`zfp_field_stride` - :p zFORp_field field [in]: Zfp_field - :r encoded_metadata: encoded metadata of field - :rtype encoded_metadata: integer (kind=8) + :p zFORp_field field [in]: Field metadata + :p stride_arr [inout]: Integer array to write strides into + :ptype stride_arr: integer,dimension(4),target + :r is_strided: Indicate whether field is strided (1) or not (0) + :rtype is_strided: integer - .. f:subroutine:: zFORp_field_set_pointer(field, arr_ptr) +.. f:function:: zFORp_field_metadata(field) - Wrapper for :c:func:`zfp_field_set_pointer` + Wrapper for :c:func:`zfp_field_metadata` - :p zFORp_field field [in]: Zfp_field - :p type(c_ptr) arr_ptr [in]: pointer to raw array + :p zFORp_field field [in]: Field metadata + :r encoded_metadata: Compact encoding of metadata + :rtype encoded_metadata: integer (kind=8) - .. f:function:: zFORp_field_set_type(field, scalar_type) +.. f:subroutine:: zFORp_field_set_pointer(field, arr_ptr) - Wrapper for :c:func:`zfp_field_set_type` + Wrapper for :c:func:`zfp_field_set_pointer` - :p zFORp_field field [in]: Zfp_field - :p integer scalar_type: desired zfp_type enum - :r scalar_type_result: new zfp_type on the field - :rtype scalar_type_result: integer + :p zFORp_field field [in]: Field metadata + :p c_ptr arr_ptr [in]: Pointer to beginning of uncompressed array - .. f:subroutine:: zFORp_field_set_size_1d(field, nx) +.. f:function:: zFORp_field_set_type(field, scalar_type) - Wrapper for :c:func:`zfp_field_set_size_1d` + Wrapper for :c:func:`zfp_field_set_type` - :p zFORp_field field [in]: Zfp_field - :p integer nx [in]: number of elements in data array + :p zFORp_field field [in]: Field metadata + :p integer scalar_type: :ref:`zFORp_type ` enum indicating desired scalar type + :r type_result: :ref:`zFORp_type ` enum indicating actual scalar type + :rtype type_result: integer - .. f:subroutine:: zFORp_field_set_size_2d(field, nx, ny) +.. f:subroutine:: zFORp_field_set_size_1d(field, nx) - Wrapper for :c:func:`zfp_field_set_size_2d` + Wrapper for :c:func:`zfp_field_set_size_1d` - :p zFORp_field field [in]: Zfp_field - :p integer nx [in]: number of elements in data array's x dimension - :p integer ny [in]: number of elements in data array's y dimension + :p zFORp_field field [in]: Field metadata + :p integer nx [in]: Number of array elements - .. f:subroutine:: zFORp_field_set_size_3d(field, nx, ny, nz) +.. f:subroutine:: zFORp_field_set_size_2d(field, nx, ny) - Wrapper for :c:func:`zfp_field_set_size_3d` + Wrapper for :c:func:`zfp_field_set_size_2d` - :p zFORp_field field [in]: Zfp_field - :p integer nx [in]: number of elements in data array's x dimension - :p integer ny [in]: number of elements in data array's y dimension - :p integer nz [in]: number of elements in data array's z dimension + :p zFORp_field field [in]: Field metadata + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension - .. f:subroutine:: zFORp_field_set_size_4d(field, nx, ny, nz, nw) +.. f:subroutine:: zFORp_field_set_size_3d(field, nx, ny, nz) - Wrapper for :c:func:`zfp_field_set_size_4d` + Wrapper for :c:func:`zfp_field_set_size_3d` - :p zFORp_field field [in]: Zfp_field - :p integer nx [in]: number of elements in data array's x dimension - :p integer ny [in]: number of elements in data array's y dimension - :p integer nz [in]: number of elements in data array's z dimension - :p integer nw [in]: number of elements in data array's w dimension + :p zFORp_field field [in]: Field metadata + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension + :p integer nz [in]: Number of array elements in *z* dimension - .. f:subroutine:: zFORp_field_set_stride_1d(field, sx) +.. f:subroutine:: zFORp_field_set_size_4d(field, nx, ny, nz, nw) - Wrapper for :c:func:`zfp_field_set_stride_1d` + Wrapper for :c:func:`zfp_field_set_size_4d` - :p zFORp_field field [in]: Zfp_field - :p integer sx [in]: stride of data array's x dimension + :p zFORp_field field [in]: Field metadata + :p integer nx [in]: Number of array elements in *x* dimension + :p integer ny [in]: Number of array elements in *y* dimension + :p integer nz [in]: Number of array elements in *z* dimension + :p integer nw [in]: Number of array elements in *w* dimension - .. f:subroutine:: zFORp_field_set_stride_2d(field, sx, sy) +.. f:subroutine:: zFORp_field_set_stride_1d(field, sx) - Wrapper for :c:func:`zfp_field_set_stride_2d` + Wrapper for :c:func:`zfp_field_set_stride_1d` - :p zFORp_field field [in]: Zfp_field - :p integer sx [in]: stride of data array's x dimension - :p integer sy [in]: stride of data array's y dimension + :p zFORp_field field [in]: Field metadata + :p integer sx [in]: Stride in number of scalars - .. f:subroutine:: zFORp_field_set_stride_3d(field, sx, sy, sz) +.. f:subroutine:: zFORp_field_set_stride_2d(field, sx, sy) - Wrapper for :c:func:`zfp_field_set_stride_3d` + Wrapper for :c:func:`zfp_field_set_stride_2d` - :p zFORp_field field [in]: Zfp_field - :p integer sx [in]: stride of data array's x dimension - :p integer sy [in]: stride of data array's y dimension - :p integer sz [in]: stride of data array's z dimension + :p zFORp_field field [in]: Field metadata + :p integer sx [in]: Stride in *x* dimension + :p integer sy [in]: Stride in *y* dimension - .. f:subroutine:: zFORp_field_set_stride_4d(field, sx, sy, sz, sw) +.. f:subroutine:: zFORp_field_set_stride_3d(field, sx, sy, sz) - Wrapper for :c:func:`zfp_field_set_stride_4d` + Wrapper for :c:func:`zfp_field_set_stride_3d` - :p zFORp_field field [in]: Zfp_field - :p integer sx [in]: stride of data array's x dimension - :p integer sy [in]: stride of data array's y dimension - :p integer sz [in]: stride of data array's z dimension - :p integer sw [in]: stride of data array's w dimension + :p zFORp_field field [in]: Field metadata + :p integer sx [in]: Stride in *x* dimension + :p integer sy [in]: Stride in *y* dimension + :p integer sz [in]: Stride in *z* dimension - .. f:function:: zFORp_field_set_metadata(field, encoded_metadata) +.. f:subroutine:: zFORp_field_set_stride_4d(field, sx, sy, sz, sw) - Wrapper for :c:func:`zfp_field_set_metadata` + Wrapper for :c:func:`zfp_field_set_stride_4d` - :p zFORp_field field [in]: Zfp_field - :p integer encoded_metadata [in]: encoded metadata (kind=8) - :r is_success: indicate whether metadata successfully set on field or not - :rtype is_success: integer + :p zFORp_field field [in]: Field metadata + :p integer sx [in]: Stride in *x* dimension + :p integer sy [in]: Stride in *y* dimension + :p integer sz [in]: Stride in *z* dimension + :p integer sw [in]: Stride in *w* dimension -High-level API: compression, decompression, header wrappers ------------------------------------------------------------ +.. f:function:: zFORp_field_set_metadata(field, encoded_metadata) - .. f:function:: zFORp_compress(stream, field) + Wrapper for :c:func:`zfp_field_set_metadata` - Wrapper for :c:func:`zfp_compress` + :p zFORp_field field [in]: Field metadata + :p encoded_metadata [in]: Compact encoding of metadata + :ptype encoded_metadata: integer (kind=8) + :r is_success: Indicate whether metadata was successfully set (1) or not (0) + :rtype is_success: integer - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_field field [in]: Zfp_field - :r bitstream_offset_bytes: bitstream offset after compression, in bytes - :rtype bitstream_offset_bytes: integer (kind=8) - .. f:function:: zFORp_decompress(stream, field) +Compression and Decompression +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Wrapper for :c:func:`zfp_decompress` +.. f:function:: zFORp_compress(stream, field) - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_field field [in]: Zfp_field - :r bitstream_offset_bytes: bitstream offset after decompression, in bytes - :rtype bitstream_offset_bytes: integer (kind=8) + Wrapper for :c:func:`zfp_compress` - .. f:function:: zFORp_write_header(stream, field, mask) + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_field field [in]: Field metadata + :r bitstream_offset_bytes: Bit stream offset after compression, in bytes, or zero on failure + :rtype bitstream_offset_bytes: integer (kind=8) - Wrapper for :c:func:`zfp_write_header` +.. f:function:: zFORp_decompress(stream, field) - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_field field [in]: Zfp_field - :p integer mask [in]: indicates header level of detail - :r num_bits_written: number of bits successfully written in header - :rtype num_bits_written: integer (kind=8) + Wrapper for :c:func:`zfp_decompress` - .. f:function:: zFORp_read_header(stream, field, mask) + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_field field [in]: Field metadata + :r bitstream_offset_bytes: Bit stream offset after decompression, in bytes, or zero on failure + :rtype bitstream_offset_bytes: integer (kind=8) - Wrapper for :c:func:`zfp_read_header` +.. f:function:: zFORp_write_header(stream, field, mask) - :p zFORp_stream stream [in]: Zfp_stream - :p zFORp_field field [in]: Zfp_field - :p integer mask [in]: indicates header level of detail - :r num_bits_read: number of bits successfully read in header - :rtype num_bits_read: integer (kind=8) + Wrapper for :c:func:`zfp_write_header` -Low-level API: stream manipulation wrappers -------------------------------------------- + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_field field [in]: Field metadata + :p integer mask [in]: :ref:`Bit mask ` indicating which parts of header to write + :r num_bits_written: Number of header bits written or zero on failure + :rtype num_bits_written: integer (kind=8) - .. f:subroutine:: zFORp_stream_rewind(stream) +.. f:function:: zFORp_read_header(stream, field, mask) - Wrapper for :c:func:`zfp_stream_rewind` + Wrapper for :c:func:`zfp_read_header` - :p zFORp_stream stream [in]: Zfp_stream + :p zFORp_stream stream [in]: Compressed stream + :p zFORp_field field [in]: Field metadata + :p integer mask [in]: :ref:`Bit mask ` indicating which parts of header to read + :r num_bits_read: Number of header bits read or zero on failure + :rtype num_bits_read: integer (kind=8) From 6c0ceadf053bae84cc3c9fcd70e82d145365332e Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 2 May 2019 18:28:28 -0700 Subject: [PATCH 173/194] Make is_reversible static --- include/zfp.h | 12 +++--------- src/zfp.c | 16 ++++++++-------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/include/zfp.h b/include/zfp.h index a7b067213..b2cc25d08 100644 --- a/include/zfp.h +++ b/include/zfp.h @@ -216,11 +216,6 @@ zfp_stream_bit_stream( const zfp_stream* stream /* compressed stream */ ); -int /* nonzero if lossless compression is enabled */ -zfp_stream_is_reversible( - const zfp_stream* stream /* compressed stream */ -); - /* returns enum of compression mode */ zfp_mode /* enum for compression mode */ zfp_stream_compression_mode( @@ -301,15 +296,14 @@ zfp_stream_set_accuracy( double tolerance /* desired error tolerance */ ); -/* set all compression parameters from compact representation */ -/* compression params are only set on stream upon success */ -zfp_mode /* non (zfp_mode_null) upon success */ +/* set parameters from compact encoding; leaves stream intact on failure */ +zfp_mode /* compression mode or zfp_mode_null upon failure */ zfp_stream_set_mode( zfp_stream* stream, /* compressed stream */ uint64 mode /* 12- or 64-bit encoding of parameters */ ); -/* set all compression parameters (expert mode) */ +/* set all parameters (expert mode); leaves stream intact on failure */ int /* nonzero upon success */ zfp_stream_set_params( zfp_stream* stream, /* compressed stream */ diff --git a/src/zfp.c b/src/zfp.c index c7bf7a079..f908199b2 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -31,6 +31,12 @@ type_precision(zfp_type type) } } +static int +is_reversible(const zfp_stream* zfp) +{ + return zfp->minexp < ZFP_MIN_EXP; +} + /* shared code across template instances ------------------------------------*/ #include "share/parallel.c" @@ -438,12 +444,6 @@ zfp_stream_bit_stream(const zfp_stream* zfp) return zfp->stream; } -int -zfp_stream_is_reversible(const zfp_stream* zfp) -{ - return zfp->minexp < ZFP_MIN_EXP; -} - zfp_mode zfp_stream_compression_mode(const zfp_stream* zfp) { @@ -584,12 +584,12 @@ zfp_stream_maximum_size(const zfp_stream* zfp, const zfp_field* field) return 0; case zfp_type_float: maxbits += 8; - if (zfp_stream_is_reversible(zfp)) + if (is_reversible(zfp)) maxbits += 5; break; case zfp_type_double: maxbits += 11; - if (zfp_stream_is_reversible(zfp)) + if (is_reversible(zfp)) maxbits += 6; break; default: From 3603f923af3279313677152523566c6f9047c690 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 2 May 2019 18:29:40 -0700 Subject: [PATCH 174/194] Add missing C documentation of zfp_stream_set_reversible --- docs/source/high-level-api.rst | 4 ++++ docs/source/modes.rst | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index f972cf325..2416a3281 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -359,6 +359,10 @@ Compressed Stream Compression Parameters ^^^^^^^^^^^^^^^^^^^^^^ +.. c:function:: void zfp_stream_set_reversible(zfp_stream* stream) + + Enable :ref:`reversible ` (lossless) compression. + .. c:function:: double zfp_stream_set_rate(zfp_stream* stream, double rate, zfp_type type, uint dims, int wra) Set *rate* for :ref:`fixed-rate mode ` in compressed bits diff --git a/docs/source/modes.rst b/docs/source/modes.rst index 81db2802c..b1d188473 100644 --- a/docs/source/modes.rst +++ b/docs/source/modes.rst @@ -240,7 +240,7 @@ The expert mode parameters corresponding to reversible mode are:: maxprec = ZFP_MAX_PREC minexp < ZFP_MIN_EXP -Reversible mode is enabled via :c:func:`zfp_set_reversible` and through +Reversible mode is enabled via :c:func:`zfp_stream_set_reversible` and through the :option:`-R` command-line option in the :ref:`zfp executable `. It is supported by both the low- and high-level interfaces and by the serial and OpenMP execution policies, but it is not yet implemented in CUDA. From c344f0000b2ef4a14f21a2320ac4090b5ca69ac5 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 2 May 2019 18:33:33 -0700 Subject: [PATCH 175/194] Remove duplicate include of defs.rst --- docs/source/caching.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/caching.inc b/docs/source/caching.inc index c70021590..e3f3aa741 100644 --- a/docs/source/caching.inc +++ b/docs/source/caching.inc @@ -1,4 +1,3 @@ -.. include:: defs.rst .. _caching: Caching From aa0fc8b738aa87a19e404c9e8ccecca945d0f471 Mon Sep 17 00:00:00 2001 From: lindstro Date: Thu, 2 May 2019 18:46:49 -0700 Subject: [PATCH 176/194] Remove zFORp_stream_is_reversible --- fortran/zfp.f | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/fortran/zfp.f b/fortran/zfp.f index 83f1d57db..42e325ac9 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -160,12 +160,6 @@ function zfp_stream_bit_stream(stream) result(bs) bind(c, name="zfp_stream_bit_s type(c_ptr) :: bs end function - function zfp_stream_is_reversible(stream) result(is_reversible) bind(c, name="zfp_stream_is_reversible") - import - type(c_ptr), value :: stream - integer(c_int) :: is_reversible - end function - function zfp_stream_compression_mode(stream) result(zfp_mode) bind(c, name="zfp_stream_compression_mode") import type(c_ptr), value :: stream @@ -531,7 +525,6 @@ subroutine zfp_stream_rewind(stream) bind(c, name="zfp_stream_rewind") public :: zFORp_stream_open, & zFORp_stream_close, & zFORp_stream_bit_stream, & - zFORp_stream_is_reversible, & zFORp_stream_compression_mode, & zFORp_stream_mode, & zFORp_stream_params, & @@ -640,13 +633,6 @@ function zFORp_stream_bit_stream(stream) result(bs) bind(c, name="zforp_stream_b bs%object = zfp_stream_bit_stream(stream%object) end function zFORp_stream_bit_stream - function zFORp_stream_is_reversible(stream) result(is_reversible) bind(c, name="zforp_stream_is_reversible") - implicit none - type(zFORp_stream), intent(in) :: stream - integer is_reversible - is_reversible = zfp_stream_is_reversible(stream%object) - end function zFORp_stream_is_reversible - function zFORp_stream_compression_mode(stream) result(zfp_mode) bind(c, name="zforp_stream_compression_mode") implicit none type(zFORp_stream), intent(in) :: stream From da67cfab98438cafa1d95b3085fedf39f5784277 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 07:16:23 -0700 Subject: [PATCH 177/194] Fix return type of zFORp_type_size --- docs/source/zforp.rst | 2 +- fortran/zfp.f | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index f246f189d..5411a02df 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -199,7 +199,7 @@ Utility Functions :p integer scalar_type [in]: :ref:`zFORp_type ` enum :r type_size: Size of described :c:type:`zfp_type`, in bytes, from C-language perspective - :rtype type_size: integer + :rtype type_size: integer (kind=8) Compressed Stream diff --git a/fortran/zfp.f b/fortran/zfp.f index 42e325ac9..49ac3d97d 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -607,7 +607,7 @@ end subroutine zFORp_bitstream_stream_close function zFORp_type_size(scalar_type) result(type_size) bind(c, name="zforp_type_size") implicit none integer, intent(in) :: scalar_type - integer type_size + integer (kind=8) type_size type_size = zfp_type_size(int(scalar_type, c_int)) end function zFORp_type_size From 576ade27c5e2b82426eff7617eb810be0824eb75 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 09:10:12 -0700 Subject: [PATCH 178/194] Add Fortran Makefile --- Config | 20 ++++++++++++++++---- Makefile | 4 ++++ docs/source/installation.rst | 15 ++++++++------- fortran/Makefile | 30 ++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 fortran/Makefile diff --git a/Config b/Config index 93f606b06..d26d00295 100644 --- a/Config +++ b/Config @@ -2,6 +2,7 @@ CC = gcc CXX = g++ +FC = gfortran # language standard ----------------------------------------------------------- @@ -9,6 +10,7 @@ CXX = g++ CSTD = -std=c99 CXXSTD = -std=c++98 # CXXSTD = -std=c++11 + FSTD = -std=f2003 -ffree-form -Wno-c-binding-type # common compiler options ----------------------------------------------------- @@ -53,10 +55,19 @@ OMPFLAGS = -fopenmp # build targets --------------------------------------------------------------- -BUILD_CFP = 0 -BUILD_UTILITIES = 1 -BUILD_EXAMPLES = 0 -BUILD_TESTING = 1 +ifeq ($(BUILD_ALL),0) + BUILD_CFP = 0 + BUILD_ZFORP = 0 + BUILD_UTILITIES = 1 + BUILD_EXAMPLES = 0 + BUILD_TESTING = 1 +else + BUILD_CFP = 1 + BUILD_ZFORP = 1 + BUILD_UTILITIES = 1 + BUILD_EXAMPLES = 1 + BUILD_TESTING = 1 +endif BUILD_SHARED_LIBS = 0 ifneq ($(BUILD_SHARED_LIBS),0) @@ -84,3 +95,4 @@ endif CFLAGS = $(CSTD) $(FLAGS) $(DEFS) CXXFLAGS = $(CXXSTD) $(FLAGS) $(DEFS) +FFLAGS = $(FSTD) $(FLAGS) $(DEFS) diff --git a/Makefile b/Makefile index c24719189..bddc72ae1 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ all: ifneq ($(BUILD_CFP),0) @cd cfp/src; $(MAKE) clean $(LIBRARY) endif +ifneq ($(BUILD_ZFORP),0) + @cd fortran; $(MAKE) clean $(LIBRARY) +endif ifneq ($(BUILD_UTILITIES),0) @cd utils; $(MAKE) clean all endif @@ -31,6 +34,7 @@ test: clean: @cd src; $(MAKE) clean @cd cfp/src; $(MAKE) clean + @cd fortran; $(MAKE) clean @cd utils; $(MAKE) clean @cd tests; $(MAKE) clean @cd examples; $(MAKE) clean diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 93deb531c..bc9bac67b 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -122,7 +122,8 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_ALL - Build all subdirectories; enable all options (except BUILD_SHARED_LIBS). + Build all subdirectories; enable all options (except + :c:macro:`BUILD_SHARED_LIBS`). Default: off. .. c:macro:: BUILD_CFP @@ -134,10 +135,10 @@ Regardless of the settings below, |libzfp| will always be built. Build |zfpy| for Python bindings to the C API. - Cmake will attempt to automatically detect the python installation to use. If cmake - finds multiple python installations, it will use the newest one. To specify a - specific python installation to use, set ``PYTHON_LIBRARY`` and - ``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: + Cmake will attempt to automatically detect the python installation to use. + If cmake finds multiple python installations, it will use the newest one. + To specify a specific python installation to use, set ``PYTHON_LIBRARY`` + and ``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. @@ -147,7 +148,7 @@ Regardless of the settings below, |libzfp| will always be built. Build |libzforp| for Fortran bindings to the C API. - Requires Fortran standard 2003 and later. + Requires Fortran standard 2003 or later. Default: off. @@ -168,7 +169,7 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_SHARED_LIBS - Build :file:`libzfp.so` and :file:`libcfp.so` shared objects. + Build shared objects (:file:`.so` or :file:`.dylib` files). On macOS, the :code:`SOFLAGS` line in the :file:`Config` file may have to be uncommented when compiling with GNU make. CMake default: on. diff --git a/fortran/Makefile b/fortran/Makefile new file mode 100644 index 000000000..229bf42cb --- /dev/null +++ b/fortran/Makefile @@ -0,0 +1,30 @@ +include ../Config + +LIBDIR = ../lib +MODDIR = ../modules +TARGETS = $(LIBDIR)/libzFORp.a $(LIBDIR)/libzFORp.so $(MODDIR)/zforp_module.mod +OBJECTS = zfp.o +MODULES = zforp_module.mod + +static: $(LIBDIR)/libzFORp.a $(MODDIR)/zforp_module.mod + +shared: $(LIBDIR)/libzFORp.so $(MODDIR)/zforp_module.mod + +clean: + rm -f $(TARGETS) $(OBJECTS) + +$(LIBDIR)/libzFORp.a: $(OBJECTS) + mkdir -p $(LIBDIR) + rm -f $@ + ar rc $@ $^ + +$(LIBDIR)/libzFORp.so: $(OBJECTS) + mkdir -p $(LIBDIR) + $(FC) $(FFLAGS) -shared $^ -o $@ + +$(MODDIR)/zforp_module.mod: $(OBJECTS) + mkdir -p $(MODDIR) + mv zforp_module.mod $(MODDIR) + +.f.o: + $(FC) $(FFLAGS) -c $< From 4be284e36da4437e4b0034efbdce55b1bf9e7f9d Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 13:20:38 -0700 Subject: [PATCH 179/194] Add intro, links to Python documentation --- docs/source/installation.rst | 30 +++++- docs/source/python.rst | 183 +++++++++++++++++++++++------------ 2 files changed, 146 insertions(+), 67 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index bc9bac67b..88df1e2f7 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -46,6 +46,12 @@ parallel compression, type:: make ZFP_WITH_OPENMP=1 +.. note:: + + GNU builds expose only limited functionality of |zfp|. For instance, + CUDA and Python support are not included. For full functionality, + build |zfp| using CMake. + .. _cmake_builds: CMake Builds @@ -135,14 +141,16 @@ Regardless of the settings below, |libzfp| will always be built. Build |zfpy| for Python bindings to the C API. - Cmake will attempt to automatically detect the python installation to use. - If cmake finds multiple python installations, it will use the newest one. - To specify a specific python installation to use, set ``PYTHON_LIBRARY`` - and ``PYTHON_INCLUDE_DIR`` in the cmake line. Putting it all together:: + Cmake will attempt to automatically detect the Python installation to use. + If cmake finds multiple Python installations, it will use the newest one. + To specify a specific Python installation to use, set + :c:macro:`PYTHON_LIBRARY` and :c:macro:`PYTHON_INCLUDE_DIR` in the + cmake line. Putting it all together:: cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. - Default: off. + CMake default: off. + GNU make default: off and ignored. .. c:macro:: BUILD_ZFORP @@ -275,6 +283,18 @@ in the same manner that :ref:`build targets ` are specified, e.g., clashes. Default: cfp. +.. c:macro:: PYTHON_LIBRARY + + Path to the Python library, e.g., :file:`/usr/lib/libpython2.7.so`. + CMake default: undefined/off. + GNU make default: off and ignored. + +.. c:macro:: PYTHON_INCLUDE_DIR + + Path to the Python include directory, e.g., :file:`/usr/include/python2.7`. + CMake default: undefined/off. + GNU make default: off and ignored. + Python Dependencies ------------------- diff --git a/docs/source/python.rst b/docs/source/python.rst index 25a444e4f..778480a8d 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -1,22 +1,42 @@ .. include:: defs.rst -.. _python: - -Python -======================= .. py:module:: zfpy +.. _zfpy: + +Python Bindings +=============== + +|zfp| |zfpyrelease| adds |zfpy|: Python bindings that allow compressing +and decompressing `NumPy `_ integer and +floating-point arrays. The |zfpy| implementation is based on +`Cython `_ and requires both NumPy and Cython +to be installed. The |zfpy| API is limited to two functions, for +compression and decompression, which are described below. + Compression ----------- -.. py:function:: compress_numpy(arr, tolerance = -1, rate = -1, precision = -1, write_header=True) - -Compression through the python bindings currently requires a numpy array -populated with the data to be compressed. The numpy metadata (i.e., shape, -strides, and type) are used to automatically populate ``zfp_field`` structure. -By default, all that is required to be passed to the compression function is the -numpy array; this will result in a stream that includes a header and is -compressed with the ``reversible`` mode. For example:: +.. py:function:: compress_numpy(arr, tolerance = -1, rate = -1, precision = -1, write_header = True) + + Compress NumPy array, *arr*, and return a compressed byte stream. The + non-expert :ref:`compression mode ` is selected by setting one of + *tolerance*, *rate*, or *precision*. If none of these arguments is + specified, then :ref:`reversible mode ` is used. By + default, a header that encodes array shape and scalar type as well as + compression parameters is prepended, which can be omitted by setting + *write_header* to *False*. If this function fails for any reason, an + exception is thrown. + +|zfpy| compression currently requires a NumPy array +(`ndarray `_) +populated with the data to be compressed. The array metadata (i.e., +shape, strides, and scalar type) are used to automatically populate the +:c:type:`zfp_field` structure passed to :c:func:`zfp_compress`. By default, +all that is required to be passed to the compression function is the +NumPy array; this will result in a stream that includes a header and is +losslessly compressed using the :ref:`reversible mode `. +For example:: import zfpy import numpy as np @@ -29,7 +49,8 @@ compressed with the ``reversible`` mode. For example:: np.testing.assert_array_equal(my_array, decompressed_array) Using the fixed-accuracy, fixed-rate, or fixed-precision modes simply requires -setting one of the tolerance, rate, or precision arguments, respectively. For example:: +setting one of the *tolerance*, *rate*, or *precision* arguments, respectively. +For example:: compressed_data = zfpy.compress_numpy(my_array, tolerance=1e-4) decompressed_array = zfpy.decompress_numpy(compressed_data) @@ -37,58 +58,96 @@ setting one of the tolerance, rate, or precision arguments, respectively. For ex # Note the change from "equal" to "allclose" due to the lossy compression np.testing.assert_allclose(my_array, decompressed_array, atol=1e-3) -Since numpy arrays are C-ordered by default and ``zfp_compress`` expects the -fastest changing stride to the first (i.e., Fortran-ordering), -``compress_numpy`` automatically flips the reverses the stride in order to -optimize the compression ratio for C-ordered numpy arrays. Since the -``decompress_numpy`` function also reverses the stride order, data both -compressed and decompressed with the python bindings should have the same shape -before and after. - -.. note:: ``decompress_numpy`` requires a header to decompress properly, so do - not use ``write_header=False`` if you intend to decompress the stream with - the python bindings. +Since NumPy arrays are C-ordered by default (i.e., the rightmost index +varies fastest) and :c:func:`zfp_compress` assumes Fortran ordering +(i.e., the leftmost index varies fastest), :py:func:`compress_numpy` +automatically reverses the order of dimensions and strides in order to +improve the expected memory access pattern during compression. +The :py:func:`decompress_numpy` function also reverses the order of +dimensions and strides, and therefore decompression will restore the +shape of the original array. Note, however, that the |zfp| stream does +not encode the memory layout of the original NumPy array, and therefore +layout information like strides, contiguity, and C vs. Fortran order +may not be preserved. Nevertheless, |zfpy| correctly compresses NumPy +arrays with any memory layout, including Fortran ordering and non-contiguous +storage. + +Byte streams produced by :py:func:`compress_numpy` can be decompressed +by the :ref:`zfp command-line tool `. In general, they cannot +be :ref:`deserialized ` as compressed arrays, however. + +.. note:: + :py:func:`decompress_numpy` requires a header to decompress properly, so do + not set *write_header* = *False* during compression if you intend to + decompress the stream with |zfpy|. Decompression ------------- .. py:function:: decompress_numpy(compressed_data) -``decompress_numpy`` consumes a compressed stream that includes a header and -produces a numpy array with metadata populated based on the contents of the -header. Stride information is not stored in the zfp header, so the -``decompress_numpy`` function assumes that the array was compressed with the -fastest changing dimension first (typically referred to as Fortran-ordering). -The returned numpy array is in C-ordering (the default for numpy arrays), so the -shape of the returned array is reversed from that of the shape in the -compression header. For example, if the header declares the array to be of -shape (2, 4, 8), then the returned numpy array will have a shape of (8, 4, 2). -Since the ``compress_numpy`` function also reverses the stride order, data both -compressed and decompressed with the python bindings should have the same shape -before and after. - -.. note:: Decompressing a stream without a header requires using the - internal ``_decompress`` python function (or the C API). - -.. py:function:: _decompress(compressed_data, ztype, shape, out=None, tolerance = -1, rate = -1, precision = -1,) - -.. warning:: ``_decompress`` is an "experimental" function currently used - internally for testing the . It does allow decompression of - streams without headers, but providing too small of an output - bufffer or incorrectly specifying the shape or strides can result - in segmentation faults. Use with care. - -Decompresses a compressed stream without a header. If a header is present in -the stream, it will be incorrectly interpreted as compressed data. ``ztype`` is -a ``zfp_type``, which can be manually specified (e.g., ``zfpy.type_int32``) or -generated from a numpy dtype (e.g., ``zfpy.dtype_to_ztype(array.dtype)``). If -``out`` is specified, the data is decompressed into the ``out`` buffer. ``out`` -can be a numpy array or a pointer to memory large enough to hold the -decompressed data. Regardless if ``out`` is provided or its type, -``_decompress`` always returns a numpy array. If ``out`` is not provided, the -array is allocated for the user, and if ``out`` is provided, then the returned -numpy is just a pointer to or wrapper around the user-supplied ``out``. If -``out`` is a numpy array, then the shape and type of the numpy array must match -the required arguments ``shape`` and ``ztype``. If you want to avoid this -constraint check, use ``out=ndarray.data`` rather than ``out=ndarray`` when -calling ``_decompress``. + Decompress a byte stream, *compressed_data*, produced by + :py:func:`compress_numpy` (with header enabled) and return the + decompressed NumPy array. This function throws on exception upon error. + +:py:func:`decompress_numpy` consumes a compressed stream that includes a +header and produces a NumPy array with metadata populated based on the +contents of the header. Stride information is not stored in the |zfp| +header, so :py:func:`decompress_numpy` assumes that the array was compressed +with the first (leftmost) dimension varying fastest (typically referred to as +Fortran-ordering). The returned NumPy array is in C-ordering (the default +for NumPy arrays), so the shape of the returned array is reversed from +the shape information stored in the embedded header. For example, if the +header declares the array to be of shape (*nx*, *ny*, *nz*) = (2, 4, 8), +then the returned NumPy array will have a shape of (8, 4, 2). +Since the :py:func:`compress_numpy` function also reverses the order of +dimensions, arrays both compressed and decompressed with |zfpy| will have +compatible shape. + +.. note:: + Decompressing a stream without a header requires using the + internal :py:func:`_decompress` Python function (or the + :ref:`C API `). + +.. py:function:: _decompress(compressed_data, ztype, shape, out = None, tolerance = -1, rate = -1, precision = -1) + + Decompress a headerless compressed stream (if a header is present in + the stream, it will be incorrectly interpreted as compressed data). + *ztype* specifies the array scalar type while *shape* specifies the array + dimensions; both must be known by the caller. The compression mode is + selected by specifying one (or none) or *tolerance*, *rate*, and + *precision*, as in :py:func:`compress_numpy`, and also must be known + by the caller. If *out = None*, a new NumPy array is allocated. Otherwise, + *out* specifies the NumPy array or memory buffer to decompress into. + Regardless, the decompressed NumPy array is returned unless an error occurs, + in which case an exception is thrown. + +In :py:func:`_decompress`, *ztype* is one of the |zfp| supported scalar types +(see :c:type:`zfp_type`), which are available in |zfpy| as +:: + + type_int32 = zfp_type_int32 + type_int64 = zfp_type_int64 + type_float = zfp_type_float + type_double = zfp_type_double + +These can be manually specified (e.g., :code:`zfpy.type_int32`) or generated +from a NumPy *dtype* (e.g., :code:`zfpy.dtype_to_ztype(array.dtype)`). + +If *out* is specified, the data is decompressed into the *out* buffer. +*out* can be a NumPy array or a pointer to memory large enough to hold the +decompressed data. Regardless if *out* is provided or its type, +:py:func:`_decompress` always returns a NumPy array. If *out* is not +provided, then the array is allocated for the user. If *out* is provided, +then the returned NumPy array is just a pointer to or wrapper around the +user-supplied *out*. If *out* is a NumPy array, then its shape and scalar +type must match the required arguments *shape* and *ztype*. To avoid this +constraint check, use :code:`out = ndarray.data` rather than +:code:`out = ndarray` when calling :py:func:`_decompress`. + +.. warning:: + :py:func:`_decompress` is an "experimental" function currently used + internally for testing. It does allow decompression of streams without + headers, but providing too small of an output bufffer or incorrectly + specifying the shape or strides can result in segmentation faults. + Use with care. From 610dde9e9354b03dfe8f41ffd78b79fe40512acc Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 13:21:13 -0700 Subject: [PATCH 180/194] Fix incorrect handling of BUILD_ALL --- Config | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/Config b/Config index d26d00295..957eaa087 100644 --- a/Config +++ b/Config @@ -55,21 +55,26 @@ OMPFLAGS = -fopenmp # build targets --------------------------------------------------------------- -ifeq ($(BUILD_ALL),0) - BUILD_CFP = 0 - BUILD_ZFORP = 0 - BUILD_UTILITIES = 1 - BUILD_EXAMPLES = 0 - BUILD_TESTING = 1 -else - BUILD_CFP = 1 - BUILD_ZFORP = 1 - BUILD_UTILITIES = 1 - BUILD_EXAMPLES = 1 - BUILD_TESTING = 1 -endif +# default targets +BUILD_CFP = 0 +BUILD_ZFORP = 0 +BUILD_UTILITIES = 1 +BUILD_EXAMPLES = 0 +BUILD_TESTING = 1 BUILD_SHARED_LIBS = 0 +# build all targets? +ifdef BUILD_ALL + ifneq ($(BUILD_ALL),0) + BUILD_CFP = 1 + BUILD_ZFORP = 1 + BUILD_UTILITIES = 1 + BUILD_EXAMPLES = 1 + BUILD_TESTING = 1 + endif +endif + +# build shared libraries? ifneq ($(BUILD_SHARED_LIBS),0) LIBRARY = shared LIBZFP = libzfp.so From fb7f747576f945c40185fd465c27cc398fd51036 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 13:22:47 -0700 Subject: [PATCH 181/194] Elaborate on default cache size in FAQ --- docs/source/faq.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/docs/source/faq.rst b/docs/source/faq.rst index 8fef7417c..c45772132 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -1,5 +1,7 @@ .. include:: defs.rst +.. cpp:namespace:: zfp + FAQ === @@ -34,7 +36,7 @@ Questions answered in this FAQ: #. :ref:`Are parallel compressed streams identical to serial streams? ` #. :ref:`Are zfp arrays and other data structures thread-safe? ` #. :ref:`Why does parallel compression performance not match my expectations? ` - #. :ref:`Why are 1D compressed arrays so slow? ` + #. :ref:`Why are compressed arrays so slow? ` #. :ref:`Do compressed arrays use reference counting? ` ------------------------------------------------------------------------------- @@ -890,7 +892,7 @@ to offset the overhead of setting up parallel compression. .. _q-1d-speed: -Q26: *Why are 1D compressed arrays so slow?* +Q26: *Why are compressed arrays so slow?* A: This is likely due to the use of a very small cache. Prior to |zfp| |csizerelease|, all arrays used two 'layers' of blocks as default cache @@ -901,9 +903,20 @@ cache holds only two blocks, which is likely to cause excessive thrashing. As of version |csizerelease|, the default cache size is roughly proportional to the square root of the total number of array elements, regardless of array dimensionality. While this tends to reduce thrashing, we suggest -experimenting with larger cache sizes of at least a few KB to ensure +experimenting with larger cache sizes of at least a few kilobytes to ensure acceptable performance. +Note that compressed arrays constructed with the +:ref:`default constructor ` will +have an initial cache size of only one block. Therefore, users should call +:cpp:func:`array::set_cache_size` after :ref:`resizing ` +such arrays to ensure a large enough cache. + +Depending on factors such as rate, cache size, array access pattern, +array access primitive (e.g., indices vs. iterators), and arithmetic +intensity, we usually observe an application slow-down of 1-10x when +switching from uncompressed to compressed arrays. + ------------------------------------------------------------------------------- .. _q-ref-count: From 7e45e0b7ec7aa8a7600b702bc75b243d6301ba79 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 13:23:11 -0700 Subject: [PATCH 182/194] Add zFORp to index --- docs/source/zforp.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 5411a02df..9aecc00a7 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -1,14 +1,12 @@ .. include:: defs.rst .. index:: - single: zforp + single: zFORp .. _zforp: Fortran Bindings ================ -.. cpp:namespace:: zfp - |zfp| |zforprelease| adds |zforp|: a Fortran API providing wrappers around the :ref:`high-level C API `. Wrappers for :ref:`compressed arrays ` will arrive in a future release. From b5a11d3c58332625baafd76c19d73d8bac2137a3 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 14:40:09 -0700 Subject: [PATCH 183/194] Add more discussion of dependencies --- docs/source/installation.rst | 52 ++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 11 deletions(-) diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 88df1e2f7..f3407dbaf 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -38,13 +38,13 @@ GNU Builds To compile |zfp| using `gcc `_ without `OpenMP `_, type:: - make + gmake from the |zfp| root directory. This builds |libzfp| as a static library as well as utilities and example programs. To enable OpenMP parallel compression, type:: - make ZFP_WITH_OPENMP=1 + gmake ZFP_WITH_OPENMP=1 .. note:: @@ -91,7 +91,7 @@ Testing To test that |zfp| is working properly, type:: - make test + gmake test or using CMake:: @@ -154,9 +154,12 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_ZFORP - Build |libzforp| for Fortran bindings to the C API. + Build |libzFORp| for Fortran bindings to the C API. Requires Fortran + standard 2003 or later. GNU make users may specify the Fortran compiler + to use via + :: - Requires Fortran standard 2003 or later. + gmake BUILD_ZFORP=1 FC=/path/to/fortran-compiler Default: off. @@ -227,7 +230,8 @@ in the same manner that :ref:`build targets ` are specified, e.g., GPU compression and decompression. When enabled, CUDA and a compatible host compiler must be installed. For a full list of compatible compilers, please consult the - `NVIDIA documentation `_. If a CUDA installation is in the user's path, it will be + `NVIDIA documentation `_. + If a CUDA installation is in the user's path, it will be automatically found by CMake. Alternatively, the CUDA binary directory can be specified using the :envvar:`CUDA_BIN_DIR` environment variable. CMake default: off. @@ -295,16 +299,42 @@ in the same manner that :ref:`build targets ` are specified, e.g., CMake default: undefined/off. GNU make default: off and ignored. -Python Dependencies -------------------- -Minimum Tested Versions: +Dependencies +------------ + +The core |zfp| library and compressed arrays require only a C89 and C++98 +compiler. The optional components have additional dependencies, as outlined +in the sections below. + +CMake +^^^^^ + +CMake builds require version 3.1 or later on Linux and macOS and version +3.4 or later on Windows. CMake is available `here `_. + +CUDA +^^^^ + +CUDA support requires CMake and a compatible host compiler (see +:c:macro:`ZFP_WITH_CUDA`). + +Python +^^^^^^ + +The optional Python bindings require CMake and the following minimum +versions: * Python: Python 2.7 & Python 3.5 * Cython: 0.22 * Numpy: 1.8.0 -You can install the necessary dependencies using ``pip`` and the zfp -``requirements.txt``:: +The necessary dependencies can be installed using ``pip`` and the |zfp| +:file:requirements.txt:: pip install -r $ZFP_ROOT/python/requirements.txt + +Fortran +^^^^^^^ + +The optional Fortran bindings require a Fortran 2003 compiler. From 912b0c4443b6c05371d79974510585905b4fd451 Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 14:40:29 -0700 Subject: [PATCH 184/194] Discuss future ZIF format --- docs/source/directions.rst | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/docs/source/directions.rst b/docs/source/directions.rst index 0cfa17a6a..ec47c62e8 100644 --- a/docs/source/directions.rst +++ b/docs/source/directions.rst @@ -26,6 +26,18 @@ important features, including: currently result in undefined behavior and loss of data for all values within a block that contains non-finite values. +- **Support for more general data types**. |zfp| currently does not + directly support half and quad precision floating point. Nor is there + support for 8- and 16-bit integers. With the emergence of new number + representations like *posits* and *bfloat16*, we envision the need for + a more general interface and a single unified |zfp| representation that + would allow for *conversion* between |zfp| and *any* number representation. + We are working on developing an uncompressed interchange format that acts + like an intermediary between |zfp| and other number formats. This format + decouples the |zfp| compression pipeline from the external number type and + allows new number formats to be supported via user-defined conversion + functions to and from the common interchange format. + - **Progressive decompression**. Streaming large data sets from remote storage for visualization can be time consuming, even when the data is compressed. Progressive streaming allows the data to be reconstructed @@ -61,10 +73,12 @@ important features, including: |zfp| representation to IEEE. - **Language bindings**. The main compression codec is written in C89 to - facilitate calls from other languages, but would benefit from language - wrappers to ease integration. As of |zfp| |cfprelease|, C wrappers are - available for a subset of the C++ compressed array API. Work is planned - to add complete language bindings for C, C++, Fortran, and Python. + facilitate calls from other languages. |zfp|'s compressed arrays, on + the other hand, are written in C++. |zfp| |cfprelease| and |zforprelease| + add C wrappers around compressed arrays and Fortran and Python bindings to + the high-level C API. Work is planned to provide additional language + bindings for C, C++, Fortran, and Python to expose the majority of |zfp|'s + capabilities through all of these programming languages. Please contact `Peter Lindstrom `__ with requests for features not listed above. From 54a5813b2ebd7d3f3c38e4e828cee9e3d5aa331f Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 3 May 2019 15:19:21 -0700 Subject: [PATCH 185/194] remove bind(c) from zFORp string constant (suppress build error requiring len to be 1) --- fortran/zfp.f | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fortran/zfp.f b/fortran/zfp.f index 49ac3d97d..e31221294 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -64,9 +64,7 @@ module zFORp_module integer, protected, bind(c, name="zFORp_library_version") :: zFORp_library_version data zFORp_library_version/const_zFORp_library_version/ - character(len = 36), parameter :: const_zFORp_version_string = 'zfp version 0.5.4 (October 1, 2018)' - character(len = 36), protected, bind(c, name="zFORp_version_string") :: zFORp_version_string - data zFORp_version_string/const_zFORp_version_string/ + character(len = 36), parameter :: zFORp_version_string = 'zfp version 0.5.4 (October 1, 2018)' integer, parameter :: const_zFORp_min_bits = 1 integer, parameter :: const_zFORp_max_bits = 16657 From 463ee7583b7635eef073138d4e286d09becf4eb3 Mon Sep 17 00:00:00 2001 From: Markus Salasoo Date: Fri, 3 May 2019 15:22:00 -0700 Subject: [PATCH 186/194] update aligned allocation preprocessor conditional, pass compressed array defs to test files, allocate smaller aligned size in test remove unused variable from testArrayBase.cpp --- array/zfp/memory.h | 2 +- tests/array/CMakeLists.txt | 6 ++++++ tests/array/testArrayBase.cpp | 1 - tests/array/zfp/CMakeLists.txt | 1 + tests/array/zfp/testAlignedMemory.cpp | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/array/zfp/memory.h b/array/zfp/memory.h index 32963c737..eea2ab052 100644 --- a/array/zfp/memory.h +++ b/array/zfp/memory.h @@ -40,7 +40,7 @@ allocate_aligned(size_t size, size_t alignment) #elif defined(_WIN32) ptr = _aligned_malloc(size, alignment); - #elif defined(__USE_XOPEN2K) || defined(__MACH__) + #elif (_POSIX_C_SOURCE >= 200112L) || (_XOPEN_SOURCE >= 600) || defined(__MACH__) is_mem_failed = posix_memalign(&ptr, alignment, size); #else diff --git a/tests/array/CMakeLists.txt b/tests/array/CMakeLists.txt index 03a742ae2..a1fc7b7f0 100644 --- a/tests/array/CMakeLists.txt +++ b/tests/array/CMakeLists.txt @@ -4,6 +4,7 @@ function(zfp_add_cpp_tests dims type bits) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} gtest gtest_main zfp zfpHashLib genSmoothRandNumsLib zfpChecksumsLib) + target_compile_definitions(${test_name} PRIVATE ${zfp_compressed_array_defs}) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's references @@ -11,6 +12,7 @@ function(zfp_add_cpp_tests dims type bits) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} gtest gtest_main zfp zfpHashLib rand${bits}Lib) + target_compile_definitions(${test_name} PRIVATE ${zfp_compressed_array_defs}) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's pointers @@ -18,6 +20,7 @@ function(zfp_add_cpp_tests dims type bits) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} gtest gtest_main zfp) + target_compile_definitions(${test_name} PRIVATE ${zfp_compressed_array_defs}) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's iterators @@ -25,6 +28,7 @@ function(zfp_add_cpp_tests dims type bits) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} gtest gtest_main zfp) + target_compile_definitions(${test_name} PRIVATE ${zfp_compressed_array_defs}) add_test(NAME ${test_name} COMMAND ${test_name}) # test class's views @@ -32,6 +36,7 @@ function(zfp_add_cpp_tests dims type bits) add_executable(${test_name} ${test_name}.cpp) target_link_libraries(${test_name} gtest gtest_main zfp) + target_compile_definitions(${test_name} PRIVATE ${zfp_compressed_array_defs}) add_test(NAME ${test_name} COMMAND ${test_name}) endfunction() @@ -47,6 +52,7 @@ zfp_add_cpp_tests(3 d 64) set(test_name testConstruct) add_executable(testConstruct testConstruct.cpp) target_link_libraries(testConstruct gtest gtest_main zfp) +target_compile_definitions(testConstruct PRIVATE ${zfp_compressed_array_defs}) add_test(NAME testConstruct COMMAND testConstruct) add_subdirectory(zfp) diff --git a/tests/array/testArrayBase.cpp b/tests/array/testArrayBase.cpp index 583a8cf45..77f106dae 100644 --- a/tests/array/testArrayBase.cpp +++ b/tests/array/testArrayBase.cpp @@ -74,7 +74,6 @@ void VerifyProperHeaderWritten(const zfp::array::header& h, uint chosenSizeX, ui // copy header into aligned memory suitable for bitstream r/w size_t num_64bit_entries = DIV_ROUND_UP(ZFP_HEADER_SIZE_BITS, CHAR_BIT * sizeof(uint64)); uint64* buffer = new uint64[num_64bit_entries]; - size_t buffer_size_bytes = num_64bit_entries * sizeof(uint64); memcpy(buffer, &h, BITS_TO_BYTES(ZFP_HEADER_SIZE_BITS)); diff --git a/tests/array/zfp/CMakeLists.txt b/tests/array/zfp/CMakeLists.txt index 2b036526e..6d194a78a 100644 --- a/tests/array/zfp/CMakeLists.txt +++ b/tests/array/zfp/CMakeLists.txt @@ -1,5 +1,6 @@ if(ZFP_WITH_ALIGNED_ALLOC) add_executable(testAlignedMemory testAlignedMemory.cpp) target_link_libraries(testAlignedMemory gtest gtest_main zfp) + target_compile_definitions(testAlignedMemory PRIVATE ${zfp_compressed_array_defs}) add_test(NAME testAlignedMemory COMMAND testAlignedMemory) endif() diff --git a/tests/array/zfp/testAlignedMemory.cpp b/tests/array/zfp/testAlignedMemory.cpp index f991ed10c..0b16ff108 100644 --- a/tests/array/zfp/testAlignedMemory.cpp +++ b/tests/array/zfp/testAlignedMemory.cpp @@ -19,7 +19,7 @@ INSTANTIATE_TEST_CASE_P(TestManyMemoryAlignments, TEST_FIXTURE, ::testing::Range TEST_P(TEST_FIXTURE, when_allocateAlignedMem_expect_addressAligned) { size_t alignmentBytes = (size_t)(1u << GetParam()); - void* ptr = allocate_aligned(900, alignmentBytes); + void* ptr = allocate_aligned(30, alignmentBytes); uintptr_t address = (uintptr_t)ptr; EXPECT_EQ(address % alignmentBytes, 0); From 6a445f9f24ae563074f2afe7c484cc7b5924fbbd Mon Sep 17 00:00:00 2001 From: lindstro Date: Fri, 3 May 2019 20:19:14 -0700 Subject: [PATCH 187/194] Silence unused parameter warnings and enable -Wextra in Config --- Config | 2 +- array/zfp/memory.h | 7 +++++++ examples/array2d.h | 11 ++++++++++- examples/diffusion.cpp | 7 +++++++ src/template/decodei.c | 4 ++-- src/template/revdecode.c | 2 +- src/template/revdecodef.c | 4 ++-- 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Config b/Config index 957eaa087..834bf2528 100644 --- a/Config +++ b/Config @@ -14,7 +14,7 @@ FC = gfortran # common compiler options ----------------------------------------------------- -FLAGS = -O3 -fPIC -Wall -pedantic -I../include +FLAGS = -O3 -fPIC -Wall -Wextra -pedantic -I../include SOFLAGS = # macOS compiler options (uncomment on macOS) --------------------------------- diff --git a/array/zfp/memory.h b/array/zfp/memory.h index eea2ab052..852559da3 100644 --- a/array/zfp/memory.h +++ b/array/zfp/memory.h @@ -15,8 +15,11 @@ extern "C" { #include #include "zfp/types.h" +#define unused_(x) ((void)(x)) + namespace zfp { +// allocate size bytes inline void* allocate(size_t size) { @@ -44,11 +47,13 @@ allocate_aligned(size_t size, size_t alignment) is_mem_failed = posix_memalign(&ptr, alignment, size); #else + unused_(alignment); ptr = malloc(size); #endif #else + unused_(alignment); ptr = malloc(size); #endif @@ -135,4 +140,6 @@ clone_aligned(T*& dst, const T* src, size_t count, size_t alignment) } +#undef unused_ + #endif diff --git a/examples/array2d.h b/examples/array2d.h index 861fa25a9..8ba7291cf 100644 --- a/examples/array2d.h +++ b/examples/array2d.h @@ -4,6 +4,8 @@ #include #include +#define unused_(x) ((void)(x)) + typedef unsigned int uint; // uncompressed 2D double-precision array (for comparison) @@ -11,7 +13,12 @@ namespace raw { class array2d { public: array2d() : nx(0), ny(0) {} - array2d(uint nx, uint ny, double rate = 0.0, const double* p = 0, size_t csize = 0) : nx(nx), ny(ny), data(nx * ny, 0.0) {} + array2d(uint nx, uint ny, double rate = 0.0, const double* p = 0, size_t csize = 0) : nx(nx), ny(ny), data(nx * ny, 0.0) + { + unused_(rate); + unused_(p); + unused_(csize); + } void resize(uint nx, uint ny) { this->nx = nx; this->ny = ny; data.resize(nx * ny, 0.0); } size_t size() const { return data.size(); } size_t size_x() const { return nx; } @@ -46,4 +53,6 @@ class array2d { }; } +#undef unused_ + #endif diff --git a/examples/diffusion.cpp b/examples/diffusion.cpp index 3512bff42..82cc109df 100644 --- a/examples/diffusion.cpp +++ b/examples/diffusion.cpp @@ -13,6 +13,8 @@ #include #endif +#define unused_(x) ((void)(x)) + // constants used in the solution class Constants { public: @@ -83,6 +85,9 @@ time_step_parallel(zfp::array2d& u, const Constants& c) // take forward Euler step in serial for (uint i = 0; i < u.size(); i++) u[i] += du[i]; +#else + unused_(u); + unused_(c); #endif } @@ -91,6 +96,8 @@ template <> inline void time_step_parallel(raw::array2d& u, const Constants& c) { + unused_(u); + unused_(c); } // advance solution using integer array indices diff --git a/src/template/decodei.c b/src/template/decodei.c index ad43581f1..12f62a980 100644 --- a/src/template/decodei.c +++ b/src/template/decodei.c @@ -1,4 +1,4 @@ -static uint _t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock); +static uint _t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, Int* iblock); /* public functions -------------------------------------------------------- */ @@ -6,5 +6,5 @@ static uint _t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int uint _t2(zfp_decode_block, Int, DIMS)(zfp_stream* zfp, Int* iblock) { - return REVERSIBLE(zfp) ? _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock) : _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock); + return REVERSIBLE(zfp) ? _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, iblock) : _t2(decode_block, Int, DIMS)(zfp->stream, zfp->minbits, zfp->maxbits, zfp->maxprec, iblock); } diff --git a/src/template/revdecode.c b/src/template/revdecode.c index dd8f260bf..cde9877f6 100644 --- a/src/template/revdecode.c +++ b/src/template/revdecode.c @@ -31,7 +31,7 @@ _t1(rev_inv_lift, Int)(Int* p, uint s) /* decode block of integers using reversible algorithm */ static uint -_t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, int maxprec, Int* iblock) +_t2(rev_decode_block, Int, DIMS)(bitstream* stream, int minbits, int maxbits, Int* iblock) { /* decode number of significant bits */ int bits = PBITS; diff --git a/src/template/revdecodef.c b/src/template/revdecodef.c index 2e8a55805..221a4b2e5 100644 --- a/src/template/revdecodef.c +++ b/src/template/revdecodef.c @@ -30,7 +30,7 @@ _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) bits++; if (stream_read_bit(zfp->stream)) { /* decode integer block */ - bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, iblock); /* reinterpret integers as floating values */ _t1(rev_inv_reinterpret, Scalar)(iblock, fblock, BLOCK_SIZE); } @@ -39,7 +39,7 @@ _t2(rev_decode_block, Scalar, DIMS)(zfp_stream* zfp, Scalar* fblock) bits += EBITS; int emax = (int)stream_read_bits(zfp->stream, EBITS) - EBIAS; /* decode integer block */ - bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, zfp->maxprec, iblock); + bits += _t2(rev_decode_block, Int, DIMS)(zfp->stream, zfp->minbits - bits, zfp->maxbits - bits, iblock); /* perform inverse block-floating-point transform */ _t1(rev_inv_cast, Scalar)(iblock, fblock, BLOCK_SIZE, emax); } From 00601950a5593de888f92e9fdf7bc8c20d298427 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sat, 4 May 2019 07:09:34 -0700 Subject: [PATCH 188/194] Mention need to resize cache with default constructor --- docs/source/arrays.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index 08904cd5d..b6256dd25 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -240,6 +240,9 @@ type is ommitted for readability, e.g., time of construction. Before the array can become usable, however, it must be :ref:`resized ` and its rate must be set via :cpp:func:`array::set_rate`. These two tasks can be performed in either order. + Furthermore, the desired cache size should be set using + :cpp:func:`array::set_cache_size`, as the default constructor creates a + cache that holds only one |zfp| block, i.e., the minimum possible. .. _array_ctor: .. cpp:function:: array1::array1(uint n, double rate, const Scalar* p = 0, size_t csize = 0) @@ -301,6 +304,13 @@ type is ommitted for readability, e.g., Resize the array (all previously stored data will be lost). If *clear* is true, then the array elements are all initialized to zero. +.. note:: + It is often desirable (though not a requirement) to also set the cache size + when resizing an array, e.g., in proportion to the array size; + see :cpp:func:`array::set_cache_size`. This is particularly important when + the array is default constructed, which initializes the cache size to the + minimum possible of only one |zfp| block. + .. _array_accessor: .. cpp:function:: Scalar array1::operator()(uint i) const .. cpp:function:: Scalar array2::operator()(uint i, uint j) const From 294917305bff3370b06f96122dae5e3a06390833 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sat, 4 May 2019 07:10:19 -0700 Subject: [PATCH 189/194] Document that zfPy is serial only --- docs/source/python.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/source/python.rst b/docs/source/python.rst index 778480a8d..99fd48679 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -11,8 +11,10 @@ Python Bindings and decompressing `NumPy `_ integer and floating-point arrays. The |zfpy| implementation is based on `Cython `_ and requires both NumPy and Cython -to be installed. The |zfpy| API is limited to two functions, for -compression and decompression, which are described below. +to be installed. Currently, |zfpy| supports only serial execution. + +The |zfpy| API is limited to two functions, for compression and +decompression, which are described below. Compression ----------- From 9bbbf9a1517a1364168890f59da9269dcff6d409 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sat, 4 May 2019 14:24:48 -0700 Subject: [PATCH 190/194] Bring all documentation up to date (first pass) --- VERSIONS.md | 4 +- docs/source/algorithm.rst | 29 ++++----- docs/source/arrays.rst | 6 +- docs/source/defs.rst | 2 +- docs/source/execution.rst | 25 ++++---- docs/source/faq.rst | 12 ++-- docs/source/high-level-api.rst | 12 ++-- docs/source/installation.rst | 114 +++++++++++++++++---------------- docs/source/modes.rst | 34 +++++----- docs/source/overview.rst | 42 +++++++----- docs/source/python.rst | 2 +- docs/source/versions.rst | 5 +- docs/source/views.inc | 2 +- 13 files changed, 154 insertions(+), 135 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index e0a5c1023..59dad18f9 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -1,13 +1,13 @@ # zfp Release Notes -## 0.5.5 (April ??, 2019) +## 0.5.5 (May 5, 2019) - Added support for reversible (lossless) compression of floating-point and integer data. - Added methods for serializing and deserializing zfp's compressed arrays. -- Added Python bindings for compressing numpy arrays. +- Added Python bindings for compressing NumPy arrays. - Added Fortran bindings to zfp's high-level C API. diff --git a/docs/source/algorithm.rst b/docs/source/algorithm.rst index 5c8b80f3a..a7e17ed9a 100644 --- a/docs/source/algorithm.rst +++ b/docs/source/algorithm.rst @@ -54,9 +54,9 @@ purposes): 4. The signed integer coefficients are reordered in a manner similar to JPEG zig-zag ordering so that statistically they appear in a roughly monotonically decreasing order. Coefficients corresponding to low - frequencies tend to have larger magnitude, and are listed first. In 3D, + frequencies tend to have larger magnitude and are listed first. In 3D, coefficients corresponding to frequencies *i*, *j*, *k* in the three - dimensions are ordered by *i* + *j* + *k* first, and then by + dimensions are ordered by *i* + *j* + *k* first and then by *i*\ :sup:`2` + *j*\ :sup:`2` + *k*\ :sup:`2`. 5. The two's complement signed integers are converted to their negabinary @@ -103,16 +103,16 @@ purposes): described above, which potentially results in *n* being increased. 8. The embedded coder emits one bit at a time, with each successive bit - potentially improving the quality of the reconstructed signal. The early - bits are most important and have the greatest impact on signal quality, + potentially improving the accuracy of the approximation. The early + bits are most important and have the greatest impact on accuracy, with the last few bits providing very small changes. The resulting - compressed bit stream can be truncated at any point and still allow for a - valid approximate reconstruction of the original signal. The final step - truncates the bit stream in one of three ways: to a fixed number of bits - (the fixed-rate mode); after some fixed number of bit planes have been - encoded (the fixed-precision mode); or until a lowest bit plane number - has been encoded, as expressed in relation to the common floating-point - exponent within the block (the fixed-accuracy mode). + compressed bit stream can be truncated at any point and still allow for + a valid approximate reconstruction of the original block of values. + The final step truncates the bit stream in one of three ways: to a fixed + number of bits (the fixed-rate mode); after some fixed number of bit + planes have been encoded (the fixed-precision mode); or until a lowest + bit plane number has been encoded, as expressed in relation to the common + floating-point exponent within the block (the fixed-accuracy mode). Various parameters are exposed for controlling the quality and compressed size of a block, and can be specified by the user at a very fine @@ -135,8 +135,8 @@ subtraction operations only. Finally, step 8 is modified so that no one-bits are truncated in the variable-length bit stream. However, all least significant bit planes with all-zero bits are truncated, and the number of encoded bit planes is recorded in step 7. As with lossy compression, a -floating-point block consisting of all (positive) zeros is represented as a -single bit, making it possible to efficiently encode sparse data. +floating-point block consisting of all ("positive") zeros is represented as +a single bit, making it possible to efficiently encode sparse data. If the block-floating-point transform is not lossless, then the reversible compression algorithm falls back on a simpler scheme that reinterprets @@ -146,5 +146,4 @@ algorithm proceeds from there with the modified step 3. Moreover, this conversion ensures that special values like infinities, NaNs, and negative zero are preserved. -The lossless algorithm handles integer data also, in which case step 2 -is omitted. +The lossless algorithm handles integer data also, for which step 2 is omitted. diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index b6256dd25..d530d4d40 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -130,7 +130,7 @@ Base Class are given by the header *h*. Return a pointer to the base class upon success. The optional *buffer* points to compressed data that, when passed, is copied into the array. If *buffer* is absent, the array is default - intialized with all zeroes. The optional *buffer_size_bytes* argument + initialized with all zeroes. The optional *buffer_size_bytes* argument specifies the buffer length in bytes. When passed, a comparison is made to ensure that the buffer size is at least as large as the size implied by the header. If this function fails for any reason, an @@ -200,8 +200,8 @@ and methods share obvious similarities regardless of dimensionality, only one generic description for all dimensionalities is provided. Note: In the class declarations below, the class template for the scalar -type is ommitted for readability, e.g., -:code:`class array1` is used as shorhand for +type is omitted for readability, e.g., +:code:`class array1` is used as shorthand for :code:`template class array1`. Wherever the type :code:`Scalar` appears, it refers to this template argument. diff --git a/docs/source/defs.rst b/docs/source/defs.rst index c89d458ec..2b040073a 100644 --- a/docs/source/defs.rst +++ b/docs/source/defs.rst @@ -9,7 +9,7 @@ .. |zfpy| replace:: zfPy .. |libzfp| replace:: :file:`libzfp` .. |libcfp| replace:: :file:`libcfp` -.. |libzforp| replace:: :file:`libzforp` +.. |libzforp| replace:: :file:`libzFORp` .. |zfpcmd| replace:: :program:`zfp` .. |testzfp| replace:: :program:`testzfp` .. |4powd| replace:: 4\ :sup:`d` diff --git a/docs/source/execution.rst b/docs/source/execution.rst index 1137a3ee5..d506997af 100644 --- a/docs/source/execution.rst +++ b/docs/source/execution.rst @@ -19,10 +19,11 @@ can be exploited. In principle, concurrency is limited only by the number of blocks that make up an array, though in practice each thread is responsible for compressing a *chunk* of several contiguous blocks. -Note: |zfp| parallel compression is confined to shared memory on a single -compute node or GPU. No effort is made to coordinate compression across -distributed memory on networked compute nodes, although |zfp|'s fine-grained -partitioning of arrays should facilitate distributed parallel compression. +.. note:: + |zfp| parallel compression is confined to shared memory on a single + compute node or GPU. No effort is made to coordinate compression across + distributed memory on networked compute nodes, although |zfp|'s fine-grained + partitioning of arrays should facilitate distributed parallel compression. This section describes the |zfp| parallel compression algorithm and explains how to configure |libzfp| and enable parallel compression at run time via @@ -36,9 +37,9 @@ Execution Policies |zfp| supports multiple *execution policies*, which dictate how (e.g., sequentially, in parallel) and where (e.g., on the CPU or GPU) arrays are compressed. Currently three execution policies are available: -:code:`serial`, :code:`omp`, and :code:`cuda`. The default mode is -:code:`serial`, which ensures sequential compression on a single thread. -The :code:`omp` and :code:`cuda` execution policies allow for data-parallel +``serial``, ``omp``, and ``cuda``. The default mode is +``serial``, which ensures sequential compression on a single thread. +The ``omp`` and ``cuda`` execution policies allow for data-parallel compression on multiple threads. The execution policy is set by :c:func:`zfp_stream_set_execution` and @@ -57,8 +58,8 @@ Execution Parameters Each execution policy allows tailoring the execution via its associated *execution parameters*. Examples include number of threads, chunk size, -scheduling, etc. The :code:`serial` and :code:`cuda` policies have no -parameters. The subsections below discuss the :code:`omp` parameters. +scheduling, etc. The ``serial`` and ``cuda`` policies have no +parameters. The subsections below discuss the ``omp`` parameters. Whenever the execution policy is changed via :c:func:`zfp_stream_set_execution`, its parameters (if any) are initialized @@ -72,7 +73,7 @@ By default, the number of threads to use is given by the current setting of the OpenMP internal control variable *nthreads-var*. Unless the calling thread has explicitly requested a thread count via the OpenMP API, this control variable usually defaults to the number of threads -supported by the hardware (e.g. the number of available cores). +supported by the hardware (e.g., the number of available cores). To set the number of requested threads to be used by |zfp|, which may differ from the thread count of encapsulating or surrounding OpenMP @@ -154,13 +155,13 @@ does not need temporary buffers, regardless of chunk alignment. Using OpenMP ------------ -In order to use OpenMP compression, |zfp| must be compiled with OpenMP +In order to use OpenMP compression, |zfp| must be built with OpenMP support. If built with CMake, OpenMP support is automatically enabled when available. To manually disable OpenMP support, see the :c:macro:`ZFP_WITH_OPENMP` macro. To avoid compilation errors on systems with spotty OpenMP support -(e.g. macOS), OpenMP is by default disabled in GNU builds. To enable +(e.g., macOS), OpenMP is by default disabled in GNU builds. To enable OpenMP, see :ref:`gnu_builds` and the :c:macro:`ZFP_WITH_OPENMP` macro. diff --git a/docs/source/faq.rst b/docs/source/faq.rst index c45772132..fe12b108f 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -404,10 +404,10 @@ information independently. Q15: *Must I use the same parameters during compression and decompression?* -A: Not necessarily. It is possible to use more tightly constrained -:c:type:`zfp_stream` parameters during decompression than were used during -compression. For instance, one may use a larger -:c:member:`zfp_stream.minbits`, smaller :c:member:`zfp_stream.maxbits`, +A: Not necessarily. When decompressing one block at a time, it is possible +to use more tightly constrained :c:type:`zfp_stream` parameters during +decompression than were used during compression. For instance, one may use a +larger :c:member:`zfp_stream.minbits`, smaller :c:member:`zfp_stream.maxbits`, smaller :c:member:`zfp_stream.maxprec`, or larger :c:member:`zfp_stream.minexp` during decompression to process fewer compressed bits than are stored, and to decompress the array more quickly at a lower precision. This may be useful @@ -420,7 +420,9 @@ useful when the stream is stored progressively (see :ref:`Q13 `). Note that one may not use less constrained parameters during decompression, e.g., one cannot ask for more than :c:member:`zfp_stream.maxprec` bits of -precision when decompressing. +precision when decompressing. Furthermore, the parameters must agree between +compression and decompression when calling the high-level API function +:c:func:`zfp_decompress`. Currently float arrays have a different compressed representation from compressed double arrays due to differences in exponent width. It is not diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 2416a3281..3989964db 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -81,8 +81,8 @@ Macros :c:macro:`ZFP_HEADER_META` in essence encodes the information stored in the :c:type:`zfp_field` struct, while :c:macro:`ZFP_HEADER_MODE` encodes the compression parameters stored in the :c:type:`zfp_stream` struct. - The magic can be used to uniquely identify the stream as a |zfp| stream, - and includes the CODEC version. + The magic, which includes the CODEC version, can be used to uniquely + identify the stream as a |zfp| stream. See :c:func:`zfp_read_header` and :c:func:`zfp_write_header` for how to read and write header information. @@ -125,7 +125,7 @@ Types .. c:type:: zfp_execution The :c:type:`zfp_stream` also stores information about how to execute - compression, e.g. sequentially or in parallel. The execution is determined + compression, e.g., sequentially or in parallel. The execution is determined by the policy and any policy-specific parameters such as number of threads. :: @@ -188,7 +188,7 @@ Types Enumerates the scalar types supported by the compressor, and is used to describe the uncompressed array. The compressor and decompressor must use - the same :c:type:`zfp_type`, e.g. one cannot compress doubles and decompress + the same :c:type:`zfp_type`, e.g., one cannot compress doubles and decompress to floats or integers. :: @@ -209,7 +209,7 @@ Types :: typedef struct { - zfp_type type; // scalar type (e.g. int32, double) + zfp_type type; // scalar type (e.g., int32, double) uint nx, ny, nz, nw; // sizes (zero for unused dimensions) int sx, sy, sz, sw; // strides (zero for contiguous array a[nw][nz][ny][nx]) void* data; // pointer to array data @@ -286,7 +286,7 @@ Functions .. c:function:: size_t zfp_type_size(zfp_type type) - Return byte size of the given scalar type, e.g. + Return byte size of the given scalar type, e.g., :code:`zfp_type_size(zfp_type_float) = 4`. .. _hl-func-bitstream: diff --git a/docs/source/installation.rst b/docs/source/installation.rst index f3407dbaf..3cce3575a 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -5,18 +5,16 @@ Installation ============ -|zfp| consists of three distinct parts: a compression library written in C, +|zfp| consists of four distinct parts: a compression library written in C, a set of C++ header files that implement compressed arrays and corresponding -C wrappers, and a set of C and C++ examples. The main compression codec is -written in C and should conform to both the ISO C89 and C99 standards. -The C++ array classes are implemented entirely in header files and can be -included as is, but since they call the compression library, applications -must link with |libzfp|. - -On Linux, macOS, and MinGW, |zfp| is easiest compiled using gcc and gmake. -`CMake `_ support is also available, e.g., for Windows -builds. See below for instructions on GNU and CMake builds. - +C wrappers, optional Python and Fortran bindings, and a set of C and C++ +examples and utilities. The main compression codec is written in C and +should conform to both the ISO C89 and C99 standards. The C++ array classes +are implemented entirely in header files and can be included as is, but since +they call the compression library, applications must link with |libzfp|. + +|zfp| is preferably built using `CMake `_, although the +core library can also be built using GNU make on Linux, macOS, and MinGW. |zfp| has successfully been built and tested using these compilers: * gcc versions 4.4.7, 4.7.3, 4.8.5, 4.9.4, 5.5.0, 6.1.0, 6.4.0, 7.1.0, 7.3.0, 8.1.0 @@ -28,29 +26,8 @@ builds. See below for instructions on GNU and CMake builds. |zfp| conforms to various language standards, including C89, C99, C++98, C++11, and C++14. -**NOTE: zfp requires 64-bit compiler and operating system support**. - -.. _gnu_builds: - -GNU Builds ----------- - -To compile |zfp| using `gcc `_ without -`OpenMP `_, type:: - - gmake - -from the |zfp| root directory. This builds |libzfp| as a static -library as well as utilities and example programs. To enable OpenMP -parallel compression, type:: - - gmake ZFP_WITH_OPENMP=1 - .. note:: - - GNU builds expose only limited functionality of |zfp|. For instance, - CUDA and Python support are not included. For full functionality, - build |zfp| using CMake. + |zfp| requires 64-bit compiler and operating system support. .. _cmake_builds: @@ -60,6 +37,7 @@ CMake Builds To build |zfp| using `CMake `_ on Linux or macOS, start a Unix shell and type:: + cd zfp-0.5.5 mkdir build cd build cmake .. @@ -74,9 +52,10 @@ By default, CMake builds will attempt to locate and use cmake -DZFP_WITH_OPENMP=OFF .. -To build |zfp| using Visual Studio on Windows, start a DOS shell, -cd to the top-level |zfp| directory, and type:: +To build |zfp| using Visual Studio on Windows, start a DOS shell +and type:: + cd zfp-0.5.5 mkdir build cd build cmake .. @@ -86,18 +65,41 @@ This builds |zfp| in release mode. Replace 'Release' with 'Debug' to build |zfp| in debug mode. See the instructions for Linux on how to change the cmake line to also build the example programs. + +.. _gnu_builds: + +GNU Builds +---------- + +To build |zfp| using `gcc `_ without +`OpenMP `_, type:: + + cd zfp-0.5.5 + gmake + +This builds |libzfp| as a static library as well as the |zfp| +command-line utility. To enable OpenMP parallel compression, type:: + + gmake ZFP_WITH_OPENMP=1 + +.. note:: + GNU builds expose only limited functionality of |zfp|. For instance, + CUDA and Python support are not included. For full functionality, + build |zfp| using CMake. + + Testing ------- To test that |zfp| is working properly, type:: - gmake test + ctest -or using CMake:: +or using GNU make:: - ctest + gmake test -If the compilation or regression tests fail, it is possible that some of +If the GNU build or regression tests fail, it is possible that some of the macros in the file :file:`Config` have to be adjusted. Also, the tests may fail due to minute differences in the computed floating-point fields being compressed, which will be indicated by checksum errors. If most @@ -113,16 +115,16 @@ compressor is working correctly. Build Targets ------------- -To specify which components to build, set the macros below to :code:`1` -(GNU make) or :code:`ON` (CMake), e.g., +To specify which components to build, set the macros below to +:code:`ON` (CMake) or :code:`1` (GNU make), e.g., :: - make BUILD_UTILITIES=1 BUILD_EXAMPLES=0 + cmake -DBUILD_UTILITIES=OFF -DBUILD_EXAMPLES=ON .. -or using CMake +or using GNU make :: - cmake -DBUILD_UTILITIES=ON -DBUILD_EXAMPLES=OFF .. + gmake BUILD_UTILITIES=0 BUILD_EXAMPLES=1 Regardless of the settings below, |libzfp| will always be built. @@ -141,11 +143,11 @@ Regardless of the settings below, |libzfp| will always be built. Build |zfpy| for Python bindings to the C API. - Cmake will attempt to automatically detect the Python installation to use. - If cmake finds multiple Python installations, it will use the newest one. + CMake will attempt to automatically detect the Python installation to use. + If CMake finds multiple Python installations, it will use the newest one. To specify a specific Python installation to use, set - :c:macro:`PYTHON_LIBRARY` and :c:macro:`PYTHON_INCLUDE_DIR` in the - cmake line. Putting it all together:: + :c:macro:`PYTHON_LIBRARY` and :c:macro:`PYTHON_INCLUDE_DIR` on the + cmake line:: cmake -DBUILD_ZFPY=ON -DPYTHON_LIBRARY=/path/to/lib/libpython2.7.so -DPYTHON_INCLUDE_DIR=/path/to/include/python2.7 .. @@ -154,7 +156,7 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_ZFORP - Build |libzFORp| for Fortran bindings to the C API. Requires Fortran + Build |libzforp| for Fortran bindings to the C API. Requires Fortran standard 2003 or later. GNU make users may specify the Fortran compiler to use via :: @@ -180,9 +182,9 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_SHARED_LIBS - Build shared objects (:file:`.so` or :file:`.dylib` files). + Build shared objects (:file:`.so`, :file:`.dylib`, or :file:`.dll` files). On macOS, the :code:`SOFLAGS` line in the :file:`Config` file may have - to be uncommented when compiling with GNU make. + to be uncommented when building with GNU make. CMake default: on. GNU make default: off. @@ -191,8 +193,8 @@ Regardless of the settings below, |libzfp| will always be built. single: Configuration .. _config: -Compile-Time Macros -------------------- +Configuration +------------- The behavior of |zfp| can be configured at compile time via a set of macros in the same manner that :ref:`build targets ` are specified, e.g., @@ -285,7 +287,7 @@ in the same manner that :ref:`build targets ` are specified, e.g., Macro for renaming the outermost |cfp| namespace, e.g., to avoid name clashes. - Default: cfp. + Default: :code:`cfp`. .. c:macro:: PYTHON_LIBRARY @@ -327,10 +329,10 @@ versions: * Python: Python 2.7 & Python 3.5 * Cython: 0.22 -* Numpy: 1.8.0 +* NumPy: 1.8.0 The necessary dependencies can be installed using ``pip`` and the |zfp| -:file:requirements.txt:: +:file:`requirements.txt`:: pip install -r $ZFP_ROOT/python/requirements.txt diff --git a/docs/source/modes.rst b/docs/source/modes.rst index b1d188473..72d46c802 100644 --- a/docs/source/modes.rst +++ b/docs/source/modes.rst @@ -42,7 +42,8 @@ parameters. Although most users will not directly select this mode, we discuss it first since the other modes can be expressed in terms of setting expert mode parameters. -The four parameters denote constraints that are applied to each block. +The four parameters denote constraints that are applied to each block +in the :ref:`compression algorithm `. Compression is terminated as soon as one of these constraints is not met, which has the effect of truncating the compressed bit stream that encodes the block. The four constraints are as follows: @@ -69,11 +70,11 @@ the block. The four constraints are as follows: of most significant uncompressed bits encoded per transform coefficient. It does not directly correspond to the number of uncompressed mantissa bits for the floating-point or integer values being compressed, but is closely - related. This is the parameter that specifies the precision in - :ref:`fixed-precision mode `, and it provides a - mechanism for controlling the *relative error*. Note that this parameter - selects how many bits planes to encode regardless of the magnitude of the - common floating-point exponent within the block. + :ref:`related `. This is the parameter that specifies the + precision in :ref:`fixed-precision mode `, and it + provides a mechanism for controlling the *relative error*. Note that this + parameter selects how many bits planes to encode regardless of the magnitude + of the common floating-point exponent within the block. .. c:member:: int zfp_stream.minexp @@ -85,8 +86,8 @@ the block. The four constraints are as follows: encoded is (one plus) the difference between *e* and :c:member:`zfp_stream.minexp`. As an analogy, consider representing currency in decimal. Setting :c:member:`zfp_stream.minexp` to -2 would, - if generalized to base-10, ensure that amounts are represented to cent - accuracy, i.e. in units of 10\ :sup:`-2` = $0.01. This parameter governs + if generalized to base 10, ensure that amounts are represented to cent + accuracy, i.e., in units of 10\ :sup:`-2` = $0.01. This parameter governs the *absolute error* in :ref:`fixed-accuracy mode `. Note that to achieve a certain accuracy in the decompressed values, the :c:member:`zfp_stream.minexp` value has to be conservatively lowered since @@ -106,9 +107,9 @@ allocated, one may in conjunction with other constraints set maxbits = 4^d * CHAR_BIT * sizeof(Type) -where Type is either float or double. The minbits parameter is useful only -in fixed-rate mode--when minbits = maxbits, zero-bits are padded to blocks -that compress to fewer than maxbits bits. +where Type is either float or double. The ``minbits`` parameter is useful +only in fixed-rate mode; when ``minbits`` = ``maxbits``, zero-bits are +padded to blocks that compress to fewer than ``maxbits`` bits. The effects of the above four parameters are best explained in terms of the three main compression modes supported by |zfp|, described below. @@ -148,8 +149,11 @@ the mode used in the implementation of |zfp|'s :ref:`compressed arrays `. Fixed-rate mode also ensures a predictable memory/storage footprint, but usually results in far worse accuracy per bit than the variable-rate fixed-precision and fixed-accuracy -modes. **Use fixed-rate mode only if you have to bound the compressed size -or need random access to blocks**. +modes. + +.. note:: + Use fixed-rate mode only if you have to bound the compressed size + or need random access to blocks. .. _mode-fixed-precision: .. index:: @@ -159,7 +163,7 @@ Fixed-Precision Mode -------------------- In fixed-precision mode, the number of bits used to encode a block may -vary, but the number of bit planes (i.e. the precision) encoded for the +vary, but the number of bit planes (i.e., the precision) encoded for the transform coefficients is fixed. To achieve the desired precision, use option :option:`-p` with the :ref:`zfp executable ` or call :c:func:`zfp_stream_set_precision`. In expert mode, fixed precision is @@ -194,7 +198,7 @@ value, *g*, the absolute difference \| *f* |minus| *g* \| is at most 2\ :sup:`minexp`. (Note that it is not possible to guarantee error tolerances smaller than machine epsilon relative to the largest value within a block.) This error -tolerance is not always tight (especially for 3D arrays), but can +tolerance is not always tight (especially for 3D and 4D arrays), but can conservatively be set so that even for worst-case inputs the error tolerance is respected. To achieve fixed accuracy to within 'tolerance', use option :option:`-a` with the :ref:`zfp executable ` or call diff --git a/docs/source/overview.rst b/docs/source/overview.rst index f2bd961b0..f7391cfdd 100644 --- a/docs/source/overview.rst +++ b/docs/source/overview.rst @@ -11,26 +11,33 @@ though the user may specify error tolerances to limit the amount of loss. Fully :ref:`lossless compression `, where values are represented exactly, is also possible. -The |zfp| software consists of three main components: a C library for -compressing whole arrays (or smaller pieces of arrays); C++ classes -(plus C wrappers) that implement compressed arrays; and a command-line -compression tool and other code examples. |zfp| has also been incorporated -into several independently developed plugins for interfacing |zfp| with -popular I/O libraries and visualization tools such as +The |zfp| software primarily consists of three components: a C library +for compressing whole arrays (or smaller pieces of arrays); C++ classes +that implement random-accessible compressed arrays; and a command-line +compression tool and other code examples. Additional language bindings +are also available for the first two components. + +|zfp| has also been incorporated into several independently developed +plugins for interfacing |zfp| with popular I/O libraries and visualization +tools such as `ADIOS `_, -`HDF5 `_, and -`VTK `_. +`HDF5 `_, +`Intel IPP `_, +`TTK `_, and +`VTK-m `_. The typical user will interact with |zfp| via one or more of those components, specifically * Via the :ref:`C API ` when doing I/O in an application or - otherwise performing data (de)compression online. + otherwise performing data (de)compression online. High-speed, + parallel compression is supported via OpenMP and CUDA. -* Via |zfp|'s in-memory :ref:`compressed array classes ` when +* Via |zfp|'s in-memory :ref:`compressed-array classes ` when performing computations on very large arrays that demand random access to array elements, e.g., in visualization, data analysis, or even in numerical - simulation. + simulation. These classes can often substitute C/C++ arrays and STL + vectors in applications with minimal code changes. * Via the |zfp| :ref:`command-line tool ` when compressing binary files offline. @@ -40,7 +47,10 @@ components, specifically * `ADIOS plugin `_ * `HDF5 plugin `_ + * `Intel IPP plugin `_ + * `TTK plugin `_ * `VTK plugin `_ + * `VTK-m plugin `_ In all cases, it is important to know how to use |zfp|'s :ref:`compression modes ` as well as what the @@ -67,11 +77,11 @@ in a floating-point number have less significance than the first several bits and can often be discarded (zeroed) with limited impact on accuracy. The next several sections cover information on the |zfp| algorithm and its -parameters; the C API; the compressed array classes; examples of how to -perform compression and work with the classes; how to use the binary file -compressor; and code examples that further illustrate how to use |zfp|. -The documentation concludes with frequently asked questions and -troubleshooting, as well as current limitations and future development +parameters; the C API; the compressed array classes; the Python and Fortran +APIs; examples of how to perform compression and work with the classes; how +to use the binary file compressor; and code examples that further illustrate +how to use |zfp|. The documentation concludes with frequently asked questions +and troubleshooting, as well as current limitations and future development directions. For questions not answered here, please contact diff --git a/docs/source/python.rst b/docs/source/python.rst index 99fd48679..f5d1f7c4c 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -150,6 +150,6 @@ constraint check, use :code:`out = ndarray.data` rather than .. warning:: :py:func:`_decompress` is an "experimental" function currently used internally for testing. It does allow decompression of streams without - headers, but providing too small of an output bufffer or incorrectly + headers, but providing too small of an output buffer or incorrectly specifying the shape or strides can result in segmentation faults. Use with care. diff --git a/docs/source/versions.rst b/docs/source/versions.rst index f9d7c8c0f..d8b9a4af5 100644 --- a/docs/source/versions.rst +++ b/docs/source/versions.rst @@ -3,14 +3,14 @@ Release Notes ============= -zfp 0.5.5, April ??, 2019 +zfp 0.5.5, May 5, 2019 - Added support for reversible (lossless) compression of floating-point and integer data. - Added methods for serializing and deserializing zfp's compressed arrays. - - Added Python bindings for compressing numpy arrays. + - Added Python bindings for compressing NumPy arrays. - Added Fortran bindings to zfp's high-level C API. @@ -23,6 +23,7 @@ zfp 0.5.5, April ??, 2019 - Incorrect handling of execution policy in zfp utility. - Incorrect handling of decompression via header in zfp utility. + - Incorrect cleanup of device memory in CUDA decompress. - Tests for failing mallocs. - CMake installation of CFP when built. - zfp_write_header and zfp_field_metadata now fail if array dimensions diff --git a/docs/source/views.inc b/docs/source/views.inc index 50b6d5bfb..40517bde6 100644 --- a/docs/source/views.inc +++ b/docs/source/views.inc @@ -532,7 +532,7 @@ blocks upon compression would be a potential solution, this would either serialize compression, thus hurting performance, or add a possibly large memory overhead by maintaining a lock with each block. -To avoid multiple threads simultanously compressing the same block, +To avoid multiple threads simultaneously compressing the same block, **private mutable views of an array must reference disjoint, block-aligned subarrays** for thread-safe access. Each block of |4powd| array elements must be associated with at most one private mutable view, From 89dd712dd7fc591954d2965bef941ad16c77432c Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 5 May 2019 08:28:57 -0700 Subject: [PATCH 191/194] Silence compiler warnings --- src/template/compress.c | 12 ++++++------ src/template/decompress.c | 12 ++++++------ src/template/ompcompress.c | 12 ++++++------ src/zfp.c | 6 +++--- tests/testviews.cpp | 2 ++ 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/template/compress.c b/src/template/compress.c index 037157675..3bef658df 100644 --- a/src/template/compress.c +++ b/src/template/compress.c @@ -41,7 +41,7 @@ _t2(compress_strided, Scalar, 2)(zfp_stream* stream, const zfp_field* field) uint nx = field->nx; uint ny = field->ny; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; + int sy = field->sy ? field->sy : (int)nx; uint x, y; /* compress array one block of 4x4 values at a time */ @@ -64,8 +64,8 @@ _t2(compress_strided, Scalar, 3)(zfp_stream* stream, const zfp_field* field) uint ny = field->ny; uint nz = field->nz; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : nx * ny; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); uint x, y, z; /* compress array one block of 4x4x4 values at a time */ @@ -90,9 +90,9 @@ _t2(compress_strided, Scalar, 4)(zfp_stream* stream, const zfp_field* field) uint nz = field->nz; uint nw = field->nw; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : (ptrdiff_t)nx * ny; - int sw = field->sw ? field->sw : (ptrdiff_t)nx * ny * nz; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); + int sw = field->sw ? field->sw : (int)(nx * ny * nz); uint x, y, z, w; /* compress array one block of 4x4x4x4 values at a time */ diff --git a/src/template/decompress.c b/src/template/decompress.c index 58c28132a..22313f81d 100644 --- a/src/template/decompress.c +++ b/src/template/decompress.c @@ -41,7 +41,7 @@ _t2(decompress_strided, Scalar, 2)(zfp_stream* stream, zfp_field* field) uint nx = field->nx; uint ny = field->ny; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; + int sy = field->sy ? field->sy : (int)nx; uint x, y; /* decompress array one block of 4x4 values at a time */ @@ -64,8 +64,8 @@ _t2(decompress_strided, Scalar, 3)(zfp_stream* stream, zfp_field* field) uint ny = field->ny; uint nz = field->nz; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : nx * ny; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); uint x, y, z; /* decompress array one block of 4x4x4 values at a time */ @@ -90,9 +90,9 @@ _t2(decompress_strided, Scalar, 4)(zfp_stream* stream, zfp_field* field) uint nz = field->nz; uint nw = field->nw; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : (ptrdiff_t)nx * ny; - int sw = field->sw ? field->sw : (ptrdiff_t)nx * ny * nz; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); + int sw = field->sw ? field->sw : (int)(nx * ny * nz); uint x, y, z, w; /* decompress array one block of 4x4x4x4 values at a time */ diff --git a/src/template/ompcompress.c b/src/template/ompcompress.c index c6482f4a5..b0f86d230 100644 --- a/src/template/ompcompress.c +++ b/src/template/ompcompress.c @@ -104,7 +104,7 @@ _t2(compress_strided_omp, Scalar, 2)(zfp_stream* stream, const zfp_field* field) uint nx = field->nx; uint ny = field->ny; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; + int sy = field->sy ? field->sy : (int)nx; /* number of omp threads, blocks, and chunks */ uint threads = thread_count_omp(stream); @@ -160,8 +160,8 @@ _t2(compress_strided_omp, Scalar, 3)(zfp_stream* stream, const zfp_field* field) uint ny = field->ny; uint nz = field->nz; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : (ptrdiff_t)nx * ny; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); /* number of omp threads, blocks, and chunks */ uint threads = thread_count_omp(stream); @@ -220,9 +220,9 @@ _t2(compress_strided_omp, Scalar, 4)(zfp_stream* stream, const zfp_field* field) uint nz = field->nz; uint nw = field->nw; int sx = field->sx ? field->sx : 1; - int sy = field->sy ? field->sy : nx; - int sz = field->sz ? field->sz : (ptrdiff_t)nx * ny; - int sw = field->sw ? field->sw : (ptrdiff_t)nx * ny * nz; + int sy = field->sy ? field->sy : (int)nx; + int sz = field->sz ? field->sz : (int)(nx * ny); + int sw = field->sw ? field->sw : (int)(nx * ny * nz); /* number of omp threads, blocks, and chunks */ uint threads = thread_count_omp(stream); diff --git a/src/zfp.c b/src/zfp.c index f908199b2..0d6b69549 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -221,13 +221,13 @@ zfp_field_stride(const zfp_field* field, int* stride) if (stride) switch (zfp_field_dimensionality(field)) { case 4: - stride[3] = field->sw ? field->sw : field->nx * field->ny * field->nz; + stride[3] = field->sw ? field->sw : (int)(field->nx * field->ny * field->nz); /* FALLTHROUGH */ case 3: - stride[2] = field->sz ? field->sz : field->nx * field->ny; + stride[2] = field->sz ? field->sz : (int)(field->nx * field->ny); /* FALLTHROUGH */ case 2: - stride[1] = field->sy ? field->sy : field->nx; + stride[1] = field->sy ? field->sy : (int)field->nx; /* FALLTHROUGH */ case 1: stride[0] = field->sx ? field->sx : 1; diff --git a/tests/testviews.cpp b/tests/testviews.cpp index 56e094d2b..b1dfa1d4e 100644 --- a/tests/testviews.cpp +++ b/tests/testviews.cpp @@ -47,11 +47,13 @@ int main(int argc, char* argv[]) sscanf(argv[8], "%u", &my) != 1 || sscanf(argv[9], "%u", &mz) != 1) return EXIT_FAILURE; + // FALLTHROUGH case 4: if (sscanf(argv[1], "%u", &nx) != 1 || sscanf(argv[2], "%u", &ny) != 1 || sscanf(argv[3], "%u", &nz) != 1) return EXIT_FAILURE; + // FALLTHROUGH case 1: break; } From 278ec55c48b5a1257bfa9ac099f92b7f92ac1104 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 5 May 2019 12:16:02 -0700 Subject: [PATCH 192/194] Silence copy constructor compiler warnings --- array/zfparray1.h | 3 ++- array/zfparray2.h | 3 ++- array/zfparray3.h | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/array/zfparray1.h b/array/zfparray1.h index 3080850c0..f95b430d1 100644 --- a/array/zfparray1.h +++ b/array/zfparray1.h @@ -49,7 +49,8 @@ class array1 : public array { } // copy constructor--performs a deep copy - array1(const array1& a) + array1(const array1& a) : + array() { deep_copy(a); } diff --git a/array/zfparray2.h b/array/zfparray2.h index 4ccfd0ced..73dfaa8d7 100644 --- a/array/zfparray2.h +++ b/array/zfparray2.h @@ -49,7 +49,8 @@ class array2 : public array { } // copy constructor--performs a deep copy - array2(const array2& a) + array2(const array2& a) : + array() { deep_copy(a); } diff --git a/array/zfparray3.h b/array/zfparray3.h index e8ad92528..f0f42e88e 100644 --- a/array/zfparray3.h +++ b/array/zfparray3.h @@ -49,7 +49,8 @@ class array3 : public array { } // copy constructor--performs a deep copy - array3(const array3& a) + array3(const array3& a) : + array() { deep_copy(a); } From af8e50418fc4fcea31c335adc6001f963cafad44 Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 5 May 2019 13:47:06 -0700 Subject: [PATCH 193/194] Final pass over documentation --- VERSIONS.md | 10 ++++---- docs/source/arrays.rst | 12 ++++----- docs/source/bit-stream.rst | 29 ++++++++++++---------- docs/source/caching.inc | 10 ++++---- docs/source/conf.py | 2 +- docs/source/directions.rst | 4 +-- docs/source/faq.rst | 15 ++++++++---- docs/source/high-level-api.rst | 19 +++++++------- docs/source/installation.rst | 5 ++-- docs/source/issues.rst | 19 +++++++++----- docs/source/iterators.inc | 2 +- docs/source/limitations.rst | 2 +- docs/source/low-level-api.rst | 4 +-- docs/source/pointers.inc | 6 ++--- docs/source/python.rst | 6 ++--- docs/source/references.inc | 2 +- docs/source/serialization.inc | 6 ++++- docs/source/testing.rst | 2 +- docs/source/tutorial.rst | 28 ++++++++++----------- docs/source/versions.rst | 10 ++++---- docs/source/views.inc | 45 ++++++++++++++++++---------------- docs/source/zforp.rst | 5 ++-- docs/source/zfpcmd.rst | 10 +++++--- 23 files changed, 140 insertions(+), 113 deletions(-) diff --git a/VERSIONS.md b/VERSIONS.md index 59dad18f9..2b7e0e72e 100644 --- a/VERSIONS.md +++ b/VERSIONS.md @@ -144,11 +144,11 @@ - Changed behavior of zfp\_compress and zfp\_decompress to not automatically rewind the bit stream. This makes it easier to concatenate multiple - compressed bit streams, e.g. when compressing vector fields or multiple + compressed bit streams, e.g., when compressing vector fields or multiple scalars together. - Added functions for compactly encoding the compression parameters - and field meta data, e.g. for producing self-contained compressed + and field meta data, e.g., for producing self-contained compressed streams. Also added functions for reading and writing a header containing these parameters. @@ -221,7 +221,7 @@ faster, also has some theoretical optimality properties and tends to improve rate distortion. -- Added compile-time support for parameterized transforms, e.g. to +- Added compile-time support for parameterized transforms, e.g., to support other popular transforms like DCT, HCT, and Walsh-Hadamard. - Made forward transform range preserving: (-1, 1) is mapped to (-1, 1). @@ -229,7 +229,7 @@ - Changed the order in which bits are emitted within each bit plane to be more intelligent. Group tests are now deferred until they - are needed, i.e. just before the value bits for the group being + are needed, i.e., just before the value bits for the group being tested. This improves the quality of fixed-rate encodings, but has no impact on compressed size. @@ -274,7 +274,7 @@ - The Array class functionality was expanded: * Support for accessing the compressed bit stream stored with an - array, e.g. for offline compressed storage and for initializing + array, e.g., for offline compressed storage and for initializing an already compressed array. * Functions for dynamically specifying the cache size. diff --git a/docs/source/arrays.rst b/docs/source/arrays.rst index d530d4d40..1d77eb187 100644 --- a/docs/source/arrays.rst +++ b/docs/source/arrays.rst @@ -118,9 +118,9 @@ Base Class .. cpp:function:: array::header array::get_header() const - Return a short :ref:`header
` describing the scalar type, - dimensions, and rate associated with the array. - A :cpp:class:`array::header::exception` is thrown if the header cannot + Return a short fixed-length :ref:`header
` describing the scalar + type, dimensions, and rate associated with the array. + An :cpp:class:`array::header::exception` is thrown if the header cannot describe the array. .. _array_factory: @@ -145,7 +145,7 @@ class. .. cpp:function:: size_t array::size() const - Total number of elements in array, e.g. *nx* |times| *ny* |times| *nz* for + Total number of elements in array, e.g., *nx* |times| *ny* |times| *nz* for 3D arrays. .. cpp:function:: size_t array::cache_size() const @@ -162,7 +162,7 @@ class. Decompress entire array and store at *p*, for which sufficient storage must have been allocated. The uncompressed array is assumed to be contiguous - (with default strides) and stored in the usual "row-major" order, i.e. with + (with default strides) and stored in the usual "row-major" order, i.e., with *x* varying faster than *y* and *y* varying faster than *z*. .. cpp:function:: void array::set(const Scalar* p) @@ -218,7 +218,7 @@ type is omitted for readability, e.g., :cpp:class:`array` base class. The template argument, :cpp:type:`Scalar`, specifies the floating type returned for array elements. The suffixes :code:`f` and :code:`d` can also be appended to each class to indicate float - or double type, e.g. :cpp:class:`array1f` is a synonym for + or double type, e.g., :cpp:class:`array1f` is a synonym for :cpp:class:`array1\`. .. cpp:class:: arrayANY : public array diff --git a/docs/source/bit-stream.rst b/docs/source/bit-stream.rst index 9f411022a..5e3df2ac3 100644 --- a/docs/source/bit-stream.rst +++ b/docs/source/bit-stream.rst @@ -5,7 +5,7 @@ Bit Stream API ============== -|zfp| relies on low-level functions for bit stream I/O, e.g. for +|zfp| relies on low-level functions for bit stream I/O, e.g., for reading/writing single bits or groups of bits. |zfp|'s bit streams support random access (with some caveats) and, optionally, strided access. The functions read from and write to main memory allocated @@ -18,8 +18,8 @@ word size is configured at :ref:`compile time `, and is limited to 8, 16, 32, or 64 bits. The bit stream API is publicly exposed and may be used to write additional -information such as metadata into the |zfp| compressed stream, as well as -to manipulate whole or partial bit streams. Moreover, we envision releasing +information such as metadata into the |zfp| compressed stream and to +manipulate whole or partial bit streams. Moreover, we envision releasing the bit stream functions as a separate library in the future that may be used, for example, in other compressors. @@ -44,8 +44,8 @@ compressed blocks in order to support progressive access. To enable strided access, which does carry a small performance penalty, the macro :c:macro:`BIT_STREAM_STRIDED` must be defined during compilation. -Strides are specified in terms of a *block size*--a power-of-two number -of contiguous words--and a *delta*, which specifies how many words to +Strides are specified in terms of a *block size*---a power-of-two number +of contiguous words---and a *delta*, which specifies how many words to advance the stream by to get to the next contiguous block. These bit stream blocks are entirely independent of the |4powd| blocks used for compression in |zfp|. Setting *delta* to zero ensures a non-strided, @@ -140,8 +140,7 @@ Functions .. c:function:: uint stream_write_bit(bitstream* stream, uint bit) - Write the least significant bit of *bit* to *stream*. *bit* should be - one of 0 or 1. + Write single *bit* to *stream*. *bit* must be one of 0 or 1. .. c:function:: uint64 stream_read_bits(bitstream* stream, uint n) @@ -150,7 +149,7 @@ Functions .. c:function:: uint64 stream_write_bits(bitstream* stream, uint64 value, uint n) Write 0 |leq| *n* |leq| 64 low bits of *value* to *stream*. Return any - remaining bits from *value*, i.e. *value* >> *n*. + remaining bits from *value*, i.e., *value* >> *n*. .. c:function:: size_t stream_rtell(const bitstream* stream) @@ -177,7 +176,7 @@ Functions .. c:function:: void stream_skip(bitstream* stream, uint n) - Skip over the next *n* bits, i.e. without reading them. + Skip over the next *n* bits, i.e., without reading them. .. c:function:: void stream_pad(bitstream* stream, uint n) @@ -185,11 +184,15 @@ Functions .. c:function:: size_t stream_align(bitstream* stream) - Align stream on next word boundary by skipping bits. + Align stream on next word boundary by skipping bits. No skipping is + done if the stream is already word aligned. Return the number of + skipped bits, if any. .. c:function:: size_t stream_flush(bitstream* stream) - Write out any remaining buffered bits. + Write out any remaining buffered bits. When one or more bits are + buffered, append zero-bits to the stream to align it on a word boundary. + Return the number of bits of padding, if any. .. c:function:: void stream_copy(bitstream* dst, bitstream* src, size_t n) @@ -208,5 +211,5 @@ Functions .. c:function:: int stream_set_stride(bitstream* stream, size_t block, ptrdiff_t delta) - Set block size in number of words and spacing in number of blocks for - strided access. Requires :c:macro:`BIT_STREAM_STRIDED`. + Set block size, *block*, in number of words and spacing, *delta*, in number + of blocks for strided access. Requires :c:macro:`BIT_STREAM_STRIDED`. diff --git a/docs/source/caching.inc b/docs/source/caching.inc index e3f3aa741..9243b3c5e 100644 --- a/docs/source/caching.inc +++ b/docs/source/caching.inc @@ -8,18 +8,18 @@ of at least one uncompressed block. When a block in this cache is evicted (e.g., due to a conflict), it is compressed back to permanent storage only if it was modified while stored in the cache. -The size cache to use is specified by the user, and is an important +The size cache to use is specified by the user and is an important parameter that needs careful consideration in order to balance the extra memory usage, performance, and quality (recall that data loss is incurred only when a block is evicted from the cache and compressed). Although the best choice varies from one application to another, we suggest allocating -at least two "layers" of blocks, e.g. 2 |times| (*nx* / 4) |times| (*ny* / 4) +at least two "layers" of blocks, e.g., 2 |times| (*nx* / 4) |times| (*ny* / 4) blocks for 3D arrays, for applications that stream through the array and perform stencil computations such as gathering data from neighboring elements. This allows limiting the cache misses to compulsory ones. If the *csize* parameter provided to the constructor is set to zero bytes, then a default -cache size of |sqrt|\ *n* blocks is used, where *n* is the total number of -blocks contained in the array. +cache size of at least |sqrt|\ *n* blocks is used, where *n* is the total +number of blocks contained in the array. The cache size can be set during construction, or can be set at a later time via :cpp:func:`array::set_cache_size`. Note that if *csize* = 0, then @@ -30,7 +30,7 @@ by calling :cpp:func:`array::flush_cache`. To empty the cache without compressing any cached data, call :cpp:func:`array::clear_cache`. To query the byte size of the cache, use :cpp:func:`array::cache_size`. -By default a direct-mapped cache is used with a hash function that maps +By default, a direct-mapped cache is used with a hash function that maps block indices to cache lines. A faster but more collision prone hash can be enabled by defining the preprocessor macro :c:macro:`ZFP_WITH_CACHE_FAST_HASH`. diff --git a/docs/source/conf.py b/docs/source/conf.py index a75db83c7..e36f572fe 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -146,7 +146,7 @@ # author, documentclass [howto, manual, or own class]). latex_documents = [ (master_doc, 'zfp.tex', u'zfp Documentation', - u'\shortstack{Peter Lindstrom\\\\Markus Salasoo}', 'manual'), + u'\shortstack[l]{Peter Lindstrom\\\\Markus Salasoo\\\\Matt Larsen\\\\Stephen Herbein}', 'manual'), ] diff --git a/docs/source/directions.rst b/docs/source/directions.rst index ec47c62e8..b0fe29fd5 100644 --- a/docs/source/directions.rst +++ b/docs/source/directions.rst @@ -68,9 +68,9 @@ important features, including: - **Array operations**. |zfp|'s compressed arrays currently support basic indexing and initialization, but lack array-wise operations such as arithmetic, reductions, etc. Some such operations can exploit the - higher precision (than IEEE) supported by |zfp|, as well as accelerated + higher precision (than IEEE-754) supported by |zfp|, as well as accelerated blockwise computations that need not fully decompress and convert the - |zfp| representation to IEEE. + |zfp| representation to IEEE-754. - **Language bindings**. The main compression codec is written in C89 to facilitate calls from other languages. |zfp|'s compressed arrays, on diff --git a/docs/source/faq.rst b/docs/source/faq.rst index fe12b108f..1a6214625 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -194,10 +194,12 @@ irregular the sampling is. Q6: *Does zfp handle infinities, NaNs,and subnormal floating-point numbers?* -A: Only finite, valid floating-point values are currently supported. If a -block contains a NaN or an infinity, undefined behavior is invoked due to the -C math function :c:func:`frexp` being undefined for non-numbers. Subnormal -numbers are, however, handled correctly. +A: Yes, but only in :ref:`reversible mode `. + +|zfp|'s lossy compression modes currently support only finite +floating-point values. If a block contains a NaN or an infinity, undefined +behavior is invoked due to the C math function :c:func:`frexp` being +undefined for non-numbers. Subnormal numbers are, however, handled correctly. ------------------------------------------------------------------------------- @@ -250,7 +252,10 @@ Q9: *Can I compress 32-bit integers using zfp?* I have some 32-bit integer data. Can I compress it using |zfp|'s 32-bit integer support? -A: Maybe. zfp compression of 32-bit and 64-bit integers requires that each +A: Yes, this can safely be done in :ref:`reversible mode `. + +In other (lossy) modes, the answer depends. +|zfp| compression of 32-bit and 64-bit integers requires that each integer *f* have magnitude \|\ *f*\ \| < 2\ :sup:`30` and \|\ *f*\ \| < 2\ :sup:`62`, respectively. To handle signed integers that span the entire range |minus|\ 2\ :sup:`31` |leq| x < 2\ :sup:`31`, or diff --git a/docs/source/high-level-api.rst b/docs/source/high-level-api.rst index 3989964db..1ddfca131 100644 --- a/docs/source/high-level-api.rst +++ b/docs/source/high-level-api.rst @@ -311,7 +311,7 @@ Compressed Stream .. c:function:: zfp_mode zfp_stream_compression_mode(const zfp_stream* stream) - Return compression mode associated with compression parameters. Returns + Return compression mode associated with compression parameters. Return :code:`zfp_mode_null` when compression parameters are invalid. .. c:function:: uint64 zfp_stream_mode(const zfp_stream* stream) @@ -396,7 +396,7 @@ Compression Parameters .. c:function:: zfp_mode zfp_stream_set_mode(zfp_stream* stream, uint64 mode) Set all compression parameters from compact integer representation. - See :c:func:`zfp_stream_mode` for how to encode the parameters. Returns + See :c:func:`zfp_stream_mode` for how to encode the parameters. Return the mode associated with the newly-set compression parameters. If the decoded compression parameters are invalid, they are not set and the function returns :code:`zfp_mode_null`. @@ -496,7 +496,7 @@ Array Metadata .. c:function:: uint zfp_field_precision(const zfp_field* field) - Return scalar precision in number of bits, e.g. 32 for + Return scalar precision in number of bits, e.g., 32 for :code:`zfp_type_float`. .. c:function:: uint zfp_field_dimensionality(const zfp_field* field) @@ -578,7 +578,7 @@ Array Metadata .. c:function:: int zfp_field_set_metadata(zfp_field* field, uint64 meta) Specify array scalar type and dimensions from compact 52-bit representation. - Returns nonzero upon success. See :c:func:`zfp_field_metadata` for how to + Return nonzero upon success. See :c:func:`zfp_field_metadata` for how to encode *meta*. .. _hl-func-codec: @@ -600,16 +600,17 @@ Compression and Decompression Decompress from *stream* to array described by *field* and align the stream on the next word boundary. Upon success, the nonzero return value is the same as would be returned by a corresponding :c:func:`zfp_compress` call, - i.e. the current byte offset or the number of compressed bytes consumed. + i.e., the current byte offset or the number of compressed bytes consumed. Zero is returned if decompression failed. .. _zfp-header: .. c:function:: size_t zfp_write_header(zfp_stream* stream, const zfp_field* field, uint mask) - Write an optional header to the stream that encodes compression parameters, - array metadata, etc. The header information written is determined by the - bit *mask* (see :c:macro:`macros `). The return value is - the number of bits written, or zero upon failure. See the + Write an optional variable-length header to the stream that encodes + compression parameters, array metadata, etc. The header information written + is determined by the bit *mask* (see :c:macro:`macros `). + The return value is the number of bits written, or zero upon failure. + Unlike in :c:func:`zfp_compress`, no word alignment is enforced. See the :ref:`limitations ` section for limits on the maximum array size supported by the header. diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 3cce3575a..1258bdf4b 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -18,7 +18,7 @@ core library can also be built using GNU make on Linux, macOS, and MinGW. |zfp| has successfully been built and tested using these compilers: * gcc versions 4.4.7, 4.7.3, 4.8.5, 4.9.4, 5.5.0, 6.1.0, 6.4.0, 7.1.0, 7.3.0, 8.1.0 -* icc versions 15.0.6, 16.0.4, 17.0.2, 18.0.2, 19.0.0 +* icc versions 14.0.3, 15.0.6, 16.0.4, 17.0.2, 18.0.2, 19.0.3 * clang versions 3.9.1, 4.0.0, 5.0.0, 6.0.0 * MinGW version 5.3.0 * Visual Studio versions 14 (2015), 15 (2017) @@ -177,7 +177,8 @@ Regardless of the settings below, |libzfp| will always be built. .. c:macro:: BUILD_TESTING - Build |testzfp| and (when on the develop branch) unit tests. + Build |testzfp| and (when on the GitHub + `develop branch `_) unit tests. Default: on. .. c:macro:: BUILD_SHARED_LIBS diff --git a/docs/source/issues.rst b/docs/source/issues.rst index b046d9d2b..32700abf1 100644 --- a/docs/source/issues.rst +++ b/docs/source/issues.rst @@ -44,7 +44,7 @@ images (of the same size) could be represented in C as a 3D array:: imstack[count][ny][nx] but since in this case the images are unrelated, no correlation would be -expected along the third dimension--the underlying dimensionality of the data +expected along the third dimension---the underlying dimensionality of the data is here two. In this case, the images could be compressed one at a time, or they could be compressed together by treating the array dimensions as:: @@ -364,8 +364,9 @@ metadata may be embedded in the file. P13: *Has the appropriate compression mode been set?* -|zfp| provides three different -:ref:`modes of compression ` that trade storage and accuracy. In +|zfp| provides three different lossy +:ref:`modes of compression ` that trade storage and accuracy, +plus one :ref:`lossless mode `. In fixed-rate mode, the user specifies the exact number of bits (often in increments of a fraction of a bit) of compressed storage per value (but see FAQ :ref:`#18 ` for caveats). From the user's perspective, this @@ -394,7 +395,7 @@ returned by |zfp| in its fixed-precision mode may in fact vary. In practice, the precision requested is only an upper bound, though typically at least one value within a block has the requested precision. -Finally, |zfp| supports a fixed-accuracy mode, which except in rare +|zfp| supports a fixed-accuracy mode, which except in rare circumstances (see FAQ :ref:`#17 `) ensures that the absolute error is bounded, i.e., the difference between any decompressed and original value is at most the tolerance specified by the user (but usually several @@ -402,6 +403,12 @@ times smaller). Whenever possible, we recommend using this compression mode, which depending on how easy the data is to compress results in the smallest compressed stream that respects the error tolerance. -There is also an expert mode that allows the user to combine the constraints -of fixed rate, precision, and accuracy. See the section on +As of |zfp| |revrelease|, reversible (lossless) compression is available. +The amount of lossless reduction of floating-point data is usually quite +limited, however, especially for double-precision data. Unless a bit-for-bit +exact reconstruction is needed, we strongly advocate the use of lossy +compression. + +Finally, there is also an expert mode that allows the user to combine the +constraints of fixed rate, precision, and accuracy. See the section on :ref:`compression modes ` for more details. diff --git a/docs/source/iterators.inc b/docs/source/iterators.inc index 74ddc73ef..eaadaa545 100644 --- a/docs/source/iterators.inc +++ b/docs/source/iterators.inc @@ -28,7 +28,7 @@ a whole. Note that the iterator traversal order differs in this respect from traversal by :ref:`pointers `. The order of blocks visited is row-major (as in C), and the elements -within a block are also visited in row-major order, i.e. first by *x*, +within a block are also visited in row-major order, i.e., first by *x*, then by *y*, and finally by *z*. All |4powd| values in a block are visited before moving on to the next block. diff --git a/docs/source/limitations.rst b/docs/source/limitations.rst index 88a7c3e62..3eaa0c7a9 100644 --- a/docs/source/limitations.rst +++ b/docs/source/limitations.rst @@ -58,7 +58,7 @@ that will address some of these limitations. - Complex-valued arrays are not directly supported. Real and imaginary components must be stored as separate arrays, which may result in lost - opportunities for compression, e.g. if the complex magnitude is constant + opportunities for compression, e.g., if the complex magnitude is constant and only the phase varies. - Version |omprelease| adds support for OpenMP compression. However, diff --git a/docs/source/low-level-api.rst b/docs/source/low-level-api.rst index 3f8a8230c..89f40bb79 100644 --- a/docs/source/low-level-api.rst +++ b/docs/source/low-level-api.rst @@ -9,8 +9,8 @@ The low-level C API provides functionality for compressing individual *d*-dimensional blocks of up to |4powd| values. If a block is not complete, i.e., contains fewer than |4powd| values, then |zfp|'s partial block support should be favored over padding the block with, say, zeros -or other fill values. The blocks (de)compressed need not be contiguous, -but can be gathered from or scattered to a larger array by setting +or other fill values. The blocks (de)compressed need not be contiguous +and can be gathered from or scattered to a larger array by setting appropriate strides. The following topics are available: diff --git a/docs/source/pointers.inc b/docs/source/pointers.inc index 5f6357c21..e623fe81d 100644 --- a/docs/source/pointers.inc +++ b/docs/source/pointers.inc @@ -18,7 +18,7 @@ Pointers Similar to :ref:`references `, |zfp| supports proxies for pointers to individual array elements. From the user's perspective, such -pointers behave much like regular pointers to uncompressed data, e.g. +pointers behave much like regular pointers to uncompressed data, e.g., instead of :: @@ -79,13 +79,13 @@ to the pointer being acted upon. .. cpp:function:: pointer& pointer::operator++() .. cpp:function:: pointer& pointer::operator--() - Pre increment (decrement) pointer, e.g. :code:`++p`. Return reference to + Pre increment (decrement) pointer, e.g., :code:`++p`. Return reference to the incremented (decremented) pointer. .. cpp:function:: pointer pointer::operator++(int) .. cpp:function:: pointer pointer::operator--(int) - Post increment (decrement) pointer, e.g. :code:`p++`. Return a copy of + Post increment (decrement) pointer, e.g., :code:`p++`. Return a copy of the pointer before it was incremented (decremented). .. cpp:function:: pointer pointer::operator+=(ptrdiff_t d) diff --git a/docs/source/python.rst b/docs/source/python.rst index f5d1f7c4c..92373c814 100644 --- a/docs/source/python.rst +++ b/docs/source/python.rst @@ -54,7 +54,7 @@ Using the fixed-accuracy, fixed-rate, or fixed-precision modes simply requires setting one of the *tolerance*, *rate*, or *precision* arguments, respectively. For example:: - compressed_data = zfpy.compress_numpy(my_array, tolerance=1e-4) + compressed_data = zfpy.compress_numpy(my_array, tolerance=1e-3) decompressed_array = zfpy.decompress_numpy(compressed_data) # Note the change from "equal" to "allclose" due to the lossy compression @@ -117,7 +117,7 @@ compatible shape. the stream, it will be incorrectly interpreted as compressed data). *ztype* specifies the array scalar type while *shape* specifies the array dimensions; both must be known by the caller. The compression mode is - selected by specifying one (or none) or *tolerance*, *rate*, and + selected by specifying one (or none) of *tolerance*, *rate*, and *precision*, as in :py:func:`compress_numpy`, and also must be known by the caller. If *out = None*, a new NumPy array is allocated. Otherwise, *out* specifies the NumPy array or memory buffer to decompress into. @@ -138,7 +138,7 @@ from a NumPy *dtype* (e.g., :code:`zfpy.dtype_to_ztype(array.dtype)`). If *out* is specified, the data is decompressed into the *out* buffer. *out* can be a NumPy array or a pointer to memory large enough to hold the -decompressed data. Regardless if *out* is provided or its type, +decompressed data. Regardless of the type of *out* and whether it is provided, :py:func:`_decompress` always returns a NumPy array. If *out* is not provided, then the array is allocated for the user. If *out* is provided, then the returned NumPy array is just a pointer to or wrapper around the diff --git a/docs/source/references.inc b/docs/source/references.inc index 98a18b5be..5fd0d7c1b 100644 --- a/docs/source/references.inc +++ b/docs/source/references.inc @@ -19,7 +19,7 @@ References Array :ref:`indexing operators ` must return lvalue references that alias array elements and serve as vehicles for assigning values to those elements. Unfortunately, |zfp| cannot simply return a standard C++ reference -(e.g. :code:`float&`) to an uncompressed array element since the element in +(e.g., :code:`float&`) to an uncompressed array element since the element in question may exist only in compressed form or as a transient cached entry that may be invalidated (evicted) at any point. diff --git a/docs/source/serialization.inc b/docs/source/serialization.inc index 0b06ec609..ed5f93a29 100644 --- a/docs/source/serialization.inc +++ b/docs/source/serialization.inc @@ -16,7 +16,9 @@ and a :ref:`header
` that describes the array scalar type, dimensions, and rate, obtained via :cpp:func:`array::get_header`. The user may concatenate the header and compressed data to form a fixed-rate byte stream that can be read by the |zfp| -:ref:`command-line tool `. +:ref:`command-line tool `. When serializing the array, +the user should first call :cpp:func:`array::flush_cache()` before +accessing the raw compressed data. There are two primary ways to construct a compressed-array object from compressed data: via array-specific :ref:`constructors ` @@ -60,6 +62,8 @@ Below is a simple example of serialization of a 3D compressed array of doubles (error checking has been omitted for clarity):: zfp::array3d a(nx, ny, nz, rate); + ... + a.flush_cache(); zfp::array::header h = a.get_header(); fwrite(&h, sizeof(h), 1, file); fwrite(a.compressed_data(), a.compressed_size(), 1, file); diff --git a/docs/source/testing.rst b/docs/source/testing.rst index 9ecb024eb..7d20ab767 100644 --- a/docs/source/testing.rst +++ b/docs/source/testing.rst @@ -14,5 +14,5 @@ used, the (de)compression throughput is also measured and reported in number of uncompressed bytes per second. More extensive unit and functional tests are available on the |zfp| GitHub -`develop `_ branch in the +`develop branch `_ in the :file:`tests` directory. diff --git a/docs/source/tutorial.rst b/docs/source/tutorial.rst index 04056e404..db7010b3a 100644 --- a/docs/source/tutorial.rst +++ b/docs/source/tutorial.rst @@ -55,7 +55,7 @@ type, size, and memory layout of the array:: zfp_field* field = zfp_field_3d(&a[0][0][0], type, nx, ny, nz); For single-precision data, use :code:`zfp_type_float`. As of version 0.5.1, -the the high-level API also supports integer arrays (:code:`zfp_type_int32` +the high-level API also supports integer arrays (:code:`zfp_type_int32` and :code:`zfp_type_int64`). See FAQs :ref:`#8 ` and :ref:`#9 ` regarding integer compression. @@ -100,7 +100,7 @@ are needed:: uchar* buffer = new uchar[bufsize]; Note that :c:func:`zfp_stream_maximum_size` returns the smallest buffer -size necessary to safely compress the data--the *actual* compressed size +size necessary to safely compress the data---the *actual* compressed size may be smaller. If the members of :code:`zfp` and :code:`field` are for whatever reason not initialized correctly, then :c:func:`zfp_stream_maximum_size` returns 0. @@ -139,12 +139,12 @@ location pointed to by *buffer*. To decompress the data, the field and compression parameters must be initialized with the same values as used for compression, either via -the same sequence of function calls as above, or by recording these +the same sequence of function calls as above or by recording these fields and setting them directly. Metadata such as array dimensions and compression parameters are by default not stored in the compressed stream. It is up to the caller to store this information, either separate from the compressed data, or via the :c:func:`zfp_write_header` and -:c:func:`zfp_read_header` calls, which must precede the corresponding +:c:func:`zfp_read_header` calls, which should precede the corresponding :c:func:`zfp_compress` and :c:func:`zfp_decompress` calls, respectively. These calls allow the user to specify what information to store in the header, including a 'magic' format identifier, the field type and dimensions, and the @@ -293,25 +293,25 @@ rely on addresses or references to array elements may have to be modified to use special proxy classes that implement pointers and references; see :ref:`limitations`. -|zfp| does not support special floating-point values like infinities and -NaNs, although denormalized numbers are handled correctly. Similarly, -because the compressor assumes that the array values vary smoothly, +|zfp|'s compressed arrays do not support special floating-point values like +infinities and NaNs, although subnormal numbers are handled correctly. +Similarly, because the compressor assumes that the array values vary smoothly, using finite but large values like :c:macro:`HUGE_VAL` in place of infinities is not advised, as this will introduce large errors in smaller values within the same block. Future extensions will provide support for a bit mask to mark the presence of non-values. The |zfp| C++ classes are implemented entirely as header files and make -extensive use of C++ templates to reduce code redundancy. Most classes +extensive use of C++ templates to reduce code redundancy. These classes are wrapped in the :cpp:any:`zfp` namespace. -Currently there are six array classes for 1D, 2D, and 3D arrays, each of +Currently, there are six array classes for 1D, 2D, and 3D arrays, each of which can represent single- or double-precision values. Although these arrays store values in a form different from conventional single- and double-precision floating point, the user interacts with the arrays via floats and doubles. -The description below is for 3D arrays of doubles--the necessary changes +The description below is for 3D arrays of doubles---the necessary changes for other array types should be obvious. To declare and zero initialize an array, use :: @@ -335,10 +335,10 @@ the suffix 'f' is used for floats.) .. include:: disclaimer.inc -Note that the array dimensions can be arbitrary, and need not be multiples +Note that the array dimensions can be arbitrary and need not be multiples of four (see above for a discussion of incomplete blocks). The *rate* argument specifies how many bits per value (amortized) to store in the -compressed representation. By default the block size is restricted to a +compressed representation. By default, the block size is restricted to a multiple of 64 bits, and therefore the rate argument can be specified in increments of 64 / |4powd| bits in *d* dimensions, i.e. :: @@ -507,7 +507,7 @@ uninitialized. Here is an example of initializing a 3D array:: Pointers to array elements are available via a special pointer class. Such pointers may be a useful way of passing (flattened) |zfp| arrays to functions -that expect uncompressed arrays, e.g. by using the pointer type as template +that expect uncompressed arrays, e.g., by using the pointer type as template argument. For example:: template @@ -573,7 +573,7 @@ if it was modified while stored in the cache. The size cache to use is specified by the user and is an important parameter that needs careful consideration in order to balance the extra -memory usage, performance, and quality (recall that data loss is incurred +memory usage, performance, and accuracy (recall that data loss is incurred only when a block is evicted from the cache and compressed). Although the best choice varies from one application to another, we suggest allocating at least two layers of blocks (2 |times| (*nx* / 4) |times| (*ny* / 4) diff --git a/docs/source/versions.rst b/docs/source/versions.rst index d8b9a4af5..389fd5210 100644 --- a/docs/source/versions.rst +++ b/docs/source/versions.rst @@ -151,11 +151,11 @@ zfp 0.5.0, February 29, 2016 - Changed behavior of zfp_compress and zfp_decompress to not automatically rewind the bit stream. This makes it easier to concatenate multiple - compressed bit streams, e.g. when compressing vector fields or multiple + compressed bit streams, e.g., when compressing vector fields or multiple scalars together. - Added functions for compactly encoding the compression parameters - and field meta data, e.g. for producing self-contained compressed + and field meta data, e.g., for producing self-contained compressed streams. Also added functions for reading and writing a header containing these parameters. @@ -228,7 +228,7 @@ zfp 0.3.0, March 3, 2015 faster, also has some theoretical optimality properties and tends to improve rate distortion. - - Added compile-time support for parameterized transforms, e.g. to + - Added compile-time support for parameterized transforms, e.g., to support other popular transforms like DCT, HCT, and Walsh-Hadamard. - Made forward transform range preserving: (-1, 1) is mapped to (-1, 1). @@ -236,7 +236,7 @@ zfp 0.3.0, March 3, 2015 - Changed the order in which bits are emitted within each bit plane to be more intelligent. Group tests are now deferred until they - are needed, i.e. just before the value bits for the group being + are needed, i.e., just before the value bits for the group being tested. This improves the quality of fixed-rate encodings, but has no impact on compressed size. @@ -281,7 +281,7 @@ zfp 0.2.0, December 2, 2014 - The Array class functionality was expanded: * Support for accessing the compressed bit stream stored with an - array, e.g. for offline compressed storage and for initializing + array, e.g., for offline compressed storage and for initializing an already compressed array. * Functions for dynamically specifying the cache size. diff --git a/docs/source/views.inc b/docs/source/views.inc index 40517bde6..a0e2dc962 100644 --- a/docs/source/views.inc +++ b/docs/source/views.inc @@ -30,11 +30,12 @@ array access analogous to the C/C++ nested array syntax :code:`array[i][j]`. Finally, |zfp|'s *private views* can be used to ensure thread-safe access to its compressed arrays. -Like iterators and proxy references and pointers, a view is valid only -during the lifetime of the array that it references. **No reference -counting** is done to keep the array alive. It is up to the user to -ensure that the referenced array object is valid when accessed through -a view. +.. note:: + Like iterators and proxy references and pointers, a view is valid only + during the lifetime of the array that it references. **No reference + counting** is done to keep the array alive. It is up to the user to + ensure that the referenced array object is valid when accessed through + a view. There are several types of views distinguished by these attributes: @@ -445,7 +446,7 @@ it were locked upon each and every array access, which would have a prohibitive performance cost. To ensure thread-safe access, |zfp| provides private mutable and -immutable views of arrays that maintain their own, private caches. +immutable views of arrays that maintain their own private caches. The :code:`private_const_view` immutable view provides read-only access to the underlying array. It is similar to a :ref:`const_view ` in this sense, but differs in @@ -453,11 +454,12 @@ that it maintains its own private cache rather than sharing the cache owned by the array. Multiple threads may thus access the same array in parallel through their own private views. -Private views **do not guarantee cache coherence**. If, for example, -the array is modified, then already cached data in a private view is -not automatically updated. It is up to the user to ensure cache -coherence by flushing (compressing modified blocks) or clearing -(emptying) caches when appropriate. +.. note:: + Private views **do not guarantee cache coherence**. If, for example, + the array is modified, then already cached data in a private view is + not automatically updated. It is up to the user to ensure cache + coherence by flushing (compressing modified blocks) or clearing + (emptying) caches when appropriate. The cache associated with a private view can be manipulated in the same way an array's cache can. For instance, the user may set the @@ -532,21 +534,22 @@ blocks upon compression would be a potential solution, this would either serialize compression, thus hurting performance, or add a possibly large memory overhead by maintaining a lock with each block. -To avoid multiple threads simultaneously compressing the same block, -**private mutable views of an array must reference disjoint, -block-aligned subarrays** for thread-safe access. Each block of |4powd| -array elements must be associated with at most one private mutable view, -and therefore these views must reference non-overlapping rectangular -subsets that are aligned on block boundaries, except possibly for partial -blocks on the array boundary. (Expert users may alternatively ensure -serialization of block compression calls and cache coherence in other -ways, in which case overlapping private views may be permitted.) +.. note:: + To avoid multiple threads simultaneously compressing the same block, + **private mutable views of an array must reference disjoint, + block-aligned subarrays** for thread-safe access. Each block of |4powd| + array elements must be associated with at most one private mutable view, + and therefore these views must reference non-overlapping rectangular + subsets that are aligned on block boundaries, except possibly for partial + blocks on the array boundary. (Expert users may alternatively ensure + serialization of block compression calls and cache coherence in other + ways, in which case overlapping private views may be permitted.) Aside from this requirement, the user may partition the array into disjoint views in whatever manner is suitable for the application. The :code:`private_view` API supplies a very basic partitioner to facilitate this task, but may not result in optimal partitions or -good load balancing. +good load balance. When multithreaded write access is desired, any direct accesses to the array itself (i.e., not through a view) could invoke compression. Even diff --git a/docs/source/zforp.rst b/docs/source/zforp.rst index 9aecc00a7..430dd0c69 100644 --- a/docs/source/zforp.rst +++ b/docs/source/zforp.rst @@ -21,8 +21,9 @@ In addition to the high-level C API, two essential functions from the :ref:`bit stream API ` for opening and closing bit streams are available. -See example code :file:`tests/fortran/testFortran.f` for how the -Fortran API is used to compress and decompress data. +See example code :file:`tests/fortran/testFortran.f` (on the GitHub +`develop branch `_) +for how the Fortran API is used to compress and decompress data. Types ----- diff --git a/docs/source/zfpcmd.rst b/docs/source/zfpcmd.rst index 1ec32761f..c8095f482 100644 --- a/docs/source/zfpcmd.rst +++ b/docs/source/zfpcmd.rst @@ -40,9 +40,9 @@ So, to compress a file, use :code:`-i file.in -z file.zfp`. To later decompress the file, use :code:`-z file.zfp -o file.out`. A single dash "-" can be used in place of a file name to denote standard input or output. -When reading uncompressed input, the floating-point precision (single or -double) must be specified using either :option:`-f` (float) or -:option:`-d` (double). In addition, the array dimensions must be specified +When reading uncompressed input, the scalar type must be specified using +:option:`-f` (float) or :option:`-d` (double), or using :option:`-t` +for integer-valued data. In addition, the array dimensions must be specified using :option:`-1` (for 1D arrays), :option:`-2` (for 2D arrays), :option:`-3` (for 3D arrays), or :option:`-4` (for 4D arrays). For multidimensional arrays, *x* varies faster than *y*, which in turn @@ -86,7 +86,9 @@ and :option:`-a` provide a simpler interface to setting all of the above parameters by invoking :ref:`fixed-rate ` (:option:`-r`), :ref:`-precision ` (:option:`-p`), and -:ref:`-accuracy ` (:option:`-a`). +:ref:`-accuracy ` (:option:`-a`) mode. +:ref:`Reversible mode ` for lossless compression is +specified using :option:`-R`. Usage ----- From 697dd5d96a7fef6d04e4b0fa23f109127e7c587c Mon Sep 17 00:00:00 2001 From: lindstro Date: Sun, 5 May 2019 14:17:24 -0700 Subject: [PATCH 194/194] Set release version and date --- appveyor.yml | 2 +- fortran/zfp.f | 6 +++--- src/zfp.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 0875a9778..deea4b3cc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.5.4-{build} +version: 0.5.5-{build} environment: matrix: diff --git a/fortran/zfp.f b/fortran/zfp.f index e31221294..3ce9563c7 100644 --- a/fortran/zfp.f +++ b/fortran/zfp.f @@ -48,7 +48,7 @@ module zFORp_module integer, parameter :: const_zFORp_version_major = 0 integer, parameter :: const_zFORp_version_minor = 5 - integer, parameter :: const_zFORp_version_patch = 4 + integer, parameter :: const_zFORp_version_patch = 5 integer, protected, bind(c, name="zFORp_version_major") :: zFORp_version_major integer, protected, bind(c, name="zFORp_version_minor") :: zFORp_version_minor integer, protected, bind(c, name="zFORp_version_patch") :: zFORp_version_patch @@ -60,11 +60,11 @@ module zFORp_module integer, protected, bind(c, name="zFORp_codec_version") :: zFORp_codec_version data zFORp_codec_version/const_zFORp_codec_version/ - integer, parameter :: const_zFORp_library_version = 84 ! 0x54 + integer, parameter :: const_zFORp_library_version = 85 ! 0x55 integer, protected, bind(c, name="zFORp_library_version") :: zFORp_library_version data zFORp_library_version/const_zFORp_library_version/ - character(len = 36), parameter :: zFORp_version_string = 'zfp version 0.5.4 (October 1, 2018)' + character(len = 36), parameter :: zFORp_version_string = 'zfp version 0.5.5 (May 5, 2019)' integer, parameter :: const_zFORp_min_bits = 1 integer, parameter :: const_zFORp_max_bits = 16657 diff --git a/src/zfp.c b/src/zfp.c index 0d6b69549..54a0e5f2a 100644 --- a/src/zfp.c +++ b/src/zfp.c @@ -10,7 +10,7 @@ export_ const uint zfp_codec_version = ZFP_CODEC; export_ const uint zfp_library_version = ZFP_VERSION; -export_ const char* const zfp_version_string = "zfp version " ZFP_VERSION_STRING " (October 1, 2018)"; +export_ const char* const zfp_version_string = "zfp version " ZFP_VERSION_STRING " (May 5, 2019)"; /* private functions ------------------------------------------------------- */