#include "fftw_mpi.h" #include"mpi.h" #include<stdio.h>
int main(int argc, char **argv) { int i; const int N=8; int local_n=2,local_start=0,local_n_after_transform=2, local_start_after_transform=0; fftw_mpi_plan plan; fftw_complex *data,*in; MPI_Init(&argc,&argv);
plan = fftw_mpi_create_plan(MPI_COMM_WORLD, N, FFTW_FORWARD, FFTW_ESTIMATE); data= (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * N);
fftw_mpi_local_size(plan,&local_n,&local_start,&local_n_after_transform, &local_start_after_transform,N); for(i=0; i<N; i++)/*测试数据 */ { in[i].re = i; in[i].im= i+1; } for(i=0;i<local_n;i++) { data[i]=in[i+local_start]; } fftw_mpi(plan, 1, data, NULL);
fftw_mpi_destroy_plan(plan); for(i=0; i<N; i++) printf("%f,%fi\n",data[i].re,data[i].im ); MPI_Finalize();
}
|