1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-13 19:50:34 +00:00

Fix building with -DENABLE_CUDA=ON

This commit is contained in:
Carles Fernandez 2020-08-27 14:57:44 +02:00
parent a9472dea30
commit 15428a47cc
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
9 changed files with 85 additions and 41 deletions

View File

@ -2693,6 +2693,7 @@ if(ENABLE_CUDA)
PURPOSE "Used in some processing block implementations."
TYPE REQUIRED
)
set(CMAKE_CUDA_STANDARD 14)
if(NOT CUDA_FOUND)
set(ENABLE_CUDA OFF)
endif()
@ -2991,7 +2992,9 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
add_compile_options(-Wno-missing-field-initializers)
endif()
if(CMAKE_CROSSCOMPILING OR NOT ENABLE_PACKAGING)
add_compile_options(-Wno-psabi)
if(NOT ENABLE_CUDA)
add_compile_options(-Wno-psabi)
endif()
endif()
if(IS_ARM)
if((CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.1.0") AND (CMAKE_VERSION VERSION_GREATER "3.1"))
@ -3025,7 +3028,9 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32)
add_compile_options(-mtune=native)
endif()
else()
add_compile_options(-march=native)
if(NOT ENABLE_CUDA)
add_compile_options(-march=native)
endif()
endif()
endif()
endif()

View File

@ -31,6 +31,7 @@ SPDX-FileCopyrightText: 2011-2020 Carles Fernandez-Prades <carles.fernandez@cttc
- Replaced `git://` by `https://` as the used protocol when downloading Gflags,
so it can work through firewalls requiring authentication.
- Fixed static linking of the matio library when downloaded and built by CMake.
- Fix building with `-DENABLE_CUDA=ON` for blocks implemented with CUDA.
### Improvements in Usability:

View File

@ -107,14 +107,22 @@ target_include_directories(tracking_adapters
${CMAKE_SOURCE_DIR}/src/core/interfaces
)
if(ENABLE_CUDA AND NOT CMAKE_VERSION VERSION_GREATER 3.11)
target_link_libraries(tracking_adapters
PUBLIC
${CUDA_LIBRARIES}
)
target_include_directories(tracking_adapters
PUBLIC
${CUDA_INCLUDE_DIRS}
if(ENABLE_CUDA)
if(CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(tracking_adapters
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
else()
target_link_libraries(tracking_adapters
PUBLIC ${CUDA_LIBRARIES}
)
target_include_directories(tracking_adapters
PUBLIC ${CUDA_INCLUDE_DIRS}
)
endif()
set_target_properties(tracking_adapters PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
endif()

View File

@ -103,14 +103,22 @@ if(GNURADIO_USES_STD_POINTERS)
)
endif()
if(ENABLE_CUDA AND NOT CMAKE_VERSION VERSION_GREATER 3.11)
target_link_libraries(tracking_gr_blocks
PUBLIC
${CUDA_LIBRARIES}
)
target_include_directories(tracking_gr_blocks
PUBLIC
${CUDA_INCLUDE_DIRS}
if(ENABLE_CUDA)
if(CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(tracking_gr_blocks
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
else()
target_link_libraries(tracking_gr_blocks
PUBLIC cuda_correlator_lib
)
target_include_directories(tracking_gr_blocks
PUBLIC ${CUDA_INCLUDE_DIRS}
)
endif()
set_target_properties(tracking_gr_blocks PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
endif()

View File

@ -177,7 +177,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking()
d_code_phase_step_chips = static_cast<double>(d_code_freq_chips) / static_cast<double>(d_fs_in);
const double T_chip_mod_seconds = 1 / d_code_freq_chips;
const double T_prn_mod_seconds = T_chip_mod_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS;
T_prn_mod_samples T_prn_mod_samples = T_prn_mod_seconds * static_cast<double>(d_fs_in);
const double T_prn_mod_samples = T_prn_mod_seconds * static_cast<double>(d_fs_in);
d_correlation_length_samples = round(T_prn_mod_samples);

View File

@ -48,7 +48,7 @@ typedef std::shared_ptr<Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc>
#else
typedef boost::shared_ptr<Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc>
gps_l1_ca_dll_pll_tracking_gpu_cc_sptr;
#end
#endif
gps_l1_ca_dll_pll_tracking_gpu_cc_sptr
gps_l1_ca_dll_pll_make_tracking_gpu_cc(

View File

@ -42,8 +42,6 @@ set(TRACKING_LIB_HEADERS
exponential_smoother.h
)
set(OPT_TRACKING_LIBRARIES "")
set(OPT_TRACKING_INCLUDES "")
if(ENABLE_CUDA)
if(CMAKE_VERSION VERSION_GREATER 3.11)
set(TRACKING_LIB_SOURCES ${TRACKING_LIB_SOURCES} cuda_multicorrelator.cu)
@ -53,9 +51,7 @@ if(ENABLE_CUDA)
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})
cuda_add_library(cuda_correlator_lib ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu)
endif()
endif()
@ -94,20 +90,27 @@ target_link_libraries(tracking_libs
Volkgnsssdr::volkgnsssdr
core_system_parameters
algorithms_libs
${OPT_TRACKING_LIBRARIES}
PRIVATE
gnss_sdr_flags
Glog::glog
)
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}
if(ENABLE_CUDA)
if(CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(tracking_libs
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
else()
target_link_libraries(tracking_libs
PUBLIC ${CUDA_LIBRARIES}
)
target_include_directories(tracking_libs
PUBLIC ${CUDA_INCLUDE_DIRS}
)
endif()
set_target_properties(tracking_libs PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
endif()

View File

@ -120,9 +120,22 @@ else()
endif()
if(ENABLE_CUDA)
if(NOT CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(core_receiver PUBLIC ${CUDA_INCLUDE_DIRS})
if(CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(core_receiver
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
else()
target_link_libraries(core_receiver
PUBLIC ${CUDA_LIBRARIES}
)
target_include_directories(core_receiver
PUBLIC ${CUDA_INCLUDE_DIRS}
)
endif()
set_target_properties(core_receiver PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
target_compile_definitions(core_receiver PRIVATE -DCUDA_GPU_ACCEL=1)
endif()

View File

@ -39,16 +39,22 @@ target_link_libraries(gnss-sdr
target_compile_definitions(gnss-sdr PRIVATE -DGNSS_SDR_VERSION="${VERSION}")
if(ENABLE_CUDA)
if(NOT CMAKE_VERSION VERSION_GREATER 3.11)
if(CMAKE_VERSION VERSION_GREATER 3.11)
target_include_directories(gnss-sdr
PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES}
)
else()
target_link_libraries(gnss-sdr
PRIVATE
${CUDA_LIBRARIES}
PUBLIC ${CUDA_LIBRARIES}
)
target_include_directories(gnss-sdr
PRIVATE
${CUDA_INCLUDE_DIRS}
PUBLIC ${CUDA_INCLUDE_DIRS}
)
endif()
set_target_properties(gnss-sdr PROPERTIES
CUDA_SEPARABLE_COMPILATION ON
POSITION_INDEPENDENT_CODE ON
)
target_compile_definitions(gnss-sdr PRIVATE -DCUDA_GPU_ACCEL=1)
endif()