Skip to content

Commit

Permalink
Merge commit '234e2a2e008bd2b6f6e037111af510a49bb3e122' into update-sz3
Browse files Browse the repository at this point in the history
  • Loading branch information
t20100 committed Jan 19, 2024
2 parents 160f999 + 234e2a2 commit 1f0e7ed
Show file tree
Hide file tree
Showing 70 changed files with 2,222 additions and 1,928 deletions.
117 changes: 60 additions & 57 deletions src/SZ3/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 src/SZ3/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 src/SZ3/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 src/SZ3/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 1f0e7ed

Please sign in to comment.