Skip to content

Commit

Permalink
Merge pull request #35 from tbirdso/cuda-linux
Browse files Browse the repository at this point in the history
BUG: Resolve CUDA warnings on Linux
  • Loading branch information
tbirdso committed Apr 7, 2022
2 parents e45d4bc + f10ef33 commit db9022d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
8 changes: 7 additions & 1 deletion itk-module-init.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#
# Find the packages required by this module
#
find_package(OpenCL REQUIRED)
set(VKFFT_BACKEND 3 CACHE STRING "1 - CUDA, 3 - OpenCL")
if(${VKFFT_BACKEND} EQUAL 1)
find_package(CUDA 9.0 REQUIRED)
find_library(CUDA_NVRTC_LIB libnvrtc nvrtc HINTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" "/usr/lib64" "/usr/local/cuda/lib64")
elseif(${VKFFT_BACKEND} EQUAL 3)
find_package(OpenCL REQUIRED)
endif()
18 changes: 15 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@ set(VkFFTBackend_SRCS
itk_module_add_library(VkFFTBackend ${VkFFTBackend_SRCS})

if(${VKFFT_BACKEND} EQUAL 1)
find_package(CUDA 9.0 REQUIRED)
find_library(CUDA_NVRTC_LIB libnvrtc nvrtc HINTS "${CUDA_TOOLKIT_ROOT_DIR}/lib64" "${LIBNVRTC_LIBRARY_DIR}" "${CUDA_TOOLKIT_ROOT_DIR}/lib/x64" /usr/lib64 /usr/local/cuda/lib64)
target_link_libraries(VkFFTBackend PUBLIC ${CUDA_LIBRARIES} cuda ${CUDA_NVRTC_LIB} VkFFT half)
if(MSVC)
else()
set_source_files_properties(itkVkCommon.cpp PROPERTIES LANGUAGE CUDA)
endif()
target_compile_options(VkFFTBackend PUBLIC "$<$<COMPILE_LANGUAGE:CUDA>:SHELL
-DVKFFT_BACKEND=${VKFFT_BACKEND}
-gencode arch=compute_35,code=compute_35
-gencode arch=compute_60,code=compute_60
-gencode arch=compute_70,code=compute_70
-gencode arch=compute_75,code=compute_75
-gencode arch=compute_80,code=compute_80
-gencode arch=compute_86,code=compute_86>")
set_target_properties(VkFFTBackend PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(VkFFTBackend PROPERTIES CUDA_RESOLVE_DEVICE_SYMBOLS ON)
elseif(${VKFFT_BACKEND} EQUAL 3)
target_link_libraries(VkFFTBackend PUBLIC ${OpenCL_LIBRARY})
target_link_libraries(VkFFTBackend PUBLIC ${OpenCL_LIBRARY})
endif()

0 comments on commit db9022d

Please sign in to comment.