Open NevilleAdvan opened 1 month ago
Hi, you may want to try fftw_malloc()
(or attribute __aligned__
if static) for all input and output buffers (array, out_cpx and out). Internal FFTW kernels requires data to be aligned in a certain condition, specially for x86.
Hi, you may want to try
fftw_malloc()
(orattribute __aligned__
if static) for all input and output buffers (array, out_cpx and out). Internal FFTW kernels requires data to be aligned in a certain condition, specially for x86.
Thanks for your answer. How can I fix this problem? Or provide some solutions? Because the parameters that the fftw_plan_dft_r2c_1d function needs to pass in require the data type of fftw_complex and the data type of double. However, according to this seemingly problem-free code, it will cause "Segmentation fault"
Internal FFTW kernels requires data to be aligned in a certain condition, specially for x86.
FFTW does not require all data to be specially aligned. It is faster for specially aligned data (which is provided by fftw_malloc
), but does not require it. (Unless you calll the new-array execute functions, which aren't being used here.)
(IIRC, x86 itself requires double
arrays to be 8-byte aligned, but this should be enforced by the compiler.)
I can't reproduce your problem, the program runs fine for me and outputs:
0.000000 0.000000
1.000000 1.000000
2.000000 2.000000
3.000000 3.000000
4.000000 4.000000
5.000000 5.000000
6.000000 6.000000
7.000000 7.000000
8.000000 8.000000
9.000000 9.000000
How are you compiling FFTW? Maybe there is some kind of architecture mismatch.
I wrote a test demo, and I noticed that many test demos online are tested in this way. But every time I run fftw_plan_dft-r2c_1d and then call fftw_execute, there will be a Segmentation fault. Is there an issue with incorrect compilation. In theory, there is no problem with the code. Here is my code: