Moved FFTW to WISDOM and save/load from file

master
Ismael Gomez 7 years ago
parent 82a90fe4f1
commit 6e0fd43c1f

@ -72,9 +72,11 @@ typedef struct SRSLTE_API {
srslte_dft_mode_t mode; // Complex/Real srslte_dft_mode_t mode; // Complex/Real
}srslte_dft_plan_t; }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, int dft_points,
srslte_dft_dir_t dir, srslte_dft_dir_t dir,
srslte_dft_mode_t type); srslte_dft_mode_t type);

@ -37,6 +37,20 @@
#define dft_ceil(a,b) ((a-1)/b+1) #define dft_ceil(a,b) ((a-1)/b+1)
#define dft_floor(a,b) (a/b) #define dft_floor(a,b) (a/b)
#define FFTW_WISDOM_FILE ".fftw_wisdom"
void srslte_dft_load() {
if (!fftwf_import_wisdom_from_filename(FFTW_WISDOM_FILE)) {
fprintf(stderr, "Error loading FFTW wisdom from file %s\n", 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, int srslte_dft_plan(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir,
srslte_dft_mode_t mode) { srslte_dft_mode_t mode) {
if(mode == SRSLTE_DFT_COMPLEX){ if(mode == SRSLTE_DFT_COMPLEX){
@ -85,7 +99,7 @@ int srslte_dft_replan_c(srslte_dft_plan_t *plan, const int new_dft_points) {
int srslte_dft_plan_c(srslte_dft_plan_t *plan, const int dft_points, srslte_dft_dir_t dir) { 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); allocate(plan,sizeof(fftwf_complex),sizeof(fftwf_complex), dft_points);
int sign = (dir == SRSLTE_DFT_FORWARD) ? FFTW_FORWARD : FFTW_BACKWARD; 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) { if (!plan->p) {
return -1; return -1;
} }
@ -108,7 +122,7 @@ int srslte_dft_replan_r(srslte_dft_plan_t *plan, const int new_dft_points) {
fftwf_destroy_plan(plan->p); fftwf_destroy_plan(plan->p);
plan->p = NULL; plan->p = NULL;
} }
plan->p = fftwf_plan_r2r_1d(new_dft_points, plan->in, plan->out, sign, 0U); plan->p = fftwf_plan_r2r_1d(new_dft_points, plan->in, plan->out, sign, FFTW_MEASURE);
if (!plan->p) { if (!plan->p) {
return -1; return -1;
} }

@ -54,11 +54,13 @@ void enb::cleanup(void)
enb::enb() enb::enb()
:started(false) :started(false)
{ {
srslte_dft_load();
pool = srslte::byte_buffer_pool::get_instance(); pool = srslte::byte_buffer_pool::get_instance();
} }
enb::~enb() enb::~enb()
{ {
srslte_dft_exit();
srslte::byte_buffer_pool::cleanup(); srslte::byte_buffer_pool::cleanup();
} }

@ -135,7 +135,7 @@ class ue_base
,public ue_metrics_interface ,public ue_metrics_interface
{ {
public: public:
ue_base() {} ue_base();
virtual ~ue_base() {} virtual ~ue_base() {}
static ue_base* get_instance(srsue_instance_type_t type); static ue_base* get_instance(srsue_instance_type_t type);

@ -179,7 +179,7 @@ bool ue::init(all_args_t *args_)
phy.wait_initialize(); phy.wait_initialize();
phy.configure_ul_params(); phy.configure_ul_params();
printf("\n\nRequesting NAS Attach...\n"); printf("...\n");
nas.attach_request(); nas.attach_request();
started = true; started = true;

@ -57,8 +57,16 @@ ue_base* ue_base::get_instance(srsue_instance_type_t type)
return(instance); return(instance);
} }
ue_base::ue_base() {
// load FFTW wisdom
srslte_dft_load();
}
void ue_base::cleanup(void) void ue_base::cleanup(void)
{ {
// save FFTW wisdom
srslte_dft_exit();
pthread_mutex_lock(&ue_instance_mutex); pthread_mutex_lock(&ue_instance_mutex);
if(NULL != instance) { if(NULL != instance) {
delete instance; delete instance;

Loading…
Cancel
Save