Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BLOSC2 operator using the c-blosc-2 library. It works identical… #3374

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ endif()
include(CTest)

adios_option(Blosc "Enable support for Blosc transforms" AUTO)
adios_option(Blosc2 "Enable support for c-blosc-2 transforms" AUTO)
adios_option(BZip2 "Enable support for BZip2 transforms" AUTO)
adios_option(ZFP "Enable support for ZFP transforms" AUTO)
adios_option(SZ "Enable support for SZ transforms" AUTO)
Expand Down Expand Up @@ -224,7 +225,7 @@ endif()


set(ADIOS2_CONFIG_OPTS
BP5 DataMan DataSpaces HDF5 HDF5_VOL MHS SST CUDA Fortran MPI Python Blosc BZip2 LIBPRESSIO MGARD PNG SZ ZFP DAOS IME O_DIRECT Sodium Catalyst SysVShMem ZeroMQ Profiling Endian_Reverse
BP5 DataMan DataSpaces HDF5 HDF5_VOL MHS SST CUDA Fortran MPI Python Blosc Blosc2 BZip2 LIBPRESSIO MGARD PNG SZ ZFP DAOS IME O_DIRECT Sodium Catalyst SysVShMem ZeroMQ Profiling Endian_Reverse
)

GenerateADIOSHeaderConfig(${ADIOS2_CONFIG_OPTS})
Expand Down
10 changes: 10 additions & 0 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ if(BLOSC_FOUND)
set(ADIOS2_HAVE_Blosc TRUE)
endif()

# Blosc2
if(ADIOS2_USE_Blosc2 STREQUAL AUTO)
find_package(Blosc2 2.4)
elseif(ADIOS2_USE_Blosc2)
find_package(Blosc2 2.4 REQUIRED)
endif()
if(BLOSC2_FOUND)
set(ADIOS2_HAVE_Blosc2 TRUE)
endif()

# BZip2
if(ADIOS2_USE_BZip2 STREQUAL AUTO)
find_package(BZip2)
Expand Down
91 changes: 91 additions & 0 deletions cmake/FindBlosc2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#------------------------------------------------------------------------------#
# Distributed under the OSI-approved Apache License, Version 2.0. See
# accompanying file Copyright.txt for details.
#------------------------------------------------------------------------------#
#
# FindBLOSC22
# -----------
#
# Try to find the BLOSC2 library
#
# This module defines the following variables:
#
# BLOSC2_FOUND - System has BLOSC2
# BLOSC2_INCLUDE_DIRS - The BLOSC2 include directory
# BLOSC2_LIBRARIES - Link these to use BLOSC2
# BLOSC2_VERSION - Version of the BLOSC2 library to support
#
# and the following imported targets:
# Blosc2::Blosc2 - The core BLOSC2 library
#
# You can also set the following variable to help guide the search:
# BLOSC2_ROOT - The install prefix for BLOSC2 containing the
# include and lib folders
# Note: this can be set as a CMake variable or an
# environment variable. If specified as a CMake
# variable, it will override any setting specified
# as an environment variable.

if(NOT BLOSC2_FOUND)
if((NOT BLOSC2_ROOT) AND (DEFINED ENV{BLOSC2_ROOT}))
set(BLOSC2_ROOT "$ENV{BLOSC2_ROOT}")
endif()
if(BLOSC2_ROOT)
set(BLOSC2_INCLUDE_OPTS HINTS ${BLOSC2_ROOT}/include NO_DEFAULT_PATHS)
set(BLOSC2_LIBRARY_OPTS
HINTS ${BLOSC2_ROOT}/lib ${BLOSC2_ROOT}/lib64
NO_DEFAULT_PATHS
)
endif()
if(WIN32) # uses a Unix-like library prefix on Windows
set(BLOSC2_LIBRARY_OPTS
libblosc2 ${BLOSC2_LIBRARY_OPTS}
)
endif()

