diff --git a/lib/include/srslte/phy/dft/dft.h b/lib/include/srslte/phy/dft/dft.h index 12c06dd98..b90aab2e5 100644 --- a/lib/include/srslte/phy/dft/dft.h +++ b/lib/include/srslte/phy/dft/dft.h @@ -71,9 +71,11 @@ typedef struct SRSLTE_API { srslte_dft_mode_t mode; // Complex/Real }srslte_dft_plan_t; -/* Create DFT plans */ +SRSLTE_API void srslte_dft_load(); -SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t *plan, +SRSLTE_API void srslte_dft_exit(); + +SRSLTE_API int srslte_dft_plan(srslte_dft_plan_t *plan, int dft_points, srslte_dft_dir_t dir, srslte_dft_mode_t type); diff --git a/lib/src/phy/dft/dft_fftw.c b/lib/src/phy/dft/dft_fftw.c index 347e04547..5fb34bb3c 100644 --- a/lib/src/phy/dft/dft_fftw.c +++ b/lib/src/phy/dft/dft_fftw.c @@ -36,6 +36,18 @@ #define dft_ceil(a,b) ((a-1)/b+1) #define dft_floor(a,b) (a/b) +#define FFTW_WISDOM_FILE ".fftw_wisdom" + +void srslte_dft_load() { + fftwf_import_wisdom_from_filename(FFTW_WISDOM_FILE); +} + +void srslte_dft_exit() { + if (!fftwf_export_wisdom_to_filename(FFTW_WISDOM_FILE)) { + fprintf(stderr, "Error saving FFTW wisdom to file %s\n", FFTW_WISDOM_FILE); + } +} + int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir, srslte_dft_mode_t mode) { if(mode == SRSLTE_DFT_COMPLEX){ @@ -54,7 +66,7 @@ static void allocate(srslte_dft_plan_t *plan, int size_in, int size_out, int len int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) { allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points); int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; - plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, 0U); + plan->p = fftwf_plan_dft_1d(dft_points, plan->in, plan->out, sign, FFTW_MEASURE); if (!plan->p) { return -1; } @@ -73,7 +85,7 @@ int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_ int srslte_dft_plan_r(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) { allocate(plan,sizeof(float),sizeof(float), dft_points); int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_R2HC : FFTW_HC2R; - plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, 0U); + plan->p = fftwf_plan_r2r_1d(dft_points, plan->in, plan->out, sign, FFTW_MEASURE); if (!plan->p) { return -1; } diff --git a/srsenb/src/enb.cc b/srsenb/src/enb.cc index 9a747dba6..1bd7240a2 100644 --- a/srsenb/src/enb.cc +++ b/srsenb/src/enb.cc @@ -44,6 +44,7 @@ enb* enb::get_instance(void) } void enb::cleanup(void) { + srslte_dft_exit(); boost::mutex::scoped_lock lock(enb_instance_mutex); if(NULL != instance) { delete instance; @@ -54,6 +55,7 @@ void enb::cleanup(void) enb::enb() :started(false) { + srslte_dft_load(); pool = srslte::byte_buffer_pool::get_instance(); } diff --git a/srsenb/src/main.cc b/srsenb/src/main.cc index 1e337b3ba..528878388 100644 --- a/srsenb/src/main.cc +++ b/srsenb/src/main.cc @@ -373,6 +373,7 @@ int main(int argc, char *argv[]) pthread_cancel(input); metrics.stop(); enb->stop(); + enb->cleanup(); cout << "--- exiting ---" << endl; exit(0); } diff --git a/srsue/hdr/ue_base.h b/srsue/hdr/ue_base.h index 06c3f3e24..4720d8062 100644 --- a/srsue/hdr/ue_base.h +++ b/srsue/hdr/ue_base.h @@ -134,7 +134,7 @@ class ue_base ,public ue_metrics_interface { public: - ue_base() {} + ue_base(); virtual ~ue_base() {} static ue_base* get_instance(srsue_instance_type_t type); diff --git a/srsue/src/ue_base.cc b/srsue/src/ue_base.cc index 61cbafb2c..c84393ae4 100644 --- a/srsue/src/ue_base.cc +++ b/srsue/src/ue_base.cc @@ -57,8 +57,16 @@ ue_base* ue_base::get_instance(srsue_instance_type_t type) return(instance); } +ue_base::ue_base() { + // load FFTW wisdom + srslte_dft_load(); +} + void ue_base::cleanup(void) { + // save FFTW wisdom + srslte_dft_exit(); + pthread_mutex_lock(&ue_instance_mutex); if(NULL != instance) { delete instance;