Skip to content

Commit 1f0e7ed

Browse files
committed
Merge commit '234e2a2e008bd2b6f6e037111af510a49bb3e122' into update-sz3
2 parents 160f999 + 234e2a2 commit 1f0e7ed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+2222
-1928
lines changed

src/SZ3/CMakeLists.txt

+60-57
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
cmake_minimum_required(VERSION 3.18)
2-
project(SZ3 VERSION 3.1.7)
2+
project(SZ3 VERSION 3.1.8)
33
include(GNUInstallDirs)
44
include(CTest)
55

66
option(BUILD_SHARED_LIBS "build shared libraries by default" ON)
77
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
88
if (MSVC)
9-
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
10-
endif()
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
10+
endif ()
1111
set(default_build_type "Release")
12-
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
13-
message(STATUS "No build type was set. Setting build type to ${default_build_type}.")
14-
set(CMAKE_BUILD_TYPE ${default_build_type} CACHE
15-
STRING "Choose the type to build" FORCE)
16-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
17-
"MinSizeRel" "RelWithDebInfo")
18-
endif()
12+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
13+
message(STATUS "No build type was set. Setting build type to ${default_build_type}.")
14+
set(CMAKE_BUILD_TYPE ${default_build_type} CACHE
15+
STRING "Choose the type to build" FORCE)
16+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
17+
"MinSizeRel" "RelWithDebInfo")
18+
endif ()
1919

2020
find_package(PkgConfig)
21-
find_package(OpenMP)
21+
2222

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

@@ -28,80 +28,83 @@ target_include_directories(
2828
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
2929
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
3030
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
31-
)
31+
)
3232
target_compile_features(${PROJECT_NAME}
33-
INTERFACE cxx_std_17
34-
)
33+
INTERFACE cxx_std_17
34+
)
3535

36-
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
36+
find_package(OpenMP)
37+
if (OpenMP_FOUND)
38+
target_link_libraries(${PROJECT_NAME} INTERFACE OpenMP::OpenMP_CXX)
39+
endif ()
3740

3841
if (MSVC)
3942
option(SZ3_USE_BUNDLED_ZSTD "prefer the bundled version of Zstd" ON)
40-
else()
43+
else ()
4144
option(SZ3_USE_BUNDLED_ZSTD "prefer the bundled version of Zstd" OFF)
42-
endif()
43-
option(SZ3_DEBUG_TIMINGS "print debug timing information" ON)
45+
endif ()
4446

45-
if(SZ3_DEBUG_TIMINGS)
46-
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=1)
47-
else()
48-
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=0)
49-
endif()
47+
option(SZ3_DEBUG_TIMINGS "print debug timing information" OFF)
48+
if (SZ3_DEBUG_TIMINGS)
49+
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=1)
50+
else ()
51+
target_compile_definitions(${PROJECT_NAME} INTERFACE SZ3_DEBUG_TIMINGS=0)
52+
endif ()
5053

5154
pkg_search_module(ZSTD IMPORTED_TARGET libzstd)
52-
if(ZSTD_FOUND AND NOT SZ3_USE_BUNDLED_ZSTD)
53-
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ZSTD)
54-
else()
55-
add_subdirectory(tools/zstd)
56-
target_link_libraries(${PROJECT_NAME} INTERFACE zstd)
57-
endif()
55+
if (ZSTD_FOUND AND NOT SZ3_USE_BUNDLED_ZSTD)
56+
target_link_libraries(${PROJECT_NAME} INTERFACE PkgConfig::ZSTD)
57+
else ()
58+
add_subdirectory(tools/zstd)
59+
target_link_libraries(${PROJECT_NAME} INTERFACE zstd)
60+
endif ()
5861

5962
find_package(GSL)
6063
if (GSL_FOUND)
61-
target_compile_definitions(${PROJECT_NAME} INTERFACE -DENABLE_GSL="TRUE")
62-
target_link_libraries(${PROJECT_NAME} INTERFACE GSL::gsl)
63-
endif()
64+
target_compile_definitions(${PROJECT_NAME} INTERFACE -DENABLE_GSL="TRUE")
65+
target_link_libraries(${PROJECT_NAME} INTERFACE GSL::gsl)
66+
endif ()
6467

6568
add_subdirectory(tools/sz3)
6669
add_subdirectory(tools/sz3c)
6770

6871

6972
option(BUILD_H5Z_FILTER "build the H5Z-SZ3 filter" OFF)
70-
if(BUILD_H5Z_FILTER)
71-
add_subdirectory(tools/H5Z-SZ3)
72-
endif()
73+
if (BUILD_H5Z_FILTER)
74+
add_subdirectory(tools/H5Z-SZ3)
75+
endif ()
7376

