diff --git a/.github/workflows/gpu-sim.yml b/.github/workflows/gpu-sim.yml new file mode 100644 index 000000000..1c409df82 --- /dev/null +++ b/.github/workflows/gpu-sim.yml @@ -0,0 +1,123 @@ +# SPDX-License-Identifier: GPL-3.0-or-later +# 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 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. +# 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: + branches: + - next + paths: + - "src/**" + - "tests/**" + - "cmake/**" + - "CMakeLists.txt" + - ".github/workflows/gpu-sim.yml" + pull_request: + paths: + # 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 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +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@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@v0.1.10 + 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@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 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 \ + -DCMAKE_CUDA_RUNTIME_LIBRARY=Shared \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CUDA_COMPILER_LAUNCHER=ccache + + - name: Build gnss-sdr and run_tests + run: | + unset CMAKE_TOOLCHAIN_FILE + ccache -z + cmake --build build -j3 --target gnss-sdr run_tests + ccache -s + + - name: CUDA acquisition engine tests + 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.*' + + - name: CUDA multicorrelator test + run: vgpu run --gpu nvidia/h100 ./install/run_tests --gtest_filter='GpuMulticorrelatorTest.*' 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: 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