> I have the same problem using inverse FFT in GNURADIO. The code
works on 32bit only.
I tried your code snippet, turning it into a stand-alone program by
filling in a few missing declarations and functions (e.g. gri_complex
and inbuf_length) with what they obviously should be, and it worked
fine for me on amd64 Debian, and even passes valgrind. See below for
my test program.
Almost certainly you have a bug elsewhere in your program. (Please
realize that FFTW has been heavily tested on 64-bit platforms in
general, and Debian amd64 in particular, for many years now. See also http://fftw.org/faq/section3.html#segfault
)
--SGJ
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <complex>
#include <stdexcept>
#include <cassert>
#include <stdio.h>
#include <stdlib.h>
#include <fftw3.h>
typedef std::complex<float> gr_complex;
int main(int argc, char **argv)
{
int fft_size = atoi(argv[1]), d_fft_size;
bool forward = false;
gr_complex *d_inbuf, *d_outbuf;
fftwf_plan d_plan;
assert (sizeof (fftwf_complex) == sizeof (gr_complex));
if (fft_size <= 0)
throw std::out_of_range ("gri_fftw: invalid fft_size");
d_fft_size = fft_size;
d_inbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
fft_size);
if (d_inbuf == 0)
throw std::runtime_error ("fftwf_malloc");
d_outbuf = (gr_complex *) fftwf_malloc (sizeof (gr_complex) *
fft_size);
if (d_outbuf == 0){
fftwf_free (d_inbuf);
throw std::runtime_error ("fftwf_malloc");
}
FILE *f = fopen("wis.dat", "r");
if (f) {
fftwf_import_wisdom_from_file(f); // load prior wisdom from disk
fclose(f);
}
d_plan = fftwf_plan_dft_1d (fft_size,
reinterpret_cast<fftwf_complex *>(d_inbuf),
reinterpret_cast<fftwf_complex *>(d_outbuf),
forward ? FFTW_FORWARD : FFTW_BACKWARD,
FFTW_MEASURE);
if (d_plan == NULL) {
fprintf(stderr, "gri_fft_complex: error creating plan\n");
throw std::runtime_error ("fftwf_plan_dft_1d failed");
}
f = fopen("wis.dat", "w");
if (f) {
fftwf_export_wisdom_to_file(f); // store new wisdom to disk
fclose(f);
}
fftwf_execute(d_plan); // execute a few times
fftwf_execute(d_plan);
fftwf_execute(d_plan);
fftwf_destroy_plan(d_plan);
fftwf_free(d_inbuf);
fftwf_free(d_outbuf);
fftwf_cleanup(); // prevent valgrind from complainng
return EXIT_SUCCESS;
}