From b53efacd99ccd3be9447a3e13d7ccfd5ed9c2c97 Mon Sep 17 00:00:00 2001 From: Saqib Khan <11544614+saqibkh@users.noreply.github.com> Date: Fri, 13 Nov 2026 13:26:02 -0600 Subject: [PATCH 1/4] Add a CI workflow for the CUDA tests on a simulated H100 Build run_tests with ENABLE_CUDA=ON (PTX for compute_90, shared CUDA runtime) and run the CUDA unit tests on a simulated NVIDIA H100. Signed-off-by: Saqib Khan <11544614+saqibkh@users.noreply.github.com> --- .github/workflows/gpu-sim.yml | 99 +++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 .github/workflows/gpu-sim.yml diff --git a/.github/workflows/gpu-sim.yml b/.github/workflows/gpu-sim.yml new file mode 100644 index 000000000..2fbb82179 --- /dev/null +++ b/.github/workflows/gpu-sim.yml @@ -0,0 +1,99 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-FileCopyrightText: 2026 Saqib Khan <11544614+saqibkh@users.noreply.github.com> +name: CUDA on simulated H100 + +# The hosted runners have no GPU, so the other workflows never build with +# ENABLE_CUDA=ON. This builds run_tests with the CUDA blocks and runs the CUDA +# unit tests on a simulated NVIDIA H100 +# (https://github.com/pantheongpu/pantheonsim). A simulator cannot reproduce +# hardware-specific behavior or timing, so it complements real-GPU testing and +# does not replace it. + +on: + workflow_dispatch: + pull_request: + paths: + - "src/**" + - "tests/**" + - "cmake/**" + - "CMakeLists.txt" + - ".github/workflows/gpu-sim.yml" + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + cuda-sim: + name: CUDA 13.0 on simulated H100 + runs-on: ubuntu-24.04 + timeout-minutes: 120 + steps: + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + with: + persist-credentials: false + + # library-path false: the build links the toolkit's cuFFT as usual, and + # the tests run under `vgpu run`, which supplies the simulator's libraries + - name: Set up the simulated H100 and CUDA toolkit + uses: pantheongpu/setup-pantheonsim@68edfd58c091361dd6baf060b63de412e544d858 # v0.1.7 + with: + gpu: nvidia/h100 + cuda-toolkit: "13.0" + library-path: "false" + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y --no-install-recommends ninja-build ccache \ + libunwind-dev libboost-dev libboost-date-time-dev libboost-system-dev \ + libboost-filesystem-dev libboost-thread-dev libboost-chrono-dev \ + libboost-serialization-dev liblog4cpp5-dev gnuradio-dev gr-osmosdr \ + libpugixml-dev libpcap-dev libblas-dev liblapack-dev libarmadillo-dev \ + libgflags-dev libgoogle-glog-dev libgnutls-openssl-dev libmatio-dev \ + googletest protobuf-compiler libprotobuf-dev python3-mako liborc-0.4-dev + + - name: Restore ccache + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: ~/.cache/ccache + key: ccache-gpu-sim-${{ github.sha }} + restore-keys: | + ccache-gpu-sim- + + # The simulator runs PTX (90-virtual) and needs the shared CUDA runtime + - name: Configure + run: | + cmake -S . -B build -GNinja \ + -DENABLE_CUDA=ON \ + -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.0/bin/nvcc \ + -DCUDAToolkit_ROOT=/usr/local/cuda-13.0 \ + -DCMAKE_CUDA_ARCHITECTURES=90-virtual \ + -DCMAKE_CUDA_RUNTIME_LIBRARY=Shared \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache + + - name: Build run_tests + run: | + ccache -z + cmake --build build -j3 --target run_tests + ccache -s + + # MatchesCpuReferenceLongCoherentIntegration is left out: with 4 ms of + # coherent integration the local code holds 4 identical periods, so the + # grid has 4 equal maxima (code phase 524, 4524, 8524, 12524) and which + # one the CPU and the GPU pick depends only on FFT rounding. + - name: CUDA acquisition engine tests + run: | + vgpu run --gpu nvidia/h100 ./install/run_tests \ + --gtest_filter='CudaPcpsEngineTest.*:-CudaPcpsEngineTest.MatchesCpuReferenceLongCoherentIntegration' + + - name: CUDA PCPS acquisition block tests + run: vgpu run --gpu nvidia/h100 ./install/run_tests --gtest_filter='GpsL1CaPcpsAcquisitionCudaTest.*' + + - name: CUDA multicorrelator test + run: vgpu run --gpu nvidia/h100 ./install/run_tests --gtest_filter='GpuMulticorrelatorTest.*' From e60e39b91a5afee7ad694c66242412e44d87e468 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 17 Nov 2026 19:55:31 +0100 Subject: [PATCH 2/4] Compare the CUDA and CPU acquisition peaks modulo the code period --- .../acquisition/cuda_pcps_engine_test.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/unit-tests/signal-processing-blocks/acquisition/cuda_pcps_engine_test.cc b/tests/unit-tests/signal-processing-blocks/acquisition/cuda_pcps_engine_test.cc index 19fc2bfef..216fc6b6d 100644 --- a/tests/unit-tests/signal-processing-blocks/acquisition/cuda_pcps_engine_test.cc +++ b/tests/unit-tests/signal-processing-blocks/acquisition/cuda_pcps_engine_test.cc @@ -255,12 +255,14 @@ void run_parity_case(const PcpsScenario& sc, uint32_t dwells) const GridPeak pc = find_peak(cpu.magnitude(), bins, E); const GridPeak pg = find_peak(gpu_grid, bins, E); EXPECT_EQ(pc.bin, pg.bin) << "Doppler bin of the peak differs"; - EXPECT_EQ(pc.index, pg.index) << "Code phase of the peak differs"; + // The local code is tiled sampled_ms times, so the grid repeats every code + // period and the peak is a sampled_ms-way tie that only rounding breaks. + const uint32_t samples_per_code = static_cast(sc.fs_in / 1000); + EXPECT_EQ(pc.index % samples_per_code, pg.index % samples_per_code) << "Code phase of the peak differs"; // And the peak must sit where the synthetic signal was put const int32_t expected_bin = (sc.doppler_max + static_cast(std::lround(sc.doppler_hz))) / sc.doppler_step; EXPECT_NEAR(static_cast(pg.bin), static_cast(expected_bin), 1.0); - const uint32_t samples_per_code = static_cast(sc.fs_in / 1000); EXPECT_EQ(pg.index % samples_per_code, sc.delay_samples % samples_per_code); std::cout << " fft_size=" << N << " bins=" << bins << " dwells=" << dwells From 79994e82f98fd01055b336d24fda0c1d2156b49a Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 17 Nov 2026 20:17:03 +0100 Subject: [PATCH 3/4] Build gnss-sdr and run all the CUDA tests on the simulated GPU Build gnss-sdr in addition to run_tests, with ENABLE_EVK1029=ON so that cuda_ddc_engine.cu is compiled too, and run the whole CudaPcpsEngineTest suite: MatchesCpuReferenceLongCoherentIntegration no longer depends on FFT rounding. Unset the CMAKE_TOOLCHAIN_FILE exported by the setup action, since GNSS-SDR takes a toolchain file as a sign of cross-compilation. The shared CUDA runtime that it selects is already requested explicitly. Run the workflow on pushes to next as well, so that the simulator build and the ccache are saved where every pull request can restore them, and do not cancel those runs. Refer to the actions by version tag, as the other workflows do, and update pantheongpu/setup-pantheonsim to v0.1.10. Add the job to the changelog and update the contact address in the copyright notice. --- .github/workflows/gpu-sim.yml | 48 ++++++++++++++++++++++------------- docs/CHANGELOG.md | 2 ++ 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/.github/workflows/gpu-sim.yml b/.github/workflows/gpu-sim.yml index 2fbb82179..a786ea877 100644 --- a/.github/workflows/gpu-sim.yml +++ b/.github/workflows/gpu-sim.yml @@ -1,16 +1,28 @@ # SPDX-License-Identifier: GPL-3.0-or-later -# SPDX-FileCopyrightText: 2026 Saqib Khan <11544614+saqibkh@users.noreply.github.com> +# SPDX-FileCopyrightText: 2026 Saqib Khan name: CUDA on simulated H100 # The hosted runners have no GPU, so the other workflows never build with -# ENABLE_CUDA=ON. This builds run_tests with the CUDA blocks and runs the CUDA -# unit tests on a simulated NVIDIA H100 +# ENABLE_CUDA=ON. This builds gnss-sdr and run_tests with the CUDA blocks and +# runs the CUDA unit tests on a simulated NVIDIA H100 # (https://github.com/pantheongpu/pantheonsim). A simulator cannot reproduce # hardware-specific behavior or timing, so it complements real-GPU testing and # does not replace it. +# A cache saved by a pull request run is only visible to that pull request. The +# runs on pushes to next save the simulator build and the ccache where every +# pull request targeting next can restore them. on: workflow_dispatch: + push: + branches: + - next + paths: + - "src/**" + - "tests/**" + - "cmake/**" + - "CMakeLists.txt" + - ".github/workflows/gpu-sim.yml" pull_request: paths: - "src/**" @@ -19,9 +31,10 @@ on: - "CMakeLists.txt" - ".github/workflows/gpu-sim.yml" +# Runs on next are left to finish, so that they save their caches concurrency: group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true + cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read @@ -32,14 +45,14 @@ jobs: runs-on: ubuntu-24.04 timeout-minutes: 120 steps: - - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 + - uses: actions/checkout@v7 with: persist-credentials: false # library-path false: the build links the toolkit's cuFFT as usual, and # the tests run under `vgpu run`, which supplies the simulator's libraries - name: Set up the simulated H100 and CUDA toolkit - uses: pantheongpu/setup-pantheonsim@68edfd58c091361dd6baf060b63de412e544d858 # v0.1.7 + uses: pantheongpu/setup-pantheonsim@v0.1.10 with: gpu: nvidia/h100 cuda-toolkit: "13.0" @@ -57,18 +70,24 @@ jobs: googletest protobuf-compiler libprotobuf-dev python3-mako liborc-0.4-dev - name: Restore ccache - uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + uses: actions/cache@v6 with: path: ~/.cache/ccache key: ccache-gpu-sim-${{ github.sha }} restore-keys: | ccache-gpu-sim- - # The simulator runs PTX (90-virtual) and needs the shared CUDA runtime + # The simulator runs PTX (90-virtual) and needs the shared CUDA runtime. + # The setup action exports a CMAKE_TOOLCHAIN_FILE that only selects that + # runtime, which is done here explicitly: it is unset because GNSS-SDR + # takes a toolchain file as a sign of cross-compilation. + # ENABLE_EVK1029 adds cuda_ddc_engine.cu to the build. - name: Configure run: | + unset CMAKE_TOOLCHAIN_FILE cmake -S . -B build -GNinja \ -DENABLE_CUDA=ON \ + -DENABLE_EVK1029=ON \ -DCMAKE_CUDA_COMPILER=/usr/local/cuda-13.0/bin/nvcc \ -DCUDAToolkit_ROOT=/usr/local/cuda-13.0 \ -DCMAKE_CUDA_ARCHITECTURES=90-virtual \ @@ -77,20 +96,15 @@ jobs: -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache - - name: Build run_tests + - name: Build gnss-sdr and run_tests run: | + unset CMAKE_TOOLCHAIN_FILE ccache -z - cmake --build build -j3 --target run_tests + cmake --build build -j3 --target gnss-sdr run_tests ccache -s - # MatchesCpuReferenceLongCoherentIntegration is left out: with 4 ms of - # coherent integration the local code holds 4 identical periods, so the - # grid has 4 equal maxima (code phase 524, 4524, 8524, 12524) and which - # one the CPU and the GPU pick depends only on FFT rounding. - name: CUDA acquisition engine tests - run: | - vgpu run --gpu nvidia/h100 ./install/run_tests \ - --gtest_filter='CudaPcpsEngineTest.*:-CudaPcpsEngineTest.MatchesCpuReferenceLongCoherentIntegration' + run: vgpu run --gpu nvidia/h100 ./install/run_tests --gtest_filter='CudaPcpsEngineTest.*' - name: CUDA PCPS acquisition block tests run: vgpu run --gpu nvidia/h100 ./install/run_tests --gtest_filter='GpsL1CaPcpsAcquisitionCudaTest.*' diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index dd97c5a2f..9eec88aa4 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -185,6 +185,8 @@ All notable changes to GNSS-SDR will be documented in this file. with the current Khronos OpenCL C++ bindings (`CL/opencl.hpp`, from OpenCL-CLHPP v2026.05.29). A system-wide `CL/opencl.hpp` is used if found, and the bundled copy otherwise. +- Added a CI job that builds the CUDA processing blocks and runs their unit + tests on a simulated GPU. Contributed by @saqibkh. ### Improvements in Reliability: From bc22f50d6fccfc2bbda3f25ce1d07604ed81b572 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Tue, 17 Nov 2026 21:03:31 +0100 Subject: [PATCH 4/4] CI: Run the CUDA job only on pull requests that touch the CUDA code --- .github/workflows/gpu-sim.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gpu-sim.yml b/.github/workflows/gpu-sim.yml index a786ea877..1c409df82 100644 --- a/.github/workflows/gpu-sim.yml +++ b/.github/workflows/gpu-sim.yml @@ -12,6 +12,8 @@ name: CUDA on simulated H100 # A cache saved by a pull request run is only visible to that pull request. The # runs on pushes to next save the simulator build and the ccache where every # pull request targeting next can restore them. +# Pull requests run this job only if they touch the CUDA code. A change +# elsewhere that breaks the CUDA build is caught by the run on next. on: workflow_dispatch: push: @@ -25,10 +27,18 @@ on: - ".github/workflows/gpu-sim.yml" pull_request: paths: - - "src/**" - - "tests/**" - - "cmake/**" - - "CMakeLists.txt" + # CUDA sources, the GPU tracking block and their tests + - "**/*cuda*" + - "**/*gpu*" + - "**/*.cu" + # Code with CUDA-specific branches + - "src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.*" + - "src/algorithms/acquisition/libs/acq_conf.*" + - "src/algorithms/signal_source/gnuradio_blocks/evk1029_source.*" + # Where the CUDA sources are added to the build + - "src/algorithms/acquisition/libs/CMakeLists.txt" + - "src/algorithms/tracking/libs/CMakeLists.txt" + - "src/algorithms/signal_source/libs/CMakeLists.txt" - ".github/workflows/gpu-sim.yml" # Runs on next are left to finish, so that they save their caches