From 75c906dda2373265b43a1cef3589005d100f1042 Mon Sep 17 00:00:00 2001 From: Kai Zhao Date: Fri, 16 Aug 2024 09:01:10 -0400 Subject: [PATCH] update compress api --- include/SZ3/api/impl/SZAlgoInterp.hpp | 2 +- include/SZ3/lossless/Lossless_zstd.hpp | 8 ++++---- tools/H5Z-SZ3/src/H5Z_SZ3.cpp | 8 ++++---- tools/H5Z-SZ3/test/dsz3FromHDF5.cpp | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/SZ3/api/impl/SZAlgoInterp.hpp b/include/SZ3/api/impl/SZAlgoInterp.hpp index 41381715..4ef42284 100644 --- a/include/SZ3/api/impl/SZAlgoInterp.hpp +++ b/include/SZ3/api/impl/SZAlgoInterp.hpp @@ -59,7 +59,7 @@ namespace SZ3 { HuffmanEncoder(), Lossless_zstd()); - std::vector buffer(num * 2); + std::vector buffer(num * sizeof(T)); size_t outSize = sz.compress(conf, data1.data(), buffer.data(), buffer.size()); // delete[]cmpData; auto compression_ratio = num * sizeof(T) * 1.0 / outSize; diff --git a/include/SZ3/lossless/Lossless_zstd.hpp b/include/SZ3/lossless/Lossless_zstd.hpp index 046962e4..482035c1 100644 --- a/include/SZ3/lossless/Lossless_zstd.hpp +++ b/include/SZ3/lossless/Lossless_zstd.hpp @@ -24,10 +24,10 @@ namespace SZ3 { // uchar *compressBytes = new uchar[estimatedCompressedSize]; // uchar *dstPos = dst; // write(srcLen, dstPos); - if (dstCap < srcLen) { - throw std::invalid_argument( - "dstCap not large enough for zstd"); - } +// if (dstCap < srcLen) { +// throw std::invalid_argument( +// "dstCap not large enough for zstd"); +// } return ZSTD_compress(dst, dstCap, src, srcLen, compression_level); // dstLen += sizeof(size_t); // return compressBytes; diff --git a/tools/H5Z-SZ3/src/H5Z_SZ3.cpp b/tools/H5Z-SZ3/src/H5Z_SZ3.cpp index c9452b5e..9a28a134 100644 --- a/tools/H5Z-SZ3/src/H5Z_SZ3.cpp +++ b/tools/H5Z-SZ3/src/H5Z_SZ3.cpp @@ -154,11 +154,11 @@ void process_data(SZ3::Config &conf, void **buf, size_t *buf_size, size_t nbytes *buf = processedData; *buf_size = conf.num * sizeof(T); } else { - size_t outSize = 0; - char *processedData = SZ_compress(conf, (T *) *buf, outSize); + size_t cmpCap = sizeof(T) * conf.num; + char *cmpData = (char *) malloc(cmpCap); + *buf_size = SZ_compress(conf, (T *) *buf, cmpData, cmpCap); free(*buf); - *buf = processedData; - *buf_size = outSize; + *buf = cmpData; } } diff --git a/tools/H5Z-SZ3/test/dsz3FromHDF5.cpp b/tools/H5Z-SZ3/test/dsz3FromHDF5.cpp index f93aa6ba..ab046e82 100644 --- a/tools/H5Z-SZ3/test/dsz3FromHDF5.cpp +++ b/tools/H5Z-SZ3/test/dsz3FromHDF5.cpp @@ -206,7 +206,7 @@ int main(int argc, char *argv[]) { int i; printf("reconstructed data = "); for (i = 0; i < 20; i++) - printf("%ld ", data[i]); + printf("%llu ", data[i]); printf("\n"); free(data); } @@ -260,7 +260,7 @@ int main(int argc, char *argv[]) { int i; printf("reconstructed data = "); for (i = 0; i < 20; i++) - printf("%ld ", data[i]); + printf("%lld ", data[i]); printf("\n"); free(data); }