1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-04-06 02:37:20 +00:00

volk_gnsssdr: improve install path detection

Re-enable usage of own cpu_features if volk >= 3.1 and not found
Add toolchain file for riscv64 RVV and CI tests
This commit is contained in:
Carles Fernandez 2025-02-11 19:07:14 +01:00
parent 32e7dc03ae
commit b4f373df57
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
8 changed files with 170 additions and 31 deletions

View File

@ -76,3 +76,42 @@ jobs:
./apps/volk_gnsssdr-config-info --malloc
./apps/volk_gnsssdr-config-info --cc
ctest -V
RISCV64-RVV-tests:
runs-on: ubuntu-24.04
name: RISCV64 RVV tests
steps:
- uses: actions/checkout@v4
- name: Install packages
run: |
sudo apt-get update -q -y
sudo apt-get install -y python3-mako cmake qemu-user-static g++-14-riscv64-linux-gnu clang-18
- name: Test RVV with gcc-14 VLEN=128
run: |
mkdir -p gcc14_VLEN_128; cd gcc14_VLEN_128
CXX=riscv64-linux-gnu-g++-14 CC=riscv64-linux-gnu-gcc-14 VLEN=128 cmake -DCMAKE_TOOLCHAIN_FILE=../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/rv64gcv-linux-gnu.cmake ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/
make -j$(nproc)
ARGS=-V make test
cd ..; rm -rf gcc14_VLEN_128
- name: Test RVV with gcc-14 VLEN=256
run: |
mkdir -p gcc14_VLEN_256; cd gcc14_VLEN_256
CXX=riscv64-linux-gnu-g++-14 CC=riscv64-linux-gnu-gcc-14 VLEN=256 cmake -DCMAKE_TOOLCHAIN_FILE=../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/rv64gcv-linux-gnu.cmake -DCMAKE_BUILD_TYPE=Release ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/
make -j$(nproc)
ARGS=-V make test
cd ..; rm -rf gcc14_VLEN_256
- name: Test RVV with clang-18 VLEN=512
run: |
mkdir -p clang18_VLEN_512; cd clang18_VLEN_512
CXX=clang++-18 CC=clang-18 CFLAGS=--target=riscv64-linux-gnu VLEN=512 cmake -DCMAKE_TOOLCHAIN_FILE=../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/rv64gcv-linux-gnu.cmake ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/
make -j$(nproc)
ARGS=-V make test
cd ..; rm -rf clang18_VLEN_512
- name: Test RVV with clang-18 VLEN=1024
run: |
mkdir -p clang18_VLEN_1024; cd clang18_VLEN_1024
CXX=clang++-18 CC=clang-18 CFLAGS=--target=riscv64-linux-gnu VLEN=1024 cmake -DCMAKE_TOOLCHAIN_FILE=../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Toolchains/rv64gcv-linux-gnu.cmake -DCMAKE_BUILD_TYPE=Release ../src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/
make -j$(nproc)
ARGS=-V make test
cd ..; rm -rf clang18_VLEN_1024

View File

