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

BUG: Resolve CUDA warnings on Linux #35

Merged
merged 2 commits into from
Apr 7, 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
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()