mirror of
				https://github.com/gnss-sdr/gnss-sdr
				synced 2025-10-31 15:23:04 +00:00 
			
		
		
		
	Add cpu_multicorrelator_real_codes_test
and minor cosmetics
This commit is contained in:
		| @@ -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)); | ||||
|                     index = index + 4; | ||||
|                 } | ||||
|  | ||||
|         } | ||||
|     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) | ||||
| { | ||||
|     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) | ||||
| { | ||||
|     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]) | ||||
| { | ||||
|     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 unsigned int delay = ((static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS) - _chip_shift) | ||||
|                                 % static_cast<int>(Galileo_E1_B_CODE_LENGTH_CHIPS)) | ||||
|                                 * _samplesPerCode / Galileo_E1_B_CODE_LENGTH_CHIPS; | ||||
|             % static_cast<int>(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 | ||||
|  | ||||
| @@ -195,29 +191,24 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], | ||||
|             _signal_E1 = _resampled_signal; | ||||
|         } | ||||
|  | ||||
|  | ||||
|     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[ | ||||
|             static_cast<int>(Galileo_E1_C_SECONDARY_CODE_LENGTH) | ||||
|                                                     * _samplesPerCode]; | ||||
|             for (unsigned int i = 0; i < static_cast<unsigned int>(Galileo_E1_C_SECONDARY_CODE_LENGTH); i++) | ||||
|                 { | ||||
|                     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++) | ||||
|             { | ||||
|                 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); | ||||
|  | ||||
|         _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++) | ||||
|         { | ||||
| @@ -227,20 +218,20 @@ void galileo_e1_code_gen_float_sampled(float* _dest, char _Signal[3], | ||||
|     delete[] _signal_E1; | ||||
| } | ||||
|  | ||||
|  | ||||
| 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 _secondary_flag) | ||||
| { | ||||
|     std::string _galileo_signal = _Signal; | ||||
|     const int _codeFreqBasis = Galileo_E1_CODE_CHIP_RATE_HZ; //Hz | ||||
|     unsigned int _samplesPerCode = static_cast<unsigned int>(  | ||||
|             static_cast<double>(_fs) / (static_cast<double>(_codeFreqBasis )  | ||||
|                 / static_cast<double>(Galileo_E1_B_CODE_LENGTH_CHIPS))); | ||||
|     unsigned int _samplesPerCode = static_cast<unsigned int>( static_cast<double>(_fs) / | ||||
|             (static_cast<double>(_codeFreqBasis )  / static_cast<double>(Galileo_E1_B_CODE_LENGTH_CHIPS))); | ||||
|  | ||||
|     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]; | ||||
|  | ||||
| @@ -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], | ||||
|         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); | ||||
| } | ||||
|  | ||||
|  | ||||
| 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) | ||||
| { | ||||
|   | ||||
| @@ -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) | ||||
| { | ||||
|     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 ); | ||||
|  | ||||
|     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) | ||||
| { | ||||
|     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 ); | ||||
|  | ||||
|     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 ); | ||||
|         } | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -127,12 +127,12 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( | ||||
|  | ||||
|     // correlator outputs (scalar) | ||||
|     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++) | ||||
|     { | ||||
|         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_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())); | ||||
|     // Set TAPs delay values [chips] | ||||
|     d_local_code_shift_chips[0] = - d_early_late_spc_chips; | ||||
|     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; | ||||
|     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; | ||||
|     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); | ||||
|     // Doppler effect | ||||
|     // Fd=(C/(C+Vr))*F | ||||
|   | ||||
| @@ -132,7 +132,6 @@ private: | ||||
|     gr_complex* d_correlator_outs; | ||||
|     cpu_multicorrelator_real_codes multicorrelator_cpu; | ||||
|  | ||||
|  | ||||
|     // tracking vars | ||||
|     double d_code_freq_chips; | ||||
|     double d_code_phase_step_chips; | ||||
|   | ||||
| @@ -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/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_real_codes_test.cc" | ||||
|  | ||||
| #if CUDA_BLOCKS_TEST | ||||
| #include "unit-tests/signal-processing-blocks/tracking/gpu_multicorrelator_test.cc" | ||||
|   | ||||
| @@ -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_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_carrier_phase_step_rad, | ||||
|                     float d_code_phase_step_chips, | ||||
| @@ -137,7 +137,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) | ||||
|                             //create the concurrent correlator threads | ||||
|                             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], | ||||
|                                             d_rem_carrier_phase_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); | ||||
|                             std::cout << "CPU Multicorrelator (real codes) execution time for length=" << correlation_sizes[correlation_sizes_idx] | ||||
|                                       << " : " << execution_times[correlation_sizes_idx] << " [s]" << std::endl; | ||||
|  | ||||
|                         } | ||||
|                 } | ||||
|     ); | ||||
| @@ -166,7 +165,7 @@ TEST(CpuMulticorrelatorRealCodesTest, MeasureExecutionTime) | ||||
|     volk_gnsssdr_free(d_ca_code); | ||||
|     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(); | ||||
|         } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Carles Fernandez
					Carles Fernandez