@ -28,7 +28,6 @@ list(APPEND CMAKE_MODULE_PATH ${GNSSSDR_SOURCE_DIR}/cmake/Modules)
# Enable them at the command line by doing 'cmake -DENABLE_XXX=ON ..'
################################################################################
include(FeatureSummary)
include(GnsssdrLibPaths)
# Support of optional RF front-ends
option(ENABLE_UHD "Enable the use of UHD (driver for all USRP devices)" ON)
@ -611,6 +610,13 @@ set_package_properties(Threads PROPERTIES
################################################################################
# Set GNSSSDR_LIB_PATHS
################################################################################
include(GnsssdrLibPaths)
################################################################################
# Googletest - https://github.com/google/googletest
################################################################################
@ -1298,9 +1304,6 @@ if(NOT VOLKGNSSSDR_FOUND)
CMAKE_SYSTEM_PROCESSOR MATCHES "^loongarch")
set(SUPPORTED_CPU_FEATURES_ARCH TRUE)
endif()
if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64)
set(VOLK_GNSSSDR_LIB_SUFFIX 64)
endif()
if(CMAKE_VERSION VERSION_LESS 3.2)
ExternalProject_Add(volk_gnsssdr_module
PREFIX ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module
@ -1318,7 +1321,7 @@ if(NOT VOLKGNSSSDR_FOUND)
else()
if(SUPPORTED_CPU_FEATURES_ARCH)
set(VOLK_GNSSSDR_BUILD_BYPRODUCTS
${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}
${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}
${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile
)
if(ENABLE_CPUFEATURES)
@ -1341,7 +1344,7 @@ if(NOT VOLKGNSSSDR_FOUND)
set_package_properties(CPUFEATURES PROPERTIES
DESCRIPTION "A cross platform C99 library to get CPU features at runtime"
)
if((DEFINED VOLK_VERSION AND VOLK_VERSION VERSION_GREATER "2.3") OR (CMAKE_VERSION VERSION_LESS "3.13")) # avoid clash with volk's cpufeatures.
if((DEFINED VOLK_VERSION AND VOLK_VERSION VERSION_GREATER "2.3" AND VOLK_VERSION VERSION_LESS "3.1") OR (CMAKE_VERSION VERSION_LESS "3.13")) # avoid clash with volk's cpufeatures.
set(ENABLE_CPUFEATURES OFF)
else()
set_package_properties(CPUFEATURES PROPERTIES
@ -1386,7 +1389,7 @@ if(NOT VOLKGNSSSDR_FOUND)
UPDATE_COMMAND ""
PATCH_COMMAND ""
BUILD_COMMAND ${VOLK_GNSSSDR_BUILD_COMMAND}
BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}
BUILD_BYPRODUCTS ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/${CMAKE_FIND_LIBRARY_PREFIXES}volk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}
${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr_profile
${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/bin/volk_gnsssdr-config-info
INSTALL_DIR ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install
@ -1400,7 +1403,7 @@ if(NOT VOLKGNSSSDR_FOUND)
endif()
add_library(volk_gnsssdr UNKNOWN IMPORTED)
set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX})
set_property(TARGET volk_gnsssdr PROPERTY IMPORTED_LOCATION ${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX})
set(VOLK_GNSSSDR_INCLUDE_DIRS "${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/build/include/;${GNSSSDR_SOURCE_DIR}/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/include;${ORC_INCLUDE_DIRS}")
set(VOLK_GNSSSDR_LIBRARIES volk_gnsssdr ${ORC_LIBRARIES_STATIC})
if(CPUFEATURES_FOUND)
@ -1413,7 +1416,7 @@ if(NOT VOLKGNSSSDR_FOUND)
add_dependencies(Volkgnsssdr::volkgnsssdr volk_gnsssdr_module)
set_target_properties(Volkgnsssdr::volkgnsssdr PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/lib${VOLK_GNSSSDR_LIB_SUFFIX}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}"
IMPORTED_LOCATION "${GNSSSDR_BINARY_DIR}/volk_gnsssdr_module/install/${CMAKE_INSTALL_LIBDIR}/libvolk_gnsssdr${CMAKE_STATIC_LIBRARY_SUFFIX}"
INCLUDE_DIRECTORIES "${VOLK_GNSSSDR_INCLUDE_DIRS}"
INTERFACE_INCLUDE_DIRECTORIES "${VOLK_GNSSSDR_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${VOLK_GNSSSDR_LIBRARIES}"

View File

@ -0,0 +1,32 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# Copyright (C) 2011-2025 (see AUTHORS file for a list of contributors)
# SPDX-License-Identifier: BSD-3-Clause
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR riscv64)
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_C_FLAGS "$ENV{CFLAGS} -march=rv64gcv" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -g" CACHE STRING "" FORCE)
set(CMAKE_OBJCOPY
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy
CACHE INTERNAL "objcopy tool")
set(CMAKE_SIZE_UTIL
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size
CACHE INTERNAL "size tool")
set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(QEMU_VLEN $ENV{VLEN})
if(NOT QEMU_VLEN)
set(QEMU_VLEN "128")
endif()
set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-riscv64-static -L /usr/riscv64-linux-gnu/ -cpu rv64,zba=true,zbb=true,v=on,vlen=${QEMU_VLEN},rvv_ta_all_1s=on,rvv_ma_all_1s=on")

View File

