diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index 648ccffdc..a23c88c56 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -287,6 +287,13 @@ if(GNURADIO_VERSION VERSION_GREATER 3.8.99) endforeach() endif() +# Detect if FFT are templates +if(EXISTS ${GNURADIO_FFT_INCLUDE_DIRS}/gnuradio/fft/fft_vfc.h) + set(GNURADIO_FFT_USES_TEMPLATES FALSE) +else() + set(GNURADIO_FFT_USES_TEMPLATES TRUE) +endif() + # Search for IIO component if(GNURADIO_VERSION VERSION_GREATER 3.8.99) pkg_check_modules(PC_GNURADIO_IIO QUIET gnuradio-iio) diff --git a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt index bf641ed3d..cdc89e2eb 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt @@ -96,6 +96,12 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_FFT_USES_TEMPLATES) + target_compile_definitions(acquisition_gr_blocks + PUBLIC -DGNURADIO_FFT_USES_TEMPLATES=1 + ) +endif() + if(ENABLE_ARMA_NO_DEBUG) target_compile_definitions(acquisition_gr_blocks PUBLIC -DARMA_NO_BOUND_CHECKING=1 diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index 32b22f3f3..f3ec3ba89 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -69,8 +69,8 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit int CAF_window_hz_, int Zero_padding_, bool enable_monitor_output) : gr::block("galileo_e5a_noncoherentIQ_acquisition_caf_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -122,12 +122,17 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit } } +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); - +#endif // For dumping samples into a file d_dump = dump; d_dump_filename = dump_filename; @@ -303,7 +308,7 @@ int galileo_e5a_noncoherentIQ_acquisition_caf_cc::general_work(int noutput_items */ int acquisition_message = -1; // 0=STOP_CHANNEL 1=ACQ_SUCCEES 2=ACQ_FAIL - int return_value = 0; // 0=Produces no Gnss_Synchro objects + int return_value = 0; // 0=Produces no Gnss_Synchro objects /* States: 0 Stop Channel * 1 Load the buffer until it reaches fft_size * 2 Acquisition algorithm diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h index 3f9a5557d..1dca05cb4 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.h @@ -207,9 +207,13 @@ private: float estimate_input_power(gr_complex* in); std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; - +#endif std::vector> d_grid_doppler_wipeoffs; std::vector d_fft_code_I_A; std::vector d_fft_code_I_B; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index 8b3c23b4f..663d3586d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -57,8 +57,8 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( bool dump, const std::string &dump_filename, bool enable_monitor_output) : gr::block("galileo_pcps_8ms_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -80,11 +80,17 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( d_fft_code_B = std::vector(d_fft_size, lv_cmake(0.0F, 0.0F)); d_magnitude = std::vector(d_fft_size, 0.0F); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); +#endif // For dumping samples into a file d_dump = dump; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h index 31d957ab7..79633dd70 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.h @@ -193,9 +193,13 @@ private: int32_t doppler_offset); std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; - +#endif std::vector> d_grid_doppler_wipeoffs; std::vector d_fft_code_A; std::vector d_fft_code_B; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 035a71d46..78df6b841 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -130,11 +130,17 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu d_fft_codes = volk_gnsssdr::vector>(d_fft_size); d_input_signal = volk_gnsssdr::vector>(d_fft_size); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); +#endif d_gnss_synchro = nullptr; d_worker_active = false; @@ -1022,15 +1028,16 @@ int pcps_acquisition::general_work(int noutput_items __attribute__((unused)), // Send outputs to the monitor if (d_acq_parameters.enable_monitor_output) { - auto **out = reinterpret_cast(&output_items[0]); + auto** out = reinterpret_cast(&output_items[0]); if (!d_monitor_queue.empty()) { int num_gnss_synchro_objects = d_monitor_queue.size(); - for (int i = 0; i < num_gnss_synchro_objects; ++i) { - Gnss_Synchro current_synchro_data = d_monitor_queue.front(); - d_monitor_queue.pop(); - *out[i] = current_synchro_data; - } + for (int i = 0; i < num_gnss_synchro_objects; ++i) + { + Gnss_Synchro current_synchro_data = d_monitor_queue.front(); + d_monitor_queue.pop(); + *out[i] = current_synchro_data; + } return num_gnss_synchro_objects; } } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h index 2d494ac70..fedd18d18 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.h @@ -243,8 +243,14 @@ private: volk_gnsssdr::vector> d_data_buffer; volk_gnsssdr::vector d_data_buffer_sc; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif + std::weak_ptr d_channel_fsm; Acq_Conf d_acq_parameters; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index 73114f7ca..3c7173c2d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -80,11 +80,17 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con d_fft_codes.reserve(d_fft_size); d_magnitude.reserve(d_fft_size); d_10_ms_buffer.reserve(50 * d_samples_per_ms); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); +#endif // For dumping samples into a file d_dump = conf_.dump; @@ -380,7 +386,11 @@ int pcps_acquisition_fine_doppler_cc::estimate_Doppler() int signal_samples = prn_replicas * d_fft_size; // int fft_size_extended = nextPowerOf2(signal_samples * zero_padding_factor); int fft_size_extended = signal_samples * zero_padding_factor; +#if GNURADIO_FFT_USES_TEMPLATES + auto fft_operator = std::make_unique(fft_size_extended); +#else auto fft_operator = std::make_unique(fft_size_extended, true); +#endif // zero padding the entire vector std::fill_n(fft_operator->get_inbuf(), fft_size_extended, gr_complex(0.0, 0.0)); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h index a569f7fb7..3dfd7ca8a 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.h @@ -200,8 +200,13 @@ private: bool start(); std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif volk_gnsssdr::vector>> d_grid_doppler_wipeoffs; volk_gnsssdr::vector> d_grid_data; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index b663d3eff..9b85fbb71 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -52,8 +52,8 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( int32_t max_dwells, uint32_t sampled_ms, int32_t doppler_max, int32_t doppler_min, int64_t fs_in, int32_t samples_per_ms, bool dump, const std::string &dump_filename, bool enable_monitor_output) : gr::block("pcps_assisted_acquisition_cc", - gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -72,16 +72,22 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( d_disable_assist = false; d_fft_codes.reserve(d_fft_size); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); +#endif // For dumping samples into a file d_dump = dump; d_dump_filename = dump_filename; - + d_enable_monitor_output = enable_monitor_output; d_doppler_resolution = 0; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h index abea933da..00222b58e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.h @@ -201,8 +201,13 @@ private: void redefine_grid(); std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif std::vector>> d_grid_doppler_wipeoffs; std::vector> d_grid_data; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 4c4762505..80de1e4f2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -62,8 +62,8 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( bool dump, const std::string &dump_filename, bool enable_monitor_output) : gr::block("pcps_cccwsr_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -89,12 +89,17 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( d_correlation_minus.reserve(d_fft_size); d_magnitude.reserve(d_fft_size); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); - +#endif // For dumping samples into a file d_dump = dump; d_dump_filename = dump_filename; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h index ecb1f2aa6..f2afa7517 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.h @@ -186,8 +186,13 @@ private: std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif std::vector> d_grid_doppler_wipeoffs; std::vector d_fft_code_data; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 5e24188e6..776c8fe9d 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -64,8 +64,8 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( bool dump, const std::string& dump_filename, bool enable_monitor_output) : gr::block("pcps_quicksync_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -98,10 +98,17 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( original form to perform later correlation in time domain*/ d_code = std::vector(d_samples_per_code, lv_cmake(0.0F, 0.0F)); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); +#endif // For dumping samples into a file d_dump = dump; @@ -516,7 +523,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, // Copy and push current Gnss_Synchro to monitor queue if (d_enable_monitor_output) { - auto **out = reinterpret_cast(&output_items[0]); + auto** out = reinterpret_cast(&output_items[0]); Gnss_Synchro current_synchro_data = Gnss_Synchro(); current_synchro_data = *d_gnss_synchro; *out[0] = current_synchro_data; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h index 6a6f1fe27..7bd1dc3f6 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.h @@ -215,8 +215,13 @@ private: std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif std::vector> d_grid_doppler_wipeoffs; std::vector d_code; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 93b7f0516..dd8181a18 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -80,8 +80,8 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( bool dump, const std::string &dump_filename, bool enable_monitor_output) : gr::block("pcps_tong_acquisition_cc", - gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), - gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) + gr::io_signature::make(1, 1, static_cast(sizeof(gr_complex) * sampled_ms * samples_per_ms)), + gr::io_signature::make(0, 1, sizeof(Gnss_Synchro))) { this->message_port_register_out(pmt::mp("events")); d_sample_counter = 0ULL; // SAMPLE COUNTER @@ -105,12 +105,17 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( d_fft_codes.reserve(d_fft_size); d_magnitude.reserve(d_fft_size); +#if GNURADIO_FFT_USES_TEMPLATES + // Direct FFT + d_fft_if = std::make_unique(d_fft_size); + // Inverse FFT + d_ifft = std::make_unique(d_fft_size); +#else // Direct FFT d_fft_if = std::make_unique(d_fft_size, true); - // Inverse FFT d_ifft = std::make_unique(d_fft_size, false); - +#endif // For dumping samples into a file d_dump = dump; d_dump_filename = dump_filename; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h index 249fc7731..c8777b7cf 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.h @@ -203,8 +203,13 @@ private: std::weak_ptr d_channel_fsm; +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_if; + std::unique_ptr d_ifft; +#else std::unique_ptr d_fft_if; std::unique_ptr d_ifft; +#endif std::vector> d_grid_doppler_wipeoffs; std::vector> d_grid_data; diff --git a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt index 8520c08b2..b83972f05 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/input_filter/gnuradio_blocks/CMakeLists.txt @@ -63,6 +63,13 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(GNURADIO_FFT_USES_TEMPLATES) + target_compile_definitions(input_filter_gr_blocks + PUBLIC -DGNURADIO_FFT_USES_TEMPLATES=1 + ) +endif() + + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(input_filter_gr_blocks diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc index 48d71964b..cc3ee0cbf 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.cc @@ -60,7 +60,11 @@ Notch::Notch(float pfa, angle_ = volk_gnsssdr::vector(length_); power_spect_ = volk_gnsssdr::vector(length_); last_out_ = gr_complex(0.0, 0.0); +#if GNURADIO_FFT_USES_TEMPLATES + d_fft_ = std::make_unique(length_); +#else d_fft_ = std::make_unique(length_, true); +#endif } diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h index 25ef7bf3c..bc23762dc 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_cc.h @@ -59,7 +59,11 @@ public: private: friend notch_sptr make_notch_filter(float pfa, float p_c_factor, int32_t length, int32_t n_segments_est, int32_t n_segments_reset); Notch(float pfa, float p_c_factor, int32_t length, int32_t n_segments_est, int32_t n_segments_reset); +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_; +#else std::unique_ptr d_fft_; +#endif volk_gnsssdr::vector c_samples_; volk_gnsssdr::vector angle_; volk_gnsssdr::vector power_spect_; diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc index 0260c8c0e..3b88c26c6 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.cc @@ -65,7 +65,11 @@ NotchLite::NotchLite(float p_c_factor, angle1_ = 0.0; angle2_ = 0.0; power_spect_ = volk_gnsssdr::vector(length_); +#if GNURADIO_FFT_USES_TEMPLATES + d_fft_ = std::make_unique(length_); +#else d_fft_ = std::make_unique(length_, true); +#endif } diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h index bc55c5848..4d2b83c7e 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h @@ -60,7 +60,11 @@ public: private: friend notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); NotchLite(float p_c_factor, float pfa, int32_t length, int32_t n_segments_est, int32_t n_segments_reset, int32_t n_segments_coeff); +#if GNURADIO_FFT_USES_TEMPLATES + std::unique_ptr d_fft_; +#else std::unique_ptr d_fft_; +#endif volk_gnsssdr::vector power_spect_; gr_complex last_out_; gr_complex z_0_; diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index f37086771..e55757931 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -519,6 +519,11 @@ if(ENABLE_UNIT_TESTING) PRIVATE -DGNURADIO_USES_STD_POINTERS=1 ) endif() + if(GNURADIO_FFT_USES_TEMPLATES) + target_compile_definitions(run_tests + PUBLIC -DGNURADIO_FFT_USES_TEMPLATES=1 + ) + endif() if(ENABLE_UNIT_TESTING_EXTRA) target_link_libraries(run_tests PRIVATE Gpstk::gpstk) endif() diff --git a/src/tests/unit-tests/arithmetic/fft_length_test.cc b/src/tests/unit-tests/arithmetic/fft_length_test.cc index 3cf5cdd4f..44f08e18b 100644 --- a/src/tests/unit-tests/arithmetic/fft_length_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_length_test.cc @@ -74,8 +74,11 @@ TEST(FFTLengthTest, MeasureExecutionTime) EXPECT_NO_THROW( for (it = fft_sizes_v.cbegin(); it != fft_sizes_v.cend(); ++it) { d_fft_size = *it; +#if GNURADIO_FFT_USES_TEMPLATES + auto d_fft = std::make_unique(d_fft_size); +#else auto d_fft = std::make_unique(d_fft_size, true); - +#endif std::generate_n(d_fft->get_inbuf(), d_fft_size, gen); start = std::chrono::system_clock::now(); diff --git a/src/tests/unit-tests/arithmetic/fft_speed_test.cc b/src/tests/unit-tests/arithmetic/fft_speed_test.cc index edc70c554..6f422a218 100644 --- a/src/tests/unit-tests/arithmetic/fft_speed_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_speed_test.cc @@ -39,7 +39,11 @@ TEST(FFTSpeedTest, ArmadilloVSGNURadioExecutionTime) for (unsigned int fft_size : fft_sizes) { d_fft_size = fft_size; +#if GNURADIO_FFT_USES_TEMPLATES + auto d_gr_fft = std::make_unique(d_fft_size); +#else auto d_gr_fft = std::make_unique(d_fft_size, true); +#endif arma::arma_rng::set_seed_random(); arma::cx_fvec d_arma_fft = arma::cx_fvec(d_fft_size).randn() + gr_complex(0.0, 1.0) * arma::cx_fvec(d_fft_size).randn(); arma::cx_fvec d_arma_fft_result(d_fft_size);