Skip to content

Commit

Permalink
zfp: fix version compatibility for 1.0+
Browse files Browse the repository at this point in the history
Allow cmake to find zfp >= 1.0.  Also adjusts the minimum requirement to
0.5.3 for execution policy selection
  • Loading branch information
chuckatkins committed Aug 14, 2022
1 parent b3c3fa2 commit 6a77ff1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
13 changes: 9 additions & 4 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ if(BZIP2_FOUND)
endif()

# ZFP
if(ADIOS2_USE_ZFP STREQUAL AUTO)
find_package(ZFP 0.5.1 CONFIG)
elseif(ADIOS2_USE_ZFP)
find_package(ZFP 0.5.1 REQUIRED CONFIG)
if(ADIOS2_USE_ZFP)
find_package(ZFP 1.0.0 CONFIG)
if(NOT ZFP_FOUND)
if(ADIOS2_USE_ZFP STREQUAL AUTO)
find_package(ZFP 0.5.3 CONFIG)
else()
find_package(ZFP 0.5.3 REQUIRED CONFIG)
endif()
endif()
endif()
if(ZFP_FOUND)
set(ADIOS2_HAVE_ZFP TRUE)
Expand Down
12 changes: 3 additions & 9 deletions source/adios2/operator/compress/CompressZFP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,14 @@
#include <sstream>
#include <zfp.h>

/* CMake will make sure zfp >= 5.0.1 */
#if ZFP_VERSION_RELEASE > 1 && !defined(ZFP_DEFAULT_EXECUTION_POLICY)

/* ZFP will default to SERIAL if CUDA is not available */
/* CMake will make sure zfp >= 0.5.3
ZFP will default to SERIAL if CUDA is not available */
#ifdef ADIOS2_HAVE_ZFP_CUDA
#define ZFP_DEFAULT_EXECUTION_POLICY zfp_exec_cuda
#else
#define ZFP_DEFAULT_EXECUTION_POLICY zfp_exec_serial
#endif

#endif

namespace adios2
{
namespace core
Expand Down Expand Up @@ -80,7 +76,7 @@ size_t CompressZFP::Operate(const char *dataIn, const Dims &blockStart,
PutParameter(bufferOut, bufferOutOffset,
static_cast<uint8_t>(ZFP_VERSION_MINOR));
PutParameter(bufferOut, bufferOutOffset,
static_cast<uint8_t>(ZFP_VERSION_RELEASE));
static_cast<uint8_t>(ZFP_VERSION_PATCH));
PutParameters(bufferOut, bufferOutOffset, m_Parameters);
// zfp V1 metadata end

Expand Down Expand Up @@ -302,7 +298,6 @@ zfp_stream *GetZFPStream(const Dims &dimensions, DataType type,
auto itPrecision = parameters.find("precision");
const bool hasPrecision = itPrecision != parameters.end();

#if ZFP_VERSION_RELEASE > 1
auto itBackend = parameters.find("backend");
const bool hasBackend = itBackend != parameters.end();

Expand Down Expand Up @@ -332,7 +327,6 @@ zfp_stream *GetZFPStream(const Dims &dimensions, DataType type,

zfp_stream_set_execution(stream, policy);
}
#endif

if ((hasAccuracy && hasPrecision) || (hasAccuracy && hasRate) ||
(hasPrecision && hasRate) ||
Expand Down

0 comments on commit 6a77ff1

Please sign in to comment.