1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 20:20:35 +00:00

Merge branch 'opencl' into next

This commit is contained in:
Carles Fernandez 2019-06-24 20:43:58 +02:00
commit ea68c8523c
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
17 changed files with 2224 additions and 1414 deletions

View File

@ -2099,8 +2099,6 @@ if(ENABLE_OPENCL)
if(NOT OPENCL_FOUND)
message(STATUS "Processing blocks using OpenCL will not be built.")
endif()
else()
set(OPENCL_FOUND FALSE)
endif()
@ -2114,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()

View File

@ -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) ")

View File

@ -1,4 +1,4 @@
# Copyright (C) 2011-2018 (see AUTHORS file for a list of contributors)
# Copyright (C) 2011-2019 (see AUTHORS file for a list of contributors)
#
# This file is part of GNSS-SDR.
#
@ -20,7 +20,7 @@
#
# - Try to find OpenCL
# This module tries to find an OpenCL implementation on your system. It supports
# AMD / ATI, Apple and NVIDIA implementations, but shoudl work, too.
# AMD / ATI, Apple and NVIDIA implementations.
#
# Once done this will define
# OPENCL_FOUND - system has OpenCL
@ -35,85 +35,189 @@ endif()
include(FindPackageHandleStandardArgs)
set(OPENCL_VERSION_STRING "0.1.0")
set(OPENCL_VERSION_MAJOR 0)
set(OPENCL_VERSION_MINOR 1)
set(OPENCL_VERSION_PATCH 0)
function(_FIND_OPENCL_VERSION)
include(CheckSymbolExists)
include(CMakePushCheckState)
set(CMAKE_REQUIRED_QUIET ${OPENCL_FIND_QUIETLY})
if(APPLE)
find_library(OPENCL_LIBRARIES OpenCL DOC "OpenCL lib for OSX")
find_path(OPENCL_INCLUDE_DIRS OpenCL/cl.h DOC "Include for OpenCL on OSX")
find_path(_OPENCL_CPP_INCLUDE_DIRS OpenCL/cl.hpp DOC "Include for OpenCL CPP bindings on OSX")
cmake_push_check_state()
foreach(VERSION "2_2" "2_1" "2_0" "1_2" "1_1" "1_0")
set(CMAKE_REQUIRED_INCLUDES "${OPENCL_INCLUDE_DIR}")
else()
if(WIN32)
find_path(OPENCL_INCLUDE_DIRS CL/cl.h)
find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp)
if(APPLE)
check_symbol_exists(
CL_VERSION_${VERSION}
"${OPENCL_INCLUDE_DIR}/Headers/cl.h"
OPENCL_VERSION_${VERSION}
)
else()
check_symbol_exists(
CL_VERSION_${VERSION}
"${OPENCL_INCLUDE_DIR}/CL/cl.h"
OPENCL_VERSION_${VERSION}
)
endif()
# The AMD SDK currently installs both x86 and x86_64 libraries
# This is only a hack to find out architecture
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "AMD64")
set(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86_64")
set(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86_64")
else()
set(OPENCL_LIB_DIR "$ENV{ATISTREAMSDKROOT}/lib/x86")
set(OPENCL_LIB_DIR "$ENV{ATIINTERNALSTREAMSDKROOT}/lib/x86")
endif()
if(OPENCL_VERSION_${VERSION})
string(REPLACE "_" "." VERSION "${VERSION}")
set(OPENCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
list(GET version_components 0 major_version)
list(GET version_components 1 minor_version)
set(OPENCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
set(OPENCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
break()
endif()
endforeach()
cmake_pop_check_state()
endfunction()
# find out if the user asked for a 64-bit build, and use the corresponding
# 64 or 32 bit NVIDIA library paths to the search:
string(REGEX MATCH "Win64" ISWIN64 ${CMAKE_GENERATOR})
if("${ISWIN64}" STREQUAL "Win64")
find_library(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/x64)
else()
find_library(OPENCL_LIBRARIES OpenCL.lib ${OPENCL_LIB_DIR} $ENV{CUDA_LIB_PATH} $ENV{CUDA_PATH}/lib/Win32)
endif()
find_path(OPENCL_INCLUDE_DIR
NAMES
CL/cl.h OpenCL/cl.h
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
/usr/local/cuda/include
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include"
)
get_filename_component(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
find_path(_OPENCL_CPP_INCLUDE_DIRS
NAMES
CL/cl.hpp OpenCL/cl.hpp
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV NVSDKCOMPUTE_ROOT
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
/usr/local/cuda/include
PATH_SUFFIXES
include
OpenCL/common/inc
"AMD APP/include"
)
# On Win32 search relative to the library
find_path(OPENCL_INCLUDE_DIRS CL/cl.h PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include)
find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS "${_OPENCL_INC_CAND}" $ENV{CUDA_INC_PATH} $ENV{CUDA_PATH}/include)
else()
# Unix style platforms
find_library(OPENCL_LIBRARIES OpenCL
ENV LD_LIBRARY_PATH
)
get_filename_component(OPENCL_LIB_DIR ${OPENCL_LIBRARIES} PATH)
get_filename_component(_OPENCL_INC_CAND ${OPENCL_LIB_DIR}/../../include ABSOLUTE)
# The AMD SDK currently does not place its headers
# in /usr/include, therefore also search relative
# to the library
find_path(OPENCL_INCLUDE_DIRS CL/cl.h PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include")
find_path(_OPENCL_CPP_INCLUDE_DIRS CL/cl.hpp PATHS ${_OPENCL_INC_CAND} "/usr/local/cuda/include")
endif()
set(OPENCL_INCLUDE_DIRS ${OPENCL_INCLUDE_DIR})
if(_OPENCL_CPP_INCLUDE_DIRS)
set(OPENCL_HAS_CPP_BINDINGS TRUE)
list(APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS})
# This is often the same, so clean up
list(REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS)
endif()
_FIND_OPENCL_VERSION()
if(WIN32)
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86"
lib/x86
lib/Win32
OpenCL/common/lib/Win32
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
ENV "PROGRAMFILES(X86)"
ENV AMDAPPSDKROOT
ENV INTELOCLSDKROOT
ENV CUDA_PATH
ENV NVSDKCOMPUTE_ROOT
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
PATH_SUFFIXES
"AMD APP/lib/x86_64"
lib/x86_64
lib/x64
OpenCL/common/lib/x64
)
endif()
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
ENV LD_LIBRARY_PATH
PATH_SUFFIXES
lib/x86
lib
)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
find_library(OPENCL_LIBRARY
NAMES OpenCL
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
ENV LD_LIBRARY_PATH
PATH_SUFFIXES
lib/x86_64
lib/x64
lib
lib64
)
endif()
endif()
set(OPENCL_LIBRARIES ${OPENCL_LIBRARY})
find_package_handle_standard_args(OPENCL DEFAULT_MSG OPENCL_LIBRARIES OPENCL_INCLUDE_DIRS)
if(_OPENCL_CPP_INCLUDE_DIRS)
set(OPENCL_HAS_CPP_BINDINGS TRUE)
list(APPEND OPENCL_INCLUDE_DIRS ${_OPENCL_CPP_INCLUDE_DIRS})
# This is often the same, so clean up
list(REMOVE_DUPLICATES OPENCL_INCLUDE_DIRS)
endif()
mark_as_advanced(
OPENCL_INCLUDE_DIRS
OPENCL_LIBRARIES
)
set_package_properties(OPENCL PROPERTIES
URL "https://www.khronos.org/opencl/"
DESCRIPTION "Library for parallel programming"
)
if(OPENCL_INCLUDE_DIRS AND OPENCL_LIBRARIES)
set( OPENCL_FOUND TRUE )
add_definitions( -DOPENCL=1 )
if(OPENCL_FOUND AND OPENCL_VERSION_STRING)
set_package_properties(OPENCL PROPERTIES
DESCRIPTION "Library for parallel programming (found: v${OPENCL_VERSION_STRING})"
)
else()
set( OPENCL_FOUND FALSE )
add_definitions( -DOPENCL=0 )
set_package_properties(OPENCL PROPERTIES
DESCRIPTION "Library for parallel programming"
)
endif()
if(OPENCL_FOUND AND NOT TARGET OpenCL::OpenCL)
if(OPENCL_LIBRARY MATCHES "/([^/]+)\\.framework$")
add_library(OpenCL::OpenCL INTERFACE IMPORTED)
set_target_properties(OpenCL::OpenCL PROPERTIES
INTERFACE_LINK_LIBRARIES "${OPENCL_LIBRARY}"
)
else()
add_library(OpenCL::OpenCL UNKNOWN IMPORTED)
set_target_properties(OpenCL::OpenCL PROPERTIES
IMPORTED_LOCATION "${OPENCL_LIBRARY}"
)
endif()
set_target_properties(OpenCL::OpenCL PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPENCL_INCLUDE_DIRS}"
)
endif()

View File

@ -144,6 +144,12 @@ public:
void set_resampler_latency(uint32_t latency_samples __attribute__((unused))) override{};
inline bool opencl_ready() const
{
bool ready = this->acquisition_cc_->opencl_ready();
return ready;
}
private:
ConfigurationInterface* configuration_;
pcps_opencl_acquisition_cc_sptr acquisition_cc_;

View File

@ -49,16 +49,6 @@ if(OPENCL_FOUND)
set(ACQ_GR_BLOCKS_HEADERS ${ACQ_GR_BLOCKS_HEADERS} pcps_opencl_acquisition_cc.h)
endif()
if(OPENCL_FOUND)
include_directories(${OPENCL_INCLUDE_DIRS})
if(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL")
else()
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
endif()
endif()
list(SORT ACQ_GR_BLOCKS_HEADERS)
list(SORT ACQ_GR_BLOCKS_SOURCES)
@ -78,19 +68,19 @@ endif()
target_link_libraries(acquisition_gr_blocks
PUBLIC
algorithms_libs
Gnuradio::runtime
Gnuradio::fft
Volk::volk
channel_libs
acquisition_libs
core_system_parameters
${OPT_LIBRARIES}
PRIVATE
Gflags::gflags
Glog::glog
Matio::matio
Volkgnsssdr::volkgnsssdr
algorithms_libs
)
target_include_directories(acquisition_gr_blocks
@ -101,7 +91,11 @@ target_include_directories(acquisition_gr_blocks
)
if(OPENCL_FOUND)
target_include_directories(acquisition_gr_blocks PUBLIC ${OPENCL_INCLUDE_DIRS})
target_link_libraries(acquisition_gr_blocks PUBLIC OpenCL::OpenCL)
target_include_directories(acquisition_gr_blocks
PUBLIC
${CMAKE_SOURCE_DIR}/src/algorithms/libs/opencl
)
endif()
if(ENABLE_CLANG_TIDY)
@ -116,4 +110,5 @@ endif()
set_property(TARGET acquisition_gr_blocks
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/src/algorithms/libs/opencl>
)

View File

@ -209,7 +209,7 @@ int pcps_opencl_acquisition_cc::init_opencl_environment(const std::string &kerne
std::vector<cl::Platform> all_platforms;
cl::Platform::get(&all_platforms);
if (all_platforms.size() == 0)
if (all_platforms.empty())
{
std::cout << "No OpenCL platforms found. Check OpenCL installation!" << std::endl;
return 1;
@ -223,7 +223,7 @@ int pcps_opencl_acquisition_cc::init_opencl_environment(const std::string &kerne
std::vector<cl::Device> gpu_devices;
d_cl_platform.getDevices(CL_DEVICE_TYPE_GPU, &gpu_devices);
if (gpu_devices.size() == 0)
if (gpu_devices.empty())
{
std::cout << "No GPU devices found. Check OpenCL installation!" << std::endl;
return 2;

View File

@ -51,8 +51,10 @@
#ifndef GNSS_SDR_PCPS_OPENCL_ACQUISITION_CC_H_
#define GNSS_SDR_PCPS_OPENCL_ACQUISITION_CC_H_
#define CL_SILENCE_DEPRECATION
#include "channel_fsm.h"
#include "gnss_synchro.h"
#include "opencl/cl.hpp"
#include "opencl/fft_internal.h"
#include <gnuradio/block.h>
#include <gnuradio/fft/fft.h>
@ -62,12 +64,6 @@
#include <string>
#include <vector>
#ifdef __APPLE__
#include "opencl/cl.hpp"
#else
#include <CL/cl.hpp>
#endif
class pcps_opencl_acquisition_cc;
typedef boost::shared_ptr<pcps_opencl_acquisition_cc> pcps_opencl_acquisition_cc_sptr;
@ -226,7 +222,6 @@ public:
d_channel = channel;
}
/*!
* \brief Set channel fsm associated to this acquisition instance
*/
@ -262,6 +257,16 @@ public:
d_doppler_step = doppler_step;
}
inline bool opencl_ready() const
{
bool ready = false;
if (d_opencl == 0)
{
ready = true;
}
return ready;
}
/*!
* \brief Parallel Code Phase Search Acquisition signal processing.
*/

View File

@ -73,12 +73,6 @@ if(OPENCL_FOUND)
opencl/fft_setup.cc # Needs OpenCL
opencl/fft_kernelstring.cc # Needs OpenCL
)
include_directories(${OPENCL_INCLUDE_DIRS})
if(OS_IS_MACOSX)
set(OPT_LIBRARIES ${OPT_LIBRARIES} "-framework OpenCL")
else()
set(OPT_LIBRARIES ${OPT_LIBRARIES} ${OPENCL_LIBRARIES})
endif()
endif()
list(SORT GNSS_SPLIBS_HEADERS)
@ -105,7 +99,6 @@ target_link_libraries(algorithms_libs
Gflags::gflags
Gnuradio::runtime
Gnuradio::blocks
${OPT_LIBRARIES}
PRIVATE
core_system_parameters
Volk::volk ${ORC_LIBRARIES}
@ -113,6 +106,13 @@ target_link_libraries(algorithms_libs
Glog::glog
)
if(OPENCL_FOUND)
target_link_libraries(algorithms_libs PUBLIC OpenCL::OpenCL)
target_include_directories(algorithms_libs PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/opencl
)
endif()
target_include_directories(algorithms_libs
PUBLIC
${CMAKE_SOURCE_DIR}/src/core/interfaces
@ -145,7 +145,7 @@ add_library(gnss_sdr_flags gnss_sdr_flags.cc gnss_sdr_flags.h)
if(${FILESYSTEM_FOUND})
target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM=1)
if(${find_experimental})
add_definitions(-DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM_EXPERIMENTAL=1)
endif()
target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem)
else()

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,7 @@ extern "C"
#include <stdio.h>
#ifdef __APPLE__
#define CL_SILENCE_DEPRECATION
#include <OpenCL/opencl.h>
#else
#include <CL/cl.h>

View File

@ -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}

View File

@ -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}

View File

@ -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

View File

@ -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)
@ -120,12 +114,16 @@ endif()
if(OPENCL_FOUND)
message(STATUS "Adding processing blocks implemented using OpenCL")
target_link_libraries(core_receiver PUBLIC algorithms_libs OpenCL::OpenCL)
target_compile_definitions(core_receiver PRIVATE -DOPENCL_BLOCKS=1)
else()
target_compile_definitions(core_receiver PRIVATE -DOPENCL_BLOCKS=0)
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()
@ -212,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}>
)

