Skip to content

Commit

Permalink
Squashed 'src/SZ3/' changes from 4bbe9df7e..be68d645b
Browse files Browse the repository at this point in the history
be68d645b Merge pull request silx-kit#47 from robertu94/master
e308ebf85 Merge branch 'master' of github.com:szcompressor/sz3
6198db715 default initalize config
162674f87 Merge pull request silx-kit#46 from mrmbernardi/patch-1
f834756f9 Fix SZFastFrontend::size_est() returning undefined value
13e79072e config bugfix
0ac567a76 Merge pull request silx-kit#45 from szcompressor/hdf5
d6beca327 add config support to hdf5 filter
05965ac2b update 1d lorenzo fast mode
d2a03eae4 add lorenzo 1D fast mode
fa9a7f179 Merge pull request silx-kit#44 from szcompressor/namespace
2437574dc change namespace from SZ to SZ3, to avoid conflict with SZ2
3236a6eb2 Merge branch 'huffman'
5995fa9f2 update HDF5 filter
1fc15171c update HDF5 filter
aadaaeb90 change namespace from SZ to SZ3, to avoid conflict with SZ2
e1af6bea2 change namespace from SZ to SZ3, to avoid conflict with SZ2
bdc4b503b new huffman
9aee288dd Merge pull request silx-kit#43 from mrmbernardi/decompress_output
ab7896ec4 update stateNum in preprocess_encode
44839697c Decompress function returns output matching original_dtype
f420554d3 update readme
31d7cbb6a add annotation for interfaces
d0606d3ae Merge pull request silx-kit#41 from szcompressor/mdz
3443ae347 update readme
1219a336d disable SZ3_DEBUG_TIMINGS by default
09d43dee5 clear runtime output for MDZ
f051a8361 support 3D input for MDZ
89f3b7c78 bugfix in smoke test
5a1cf1aad Merge remote-tracking branch 'origin/master'
40e9b3de5 bugfix in smoke test
140e09e9c remove the print information (OpenMP threads = ), which might be annoying and seems unneeded.
1e1dc102e Merge pull request silx-kit#38 from aumuell/uint8
9b2bf8ad5 fix missing uint8_t with GCC 13
f7d865e6e Merge pull request silx-kit#37 from robertu94/hdf5_fix
73674f3db link to MPI when hdf5 is parallel
13f835d54 openmp bugfix
318fe953f openmp bugfix
612b4993d update pysz
bce7f1202 Merge pull request silx-kit#32 from exmakhina/master
62d01de0b python: load library from a sensible default path, if not provided
ce7fb031e change sprintf to snprintf
1b1abcf39 interp+lorenzo sampling bugfix
9f396935d bugfix

git-subtree-dir: src/SZ3
git-subtree-split: be68d645b2e1350adfbd61851c0886b38b876aa5
  • Loading branch information
t20100 committed Jan 18, 2024
1 parent 7f0255b commit 8ade446
Show file tree
Hide file tree
Showing 70 changed files with 2,222 additions and 1,928 deletions.
117 changes: 60 additions & 57 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
cmake_minimum_required(VERSION 3.18)
project(SZ3 VERSION 3.1.7)
project(SZ3 VERSION 3.1.8)
include(GNUInstallDirs)
include(CTest)

option(BUILD_SHARED_LIBS "build shared libraries by default" ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if (MSVC)
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif ()
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type was set. Setting build type to ${default_build_type}.")
set(CMAKE_BUILD_TYPE ${default_build_type} CACHE
STRING "Choose the type to build" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif()
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "No build type was set. Setting build type to ${default_build_type}.")
set(CMAKE_BUILD_TYPE ${default_build_type} CACHE
STRING "Choose the type to build" FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
"MinSizeRel" "RelWithDebInfo")
endif ()

find_package(PkgConfig)
find_package(OpenMP)


configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/SZ3/version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/SZ3/version.hpp)

Expand All @@ -28,80 +28,83 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
)
target_compile_features(${PROJECT_NAME}
INTERFACE cxx_std_17
)
INTERFACE cxx_std_17
)

target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
find_package(OpenMP)
if (OpenMP_FOUND)
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
endif ()

if (MSVC)
option(SZ3_USE_BUNDLED_ZSTD "prefer the bundled version of Zstd" ON)
else()
else ()
option(SZ3_USE_BUNDLED_ZSTD "prefer the bundled version of Zstd" OFF)
endif()
option(SZ3_DEBUG_TIMINGS "print debug timing information" ON)
endif ()

