Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

36 lignes
879B

  1. #include <cuda_runtime.h>
  2. #include <math.h>
  3. extern "C" __global__ void gpud_freq_shift_kernel(
  4. const float2* __restrict__ in,
  5. float2* __restrict__ out,
  6. int n,
  7. double phase_inc,
  8. double phase_start
  9. ) {
  10. int idx = blockIdx.x * blockDim.x + threadIdx.x;
  11. if (idx >= n) return;
  12. double phase = phase_start + phase_inc * (double)idx;
  13. float si, co;
  14. sincosf((float)phase, &si, &co);
  15. float2 v = in[idx];
  16. out[idx].x = v.x * co - v.y * si;
  17. out[idx].y = v.x * si + v.y * co;
  18. }
  19. extern "C" int gpud_launch_freq_shift_cuda(
  20. const float2* in,
  21. float2* out,
  22. int n,
  23. double phase_inc,
  24. double phase_start
  25. ) {
  26. if (n <= 0) return 0;
  27. const int block = 256;
  28. const int grid = (n + block - 1) / block;
  29. gpud_freq_shift_kernel<<<grid, block>>>(in, out, n, phase_inc, phase_start);
  30. return (int)cudaGetLastError();
  31. }