Skip to content

Commit

Permalink
CMAKE: add check for ZFP_CUDA
Browse files Browse the repository at this point in the history
  • Loading branch information
vicentebolea committed Oct 29, 2021
1 parent 35c3f19 commit d0fbb7f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
24 changes: 24 additions & 0 deletions cmake/DetectOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,30 @@ elseif(ADIOS2_USE_ZFP)
endif()
if(ZFP_FOUND)
set(ADIOS2_HAVE_ZFP TRUE)
set(ADIOS2_HAVE_ZFP_CUDA ${ZFP_CUDA})

# Older versions of ZFP
if(NOT ADIOS2_HAVE_ZFP_CUDA)
get_target_property(ZFP_INCLUDE_DIRECTORIES zfp::zfp INTERFACE_INCLUDE_DIRECTORIES)
set(CMAKE_REQUIRED_INCLUDES ${ZFP_INCLUDE_DIRECTORIES})
set(CMAKE_REQUIRED_LIBRARIES zfp::zfp)
include(CheckCSourceRuns)
check_c_source_runs("
#include <zfp.h>
int main()
{
zfp_stream* stream = zfp_stream_open(NULL);
return !zfp_stream_set_execution(stream, zfp_exec_cuda);
}"
ADIOS2_HAVE_ZFP_CUDA)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()

if(ADIOS2_HAVE_ZFP_CUDA)
add_compile_definitions(ADIOS2_HAVE_ZFP_CUDA)
endif()
endif()

# SZ
Expand Down
2 changes: 2 additions & 0 deletions source/adios2/common/ADIOSTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ constexpr char precision[] = "precision";

namespace value
{
#ifdef ADIOS2_HAVE_ZFP_CUDA
constexpr char backend_cuda[] = "cuda";
#endif
constexpr char backend_omp[] = "omp";
constexpr char backend_serial[] = "serial";
}
Expand Down
16 changes: 11 additions & 5 deletions source/adios2/operator/compress/CompressZFP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

/* ZFP will default to SERIAL if CUDA is not available */
#ifndef ZFP_DEFAULT_EXECUTION_POLICY
#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
Expand Down Expand Up @@ -282,19 +286,21 @@ zfp_stream *CompressZFP::GetZFPStream(const Dims &dimensions, DataType type,
auto policy = ZFP_DEFAULT_EXECUTION_POLICY;
const auto backend = itBackend->second;

if (backend == "cuda")
if (backend == "serial")
{
policy = zfp_exec_cuda;
policy = zfp_exec_serial;
isSerial = true;
}
else if (backend == "omp")
{
policy = zfp_exec_omp;
}
else if (backend == "serial")
#ifdef ADIOS2_HAVE_ZFP_CUDA
else if (backend == "cuda")
{
policy = zfp_exec_serial;
isSerial = true;
policy = zfp_exec_cuda;
}
#endif

zfp_stream_set_execution(stream, policy);
}
Expand Down
2 changes: 1 addition & 1 deletion testing/adios2/engine/bp/operations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if(ADIOS2_HAVE_ZFP)
)
endforeach()

if(ADIOS2_HAVE_CUDA)
if(ADIOS2_HAVE_CUDA AND ADIOS2_HAVE_ZFP_CUDA)
enable_language(CUDA)

gtest_add_tests_helper(WriteReadZfpCuda MPI_ALLOW BP Engine.BP. .BP4
Expand Down

0 comments on commit d0fbb7f

Please sign in to comment.