Moved FFTW to WISDOM and save/load from file

master
Ismael Gomez 7 years ago
parent 2335d2a644
commit 38c67dc410

@ -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);

@ -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;
}

@ -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();
}

@ -373,6 +373,7 @@ int main(int argc, char *argv[])
pthread_cancel(input);
metrics.stop();
enb->stop();
enb->cleanup();
cout << "--- exiting ---" << endl;
exit(0);
}

@ -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);

@ -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;

Loading…
Cancel
Save