浏览代码

feat: validate CUDA freq-shift output

master
Jan Svabenik 3 天前
父节点
当前提交
b4a9c48af7
共有 3 个文件被更改,包括 26 次插入1 次删除
  1. 二进制
      internal/demod/gpudemod/build/kernels.obj
  2. +1
    -1
      internal/demod/gpudemod/gpudemod.go
  3. +25
    -0
      internal/demod/gpudemod/validation_test.go

二进制
internal/demod/gpudemod/build/kernels.obj 查看文件


+ 1
- 1
internal/demod/gpudemod/gpudemod.go 查看文件

@@ -181,7 +181,7 @@ func (e *Engine) Demod(iq []complex64, offsetHz float64, bw float64, mode DemodT
// by actual kernels, we fall back to the existing CPU DSP path below.
_ = fmt.Sprintf("%s:%0.3f", phaseStatus(), offsetHz)
shifted, ok := e.tryCUDAFreqShift(iq, offsetHz)
if !ok {
if !ok || !ValidateFreqShift(iq, e.sampleRate, offsetHz, shifted, 1e-3) {
shifted = dsp.FreqShift(iq, e.sampleRate, offsetHz)
}
cutoff := bw / 2


+ 25
- 0
internal/demod/gpudemod/validation_test.go 查看文件

@@ -0,0 +1,25 @@
//go:build cufft

package gpudemod

import (
"testing"

"sdr-visual-suite/internal/dsp"
)

func TestValidateFreqShiftRejectsMismatchedLength(t *testing.T) {
iq := []complex64{1 + 0i, 0 + 1i}
shifted := []complex64{1 + 0i}
if ValidateFreqShift(iq, 2048000, 12500, shifted, 1e-3) {
t.Fatal("expected mismatched lengths to fail validation")
}
}

func TestValidateFreqShiftAcceptsCPUReference(t *testing.T) {
iq := []complex64{1 + 0i, 0.5 + 0.25i, -0.25 + 0.75i, 0.1 - 0.3i}
shifted := dsp.FreqShift(iq, 2048000, 256000)
if !ValidateFreqShift(iq, 2048000, 256000, shifted, 1e-6) {
t.Fatal("expected CPU reference shifted IQ to pass validation")
}
}

正在加载...
取消
保存