@ -394,23 +394,12 @@ endif()
########################################################################
# Detect /lib versus /lib64
########################################################################
if(${CMAKE_INSTALL_LIBDIR} MATCHES lib64)
set(LIB_SUFFIX 64)
endif()
include(GNUInstallDirs)
########################################################################
# Setup the package config file
########################################################################
# set variables found in the pc.in file
if(NOT LIB_SUFFIX)
set(LIB_SUFFIX "")
endif()
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix "\${prefix}")
set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}")
set(includedir "\${prefix}/include")
configure_file(
${PROJECT_SOURCE_DIR}/tmpl/volk_gnsssdr.pc.in
${PROJECT_BINARY_DIR}/volk_gnsssdr.pc
@ -419,7 +408,7 @@ configure_file(
install(
FILES ${PROJECT_BINARY_DIR}/volk_gnsssdr.pc
DESTINATION lib${LIB_SUFFIX}/pkgconfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT "volk_gnsssdr_devel"
)
@ -427,7 +416,7 @@ install(
# Install all headers in the include directories
########################################################################
set(VOLK_RUNTIME_DIR bin)
set(VOLK_LIBRARY_DIR lib${LIB_SUFFIX})
set(VOLK_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR})
set(VOLK_INCLUDE_DIR include)
install(
@ -524,7 +513,7 @@ configure_file(
########################################################################
if(NOT CMAKE_MODULES_DIR)
set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake)
set(CMAKE_MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
endif()
install(

View File

@ -0,0 +1,32 @@
# GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
# This file is part of GNSS-SDR.
#
# Copyright (C) 2011-2025 (see AUTHORS file for a list of contributors)
# SPDX-License-Identifier: BSD-3-Clause
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR riscv64)
set(CMAKE_C_COMPILER $ENV{CC})
set(CMAKE_ASM_COMPILER ${CMAKE_C_COMPILER})
set(CMAKE_CXX_COMPILER $ENV{CXX})
set(CMAKE_C_FLAGS "$ENV{CFLAGS} -march=rv64gcv" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS ${CMAKE_C_FLAGS} CACHE STRING "" FORCE)
set(CMAKE_ASM_FLAGS "${CMAKE_C_FLAGS} -g" CACHE STRING "" FORCE)
set(CMAKE_OBJCOPY
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}objcopy
CACHE INTERNAL "objcopy tool")
set(CMAKE_SIZE_UTIL
${RISCV64_TOOLCHAIN_DIR}/${TOOLCHAIN_PREFIX}size
CACHE INTERNAL "size tool")
set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(QEMU_VLEN $ENV{VLEN})
if(NOT QEMU_VLEN)
set(QEMU_VLEN "128")
endif()
set(CMAKE_CROSSCOMPILING_EMULATOR "qemu-riscv64-static -L /usr/riscv64-linux-gnu/ -cpu rv64,zba=true,zbb=true,v=on,vlen=${QEMU_VLEN},rvv_ta_all_1s=on,rvv_ma_all_1s=on")

View File

@ -534,4 +534,48 @@ static inline void volk_gnsssdr_32f_index_max_32u_neon(uint32_t* target, const f
#endif /* LV_HAVE_NEON */
#ifdef LV_HAVE_RVV
#include <riscv_vector.h>
static inline void volk_gnsssdr_32f_index_max_32u_rvv(uint32_t* target, const float* src0, uint32_t num_points)
{
if (num_points == 0)
{
return;
}
float max_val = src0[0];
uint32_t max_idx = 0;
size_t vl;
// Process in chunks
for (size_t i = 0; i < num_points; i += vl)
{
// Set vector length for this iteration
vl = __riscv_vsetvl_e32m1(num_points - i);
// Load vector of values
vfloat32m1_t v_vals = __riscv_vle32_v_f32m1(&src0[i], vl);
// Process each element in the vector
for (size_t j = 0; j < vl; j++)
{
float val = __riscv_vfmv_f_s_f32m1_f32(v_vals);
if (val > max_val)
{
max_val = val;
max_idx = i + j;
}
// Shift to next element by reloading
if (j + 1 < vl)
{
v_vals = __riscv_vle32_v_f32m1(&src0[i + j + 1], vl - j - 1);
}
}
}
target[0] = max_idx;
}
#endif /* LV_HAVE_RVV */
#endif /* INCLUDED_volk_gnsssdr_32f_index_max_32u_H */

View File

@ -655,8 +655,8 @@ if(NOT (ENABLE_STATIC_LIBS AND (CMAKE_GENERATOR STREQUAL Xcode)))
# Install locations
install(TARGETS volk_gnsssdr
EXPORT VOLK_GNSSSDR-export
LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_runtime" # .so file
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel" # .lib file
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_gnsssdr_runtime" # .so file
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_gnsssdr_devel" # .lib file
RUNTIME DESTINATION bin COMPONENT "volk_gnsssdr_runtime" # .dll file
)
endif()
@ -703,7 +703,7 @@ if(ENABLE_STATIC_LIBS)
install(TARGETS volk_gnsssdr_static
EXPORT VOLK_GNSSSDR-export
ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_gnsssdr_devel"
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_gnsssdr_devel"
)
endif()

View File

@ -1,9 +1,9 @@
# SPDX-FileCopyrightText: 2014 Carles Fernandez-Prades <carles.fernandez@cttc.es>
# SPDX-License-Identifier: GPL-3.0-or-later
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
includedir=@includedir@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
LV_CXXFLAGS=@LV_CXXFLAGS@