fftw_mpi_plan_dft_r2c_3d的运行时行为似乎受到前三个参数的强烈影响。以下代码是从fftw doc复制的。通过将L设置为512并运行48个进程,它会给出分段错误,但只需将L更改为1024然后一切都会正常。我的Linux服务器使用fftw-3.3.3和我的mac使用fftw-3.3.4得到相同的结果。
#include <fftw3-mpi.h>
#include <stdio.h>
int main(int argc, char **argv){
const ptrdiff_t L = 512, M = 512, N = 512;
fftw_plan plan;
double *rin;
fftw_complex *cout;
ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k;
MPI_Init(&argc, &argv);
fftw_mpi_init();
/* get local data size and allocate */
alloc_local = fftw_mpi_local_size_3d(L,M,N/2+1,MPI_COMM_WORLD,&local_n0, &local_0_start);
rin = fftw_alloc_real(2 * alloc_local);
cout = fftw_alloc_complex(alloc_local);
printf("allocated\n");
/* create plan for out-of-place r2c DFT */
plan = fftw_mpi_plan_dft_r2c_3d(L,M,N,rin,cout, MPI_COMM_WORLD,FFTW_MEASURE);
printf("plan made\n");
fftw_destroy_plan(plan);
MPI_Finalize();
}
这是我的Mac上的错误
[MBP:01251] *** Process received signal ***
[MBP:01251] Signal: Segmentation fault: 11 (11)
[MBP:01251] Signal code: (0)
[MBP:01251] Failing at address: 0x0
[MBP:01251] [ 0] 0 libsystem_platform.dylib 0x00007fff8fcc8f1a _sigtramp + 26
[MBP:01251] [ 1] 0 mca_pml_ob1.so 0x0000000102eee422 append_frag_to_list + 594
[MBP:01251] *** End of error message ***