From 0703dd2af3b97d5a6d714aea3c8799a567231f85 Mon Sep 17 00:00:00 2001 From: Javier Arribas Date: Tue, 4 Sep 2012 14:29:07 +0000 Subject: [PATCH] Optimizations in PCPS Acquisition module: - Improved speed for normalization in the FFTW results - Complex multiplications now use the SIMD instructions with VOLK library - Carrier wipeoff now uses the GNU Radio fixed point NCO (gr_fxpt) git-svn-id: https://svn.code.sf.net/p/gnss-sdr/code/trunk@241 64b25241-fba3-4117-9849-534c7e92360d --- .../gnuradio_blocks/pcps_acquisition_cc.cc | 25 ++++++++++++++----- src/algorithms/libs/gnss_signal_processing.cc | 25 +++++++++++++++---- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc index f6262800d..9b671d58b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_cc.cc @@ -38,6 +38,7 @@ #include #include #include +#include using google::LogMessage; @@ -124,7 +125,7 @@ void pcps_acquisition_cc::init() for (unsigned int i = 0; i < d_fft_size; i++) { d_fft_codes[i] = std::complex(conj(d_fft_if->get_outbuf()[i])); - d_fft_codes[i] = d_fft_codes[i] / (float)d_fft_size; //to correct the scale factor introduced by FFTW + //d_fft_codes[i] = d_fft_codes[i] / (float)d_fft_size; //to correct the scale factor introduced by FFTW } } @@ -176,6 +177,8 @@ int pcps_acquisition_cc::general_work(int noutput_items, unsigned int i; + float fft_normalization_factor; + DLOG(INFO) << "Channel: " << d_channel << " , doing acquisition of satellite: " << d_gnss_synchro->System << " "<< d_gnss_synchro->PRN << " ,sample stamp: " << d_sample_counter << ", threshold: " @@ -203,16 +206,23 @@ int pcps_acquisition_cc::general_work(int noutput_items, //3- Perform the FFT-based circular convolution (parallel time search) d_fft_if->execute(); - for (i = 0; i < d_fft_size; i++) - { - d_ifft->get_inbuf()[i] = (d_fft_if->get_outbuf()[i] - * d_fft_codes[i]) / (float)d_fft_size; - } + // Using plain C++ operations +// for (i = 0; i < d_fft_size; i++) +// { +// d_ifft->get_inbuf()[i] = (d_fft_if->get_outbuf()[i] +// * d_fft_codes[i]) / (float)d_fft_size; +// } + + // Using SIMD operations with VOLK library + volk_32fc_x2_multiply_32fc_a(d_ifft->get_inbuf(), d_fft_if->get_outbuf(), d_fft_codes, d_fft_size); + d_ifft->execute(); // Search maximum indext = 0; magt = 0; + fft_normalization_factor=(float)d_fft_size*(float)d_fft_size; + for (i = 0; i < d_fft_size; i++) { tmp_magt = std::norm(d_ifft->get_outbuf()[i]); @@ -223,6 +233,9 @@ int pcps_acquisition_cc::general_work(int noutput_items, } } + // Normalize the maximum value to correct the scale factor introduced by FFTW + magt=magt/(fft_normalization_factor*fft_normalization_factor); + // Record results to files if (d_dump) { diff --git a/src/algorithms/libs/gnss_signal_processing.cc b/src/algorithms/libs/gnss_signal_processing.cc index cb278af5e..f22bb9e4e 100644 --- a/src/algorithms/libs/gnss_signal_processing.cc +++ b/src/algorithms/libs/gnss_signal_processing.cc @@ -32,17 +32,32 @@ */ #include "gnss_signal_processing.h" - +#include void complex_exp_gen(std::complex* _dest, double _f, double _fs, unsigned int _samps) { - double phase = 0; - const double phase_step = (GPS_TWO_PI * _f) / _fs; + //old + //double phase = 0; + //const double phase_step = (GPS_TWO_PI * _f) / _fs; + + //new Fixed Point NCO (faster) + int phase_i=0; + int phase_step_i; + float phase_step_f =(float)((GPS_TWO_PI * _f) / _fs); + phase_step_i=gr_fxpt::float_to_fixed(phase_step_f); + float sin_f,cos_f; + for(unsigned int i = 0; i < _samps; i++) { - _dest[i] = std::complex(cos(phase), sin(phase)); - phase += phase_step; + //old + //_dest[i] = std::complex(cos(phase), sin(phase)); + //phase += phase_step; + + //new Fixed Point NCO (faster) + gr_fxpt::sincos(phase_i,&sin_f,&cos_f); + _dest[i] = std::complex(cos_f, sin_f); + phase_i += phase_step_i; } }