kml_fft(f)_mpi_local_size_2d_transposed
Describes the size and location of the local process data and calculates the space to be allocated.
Interface Definition
C interface:
ptrdiff_t kml_fft_mpi_local_size_2d_transposed(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
ptrdiff_t kml_fftf_mpi_local_size_2d_transposed(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
ptrdiff_t kml_ffth_mpi_local_size_2d_transposed(ptrdiff_t n0, ptrdiff_t n1, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start);
Return Value
The function returns a value of the ptrdiff_t type, indicating the number of elements to be allocated.
Parameters
Parameter |
Data Type |
Description |
Input/Output |
|---|---|---|---|
n0 |
|
Size of dimension 1 of the data to be processed. Constraint: n0 ≥ 1. |
Input |
n1 |
|
Size of dimension 2 of the data to be processed. Constraint: n1 ≥ 1. |
Input |
comm |
|
MPI communicator handle. |
Input |
local_n0 |
|
Size of local process data. |
Output |
local_0_start |
|
Offset of the local process data relative to the start point of the global data. |
Output |
local_n1 |
|
Size of the output data of the local process. |
Output |
local_1_start |
|
Offset of the output data of the local process relative to the start point of the global data. |
Output |
Dependencies
C: "kfft-mpi.h"
Examples
const ptrdiff_t N0 = 4, N1 = 4;
kml_fft_plan plan;
ptrdiff_t alloc_local, local_n0, local_0_start, local_n1, local_1_start;
MPI_Init(&argc, &argv);
MPI_Comm comm = MPI_COMM_WORLD;
kml_fft_mpi_init();
double *in = NULL;
double *out = NULL;
/* get local data size and allocate */
alloc_local = kml_fft_mpi_local_size_2d_transposed(N0, N1, comm, &local_n0, &local_0_start,
&local_n1, &local_1_start);
if (alloc_local == -1) {
printf("[%s][%d] allocate size fail.\n", __func__, __LINE__);
}
in = (double *)kml_fft_malloc(sizeof(double) * alloc_local * 2);
if (in == NULL) {
printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
}
out = (double *)kml_fft_malloc(sizeof(double) * alloc_local * 2);
if (out == NULL) {
printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
}
/* create plan for in-place forward DFT */
plan = kml_fft_mpi_plan_transpose(N0, N1, in, out, comm, KML_FFT_ESTIMATE);
/* compute transforms, in-place, as many times as desired */
kml_fft_execute(plan);
kml_fft_destroy_plan(plan);
kml_fft_mpi_cleanup();
MPI_Finalize();