1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-12-14 12:10:34 +00:00

Important bug found and fixed:

Volk memory alignement for signal vectors was using a hardcoded 16 bytes
value. This parameter is machine-dependant and thus, in modern machines
caused memory exceptions if the parameter not match.

All posix_memalign functions are now replaced by the GNU Radio
volk_malloc(vector_size (bytes), volk_get_alignement());

volk_get_alignement() returns the number of bytes to align the memory
blocks in the current processor.

The memory bug showed up when the receiver is configured with higher
sample rates (>4 Msps!)
This commit is contained in:
Javier Arribas 2014-09-07 19:11:37 +02:00
parent 7d0ac88f93
commit 072d0cad67
9 changed files with 178 additions and 164 deletions

View File

@ -131,21 +131,22 @@ galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc(
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas d_very_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_very_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_very_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_very_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
// space for carrier wipeoff and signal baseband vectors d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
// correlator outputs (scalar) // correlator outputs (scalar)
if (posix_memalign((void**)&d_Very_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){}; d_Very_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Very_Late, 16, sizeof(gr_complex)) == 0){}; d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Very_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Initializations ------------------------------ //--- Initializations ------------------------------
// Initial code frequency basis of NCO // Initial code frequency basis of NCO
@ -284,17 +285,17 @@ galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_very_early_code); volk_free(d_very_early_code);
free(d_early_code); volk_free(d_early_code);
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_very_late_code); volk_free(d_very_late_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Very_Early); volk_free(d_Very_Early);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
free(d_Very_Late); volk_free(d_Very_Late);
delete[] d_ca_code; delete[] d_ca_code;
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;

View File

@ -134,21 +134,22 @@ Galileo_E1_Tcp_Connector_Tracking_cc::Galileo_E1_Tcp_Connector_Tracking_cc(
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas d_very_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_very_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_very_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_very_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
// space for carrier wipeoff and signal baseband vectors d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
// correlator outputs (scalar) // correlator outputs (scalar)
if (posix_memalign((void**)&d_Very_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){}; d_Very_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Very_Late, 16, sizeof(gr_complex)) == 0){}; d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Very_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Perform initializations ------------------------------ //--- Perform initializations ------------------------------
// define initial code frequency basis of NCO // define initial code frequency basis of NCO
@ -279,17 +280,17 @@ Galileo_E1_Tcp_Connector_Tracking_cc::~Galileo_E1_Tcp_Connector_Tracking_cc()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_very_early_code); volk_free(d_very_early_code);
free(d_early_code); volk_free(d_early_code);
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_very_late_code); volk_free(d_very_late_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Very_Early); volk_free(d_Very_Early);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
free(d_Very_Late); volk_free(d_Very_Late);
delete[] d_ca_code; delete[] d_ca_code;
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;

View File

