I am trying to compute 2D FFT on 100 million complex data (100000x1000) and it is taking 4.6 seconds approximately, but I want to reduce time. Then I tried to compute it using fftw_thread. But then the computation time has increased (in 2 threads time taken - 8.5 sec an in 4 threads time taken - 16.5 sec). I am using FFTW3 library for C++ and OS - ubuntu 18.04 I am attaching the C++ code below :
#include <iostream>
#include <time.h>
#include <fftw3.h>
using namespace std;
#define ROW 100000
#define COL 1000
int main() {
fftwf_complex *in = (fftwf_complex *)calloc(ROW*COL,sizeof(fftwf_complex));
fftwf_complex *out = (fftwf_complex *)calloc(ROW*COL,sizeof(fftwf_complex));
// generating random data
for(uint32_t i = 0 ; i < ROW*COL ; i++) {
in[i][0] = i+1;
in[i][1] = i+2;
}
int thread_number = 2;
fftwf_plan_with_nthreads(thread_number);
int h = fftwf_init_threads();
fftwf_plan p = fftwf_plan_dft_2d(ROW,COL,in,out,FFTW_FORWARD,FFTW_ESTIMATE);
fftwf_execute(p);
fftwf_destroy_plan(p);
fftwf_cleanup_threads();
}
I am getting no error. I want to reduce the execution time. Can anyone please help me in this matter to reduce the time to compute the 2D FFT on 100 million data.