Skip to content

Commit

Permalink
[cmake] perform CUDA intrinsic function check through generated confi…
Browse files Browse the repository at this point in the history
…g file
  • Loading branch information
Carsten Griwodz committed Aug 2, 2019
1 parent 86cd2e3 commit b2a1aef
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -164,16 +164,15 @@ if(CCTAG_WITH_CUDA)
# set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-gencode=arch=compute_52,code=sm_52;-gencode=arch=compute_52,code=compute_52;--default-stream;per-thread;-Xptxas;--warn-on-local-memory-usage;-Xptxas;--warn-on-spills")
cuda_find_library_local_first(CUDA_CUDADEVRT_LIBRARY cudadevrt "\"cudadevrt\" library")

if( ( CUDA_VERSION VERSION_EQUAL "9.0" ) OR ( CUDA_VERSION VERSION_GREATER "9.0") )
set(CCTAG_HAVE_SHFL_DOWN_SYNC 1)
else()
set(CCTAG_HAVE_SHFL_DOWN_SYNC 0)
endif()
else(CCTAG_WITH_CUDA)
message( STATUS "Building without CUDA" )
endif(CCTAG_WITH_CUDA)

if( ( CUDA_VERSION VERSION_EQUAL "9.0" ) OR ( CUDA_VERSION VERSION_GREATER "9.0") )
set(HAVE_SHFL_DOWN_SYNC 1)
else()
set(HAVE_SHFL_DOWN_SYNC 0)
endif()

# FIND OPENCV
find_package(OpenCV REQUIRED core videoio imgproc imgcodecs)

Expand Down
6 changes: 5 additions & 1 deletion cmake/config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@

#define CUB_CDP

#endif
#ifndef CCTAG_HAVE_SHFL_DOWN_SYNC
#cmakedefine CCTAG_HAVE_SHFL_DOWN_SYNC
#endif

#endif
7 changes: 4 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ if(CCTAG_WITH_CUDA)
PUBLIC -DCCTAG_WITH_CUDA -DCUB_CDP
PRIVATE ${TBB_DEFINITIONS})

if(CCTAG_HAVE_SHFL_DOWN_SYNC)
target_compile_definitions(CCTag PRIVATE "-DCCTAG_HAVE_SHFL_DOWN_SYNC")
endif(CCTAG_HAVE_SHFL_DOWN_SYNC)

# This is nececessary for the CCTagConfig.cmake to correctly export the
# includes, always because we used CUDA_ADD_LIBRARY
set_target_properties(CCTag PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
Expand Down Expand Up @@ -171,9 +175,6 @@ endif(CCTAG_NO_COUT)
if(CCTAG_VISUAL_DEBUG)
target_compile_definitions(CCTag PRIVATE "-DCCTAG_VISUAL_DEBUG")
endif(CCTAG_VISUAL_DEBUG)
if(HAVE_SHFL_DOWN_SYNC)
target_compile_definitions(CCTag PRIVATE "-DCCTAG_HAVE_SHFL_DOWN_SYNC")
endif(HAVE_SHFL_DOWN_SYNC)


# EXPORTING THE LIBRARY
Expand Down

0 comments on commit b2a1aef

Please sign in to comment.