Chris@19: Chris@19:
Chris@19:Chris@19: Next: FFTW MPI Transposes, Chris@19: Previous: Multi-dimensional MPI DFTs of Real Data, Chris@19: Up: Distributed-memory FFTW with MPI Chris@19:
FFTW's MPI interface also supports multi-dimensional ‘r2r’ Chris@19: transforms of all kinds supported by the serial interface Chris@19: (e.g. discrete cosine and sine transforms, discrete Hartley Chris@19: transforms, etc.). Only multi-dimensional ‘r2r’ transforms, not Chris@19: one-dimensional transforms, are currently parallelized. Chris@19: Chris@19:
These are used much like the multidimensional complex DFTs discussed
Chris@19: above, except that the data is real rather than complex, and one needs
Chris@19: to pass an r2r transform kind (fftw_r2r_kind
) for each
Chris@19: dimension as in the serial FFTW (see More DFTs of Real Data).
Chris@19:
Chris@19:
For example, one might perform a two-dimensional L × M that is Chris@19: an REDFT10 (DCT-II) in the first dimension and an RODFT10 (DST-II) in Chris@19: the second dimension with code like: Chris@19: Chris@19:
const ptrdiff_t L = ..., M = ...; Chris@19: fftw_plan plan; Chris@19: double *data; Chris@19: ptrdiff_t alloc_local, local_n0, local_0_start, i, j; Chris@19: Chris@19: /* get local data size and allocate */ Chris@19: alloc_local = fftw_mpi_local_size_2d(L, M, MPI_COMM_WORLD, Chris@19: &local_n0, &local_0_start); Chris@19: data = fftw_alloc_real(alloc_local); Chris@19: Chris@19: /* create plan for in-place REDFT10 x RODFT10 */ Chris@19: plan = fftw_mpi_plan_r2r_2d(L, M, data, data, MPI_COMM_WORLD, Chris@19: FFTW_REDFT10, FFTW_RODFT10, FFTW_MEASURE); Chris@19: Chris@19: /* initialize data to some function my_function(x,y) */ Chris@19: for (i = 0; i < local_n0; ++i) for (j = 0; j < M; ++j) Chris@19: data[i*M + j] = my_function(local_0_start + i, j); Chris@19: Chris@19: /* compute transforms, in-place, as many times as desired */ Chris@19: fftw_execute(plan); Chris@19: Chris@19: fftw_destroy_plan(plan); Chris@19:Chris@19:
Notice that we use the same ‘local_size’ functions as we did for
Chris@19: complex data, only now we interpret the sizes in terms of real rather
Chris@19: than complex values, and correspondingly use fftw_alloc_real
.
Chris@19:
Chris@19:
Chris@19:
Chris@19: