mirror of
https://github.com/gnss-sdr/gnss-sdr
synced 2025-10-16 16:17:41 +00:00
Better VOLK usage. Memory alignment, calling dispatchers instead of
aligned/unaligned versions. Code cleaning.
This commit is contained in:
@@ -79,234 +79,75 @@ void Correlator::Carrier_wipeoff_and_EPL_generic(int signal_length_samples, cons
|
||||
|
||||
|
||||
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, bool input_vector_unaligned)
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out)
|
||||
{
|
||||
gr_complex* bb_signal;
|
||||
//gr_complex* input_aligned;
|
||||
gr_complex* bb_signal = (gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex), volk_get_alignment());
|
||||
|
||||
//todo: do something if posix_memalign fails
|
||||
if (posix_memalign((void**)&bb_signal, 16, signal_length_samples * sizeof(gr_complex)) == 0) {};
|
||||
volk_32fc_x2_multiply_32fc(bb_signal, input, carrier, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(E_out, bb_signal, E_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(P_out, bb_signal, P_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(L_out, bb_signal, L_code, signal_length_samples);
|
||||
|
||||
if (input_vector_unaligned == true)
|
||||
{
|
||||
//todo: do something if posix_memalign fails
|
||||
//if (posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex)) == 0){};
|
||||
//memcpy(input_aligned,input,signal_length_samples * sizeof(gr_complex));
|
||||
|
||||
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, signal_length_samples);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* todo: There is a problem with the aligned version of volk_32fc_x2_multiply_32fc_a.
|
||||
* It crashes even if the is_aligned() work function returns true. Im keeping the unaligned version in both cases..
|
||||
*/
|
||||
//use directly the input vector
|
||||
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, 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(L_out, bb_signal, L_code, signal_length_samples);
|
||||
|
||||
free(bb_signal);
|
||||
//if (input_vector_unaligned==false)
|
||||
//{
|
||||
// free(input_aligned);
|
||||
//}
|
||||
volk_free(bb_signal);
|
||||
}
|
||||
|
||||
//void Correlator::Carrier_wipeoff_and_EPL_volk_IQ(int prn_length_samples,int integration_time ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out, bool input_vector_unaligned)
|
||||
//void Correlator::Carrier_wipeoff_and_EPL_volk_IQ(int prn_length_samples,int integration_time ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out)
|
||||
//{
|
||||
// gr_complex* bb_signal;
|
||||
// //gr_complex* input_aligned;
|
||||
//
|
||||
// //todo: do something if posix_memalign fails
|
||||
// if (posix_memalign((void**)&bb_signal, 16, integration_time * prn_length_samples * sizeof(gr_complex)) == 0) {};
|
||||
//
|
||||
// if (input_vector_unaligned == true)
|
||||
// {
|
||||
// //todo: do something if posix_memalign fails
|
||||
// //if (posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex)) == 0){};
|
||||
// //memcpy(input_aligned,input,signal_length_samples * sizeof(gr_complex));
|
||||
//
|
||||
// volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, integration_time * prn_length_samples);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// /*
|
||||
// * todo: There is a problem with the aligned version of volk_32fc_x2_multiply_32fc_a.
|
||||
// * It crashes even if the is_aligned() work function returns true. Im keeping the unaligned version in both cases..
|
||||
// */
|
||||
// //use directly the input vector
|
||||
// volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, integration_time * prn_length_samples);
|
||||
// }
|
||||
//
|
||||
// volk_32fc_x2_dot_prod_32fc_a(E_out, bb_signal, E_code, integration_time * prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc_a(P_out, bb_signal, P_code, integration_time * prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc_a(L_out, bb_signal, L_code, integration_time * prn_length_samples);
|
||||
// gr_complex* bb_signal = (gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex), volk_get_alignment());
|
||||
// volk_32fc_x2_multiply_32fc(bb_signal, input, carrier, integration_time * prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc(E_out, bb_signal, E_code, integration_time * prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc(P_out, bb_signal, P_code, integration_time * prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc(L_out, bb_signal, L_code, integration_time * prn_length_samples);
|
||||
// // Vector of Prompts of I code
|
||||
// for (int i = 0; i < integration_time; i++)
|
||||
// {
|
||||
// volk_32fc_x2_dot_prod_32fc_a(&P_data_out[i], &bb_signal[i*prn_length_samples], P_data_code, prn_length_samples);
|
||||
// volk_32fc_x2_dot_prod_32fc(&P_data_out[i], &bb_signal[i*prn_length_samples], P_data_code, prn_length_samples);
|
||||
// }
|
||||
//
|
||||
// free(bb_signal);
|
||||
//
|
||||
// volk_free(bb_signal);
|
||||
//}
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out, bool input_vector_unaligned)
|
||||
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out)
|
||||
{
|
||||
gr_complex* bb_signal;
|
||||
//gr_complex* input_aligned;
|
||||
gr_complex* bb_signal = (gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex), volk_get_alignment());
|
||||
|
||||
bb_signal=(gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex),volk_get_alignment());
|
||||
|
||||
if (input_vector_unaligned == true)
|
||||
{
|
||||
//todo: do something if posix_memalign fails
|
||||
//if (posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex)) == 0){};
|
||||
//memcpy(input_aligned,input,signal_length_samples * sizeof(gr_complex));
|
||||
|
||||
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, signal_length_samples);
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* todo: There is a problem with the aligned version of volk_32fc_x2_multiply_32fc_a.
|
||||
* It crashes even if the is_aligned() work function returns true. Im keeping the unaligned version in both cases..
|
||||
*/
|
||||
//use directly the input vector
|
||||
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, 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(L_out, bb_signal, L_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc_a(P_data_out, bb_signal, P_data_code, signal_length_samples);
|
||||
|
||||
|
||||
free(bb_signal);
|
||||
volk_32fc_x2_multiply_32fc(bb_signal, input, carrier, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(E_out, bb_signal, E_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(P_out, bb_signal, P_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(L_out, bb_signal, L_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(P_data_out, bb_signal, P_data_code, signal_length_samples);
|
||||
|
||||
volk_free(bb_signal);
|
||||
}
|
||||
|
||||
|
||||
void Correlator::Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* VE_code, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* VL_code, gr_complex* VE_out, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* VL_out)
|
||||
{
|
||||
gr_complex* bb_signal = (gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex), volk_get_alignment());
|
||||
|
||||
volk_32fc_x2_multiply_32fc(bb_signal, input, carrier, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(VE_out, bb_signal, VE_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(E_out, bb_signal, E_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(P_out, bb_signal, P_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(L_out, bb_signal, L_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc(VL_out, bb_signal, VL_code, signal_length_samples);
|
||||
|
||||
volk_free(bb_signal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Correlator::Correlator ()
|
||||
{}
|
||||
|
||||
|
||||
Correlator::~Correlator ()
|
||||
{}
|
||||
|
||||
|
||||
#ifndef GENERIC_ARCH
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier,gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, bool input_vector_unaligned)
|
||||
void Correlator::Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier,gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out)
|
||||
{
|
||||
volk_cw_epl_corr_u(input, carrier, E_code, P_code, L_code, E_out, P_out, L_out, signal_length_samples);
|
||||
}
|
||||
#endif
|
||||
|
||||
void Correlator::Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* VE_code, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* VL_code, gr_complex* VE_out, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* VL_out, bool input_vector_unaligned)
|
||||
{
|
||||
gr_complex* bb_signal;
|
||||
//gr_complex* input_aligned;
|
||||
|
||||
bb_signal=(gr_complex*)volk_malloc(signal_length_samples * sizeof(gr_complex),volk_get_alignment());
|
||||
|
||||
if (input_vector_unaligned == false)
|
||||
{
|
||||
//todo: do something if posix_memalign fails
|
||||
//if (posix_memalign((void**)&input_aligned, 16, signal_length_samples * sizeof(gr_complex)) == 0){};
|
||||
//memcpy(input_aligned,input,signal_length_samples * sizeof(gr_complex));
|
||||
|
||||
volk_32fc_x2_multiply_32fc_u(bb_signal, input, carrier, signal_length_samples);
|
||||
}
|
||||
else
|
||||
{
|
||||
//use directly the input vector
|
||||
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(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(L_out, bb_signal, L_code, signal_length_samples);
|
||||
volk_32fc_x2_dot_prod_32fc_a(VL_out, bb_signal, VL_code, signal_length_samples);
|
||||
|
||||
free(bb_signal);
|
||||
//if (input_vector_unaligned == false)
|
||||
//{
|
||||
//free(input_aligned);
|
||||
//}
|
||||
}
|
||||
|
||||
/*
|
||||
void Correlator::cpu_arch_test_volk_32fc_x2_dot_prod_32fc_a()
|
||||
{
|
||||
//
|
||||
//struct volk_func_desc desc=volk_32fc_x2_dot_prod_32fc_a_get_func_desc();
|
||||
volk_func_desc_t desc = volk_32fc_x2_dot_prod_32fc_get_func_desc();
|
||||
|
||||
std::vector<std::string> arch_list;
|
||||
|
||||
for(int i = 0; i < desc.n_archs; ++i)
|
||||
{
|
||||
//if(!(archs[i+1] & volk_get_lvarch())) continue; //this arch isn't available on this pc
|
||||
arch_list.push_back(std::string(desc.indices[i]));
|
||||
}
|
||||
|
||||
|
||||
//first let's get a list of available architectures for the test
|
||||
if(arch_list.size() < 2)
|
||||
{
|
||||
std::cout << "no architectures to test" << std::endl;
|
||||
this->volk_32fc_x2_dot_prod_32fc_a_best_arch = "generic";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Detected architectures in this machine for volk_32fc_x2_dot_prod_32fc_a:" << std::endl;
|
||||
for (unsigned int i=0; i < arch_list.size(); ++i)
|
||||
{
|
||||
std::cout << "Arch " << i << ":" << arch_list.at(i) << std::endl;
|
||||
}
|
||||
// TODO: Make a test to find the best architecture
|
||||
this->volk_32fc_x2_dot_prod_32fc_a_best_arch = arch_list.at(arch_list.size() - 1);
|
||||
}
|
||||
|
||||
std::cout << "Selected architecture for volk_32fc_x2_dot_prod_32fc_a is " << this->volk_32fc_x2_dot_prod_32fc_a_best_arch << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void Correlator::cpu_arch_test_volk_32fc_x2_multiply_32fc_a()
|
||||
{
|
||||
//
|
||||
volk_func_desc_t desc = volk_32fc_x2_multiply_32fc_a_get_func_desc();
|
||||
std::vector<std::string> arch_list;
|
||||
|
||||
for(int i = 0; i < desc.n_archs; ++i)
|
||||
{
|
||||
//if(!(archs[i+1] & volk_get_lvarch())) continue; //this arch isn't available on this pc
|
||||
arch_list.push_back(std::string(desc.indices[i]));
|
||||
}
|
||||
|
||||
this->volk_32fc_x2_multiply_32fc_a_best_arch = "generic";
|
||||
//first let's get a list of available architectures for the test
|
||||
if(arch_list.size() < 2)
|
||||
{
|
||||
std::cout << "no architectures to test" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Detected architectures in this machine for volk_32fc_x2_multiply_32fc_a:" << std::endl;
|
||||
for (unsigned int i=0; i < arch_list.size(); ++i)
|
||||
{
|
||||
std::cout << "Arch " << i << ":" << arch_list.at(i) << std::endl;
|
||||
if (arch_list.at(i).find("sse") != std::string::npos)
|
||||
{
|
||||
// TODO: Make a test to find the best architecture
|
||||
this->volk_32fc_x2_multiply_32fc_a_best_arch = arch_list.at(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Selected architecture for volk_32fc_x2_multiply_32fc_a_best_arch is " << this->volk_32fc_x2_multiply_32fc_a_best_arch << std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
Correlator::Correlator ()
|
||||
{
|
||||
//cpu_arch_test_volk_32fc_x2_dot_prod_32fc_a();
|
||||
//cpu_arch_test_volk_32fc_x2_multiply_32fc_a();
|
||||
}
|
||||
|
||||
Correlator::~Correlator ()
|
||||
{}
|
||||
|
@@ -54,22 +54,18 @@ class Correlator
|
||||
{
|
||||
public:
|
||||
void Carrier_wipeoff_and_EPL_generic(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out);
|
||||
void Carrier_wipeoff_and_EPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, bool input_vector_unaligned);
|
||||
void Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* VE_code, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* VL_code, gr_complex* VE_out, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* VL_out, bool input_vector_unaligned);
|
||||
// void Carrier_wipeoff_and_EPL_volk_IQ(int prn_length_samples,int integration_time ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out, bool input_vector_unaligned);
|
||||
void Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out, bool input_vector_unaligned);
|
||||
void Carrier_wipeoff_and_EPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out);
|
||||
void Carrier_wipeoff_and_VEPL_volk(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* VE_code, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* VL_code, gr_complex* VE_out, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* VL_out);
|
||||
// void Carrier_wipeoff_and_EPL_volk_IQ(int prn_length_samples,int integration_time ,const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out);
|
||||
void Carrier_wipeoff_and_EPL_volk_IQ(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* P_data_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, gr_complex* P_data_out);
|
||||
Correlator();
|
||||
~Correlator();
|
||||
#ifndef GENERIC_ARCH
|
||||
void Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out, bool input_vector_unaligned);
|
||||
void Carrier_wipeoff_and_EPL_volk_custom(int signal_length_samples, const gr_complex* input, gr_complex* carrier, gr_complex* E_code, gr_complex* P_code, gr_complex* L_code, gr_complex* E_out, gr_complex* P_out, gr_complex* L_out);
|
||||
#endif
|
||||
|
||||
private:
|
||||
std::string volk_32fc_x2_multiply_32fc_a_best_arch;
|
||||
std::string volk_32fc_x2_dot_prod_32fc_a_best_arch;
|
||||
unsigned long next_power_2(unsigned long v);
|
||||
void cpu_arch_test_volk_32fc_x2_dot_prod_32fc_a();
|
||||
void cpu_arch_test_volk_32fc_x2_multiply_32fc_a();
|
||||
};
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user