Wideband autonomous SDR analysis engine forked from sdr-visual-suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 line
1.9KB

  1. package gpudemod
  2. func (r *BatchRunner) buildStreamingGPUInvocations(iqNew []complex64, jobs []StreamingExtractJob) ([]StreamingGPUInvocation, error) {
  3. if r == nil || r.eng == nil {
  4. return nil, ErrUnavailable
  5. }
  6. invocations := make([]StreamingGPUInvocation, len(jobs))
  7. active := make(map[int64]struct{}, len(jobs))
  8. for i, job := range jobs {
  9. active[job.SignalID] = struct{}{}
  10. state, err := r.getOrInitExtractState(job, r.eng.sampleRate)
  11. if err != nil {
  12. return nil, err
  13. }
  14. invocations[i] = StreamingGPUInvocation{
  15. SignalID: job.SignalID,
  16. ConfigHash: state.ConfigHash,
  17. OffsetHz: job.OffsetHz,
  18. OutRate: job.OutRate,
  19. Bandwidth: job.Bandwidth,
  20. SampleRate: r.eng.sampleRate,
  21. NumTaps: state.NumTaps,
  22. Decim: state.Decim,
  23. PhaseCountIn: state.PhaseCount,
  24. NCOPhaseIn: state.NCOPhase,
  25. HistoryLen: len(state.ShiftedHistory),
  26. BaseTaps: append([]float32(nil), state.BaseTaps...),
  27. PolyphaseTaps: append([]float32(nil), state.PolyphaseTaps...),
  28. ShiftedHistory: append([]complex64(nil), state.ShiftedHistory...),
  29. IQNew: iqNew,
  30. }
  31. }
  32. for signalID := range r.streamState {
  33. if _, ok := active[signalID]; !ok {
  34. delete(r.streamState, signalID)
  35. }
  36. }
  37. r.syncNativeStreamingStates(active)
  38. return invocations, nil
  39. }
  40. func (r *BatchRunner) applyStreamingGPUExecutionResults(results []StreamingGPUExecutionResult) []StreamingExtractResult {
  41. out := make([]StreamingExtractResult, len(results))
  42. for i, res := range results {
  43. state := r.streamState[res.SignalID]
  44. if state != nil {
  45. state.NCOPhase = res.NCOPhaseOut
  46. state.PhaseCount = res.PhaseCountOut
  47. state.ShiftedHistory = append(state.ShiftedHistory[:0], res.HistoryOut...)
  48. }
  49. out[i] = StreamingExtractResult{
  50. SignalID: res.SignalID,
  51. IQ: res.IQ,
  52. Rate: res.Rate,
  53. NOut: res.NOut,
  54. PhaseCount: res.PhaseCountOut,
  55. HistoryLen: res.HistoryLenOut,
  56. }
  57. }
  58. return out
  59. }