From a64b776fc3d79f66d4e4f037706cd8d4ea6e4a3b Mon Sep 17 00:00:00 2001 From: Jan Svabenik Date: Thu, 19 Mar 2026 07:55:10 +0100 Subject: [PATCH] refactor: reuse shifted IQ from CUDA path --- internal/demod/gpudemod/doc.go | 11 +++++++++++ internal/demod/gpudemod/gpudemod.go | 7 ++++--- 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 internal/demod/gpudemod/doc.go diff --git a/internal/demod/gpudemod/doc.go b/internal/demod/gpudemod/doc.go new file mode 100644 index 0000000..25b4d4e --- /dev/null +++ b/internal/demod/gpudemod/doc.go @@ -0,0 +1,11 @@ +// Package gpudemod contains the CUDA-tagged demodulation pipeline scaffolding. +// +// Current state: +// - Standard builds use the !cufft stub. +// - cufft builds allocate GPU buffers and cross the CGO/CUDA launch boundary. +// - If/when a CUDA freq-shift launch succeeds, the shifted IQ is copied back and +// reused by the remaining CPU-side FIR/decimate/NFM pipeline. +// +// This keeps Phase 1 incremental and verifiable while later phases replace the +// placeholder launch wrappers with real kernels. +package gpudemod diff --git a/internal/demod/gpudemod/gpudemod.go b/internal/demod/gpudemod/gpudemod.go index 8e63f5a..2b2cd5c 100644 --- a/internal/demod/gpudemod/gpudemod.go +++ b/internal/demod/gpudemod/gpudemod.go @@ -175,9 +175,10 @@ func (e *Engine) Demod(iq []complex64, offsetHz float64, bw float64, mode DemodT // Real CUDA boundary is now present. If the launch wrappers are not yet backed // by actual kernels, we fall back to the existing CPU DSP path below. _ = fmt.Sprintf("%s:%0.3f", phaseStatus(), offsetHz) - _ = e.tryCUDAFreqShift(iq, offsetHz) - - shifted := dsp.FreqShift(iq, e.sampleRate, offsetHz) + shifted, ok := e.tryCUDAFreqShift(iq, offsetHz) + if !ok { + shifted = dsp.FreqShift(iq, e.sampleRate, offsetHz) + } cutoff := bw / 2 if cutoff < 200 { cutoff = 200