if(SZ3_DEBUG_TIMINGS)
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=1)
else()
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=0)
endif()
option(SZ3_DEBUG_TIMINGS "print debug timing information" OFF)
if (SZ3_DEBUG_TIMINGS)
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=1)
else ()
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=0)
endif ()

pkg_search_module(ZSTD IMPORTED_TARGET libzstd)
if(ZSTD_FOUND AND NOT SZ3_USE_BUNDLED_ZSTD)
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ZSTD)
else()
add_subdirectory(tools/zstd)
target_link_libraries(${PROJECT_NAME} INTERFACE zstd)
endif()
if (ZSTD_FOUND AND NOT SZ3_USE_BUNDLED_ZSTD)
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ZSTD)
else ()
add_subdirectory(tools/zstd)
target_link_libraries(${PROJECT_NAME} INTERFACE zstd)
endif ()

find_package(GSL)
if (GSL_FOUND)
target_compile_definitions(${PROJECT_NAME} INTERFACE -DENABLE_GSL="TRUE")
target_link_libraries(${PROJECT_NAME} INTERFACE GSL::gsl)
endif()
target_compile_definitions(${PROJECT_NAME} INTERFACE -DENABLE_GSL="TRUE")
target_link_libraries(${PROJECT_NAME} INTERFACE GSL::gsl)
endif ()

add_subdirectory(tools/sz3)
add_subdirectory(tools/sz3c)


option(BUILD_H5Z_FILTER "build the H5Z-SZ3 filter" OFF)
if(BUILD_H5Z_FILTER)
add_subdirectory(tools/H5Z-SZ3)
endif()
if (BUILD_H5Z_FILTER)
add_subdirectory(tools/H5Z-SZ3)
endif ()

option(BUILD_MDZ "build MDZ (MMD-SZ)" OFF)
if(BUILD_MDZ)
add_subdirectory(tools/mdz)
endif()
if (BUILD_MDZ)
add_subdirectory(tools/mdz)
endif ()


