diff --git a/kernel/ipfft.h b/kernel/ipfft.h index 6d49503..dbc47a9 100644 --- a/kernel/ipfft.h +++ b/kernel/ipfft.h @@ -346,8 +346,8 @@ typedef outrafo_plan_s *outrafo_plan; typedef struct{ gtransp_plan global_remap[2]; sertrafo_plan local_transp[2]; - int q0; - int q1; + int q[2]; + int rnk_n; } remap_3dto2d_plan_s; typedef remap_3dto2d_plan_s *remap_3dto2d_plan; diff --git a/tests/Makefile.am b/tests/Makefile.am index 9cdef9f..23beb6c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -100,6 +100,9 @@ check_PROGRAMS += \ check_PROGRAMS += \ simple_check_r2c_3d_on_3d_transposed_many +check_PROGRAMS += \ + simple_check_r2c_2d_on_2d + check_PROGRAMS += \ simple_check_ousam_c2c simple_check_ousam_c2c_transposed \ simple_check_ousam_c2r \ diff --git a/tests/simple_check_r2c_2d_on_2d.c b/tests/simple_check_r2c_2d_on_2d.c new file mode 100644 index 0000000..3443e48 --- /dev/null +++ b/tests/simple_check_r2c_2d_on_2d.c @@ -0,0 +1,80 @@ +#include +#include + +int main(int argc, char **argv) +{ + int np[2]; + ptrdiff_t n[2]; + ptrdiff_t alloc_local; + ptrdiff_t local_ni[2], local_i_start[2]; + ptrdiff_t local_no[2], local_o_start[2]; + double err, *in; + pfft_complex *out; + pfft_plan plan_forw=NULL, plan_back=NULL; + MPI_Comm comm_cart_2d; + + /* Set size of FFT and process mesh */ + n[0] = 29; n[1] = 27; + np[0] = 2; np[1] = 2; + + /* Initialize MPI and PFFT */ + MPI_Init(&argc, &argv); + pfft_init(); + + /* Create three-dimensional process grid of size np[0] x np[1], if possible */ + if( pfft_create_procmesh(2, MPI_COMM_WORLD, np, &comm_cart_2d) ){ + pfft_fprintf(MPI_COMM_WORLD, stderr, "Error: This test file only works with %d processes.\n", np[0]*np[1]); + MPI_Finalize(); + return 1; + } + + /* Get parameters of data distribution */ + alloc_local = pfft_local_size_dft_r2c(2, n, comm_cart_2d, PFFT_TRANSPOSED_NONE, + local_ni, local_i_start, local_no, local_o_start); + + pfft_fprintf(MPI_COMM_WORLD, stderr, "%td.\n", alloc_local); + + /* Allocate memory */ + in = pfft_alloc_real(2 * alloc_local); + out = pfft_alloc_complex(alloc_local); + + /* Plan parallel forward FFT */ + plan_forw = pfft_plan_dft_r2c(2, + n, in, out, comm_cart_2d, PFFT_FORWARD, PFFT_TRANSPOSED_NONE| PFFT_MEASURE| PFFT_DESTROY_INPUT); + + /* Plan parallel backward FFT */ + plan_back = pfft_plan_dft_c2r(2, + n, out, in, comm_cart_2d, PFFT_BACKWARD, PFFT_TRANSPOSED_NONE| PFFT_MEASURE| PFFT_DESTROY_INPUT); + + /* Initialize input with random numbers */ + pfft_init_input_real(2, n, local_ni, local_i_start, + in); + + /* execute parallel forward FFT */ + pfft_execute(plan_forw); + + /* clear the old input */ + pfft_clear_input_real(2, n, local_ni, local_i_start, + in); + + /* execute parallel backward FFT */ + pfft_execute(plan_back); + + /* Scale data */ + for(ptrdiff_t l=0; l < local_ni[0] * local_ni[1]; l++) + in[l] /= (n[0]*n[1]); + + /* Print error of back transformed data */ + MPI_Barrier(MPI_COMM_WORLD); + err = pfft_check_output_real(2, n, local_ni, local_i_start, in, comm_cart_2d); + pfft_printf(comm_cart_2d, "Error after one forward and backward trafo of size n=(%td, %td, %td):\n", n[0], n[1]); + pfft_printf(comm_cart_2d, "maxerror = %6.2e;\n", err); + + /* free mem and finalize */ + pfft_destroy_plan(plan_forw); + pfft_destroy_plan(plan_back); + MPI_Comm_free(&comm_cart_2d); + pfft_free(in); pfft_free(out); + MPI_Finalize(); + return 0; +}