@ -138,18 +138,22 @@ Galileo_E5a_Dll_Pll_Tracking_cc::Galileo_E5a_Dll_Pll_Tracking_cc(
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){};
if (posix_memalign((void**)&d_prompt_data_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_data_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; // correlator outputs (scalar)
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Prompt_data, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Prompt_data=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Perform initializations ------------------------------ //--- Perform initializations ------------------------------
// define initial code frequency basis of NCO // define initial code frequency basis of NCO
d_code_freq_chips = Galileo_E5a_CODE_CHIP_RATE_HZ; d_code_freq_chips = Galileo_E5a_CODE_CHIP_RATE_HZ;
@ -195,10 +199,14 @@ Galileo_E5a_Dll_Pll_Tracking_cc::~Galileo_E5a_Dll_Pll_Tracking_cc ()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_prompt_code);
free(d_late_code); volk_free(d_prompt_code);
free(d_early_code); volk_free(d_late_code);
free(d_carr_sign); volk_free(d_early_code);
volk_free(d_carr_sign);
volk_free(d_prompt_data_code);
volk_free(d_Prompt_data);
delete[] d_codeQ; delete[] d_codeQ;
delete[] d_codeI; delete[] d_codeI;
@ -432,10 +440,10 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
std::cout << tmp_str_stream.rdbuf() << std::flush; std::cout << tmp_str_stream.rdbuf() << std::flush;
} }
} }
d_Early = gr_complex(0,0); *d_Early = gr_complex(0,0);
d_Prompt = gr_complex(0,0); *d_Prompt = gr_complex(0,0);
d_Late = gr_complex(0,0); *d_Late = gr_complex(0,0);
d_Prompt_data = gr_complex(0,0); *d_Prompt_data = gr_complex(0,0);
*out[0] = *d_acquisition_gnss_synchro; *out[0] = *d_acquisition_gnss_synchro;
@ -496,9 +504,9 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
update_local_code(); update_local_code();
update_local_carrier(); update_local_carrier();
// Reset accumulated values // Reset accumulated values
d_Early = gr_complex(0,0); *d_Early = gr_complex(0,0);
d_Prompt = gr_complex(0,0); *d_Prompt = gr_complex(0,0);
d_Late = gr_complex(0,0); *d_Late = gr_complex(0,0);
} }
gr_complex single_early; gr_complex single_early;
gr_complex single_prompt; gr_complex single_prompt;
@ -516,18 +524,18 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
&single_early, &single_early,
&single_prompt, &single_prompt,
&single_late, &single_late,
&d_Prompt_data, d_Prompt_data,
is_unaligned()); is_unaligned());
// Accumulate results (coherent integration since there are no bit transitions in pilot signal) // Accumulate results (coherent integration since there are no bit transitions in pilot signal)
d_Early += single_early * sec_sign_Q; *d_Early += single_early * sec_sign_Q;
d_Prompt += single_prompt * sec_sign_Q; *d_Prompt += single_prompt * sec_sign_Q;
d_Late += single_late * sec_sign_Q; *d_Late += single_late * sec_sign_Q;
d_Prompt_data *= sec_sign_I; *d_Prompt_data *= sec_sign_I;
d_integration_counter++; d_integration_counter++;
// check for samples consistency (this should be done before in the receiver / here only if the source is a file) // check for samples consistency (this should be done before in the receiver / here only if the source is a file)
if (std::isnan((d_Prompt).real()) == true or std::isnan((d_Prompt).imag()) == true ) // or std::isinf(in[i].real())==true or std::isinf(in[i].imag())==true) if (std::isnan((*d_Prompt).real()) == true or std::isnan((*d_Prompt).imag()) == true ) // or std::isinf(in[i].real())==true or std::isinf(in[i].imag())==true)
{ {
const int samples_available = ninput_items[0]; const int samples_available = ninput_items[0];
d_sample_counter = d_sample_counter + samples_available; d_sample_counter = d_sample_counter + samples_available;
@ -553,11 +561,11 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
{ {
if (d_secondary_lock == true) if (d_secondary_lock == true)
{ {
carr_error_hz = pll_four_quadrant_atan(d_Prompt) / (float)GALILEO_PI*2; carr_error_hz = pll_four_quadrant_atan(*d_Prompt) / (float)GALILEO_PI*2;
} }
else else
{ {
carr_error_hz = pll_cloop_two_quadrant_atan(d_Prompt) / (float)GALILEO_PI*2; carr_error_hz = pll_cloop_two_quadrant_atan(*d_Prompt) / (float)GALILEO_PI*2;
} }
// Carrier discriminator filter // Carrier discriminator filter
@ -577,7 +585,7 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
if (d_integration_counter == d_current_ti_ms) if (d_integration_counter == d_current_ti_ms)
{ {
// DLL discriminator // DLL discriminator
code_error_chips = dll_nc_e_minus_l_normalized(d_Early, d_Late); //[chips/Ti] code_error_chips = dll_nc_e_minus_l_normalized(*d_Early, *d_Late); //[chips/Ti]
// Code discriminator filter // Code discriminator filter
code_error_filt_chips = d_code_loop_filter.get_code_nco(code_error_chips); //[chips/second] code_error_filt_chips = d_code_loop_filter.get_code_nco(code_error_chips); //[chips/second]
//Code phase accumulator //Code phase accumulator
@ -607,12 +615,12 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES-1) if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES-1)
{ {
// fill buffer with prompt correlator output values // fill buffer with prompt correlator output values
d_Prompt_buffer[d_cn0_estimation_counter] = d_Prompt; d_Prompt_buffer[d_cn0_estimation_counter] = *d_Prompt;
d_cn0_estimation_counter++; d_cn0_estimation_counter++;
} }
else else
{ {
d_Prompt_buffer[d_cn0_estimation_counter] = d_Prompt; d_Prompt_buffer[d_cn0_estimation_counter] = *d_Prompt;
// ATTEMPT SECONDARY CODE ACQUISITION // ATTEMPT SECONDARY CODE ACQUISITION
if (d_secondary_lock == false) if (d_secondary_lock == false)
{ {
@ -688,8 +696,8 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
// The first Prompt output not equal to 0 is synchronized with the transition of a navigation data bit. // The first Prompt output not equal to 0 is synchronized with the transition of a navigation data bit.
if (d_secondary_lock && d_first_transition) if (d_secondary_lock && d_first_transition)
{ {
current_synchro_data.Prompt_I = (double)(d_Prompt_data.real()); current_synchro_data.Prompt_I = (double)((*d_Prompt_data).real());
current_synchro_data.Prompt_Q = (double)(d_Prompt_data.imag()); current_synchro_data.Prompt_Q = (double)((*d_Prompt_data).imag());
// Tracking_timestamp_secs is aligned with the PRN start sample // Tracking_timestamp_secs is aligned with the PRN start sample
current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter + (double)d_current_prn_length_samples + (double)d_rem_code_phase_samples)/(double)d_fs_in; current_synchro_data.Tracking_timestamp_secs = ((double)d_sample_counter + (double)d_current_prn_length_samples + (double)d_rem_code_phase_samples)/(double)d_fs_in;
// This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, thus, Code_phase_secs=0 // This tracking block aligns the Tracking_timestamp_secs with the start sample of the PRN, thus, Code_phase_secs=0
@ -721,13 +729,13 @@ int Galileo_E5a_Dll_Pll_Tracking_cc::general_work (int noutput_items, gr_vector_
float prompt_Q; float prompt_Q;
float tmp_float; float tmp_float;
double tmp_double; double tmp_double;
prompt_I = d_Prompt_data.real(); prompt_I = (*d_Prompt_data).real();
prompt_Q = d_Prompt_data.imag(); prompt_Q = (*d_Prompt_data).imag();
if (d_integration_counter == d_current_ti_ms) if (d_integration_counter == d_current_ti_ms)
{ {
tmp_E = std::abs<float>(d_Early); tmp_E = std::abs<float>(*d_Early);
tmp_P = std::abs<float>(d_Prompt); tmp_P = std::abs<float>(*d_Prompt);
tmp_L = std::abs<float>(d_Late); tmp_L = std::abs<float>(*d_Late);
} }
try try
{ {

View File

@ -151,10 +151,10 @@ private:
gr_complex* d_prompt_data_code; gr_complex* d_prompt_data_code;
gr_complex* d_carr_sign; gr_complex* d_carr_sign;
gr_complex d_Early; gr_complex *d_Early;
gr_complex d_Prompt; gr_complex *d_Prompt;
gr_complex d_Late; gr_complex *d_Late;
gr_complex d_Prompt_data; gr_complex *d_Prompt_data;
float tmp_E; float tmp_E;
float tmp_P; float tmp_P;

View File

@ -127,18 +127,20 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc(
/* If an array is partitioned for more than one thread to operate on, /* If an array is partitioned for more than one thread to operate on,
* having the sub-array boundaries unaligned to cache lines could lead * having the sub-array boundaries unaligned to cache lines could lead
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_complex array of size 2*d_vector_length) aligned to cache of N bytes (machine dependent!)
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas // Get space for the resampled early / prompt / late local replicas
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// space for carrier wipeoff and signal baseband vectors // space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; // correlator outputs (scalar)
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
// sample synchronization // sample synchronization
d_sample_counter = 0; d_sample_counter = 0;
@ -312,13 +314,13 @@ Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Fll_Pll_Tracking_cc()
d_dump_file.close(); d_dump_file.close();
delete[] d_ca_code; delete[] d_ca_code;
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_early_code); volk_free(d_early_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;
} }

View File

@ -124,19 +124,20 @@ Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc(
/* If an array is partitioned for more than one thread to operate on, /* If an array is partitioned for more than one thread to operate on,
* having the sub-array boundaries unaligned to cache lines could lead * having the sub-array boundaries unaligned to cache lines could lead
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_complex array of size 2*d_vector_length) aligned to cache of N bytes (machine dependent!)
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas // Get space for the resampled early / prompt / late local replicas
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// space for carrier wipeoff and signal baseband vectors // space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; // correlator outputs (scalar)
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Perform initializations ------------------------------ //--- Perform initializations ------------------------------
// define initial code frequency basis of NCO // define initial code frequency basis of NCO
@ -319,13 +320,13 @@ Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Optim_Tracking_cc()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_early_code); volk_free(d_early_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
delete[] d_ca_code; delete[] d_ca_code;
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;

View File

@ -122,18 +122,21 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc(
/* If an array is partitioned for more than one thread to operate on, /* If an array is partitioned for more than one thread to operate on,
* having the sub-array boundaries unaligned to cache lines could lead * having the sub-array boundaries unaligned to cache lines could lead
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_complex array of size 2*d_vector_length) aligned to cache of N bytes (machine dependent!)
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas // Get space for the resampled early / prompt / late local replicas
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// space for carrier wipeoff and signal baseband vectors // space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){};
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; // correlator outputs (scalar)
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Perform initializations ------------------------------ //--- Perform initializations ------------------------------
// define initial code frequency basis of NCO // define initial code frequency basis of NCO
@ -309,13 +312,13 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_early_code); volk_free(d_early_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
delete[] d_ca_code; delete[] d_ca_code;
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;

View File

@ -134,17 +134,18 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::Gps_L1_Ca_Tcp_Connector_Tracking_cc(
* to performance degradation. Here we allocate memory * to performance degradation. Here we allocate memory
* (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes * (gr_comlex array of size 2*d_vector_length) aligned to cache of 16 bytes
*/ */
// todo: do something if posix_memalign fails
// Get space for the resampled early / prompt / late local replicas // Get space for the resampled early / prompt / late local replicas
if (posix_memalign((void**)&d_early_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_early_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_late_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_prompt_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_prompt_code, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_late_code=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// space for carrier wipeoff and signal baseband vectors // space for carrier wipeoff and signal baseband vectors
if (posix_memalign((void**)&d_carr_sign, 16, d_vector_length * sizeof(gr_complex) * 2) == 0){}; d_carr_sign=(gr_complex*)volk_malloc(2*d_vector_length * sizeof(gr_complex),volk_get_alignment());
// correlator outputs (scalar) // correlator outputs (scalar)
if (posix_memalign((void**)&d_Early, 16, sizeof(gr_complex)) == 0){}; d_Early=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Prompt, 16, sizeof(gr_complex)) == 0){}; d_Prompt=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&d_Late, 16, sizeof(gr_complex)) == 0){}; d_Late=(gr_complex*)volk_malloc(sizeof(gr_complex),volk_get_alignment());
//--- Perform initializations ------------------------------ //--- Perform initializations ------------------------------
// define initial code frequency basis of NCO // define initial code frequency basis of NCO
@ -328,13 +329,13 @@ Gps_L1_Ca_Tcp_Connector_Tracking_cc::~Gps_L1_Ca_Tcp_Connector_Tracking_cc()
{ {
d_dump_file.close(); d_dump_file.close();
free(d_prompt_code); volk_free(d_prompt_code);
free(d_late_code); volk_free(d_late_code);
free(d_early_code); volk_free(d_early_code);
free(d_carr_sign); volk_free(d_carr_sign);
free(d_Early); volk_free(d_Early);
free(d_Prompt); volk_free(d_Prompt);
free(d_Late); volk_free(d_Late);
delete[] d_ca_code; delete[] d_ca_code;
delete[] d_Prompt_buffer; delete[] d_Prompt_buffer;

View File

@ -156,8 +156,7 @@ void Correlator::Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples ,cons
gr_complex* bb_signal; gr_complex* bb_signal;
//gr_complex* input_aligned; //gr_complex* input_aligned;
//todo: do something if posix_memalign fails bb_signal=(gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&bb_signal, 16, signal_length_samples * sizeof(gr_complex)) == 0) {};
if (input_vector_unaligned == true) if (input_vector_unaligned == true)
{ {
@ -197,8 +196,7 @@ void Correlator::Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const
gr_complex* bb_signal; gr_complex* bb_signal;
//gr_complex* input_aligned; //gr_complex* input_aligned;
//todo: do something if posix_memalign fails bb_signal=(gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex),volk_get_alignment());
if (posix_memalign((void**)&bb_signal, 16, signal_length_samples * sizeof(gr_complex)) == 0) {};
if (input_vector_unaligned == false) if (input_vector_unaligned == false)
{ {
@ -213,7 +211,6 @@ void Correlator::Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const
//use directly the input vector //use directly the input vector
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, signal_length_samples); volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, signal_length_samples);
} }
volk_32fc_x2_dot_prod_32fc_a(VE_out, bb_signal, VE_code, signal_length_samples); volk_32fc_x2_dot_prod_32fc_a(VE_out, bb_signal, VE_code, signal_length_samples);
volk_32fc_x2_dot_prod_32fc_a(E_out, bb_signal, E_code, signal_length_samples); volk_32fc_x2_dot_prod_32fc_a(E_out, bb_signal, E_code, signal_length_samples);
volk_32fc_x2_dot_prod_32fc_a(P_out, bb_signal, P_code, signal_length_samples); volk_32fc_x2_dot_prod_32fc_a(P_out, bb_signal, P_code, signal_length_samples);