View File

@ -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()

View File

@ -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}

View File

@ -494,50 +494,57 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResults)
acquisition->init();
ASSERT_NO_THROW({
boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1);
signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of acquisition test.";
// i = 0 --> satellite in acquisition is visible
// i = 1 --> satellite in acquisition is not visible
for (unsigned int i = 0; i < 2; i++)
if (!acquisition->opencl_ready())
{
init();
std::cout << "OpenCL Platform is not ready." << std::endl;
}
else
{
ASSERT_NO_THROW({
boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1);
signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of acquisition test.";
if (i == 0)
// i = 0 --> satellite in acquisition is visible
// i = 1 --> satellite in acquisition is not visible
for (unsigned int i = 0; i < 2; i++)
{
gnss_synchro.PRN = 10; // This satellite is visible
}
else if (i == 1)
{
gnss_synchro.PRN = 20; // This satellite is not visible
}
init();
acquisition->set_local_code();
start_queue();
EXPECT_NO_THROW({
top_block->run(); // Start threads and wait
}) << "Failure running the top_block.";
if (i == 0)
{
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
if (message == 1)
if (i == 0)
{
EXPECT_EQ(static_cast<unsigned int>(1), correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
gnss_synchro.PRN = 10; // This satellite is visible
}
else if (i == 1)
{
gnss_synchro.PRN = 20; // This satellite is not visible
}
acquisition->set_local_code();
start_queue();
EXPECT_NO_THROW({
top_block->run(); // Start threads and wait
}) << "Failure running the top_block.";
if (i == 0)
{
EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS.";
if (message == 1)
{
EXPECT_EQ(static_cast<unsigned int>(1), correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation.";
}
}
else if (i == 1)
{
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
}
}
else if (i == 1)
{
EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL.";
}
}
}
@ -575,52 +582,58 @@ TEST_F(GpsL1CaPcpsOpenClAcquisitionGSoC2013Test, ValidationOfResultsProbabilitie
}) << "Failure connecting acquisition to the top_block.";
acquisition->init();
ASSERT_NO_THROW({
boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1);
signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of acquisition test.";
std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl;
// i = 0 --> satellite in acquisition is visible (prob of detection and prob of detection with wrong estimation)
// i = 1 --> satellite in acquisition is not visible (prob of false detection)
for (unsigned int i = 0; i < 2; i++)
if (!acquisition->opencl_ready())
{
init();
std::cout << "OpenCL Platform is not ready." << std::endl;
}
else
{
ASSERT_NO_THROW({
boost::shared_ptr<GenSignalSource> signal_source;
SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue);
FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1);
signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue));
signal_source->connect(top_block);
top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0);
top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events"));
}) << "Failure connecting the blocks of acquisition test.";
if (i == 0)
std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl;
// i = 0 --> satellite in acquisition is visible (prob of detection and prob of detection with wrong estimation)
// i = 1 --> satellite in acquisition is not visible (prob of false detection)
for (unsigned int i = 0; i < 2; i++)
{
gnss_synchro.PRN = 10; // This satellite is visible
}
else if (i == 1)
{
gnss_synchro.PRN = 20; // This satellite is not visible
}
init();
acquisition->set_local_code();
if (i == 0)
{
gnss_synchro.PRN = 10; // This satellite is visible
}
else if (i == 1)
{
gnss_synchro.PRN = 20; // This satellite is not visible
}
start_queue();
acquisition->set_local_code();
EXPECT_NO_THROW({
top_block->run(); // Start threads and wait
}) << "Failure running the top_block.";
start_queue();
if (i == 0)
{
std::cout << "Estimated probability of detection = " << Pd << std::endl;
std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
}
else if (i == 1)
{
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
EXPECT_NO_THROW({
top_block->run(); // Start threads and wait
}) << "Failure running the top_block.";
if (i == 0)
{
std::cout << "Estimated probability of detection = " << Pd << std::endl;
std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
}
else if (i == 1)
{
std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl;
std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl;
}
}
}
}