diff --git a/CMakeLists.txt b/CMakeLists.txt index 024774f1f..a002ba5d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,24 @@ include(ipc_toolkit_use_colors) # Generate position-independent code by default set(CMAKE_POSITION_INDEPENDENT_CODE ON) +################################################################################ +# CUDA +################################################################################ + +if(IPC_TOOLKIT_WITH_CUDA) + # If CMAKE_CUDA_ARCHITECTURES was not specified, set it to native. + if(DEFINED CMAKE_CUDA_ARCHITECTURES) + message(STATUS "CMAKE_CUDA_ARCHITECTURES was specified, skipping auto-detection") + else() + message(STATUS "CMAKE_CUDA_ARCHITECTURES was not specified, set it to native") + set(CMAKE_CUDA_ARCHITECTURES "native") + endif() + message(STATUS "Targeting CUDA_ARCHITECTURES \"${CMAKE_CUDA_ARCHITECTURES}\"") + + # Enable CUDA support + enable_language(CUDA) +endif() + ################################################################################ # IPC Toolkit Library ################################################################################ @@ -118,6 +136,13 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_library(ipc_toolkit) add_library(ipc::toolkit ALIAS ipc_toolkit) +if(IPC_TOOLKIT_WITH_CUDA) + # We need to explicitly state that we need all CUDA files in the particle + # library to be built with -dc as the member functions could be called by + # other libraries and executables. + set_target_properties(ipc_toolkit PROPERTIES CUDA_SEPARABLE_COMPILATION ON) +endif() + # Fill in configuration options configure_file( "${IPC_TOOLKIT_SOURCE_DIR}/config.hpp.in" @@ -233,29 +258,6 @@ endif() # Use C++17 target_compile_features(ipc_toolkit PUBLIC cxx_std_17) -################################################################################ -# CUDA -################################################################################ - -if(IPC_TOOLKIT_WITH_CUDA) - # If CMAKE_CUDA_ARCHITECTURES was not specified, set it to native. - if(DEFINED CMAKE_CUDA_ARCHITECTURES) - message(STATUS "CMAKE_CUDA_ARCHITECTURES was specified, skipping auto-detection") - else() - message(STATUS "CMAKE_CUDA_ARCHITECTURES was not specified, set it to native") - set(CMAKE_CUDA_ARCHITECTURES "native") - endif() - message(STATUS "Targeting CUDA_ARCHITECTURES \"${CMAKE_CUDA_ARCHITECTURES}\"") - - # Enable CUDA support - enable_language(CUDA) - - # We need to explicitly state that we need all CUDA files in the particle - # library to be built with -dc as the member functions could be called by - # other libraries and executables. - set_target_properties(ipc_toolkit PROPERTIES CUDA_SEPARABLE_COMPILATION ON) -endif() - ################################################################################ # Tests ################################################################################ diff --git a/src/ipc/broad_phase/CMakeLists.txt b/src/ipc/broad_phase/CMakeLists.txt index ff04b4cfa..49cdb1bc4 100644 --- a/src/ipc/broad_phase/CMakeLists.txt +++ b/src/ipc/broad_phase/CMakeLists.txt @@ -16,10 +16,10 @@ set(SOURCES spatial_hash.hpp sweep_and_prune.cpp sweep_and_prune.hpp - sweep_and_tiniest_queue.cpp + sweep_and_tiniest_queue.cu sweep_and_tiniest_queue.hpp voxel_size_heuristic.cpp voxel_size_heuristic.hpp ) -target_sources(ipc_toolkit PRIVATE ${SOURCES}) \ No newline at end of file +target_sources(ipc_toolkit PRIVATE ${SOURCES}) diff --git a/src/ipc/broad_phase/sweep_and_tiniest_queue.cpp b/src/ipc/broad_phase/sweep_and_tiniest_queue.cu similarity index 100% rename from src/ipc/broad_phase/sweep_and_tiniest_queue.cpp rename to src/ipc/broad_phase/sweep_and_tiniest_queue.cu