I've been having some trouble creating parallelized OMP DFTs with FFTW. I compiled with --enable-openmp and have the following code sample:
#include <fftw3.h>
int NUMBER_OF_THREADS = 40;
fftw_init_threads();
fftw_plan_with_nthreads(NUMBER_OF_THREADS);
std::vector<std::complex<double>> buf(num_trials);
fftw_plan p = fftw_plan_dft_1d(num_trials, reinterpret_cast<fftw_complex*>(buf.data()), reinterpret_cast<fftw_complex*>(buf.data()), -1, FFTW_MEASURE);
// plan is called here sequentially some number of times
for (dummy in dummy) {
fftw_execute(p);
}
fftw_destroy_plan(p);
Unfortunately, the code doesn't seem to be parallelizing. I've used the following flags in the Makefile:
CXXFLAGS = -fopenmp -O3 -std=c++17 -funroll-loops -march=native -Wno-unused -Wall -I. -g
LDFLAGS = -I /usr/local/include -L /usr/local/lib -lfftw3_omp -lfftw3 -lm
Are there available code samples detailing how to use OpenMP FFTW? What am I doing wrong here? Reference FFTW doc.