#include #include static void init_parameters( int argc, char **argv, ptrdiff_t *n, int *np, int *loops, int *inplace, unsigned *opt_flag, unsigned *tune_flag, unsigned *destroy_flag); static void measure_pfft( const ptrdiff_t *n, int *np, MPI_Comm comm, int loops, int inplace, unsigned pfft_opt_flags); int main(int argc, char **argv) { int np[2], inplace, loops; ptrdiff_t n[3]; unsigned opt, tune, destroy_input; /* Set size of FFT and process mesh */ n[0] = 29; n[1] = 27; n[2] = 31; np[0] = 2; np[1] = 2; inplace = 0; opt = PFFT_ESTIMATE; tune = PFFT_NO_TUNE; destroy_input = PFFT_PRESERVE_INPUT; loops = 1; /* Initialize MPI and PFFT */ MPI_Init(&argc, &argv); pfft_init(); /* set parameters by command line */ init_parameters(argc, argv, n, np, &loops, &inplace, &opt, &tune, &destroy_input); measure_pfft(n, np, MPI_COMM_WORLD, loops, inplace, opt | tune | destroy_input); MPI_Finalize(); return 0; } static void measure_pfft( const ptrdiff_t *n, int *np, MPI_Comm comm, int loops, int inplace, unsigned pfft_opt_flags ) { ptrdiff_t alloc_local; ptrdiff_t local_ni[3], local_i_start[3]; ptrdiff_t local_no[3], local_o_start[3]; double err=0.0, timer[4], max_timer[4]; pfft_complex *in, *out; pfft_plan plan_forw=NULL, plan_back=NULL; MPI_Comm comm_cart_2d; /* Create two-dimensional process grid of size np[0] x np[1], if possible */ if( pfft_create_procmesh_2d(comm, np[0], np[1], &comm_cart_2d) ){ pfft_fprintf(comm, stderr, "Error: This test file only works with %d processes.\n", np[0]*np[1]); return; } /* Get parameters of data distribution */ alloc_local = pfft_local_size_dft_3d(n, comm_cart_2d, PFFT_TRANSPOSED_OUT, local_ni, local_i_start, local_no, local_o_start); /* Allocate memory */ in = pfft_alloc_complex(alloc_local); out = (inplace) ? in : pfft_alloc_complex(alloc_local); /* Plan parallel forward FFT */ timer[0] = -MPI_Wtime(); plan_forw = pfft_plan_dft_3d( n, in, out, comm_cart_2d, PFFT_FORWARD, PFFT_TRANSPOSED_OUT| pfft_opt_flags); timer[0] += MPI_Wtime(); /* Plan parallel backward FFT */ timer[1] = -MPI_Wtime(); plan_back = pfft_plan_dft_3d( n, out, in, comm_cart_2d, PFFT_BACKWARD, PFFT_TRANSPOSED_IN| pfft_opt_flags); timer[1] += MPI_Wtime(); /* Initialize input with random numbers */ pfft_init_input_complex_3d(n, local_ni, local_i_start, in); pfft_reset_timer(plan_forw); pfft_reset_timer(plan_back); timer[2] = timer[3] = 0; for(int t=0; t