find_path(BLOSC2_INCLUDE_DIR blosc2.h ${BLOSC2_INCLUDE_OPTS})
find_library(BLOSC2_LIBRARY NAMES blosc2 ${BLOSC2_LIBRARY_OPTS})
if(BLOSC2_INCLUDE_DIR)
file(STRINGS ${BLOSC2_INCLUDE_DIR}/blosc2.h _ver_string
REGEX [=[BLOSC2_VERSION_STRING +"[^"]*"]=]
)
if(_ver_string MATCHES [=[BLOSC2_VERSION_STRING +"([0-9]+.[0-9]+.[0-9]+)]=])
set(BLOSC2_VERSION ${CMAKE_MATCH_1})
endif()
endif()

# Blosc2 depends on pthreads
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
if(WIN32)
# try to use the system library
find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "Blosc2: used the internal pthread library for win32 systems.")
set(BLOSC2_LIBRARIES)
else()
set(BLOSC2_LIBRARIES Threads::Threads)
endif()
else()
find_package(Threads REQUIRED)
set(BLOSC2_LIBRARIES Threads::Threads)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Blosc2
FOUND_VAR BLOSC2_FOUND
VERSION_VAR BLOSC2_VERSION
REQUIRED_VARS BLOSC2_LIBRARY BLOSC2_INCLUDE_DIR
)
if(BLOSC2_FOUND)
set(BLOSC2_INCLUDE_DIRS ${BLOSC2_INCLUDE_DIR})
set(BLOSC2_LIBRARIES ${BLOSC2_LIBRARY})
if(BLOSC2_FOUND AND NOT TARGET Blosc2::Blosc2)
add_library(Blosc2::Blosc2 UNKNOWN IMPORTED)
set_target_properties(Blosc2::Blosc2 PROPERTIES
IMPORTED_LOCATION "${BLOSC2_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${BLOSC2_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${BLOSC2_LIBRARIES}"
)
endif()
endif()
endif()
5 changes: 5 additions & 0 deletions cmake/adios2-config-common.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ if(NOT @BUILD_SHARED_LIBS@)
find_dependency(Blosc)
endif()

set(ADIOS2_HAVE_Blosc2 @ADIOS2_HAVE_Blosc2@)
if(ADIOS2_HAVE_Blosc2)
find_dependency(Blosc2)
endif()

set(ADIOS2_HAVE_BZip2 @ADIOS2_HAVE_BZip2@)
if(ADIOS2_HAVE_BZip2)
find_dependency(BZip2)
Expand Down
5 changes: 5 additions & 0 deletions source/adios2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ if(ADIOS2_HAVE_Blosc)
target_link_libraries(adios2_core PRIVATE Blosc::Blosc)
endif()

if(ADIOS2_HAVE_Blosc2)
target_sources(adios2_core PRIVATE operator/compress/CompressBlosc2.cpp)
target_link_libraries(adios2_core PRIVATE Blosc2::Blosc2)
endif()

if(ADIOS2_HAVE_BZip2)
target_sources(adios2_core PRIVATE operator/compress/CompressBZIP2.cpp)
target_link_libraries(adios2_core PRIVATE BZip2::BZip2)
Expand Down
48 changes: 48 additions & 0 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,54 @@ constexpr char doshuffle_bitshuffle[] = "BLOSC_BITSHUFFLE";

#endif

// Blosc2 PARAMETERS
#ifdef ADIOS2_HAVE_BLOSC2

constexpr char LosslessBlosc2[] = "blosc2";
namespace blosc2
{

namespace key
{
constexpr char nthreads[] = "nthreads";
constexpr char compressor[] = "compressor";
constexpr char clevel[] = "clevel";
constexpr char doshuffle[] = "doshuffle";
constexpr char blocksize[] = "blocksize";
constexpr char threshold[] = "threshold";
}

namespace value
{

constexpr char compressor_blosclz[] = "blosclz";
constexpr char compressor_lz4[] = "lz4";
constexpr char compressor_lz4hc[] = "lz4hc";
constexpr char compressor_snappy[] = "snappy";
constexpr char compressor_zlib[] = "zlib";
constexpr char compressor_zstd[] = "zstd";

constexpr char clevel_0[] = "0";
constexpr char clevel_1[] = "1";
constexpr char clevel_2[] = "2";
constexpr char clevel_3[] = "3";
constexpr char clevel_4[] = "4";
constexpr char clevel_5[] = "5";
constexpr char clevel_6[] = "6";
constexpr char clevel_7[] = "7";
constexpr char clevel_8[] = "8";
constexpr char clevel_9[] = "9";

constexpr char doshuffle_shuffle[] = "BLOSC_SHUFFLE";
constexpr char doshuffle_noshuffle[] = "BLOSC_NOSHUFFLE";
constexpr char doshuffle_bitshuffle[] = "BLOSC_BITSHUFFLE";

} // end namespace value

} // end namespace blosc2

#endif

} // end namespace ops

} // end namespace adios2
Expand Down
1 change: 1 addition & 0 deletions source/adios2/core/Operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class Operator
COMPRESS_SZ = 6,
COMPRESS_ZFP = 7,
COMPRESS_MGARDPLUS = 8,
COMPRESS_BLOSC2 = 9,
CALLBACK_SIGNATURE1 = 51,
CALLBACK_SIGNATURE2 = 52,
PLUGIN_INTERFACE = 53,
Expand Down
12 changes: 12 additions & 0 deletions source/adios2/operator/OperatorFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
#include "adios2/operator/compress/CompressBlosc.h"
#endif

#ifdef ADIOS2_HAVE_BLOSC2
#include "adios2/operator/compress/CompressBlosc2.h"
#endif

#ifdef ADIOS2_HAVE_BZIP2
#include "adios2/operator/compress/CompressBZIP2.h"
#endif
Expand Down Expand Up @@ -76,6 +80,8 @@ std::string OperatorTypeToString(const Operator::OperatorType type)
return "zfp";
case Operator::PLUGIN_INTERFACE:
return "plugin";
case Operator::COMPRESS_BLOSC2:
return "blosc2";
default:
return "null";
}
Expand Down Expand Up @@ -146,6 +152,12 @@ std::shared_ptr<Operator> MakeOperator(const std::string &type,
{
ret = std::make_shared<plugin::PluginOperator>(parameters);
}
else if (typeLowerCase == "blosc2")
{
#ifdef ADIOS2_HAVE_BLOSC2
ret = std::make_shared<compress::CompressBlosc2>(parameters);
#endif
}
else if (typeLowerCase == "null")
{
ret = std::make_shared<compress::CompressNull>(parameters);
Expand Down
Loading