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