Question

I want to compute autocorrelation using the FFTW library. I cannot create a plan when my input has more than ~1800mln elements. E.g.:

// my input 
size_t size = 1024UL * 1024 * 1024 * 2;
float * in = (float *) malloc(sizeof(float) * (size + 2));
assert(in);

// insert values in input... in[0] to in[size -1]

// I want to perform an inplace FFT (this should explains the "+2" in prev malloc)
fftwf_complex * out = (fftwf_complex *) in;

// create a real to complex FFT plan
p = fftwf_plan_dft_r2c_1d(size, in, out, FFTW_ESTIMATE);

// this assertion fails...
assert(p); 

Some info:

  • Linux 64bit with 64GB physical ram + 64GB swap
  • FFTW 3.3.3 --enable-float
  • with ~1800mln elements the previous code works and around 10-12GB of RAM are used during the computation (input + some FFTW temp data???)
  • I tried also working out of place or complex to complex FFT
  • sizeof(size_t) == 8, sizeof(float) == 4, sizeof(fftwf_complex) == 8

What is wrong with my code? Is there any upper bound on the input size when using FFTW?

Was it helpful?

Solution

From

http://www.fftw.org/doc/Real_002ddata-DFTs.html

 fftw_plan fftw_plan_dft_r2c_1d(int n0,
                                double *in, fftw_complex *out,
                                unsigned flags);

It seems the type of the first parameter of fftw_plan_dft_r2c_1d is an int and not a size_t. As your size value is huge and looks greater than INT_MAX, you are likely to pass a negative value to your function.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top