install(TARGETS ${PROJECT_NAME}
EXPORT SZ3Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(TARGETS ${PROJECT_NAME}
EXPORT SZ3Targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/include/SZ3/version.hpp"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SZ3/"
)
"${CMAKE_CURRENT_BINARY_DIR}/include/SZ3/version.hpp"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SZ3/"
)
install(EXPORT SZ3Targets NAMESPACE SZ3:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/SZ3Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
)
"${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
"${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
)
${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
)
#export sz3 target for external use
export(TARGETS SZ3 FILE SZ3.cmake)
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,5 @@ Version New features
* SZ 3.1.4 Support running on Windows. Please refer to https://github.com/szcompressor/SZ3/issues/5#issuecomment-1094039224 for instructions.
* SZ 3.1.5 Support HDF5 by H5Z-SZ3. Please add "-DBUILD_H5Z_FILTER=ON" to enable this function for CMake.
* SZ 3.1.6 Support C API and Python API.
* SZ 3.1.7 Initial MDZ(https://github.com/szcompressor/SZ3/tree/master/tools/mdz) support.
* SZ 3.1.7 Initial MDZ(https://github.com/szcompressor/SZ3/tree/master/tools/mdz) support.
* SZ 3.1.8 namespace changed from SZ to SZ3. H5Z-SZ3 supports configuration file now.
68 changes: 34 additions & 34 deletions include/SZ3/api/impl/SZDispatcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,43 @@
#include "SZ3/api/impl/SZLorenzoReg.hpp"
#include <cmath>


template<class T, SZ::uint N>
char *SZ_compress_dispatcher(SZ::Config &conf, T *data, size_t &outSize) {

assert(N == conf.N);
SZ::calAbsErrorBound(conf, data);

char *cmpData;
if (conf.absErrorBound == 0) {
auto zstd = SZ::Lossless_zstd();
cmpData = (char *) zstd.compress((SZ::uchar *) data, conf.num * sizeof(T), outSize);
} else if (conf.cmprAlgo == SZ::ALGO_LORENZO_REG) {
cmpData = (char *) SZ_compress_LorenzoReg<T, N>(conf, data, outSize);
} else if (conf.cmprAlgo == SZ::ALGO_INTERP) {
cmpData = (char *) SZ_compress_Interp<T, N>(conf, data, outSize);
} else if (conf.cmprAlgo == SZ::ALGO_INTERP_LORENZO) {
cmpData = (char *) SZ_compress_Interp_lorenzo<T, N>(conf, data, outSize);
namespace SZ3 {
template<class T, uint N>
char *SZ_compress_dispatcher(Config &conf, T *data, size_t &outSize) {

assert(N == conf.N);
calAbsErrorBound(conf, data);

char *cmpData;
if (conf.absErrorBound == 0) {
auto zstd = Lossless_zstd();
cmpData = (char *) zstd.compress((uchar *) data, conf.num * sizeof(T), outSize);
} else if (conf.cmprAlgo == ALGO_LORENZO_REG) {
cmpData = (char *) SZ_compress_LorenzoReg<T, N>(conf, data, outSize);
} else if (conf.cmprAlgo == ALGO_INTERP) {
cmpData = (char *) SZ_compress_Interp<T, N>(conf, data, outSize);
} else if (conf.cmprAlgo == ALGO_INTERP_LORENZO) {
cmpData = (char *) SZ_compress_Interp_lorenzo<T, N>(conf, data, outSize);
}
return cmpData;
}
return cmpData;
}


template<class T, SZ::uint N>
void SZ_decompress_dispatcher(SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
if (conf.absErrorBound == 0) {
auto zstd = SZ::Lossless_zstd();
auto zstdOut = zstd.decompress((SZ::uchar *) cmpData, cmpSize);
memcpy(decData, zstdOut, conf.num * sizeof(T));
} else if (conf.cmprAlgo == SZ::ALGO_LORENZO_REG) {
SZ_decompress_LorenzoReg<T, N>(conf, cmpData, cmpSize, decData);
} else if (conf.cmprAlgo == SZ::ALGO_INTERP) {
SZ_decompress_Interp<T, N>(conf, cmpData, cmpSize, decData);
} else {
printf("SZ_decompress_dispatcher, Method not supported\n");
exit(0);
}
template<class T, uint N>
void SZ_decompress_dispatcher(Config &conf, char *cmpData, size_t cmpSize, T *decData) {
if (conf.absErrorBound == 0) {
auto zstd = Lossless_zstd();
auto zstdOut = zstd.decompress((uchar *) cmpData, cmpSize);
memcpy(decData, zstdOut, conf.num * sizeof(T));
} else if (conf.cmprAlgo == ALGO_LORENZO_REG) {
SZ_decompress_LorenzoReg<T, N>(conf, cmpData, cmpSize, decData);
} else if (conf.cmprAlgo == ALGO_INTERP) {
SZ_decompress_Interp<T, N>(conf, cmpData, cmpSize, decData);
} else {
printf("SZ_decompress_dispatcher, Method not supported\n");
exit(0);
}

}
}

#endif
37 changes: 19 additions & 18 deletions include/SZ3/api/impl/SZImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,34 @@
#include "SZ3/api/impl/SZImplOMP.hpp"
#include <cmath>

template<class T, SZ::uint N>
char *SZ_compress_impl(SZ::Config &conf, const T *data, size_t &outSize) {
namespace SZ3 {
template<class T, uint N>
char *SZ_compress_impl(Config &conf, const T *data, size_t &outSize) {
#ifndef _OPENMP
conf.openmp=false;
conf.openmp=false;
#endif
if (conf.openmp) {
//dataCopy for openMP is handled by each thread
return SZ_compress_OMP<T, N>(conf, data, outSize);
} else {
std::vector<T> dataCopy(data, data + conf.num);
return SZ_compress_dispatcher<T, N>(conf, dataCopy.data(), outSize);
if (conf.openmp) {
//dataCopy for openMP is handled by each thread
return SZ_compress_OMP<T, N>(conf, data, outSize);
} else {
std::vector<T> dataCopy(data, data + conf.num);
return SZ_compress_dispatcher<T, N>(conf, dataCopy.data(), outSize);
}
}
}


template<class T, SZ::uint N>
void SZ_decompress_impl(SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
template<class T, uint N>
void SZ_decompress_impl(Config &conf, char *cmpData, size_t cmpSize, T *decData) {


#ifndef _OPENMP
conf.openmp=false;
conf.openmp=false;
#endif
if (conf.openmp) {
SZ_decompress_OMP<T, N>(conf, cmpData, cmpSize, decData);
} else {
SZ_decompress_dispatcher<T, N>(conf, cmpData, cmpSize, decData);
if (conf.openmp) {
SZ_decompress_OMP<T, N>(conf, cmpData, cmpSize, decData);
} else {
SZ_decompress_dispatcher<T, N>(conf, cmpData, cmpSize, decData);
}
}
}

#endif
Loading

0 comments on commit 8ade446

Please sign in to comment.