7477
option(BUILD_MDZ "build MDZ (MMD-SZ)" OFF)
75-
if(BUILD_MDZ)
76-
add_subdirectory(tools/mdz)
77-
endif()
78+
if (BUILD_MDZ)
79+
add_subdirectory(tools/mdz)
80+
endif ()
7881

7982

80-
install(TARGETS ${PROJECT_NAME}
81-
EXPORT SZ3Targets
82-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
83-
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
84-
)
83+
install(TARGETS ${PROJECT_NAME}
84+
EXPORT SZ3Targets
85+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
86+
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
87+
)
8588
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
8689
install(FILES
87-
"${CMAKE_CURRENT_BINARY_DIR}/include/SZ3/version.hpp"
88-
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SZ3/"
89-
)
90+
"${CMAKE_CURRENT_BINARY_DIR}/include/SZ3/version.hpp"
91+
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/SZ3/"
92+
)
9093
install(EXPORT SZ3Targets NAMESPACE SZ3:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3)
9194
include(CMakePackageConfigHelpers)
9295
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/SZ3Config.cmake.in
93-
"${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake"
94-
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
95-
)
96+
"${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake"
97+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
98+
)
9699
write_basic_package_version_file(
97-
"${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake"
98-
VERSION ${PROJECT_VERSION}
99-
COMPATIBILITY AnyNewerVersion
100-
)
100+
"${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake"
101+
VERSION ${PROJECT_VERSION}
102+
COMPATIBILITY AnyNewerVersion
103+
)
101104
install(FILES
102-
${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake
103-
${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake
104-
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
105-
)
105+
${CMAKE_CURRENT_BINARY_DIR}/SZ3Config.cmake
106+
${CMAKE_CURRENT_BINARY_DIR}/SZ3ConfigVersion.cmake
107+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SZ3
108+
)
106109
#export sz3 target for external use
107110
export(TARGETS SZ3 FILE SZ3.cmake)

src/SZ3/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,5 @@ Version New features
125125
* SZ 3.1.4 Support running on Windows. Please refer to https://github.com/szcompressor/SZ3/issues/5#issuecomment-1094039224 for instructions.
126126
* SZ 3.1.5 Support HDF5 by H5Z-SZ3. Please add "-DBUILD_H5Z_FILTER=ON" to enable this function for CMake.
127127
* SZ 3.1.6 Support C API and Python API.
128-
* SZ 3.1.7 Initial MDZ(https://github.com/szcompressor/SZ3/tree/master/tools/mdz) support.
128+
* SZ 3.1.7 Initial MDZ(https://github.com/szcompressor/SZ3/tree/master/tools/mdz) support.
129+
* SZ 3.1.8 namespace changed from SZ to SZ3. H5Z-SZ3 supports configuration file now.

src/SZ3/include/SZ3/api/impl/SZDispatcher.hpp

+34-34
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,43 @@
88
#include "SZ3/api/impl/SZLorenzoReg.hpp"
99
#include <cmath>
1010

11-
12-
template<class T, SZ::uint N>
13-
char *SZ_compress_dispatcher(SZ::Config &conf, T *data, size_t &outSize) {
14-
15-
assert(N == conf.N);
16-
SZ::calAbsErrorBound(conf, data);
17-
18-
char *cmpData;
19-
if (conf.absErrorBound == 0) {
20-
auto zstd = SZ::Lossless_zstd();
21-
cmpData = (char *) zstd.compress((SZ::uchar *) data, conf.num * sizeof(T), outSize);
22-
} else if (conf.cmprAlgo == SZ::ALGO_LORENZO_REG) {
23-
cmpData = (char *) SZ_compress_LorenzoReg<T, N>(conf, data, outSize);
24-
} else if (conf.cmprAlgo == SZ::ALGO_INTERP) {
25-
cmpData = (char *) SZ_compress_Interp<T, N>(conf, data, outSize);
26-
} else if (conf.cmprAlgo == SZ::ALGO_INTERP_LORENZO) {
27-
cmpData = (char *) SZ_compress_Interp_lorenzo<T, N>(conf, data, outSize);
11+
namespace SZ3 {
12+
template<class T, uint N>
13+
char *SZ_compress_dispatcher(Config &conf, T *data, size_t &outSize) {
14+
15+
assert(N == conf.N);
16+
calAbsErrorBound(conf, data);
17+
18+
char *cmpData;
19+
if (conf.absErrorBound == 0) {
20+
auto zstd = Lossless_zstd();
21+
cmpData = (char *) zstd.compress((uchar *) data, conf.num * sizeof(T), outSize);
22+
} else if (conf.cmprAlgo == ALGO_LORENZO_REG) {
23+
cmpData = (char *) SZ_compress_LorenzoReg<T, N>(conf, data, outSize);
24+
} else if (conf.cmprAlgo == ALGO_INTERP) {
25+
cmpData = (char *) SZ_compress_Interp<T, N>(conf, data, outSize);
26+
} else if (conf.cmprAlgo == ALGO_INTERP_LORENZO) {
27+
cmpData = (char *) SZ_compress_Interp_lorenzo<T, N>(conf, data, outSize);
28+
}
29+
return cmpData;
2830
}
29-
return cmpData;
30-
}
3131

3232

33-
template<class T, SZ::uint N>
34-
void SZ_decompress_dispatcher(SZ::Config &conf, char *cmpData, size_t cmpSize, T *decData) {
35-
if (conf.absErrorBound == 0) {
36-
auto zstd = SZ::Lossless_zstd();
37-
auto zstdOut = zstd.decompress((SZ::uchar *) cmpData, cmpSize);
38-
memcpy(decData, zstdOut, conf.num * sizeof(T));
39-
} else if (conf.cmprAlgo == SZ::ALGO_LORENZO_REG) {
40-
SZ_decompress_LorenzoReg<T, N>(conf, cmpData, cmpSize, decData);
41-
} else if (conf.cmprAlgo == SZ::ALGO_INTERP) {
42-
SZ_decompress_Interp<T, N>(conf, cmpData, cmpSize, decData);
43-
} else {
44-
printf("SZ_decompress_dispatcher, Method not supported\n");
45-
exit(0);
46-
}
33+
template<class T, uint N>
34+
void SZ_decompress_dispatcher(Config &conf, char *cmpData, size_t cmpSize, T *decData) {
35+
if (conf.absErrorBound == 0) {
36+
auto zstd = Lossless_zstd();
37+
auto zstdOut = zstd.decompress((uchar *) cmpData, cmpSize);
38+
memcpy(decData, zstdOut, conf.num * sizeof(T));
39+
} else if (conf.cmprAlgo == ALGO_LORENZO_REG) {
40+
SZ_decompress_LorenzoReg<T, N>(conf, cmpData, cmpSize, decData);
41+
} else if (conf.cmprAlgo == ALGO_INTERP) {
42+
SZ_decompress_Interp<T, N>(conf, cmpData, cmpSize, decData);
43+
} else {
44+
printf("SZ_decompress_dispatcher, Method not supported\n");
45+
exit(0);
46+
}
4747

48+
}
4849
}
49-
5050
#endif

src/SZ3/include/SZ3/api/impl/SZImpl.hpp

+19-18
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,34 @@
66
#include "SZ3/api/impl/SZImplOMP.hpp"
77
#include <cmath>
88

9-
template<class T, SZ::uint N>
10-
char *SZ_compress_impl(SZ::Config &conf, const T *data, size_t &outSize) {
9+
namespace SZ3 {
10+
template<class T, uint N>
11+
char *SZ_compress_impl(Config &conf, const T *data, size_t &outSize) {
1112
#ifndef _OPENMP
12-
conf.openmp=false;
13+
conf.openmp=false;
1314
#endif
14-
if (conf.openmp) {
15-
//dataCopy for openMP is handled by each thread
16-
return SZ_compress_OMP<T, N>(conf, data, outSize);
17-
} else {
18-
std::vector<T> dataCopy(data, data + conf.num);
19-
return SZ_compress_dispatcher<T, N>(conf, dataCopy.data(), outSize);
15+
if (conf.openmp) {
16+
//dataCopy for openMP is handled by each thread
17+
return SZ_compress_OMP<T, N>(conf, data, outSize);
18+
} else {
19+
std::vector<T> dataCopy(data, data + conf.num);
20+
return SZ_compress_dispatcher<T, N>(conf, dataCopy.data(), outSize);
21+
}
2022
}
21-
}
2223

2324

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

2728

2829
#ifndef _OPENMP
29-
conf.openmp=false;
30+
conf.openmp=false;
3031
#endif
31-
if (conf.openmp) {
32-
SZ_decompress_OMP<T, N>(conf, cmpData, cmpSize, decData);
33-
} else {
34-
SZ_decompress_dispatcher<T, N>(conf, cmpData, cmpSize, decData);
32+
if (conf.openmp) {
33+
SZ_decompress_OMP<T, N>(conf, cmpData, cmpSize, decData);
34+
} else {
35+
SZ_decompress_dispatcher<T, N>(conf, cmpData, cmpSize, decData);
36+
}
3537
}
3638
}
37-
3839
#endif

0 commit comments

Comments
 (0)