mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-01-26 00:46:59 +00:00
Modern CUDA usage
This commit is contained in:
parent
e28062de87
commit
0e5211dbf0
@ -2112,13 +2112,33 @@ if(DEFINED ENV{CUDA_GPU_ACCEL})
|
||||
endif()
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
find_package(CUDA REQUIRED)
|
||||
set_package_properties(CUDA PROPERTIES
|
||||
URL "https://developer.nvidia.com/cuda-downloads"
|
||||
DESCRIPTION "Library for parallel programming in Nvidia GPUs"
|
||||
PURPOSE "Used in some processing block implementations."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
include(CheckLanguage)
|
||||
check_language(CUDA)
|
||||
if(CMAKE_CUDA_COMPILER)
|
||||
enable_language(CUDA)
|
||||
set(CUDA_FOUND TRUE)
|
||||
if(NOT DEFINED CMAKE_CUDA_STANDARD)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
|
||||
endif()
|
||||
else()
|
||||
set(ENABLE_CUDA OFF)
|
||||
endif()
|
||||
else()
|
||||
find_package(CUDA REQUIRED)
|
||||
set_package_properties(CUDA PROPERTIES
|
||||
URL "https://developer.nvidia.com/cuda-downloads"
|
||||
DESCRIPTION "Library for parallel programming in Nvidia GPUs"
|
||||
PURPOSE "Used in some processing block implementations."
|
||||
TYPE REQUIRED
|
||||
)
|
||||
if(NOT CUDA_FOUND)
|
||||
set(ENABLE_CUDA OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
if(ENABLE_CUDA)
|
||||
message(STATUS "NVIDIA CUDA GPU Acceleration will be enabled.")
|
||||
message(STATUS " You can disable it with 'cmake -DENABLE_CUDA=OFF ..'")
|
||||
else()
|
||||
|
@ -104,7 +104,6 @@ if(MATIO_INCLUDE_DIR)
|
||||
endif()
|
||||
|
||||
if(MATIO_CONFIG_FILE)
|
||||
|
||||
# Read and parse MATIO config header file for version number
|
||||
file(STRINGS "${MATIO_INCLUDE_DIR}/${MATIO_CONFIG_FILE}" _matio_HEADER_CONTENTS REGEX "#define MATIO_((MAJOR|MINOR)_VERSION)|(RELEASE_LEVEL) ")
|
||||
|
||||
|
@ -108,7 +108,7 @@ target_include_directories(tracking_adapters
|
||||
${CMAKE_SOURCE_DIR}/src/core/interfaces
|
||||
)
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
if(ENABLE_CUDA AND NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_link_libraries(tracking_adapters
|
||||
PUBLIC
|
||||
${CUDA_LIBRARIES}
|
||||
|
@ -97,7 +97,7 @@ target_link_libraries(tracking_gr_blocks
|
||||
tracking_libs
|
||||
)
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
if(ENABLE_CUDA AND NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_link_libraries(tracking_gr_blocks
|
||||
PUBLIC
|
||||
${CUDA_LIBRARIES}
|
||||
|
@ -17,18 +17,6 @@
|
||||
#
|
||||
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
# Append current NVCC flags by something, eg comput capability
|
||||
# set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_30)
|
||||
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_30,code=sm_30; -std=c++11;-O3; -use_fast_math -default-stream per-thread")
|
||||
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
||||
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(LIB_TYPE STATIC) #set the lib type
|
||||
cuda_add_library(CUDA_CORRELATOR_LIB ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu)
|
||||
set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} CUDA_CORRELATOR_LIB)
|
||||
set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
set(TRACKING_LIB_SOURCES
|
||||
cpu_multicorrelator.cc
|
||||
cpu_multicorrelator_real_codes.cc
|
||||
@ -63,6 +51,22 @@ set(TRACKING_LIB_HEADERS
|
||||
exponential_smoother.h
|
||||
)
|
||||
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
if(CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
set(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} cuda_multicorrelator.cu)
|
||||
set(TRACKING_LIB_HEADERS ${TRACKING_LIB_HEADERS} cuda_multicorrelator.h)
|
||||
else()
|
||||
list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_30,code=sm_30; -std=c++11;-O3; -use_fast_math -default-stream per-thread")
|
||||
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
|
||||
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(LIB_TYPE STATIC) #set the lib type
|
||||
cuda_add_library(CUDA_CORRELATOR_LIB ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu)
|
||||
set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} CUDA_CORRELATOR_LIB)
|
||||
set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ARMADILLO_VERSION_STRING VERSION_GREATER 7.400)
|
||||
# sqrtmat_sympd() requires 7.400
|
||||
set(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} nonlinear_tracking.cc)
|
||||
@ -95,10 +99,16 @@ target_link_libraries(tracking_libs
|
||||
Glog::glog
|
||||
)
|
||||
|
||||
target_include_directories(tracking_libs
|
||||
PUBLIC
|
||||
${OPT_TRACKING_INCLUDES}
|
||||
)
|
||||
if(NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_link_libraries(tracking_libs
|
||||
PUBLIC
|
||||
${OPT_TRACKING_LIBRARIES}
|
||||
)
|
||||
target_include_directories(tracking_libs
|
||||
PUBLIC
|
||||
${OPT_TRACKING_INCLUDES}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(Boost_VERSION VERSION_GREATER "106599")
|
||||
target_compile_definitions(tracking_libs
|
||||
|
@ -40,12 +40,6 @@ set(GNSS_RECEIVER_HEADERS
|
||||
control_message.h
|
||||
)
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
set(OPT_RECEIVER_INCLUDE_DIRS
|
||||
${OPT_RECEIVER_INCLUDE_DIRS} ${CUDA_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
|
||||
list(SORT GNSS_RECEIVER_HEADERS)
|
||||
list(SORT GNSS_RECEIVER_SOURCES)
|
||||
|
||||
@ -127,6 +121,9 @@ else()
|
||||
endif()
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
if(NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_include_directories(core_receiver PUBLIC ${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
target_compile_definitions(core_receiver PRIVATE -DCUDA_GPU_ACCEL=1)
|
||||
endif()
|
||||
|
||||
@ -213,5 +210,4 @@ endif()
|
||||
set_property(TARGET core_receiver APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/core/receiver>
|
||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/core/interfaces>
|
||||
$<BUILD_INTERFACE:${OPT_RECEIVER_INCLUDE_DIRS}>
|
||||
)
|
||||
|
@ -45,14 +45,16 @@ if(NOT ENABLE_LOG)
|
||||
endif()
|
||||
|
||||
if(ENABLE_CUDA)
|
||||
target_link_libraries(gnss-sdr
|
||||
PUBLIC
|
||||
${CUDA_LIBRARIES}
|
||||
)
|
||||
target_include_directories(gnss-sdr
|
||||
PUBLIC
|
||||
${CUDA_INCLUDE_DIRS}
|
||||
)
|
||||
if(NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_link_libraries(gnss-sdr
|
||||
PUBLIC
|
||||
${CUDA_LIBRARIES}
|
||||
)
|
||||
target_include_directories(gnss-sdr
|
||||
PUBLIC
|
||||
${CUDA_INCLUDE_DIRS}
|
||||
)
|
||||
endif()
|
||||
target_compile_definitions(gnss-sdr PRIVATE -DCUDA_GPU_ACCEL=1)
|
||||
endif()
|
||||
|
||||
|
@ -443,7 +443,7 @@ if(ENABLE_UNIT_TESTING)
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
if(ENABLE_CUDA)
|
||||
if(ENABLE_CUDA AND NOT CMAKE_VERSION VERSION_GREATER 3.11)
|
||||
target_link_libraries(run_tests
|
||||
PUBLIC
|
||||
${CUDA_LIBRARIES}
|
||||
|
Loading…
Reference in New Issue
Block a user