1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2025-08-04 12:56:59 +00:00

Add cpu_multicorrelator_real_codes_test

and minor cosmetics
This commit is contained in:
Carles Fernandez 2017-09-16 01:14:15 +02:00
parent 9ec5558143
commit 94dfef74c1
6 changed files with 42 additions and 50 deletions

View File

@ -55,7 +55,6 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn)
hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i)); hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i));
index = index + 4; index = index + 4;
} }
} }
else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2)
{ {
@ -72,7 +71,6 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn)
} }
void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_out) void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_out)
{ {
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
@ -91,7 +89,6 @@ void galileo_e1_sinboc_11_gen_int(int* _dest, int* _prn, unsigned int _length_ou
} }
void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_out) void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_out)
{ {
const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS; const unsigned int _length_in = Galileo_E1_B_CODE_LENGTH_CHIPS;
@ -111,7 +108,6 @@ void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_ou
} }
void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3])
{ {
std::string _galileo_signal = _Signal; std::string _galileo_signal = _Signal;
@ -160,8 +156,8 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
const int _samplesPerChip = (_cboc == true) ? 12 : 2; const int _samplesPerChip = (_cboc == true) ? 12 : 2;
const unsigned int delay = ((static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) const unsigned int delay = ((static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS) - _chip_shift)
% static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS)) % static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS))
* _samplesPerCode / Galileo_E1_B_CODE_LENGTH_CHIPS; * _samplesPerCode / Galileo_E1_B_CODE_LENGTH_CHIPS;
galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip
@ -195,29 +191,24 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
_signal_E1 = _resampled_signal; _signal_E1 = _resampled_signal;
} }
if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag)
{ {
float* _signal_E1C_secondary = new float[static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH) * _samplesPerCode];
float* _signal_E1C_secondary = new float[ for (unsigned int i = 0; i < static_cast<unsigned int>(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++)
static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH) {
* _samplesPerCode]; for (unsigned k = 0; k < _samplesPerCode; k++)
{
_signal_E1C_secondary[i*_samplesPerCode + k] = _signal_E1[k]
* (Galileo_E1_C_SECONDARY_CODE.at(i) == '0' ? 1.0f : -1.0f);
}
}
for (unsigned int i = 0; i < static_cast<unsigned int>(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++) _samplesPerCode *= static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH);
{
for (unsigned k = 0; k < _samplesPerCode; k++)
{
_signal_E1C_secondary[i*_samplesPerCode + k] = _signal_E1[k]
* (Galileo_E1_C_SECONDARY_CODE.at(i) == '0'
? 1.0f : -1.0f);
}
}
_samplesPerCode *= static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH); delete[] _signal_E1;
_signal_E1 = _signal_E1C_secondary;
delete[] _signal_E1; }
_signal_E1 = _signal_E1C_secondary;
}
for (unsigned int i = 0; i < _samplesPerCode; i++) for (unsigned int i = 0; i < _samplesPerCode; i++)
{ {
@ -227,20 +218,20 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
delete[] _signal_E1; delete[] _signal_E1;
} }
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift, bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift,
bool _secondary_flag) bool _secondary_flag)
{ {
std::string _galileo_signal = _Signal; std::string _galileo_signal = _Signal;
const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz
unsigned int _samplesPerCode = static_cast<unsigned int>( unsigned int _samplesPerCode = static_cast<unsigned int>( static_cast<double>(_fs) /
static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis ) (static_cast<double>(_codeFreqBasis ) / static_cast<double>(Galileo_E1_B_CODE_LENGTH_CHIPS)));
/ static_cast<double>(Galileo_E1_B_CODE_LENGTH_CHIPS)));
if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag) if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2 && _secondary_flag)
{ {
_samplesPerCode *= static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH); _samplesPerCode *= static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH);
} }
float real_code[_samplesPerCode]; float real_code[_samplesPerCode];
@ -252,12 +243,14 @@ void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signa
} }
} }
void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{ {
galileo_e1_code_gen_float_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false); galileo_e1_code_gen_float_sampled(_dest, _Signal, _cboc, _prn, _fs, _chip_shift, false);
} }
void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3], void galileo_e1_code_gen_complex_sampled(std::complex<float>* _dest, char _Signal[3],
bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift) bool _cboc, unsigned int _prn, signed int _fs, unsigned int _chip_shift)
{ {

View File

@ -113,6 +113,7 @@ void gps_l1_ca_code_gen_int(int* _dest, signed int _prn, unsigned int _chip_shif
} }
} }
void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift) void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_shift)
{ {
unsigned int _code_length = 1023; unsigned int _code_length = 1023;
@ -121,12 +122,12 @@ void gps_l1_ca_code_gen_float(float* _dest, signed int _prn, unsigned int _chip_
gps_l1_ca_code_gen_int( ca_code_int, _prn, _chip_shift ); gps_l1_ca_code_gen_int( ca_code_int, _prn, _chip_shift );
for( unsigned int ii = 0; ii < _code_length; ++ii ) for( unsigned int ii = 0; ii < _code_length; ++ii )
{ {
_dest[ii] = static_cast<float>( ca_code_int[ii] ); _dest[ii] = static_cast<float>( ca_code_int[ii] );
} }
} }
void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift) void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, unsigned int _chip_shift)
{ {
unsigned int _code_length = 1023; unsigned int _code_length = 1023;
@ -135,10 +136,9 @@ void gps_l1_ca_code_gen_complex(std::complex<float>* _dest, signed int _prn, uns
gps_l1_ca_code_gen_int( ca_code_int, _prn, _chip_shift ); gps_l1_ca_code_gen_int( ca_code_int, _prn, _chip_shift );
for( unsigned int ii = 0; ii < _code_length; ++ii ) for( unsigned int ii = 0; ii < _code_length; ++ii )
{ {
_dest[ii] = std::complex< float >( static_cast<float>(ca_code_int[ii]), 0.0f ); _dest[ii] = std::complex<float>( static_cast<float>(ca_code_int[ii]), 0.0f );
} }
} }

View File

@ -127,12 +127,12 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc(
// correlator outputs (scalar) // correlator outputs (scalar)
d_n_correlator_taps = 3; // Early, Prompt, and Late d_n_correlator_taps = 3; // Early, Prompt, and Late
d_correlator_outs = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_n_correlator_taps*sizeof(gr_complex), volk_gnsssdr_get_alignment())); d_correlator_outs = static_cast<gr_complex*>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment()));
for (int n = 0; n < d_n_correlator_taps; n++) for (int n = 0; n < d_n_correlator_taps; n++)
{ {
d_correlator_outs[n] = gr_complex(0,0); d_correlator_outs[n] = gr_complex(0,0);
} }
d_local_code_shift_chips = static_cast<float*>(volk_gnsssdr_malloc(d_n_correlator_taps*sizeof(float), volk_gnsssdr_get_alignment())); d_local_code_shift_chips = static_cast<float*>(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment()));
// Set TAPs delay values [chips] // Set TAPs delay values [chips]
d_local_code_shift_chips[0] = - d_early_late_spc_chips; d_local_code_shift_chips[0] = - d_early_late_spc_chips;
d_local_code_shift_chips[1] = 0.0; d_local_code_shift_chips[1] = 0.0;
@ -194,7 +194,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking()
long int acq_trk_diff_samples; long int acq_trk_diff_samples;
double acq_trk_diff_seconds; double acq_trk_diff_seconds;
acq_trk_diff_samples = static_cast<long int>(d_sample_counter) - static_cast<long int>(d_acq_sample_stamp); //-d_vector_length; acq_trk_diff_samples = static_cast<long int>(d_sample_counter) - static_cast<long int>(d_acq_sample_stamp); //-d_vector_length;
DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples;
acq_trk_diff_seconds = static_cast<float>(acq_trk_diff_samples) / static_cast<float>(d_fs_in); acq_trk_diff_seconds = static_cast<float>(acq_trk_diff_samples) / static_cast<float>(d_fs_in);
// Doppler effect // Doppler effect
// Fd=(C/(C+Vr))*F // Fd=(C/(C+Vr))*F

View File

@ -132,7 +132,6 @@ private:
gr_complex* d_correlator_outs; gr_complex* d_correlator_outs;
cpu_multicorrelator_real_codes multicorrelator_cpu; cpu_multicorrelator_real_codes multicorrelator_cpu;
// tracking vars // tracking vars
double d_code_freq_chips; double d_code_freq_chips;
double d_code_phase_step_chips; double d_code_phase_step_chips;

View File

@ -110,6 +110,7 @@ DECLARE_string(log_dir);
#include "unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc" #include "unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc" #include "unit-tests/signal-processing-blocks/tracking/tracking_loop_filter_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc" #include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_test.cc"
#include "unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc"
#if CUDA_BLOCKS_TEST #if CUDA_BLOCKS_TEST
#include "unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc" #include "unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc"

View File

@ -45,7 +45,7 @@
DEFINE_int32(cpu_multicorrelator_real_codes_iterations_test, 1000, "Number of averaged iterations in CPU multicorrelator test timing test"); DEFINE_int32(cpu_multicorrelator_real_codes_iterations_test, 1000, "Number of averaged iterations in CPU multicorrelator test timing test");
DEFINE_int32(cpu_multicorrelator_real_codes_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test"); DEFINE_int32(cpu_multicorrelator_real_codes_max_threads_test, 12, "Number of maximum concurrent correlators in CPU multicorrelator test timing test");
void run_correlator_cpu(cpu_multicorrelator_real_codes* correlator, void run_correlator_cpu_real_codes(cpu_multicorrelator_real_codes* correlator,
float d_rem_carrier_phase_rad, float d_rem_carrier_phase_rad,
float d_carrier_phase_step_rad, float d_carrier_phase_step_rad,
float d_code_phase_step_chips, float d_code_phase_step_chips,
@ -137,7 +137,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime)
//create the concurrent correlator threads //create the concurrent correlator threads
for (int current_thread = 0; current_thread < current_max_threads; current_thread++) for (int current_thread = 0; current_thread < current_max_threads; current_thread++)
{ {
thread_pool.push_back(std::thread(run_correlator_cpu, thread_pool.push_back(std::thread(run_correlator_cpu_real_codes,
correlator_pool[current_thread], correlator_pool[current_thread],
d_rem_carrier_phase_rad, d_rem_carrier_phase_rad,
d_carrier_phase_step_rad, d_carrier_phase_step_rad,
@ -156,7 +156,6 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime)
execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_cpu_multicorrelator_real_codes_iterations_test); execution_times[correlation_sizes_idx] = elapsed_seconds.count() / static_cast<double>(FLAGS_cpu_multicorrelator_real_codes_iterations_test);
std::cout << "CPU Multicorrelator (real codes) execution time for length=" << correlation_sizes[correlation_sizes_idx] std::cout << "CPU Multicorrelator (real codes) execution time for length=" << correlation_sizes[correlation_sizes_idx]
<< " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl; << " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl;
} }
} }
); );
@ -166,7 +165,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime)
volk_gnsssdr_free(d_ca_code); volk_gnsssdr_free(d_ca_code);
volk_gnsssdr_free(in_cpu); volk_gnsssdr_free(in_cpu);
for (int n = 0; n< max_threads; n++) for (int n = 0; n < max_threads; n++)
{ {
correlator_pool[n]->free(); correlator_pool[n]->free();
} }