kml_fft(f)_mpi_plan_dft_c2r_3d_ext
Create a plan for the three-dimensional C2R transform of a single contiguous data array.
Interface Definition
C interface:
kml_fft_plan kml_fft_mpi_plan_dft_c2r_3d_ext(int n0, int n1, int n2, const int *inbox_order, const int *outbox_order, MPI_Comm comm, const kml_fft_mpi_options options);
kml_fftf_plan kml_fftf_mpi_plan_dft_c2r_3d_ext(int n0, int n1, int n2, const int *inbox_order, const int *outbox_order, MPI_Comm comm, const kml_fftf_mpi_options options);
Return Value
The function returns a structure pointer of the kml_fft(f)_plan type. Pass the object to the kml_fft(f)_ mpi_execute_dft_c2r_ext function and kml_fft(f)_mpi_backward _c2r function as a parameter, and the input and output buffers do not need to be specified during plan creation.
If this function returns a non-null pointer, the plan has been successfully created. Otherwise, the plan fails to be created.
Parameters
Parameter |
Data Type |
Description |
Input/Output |
|---|---|---|---|
n0 |
int |
Inputs the size of the first dimension in the FFT array. The constraint is n0 ≥ 1. |
Input |
n1 |
int |
Inputs the size of the second dimension in the FFT array. The constraint is n1 ≥ 1. |
Input |
n2 |
int |
Inputs the size of the third dimension in the FFT array. The constraint is n2 ≥ 1. |
Input |
inbox_order |
const int * |
It is a one-dimensional array with a length of 3, indicating the sequence of input data dimensions. The value is any combination of 0, 1, and 2. If this parameter is NULL, the default order is 0, 1, and 2. |
Input |
outbox_order |
const int * |
It is a one-dimensional array with a length of 3, indicating the sequence of output data dimensions. The value is any combination of 0, 1, and 2. If this parameter is NULL, the default order is 0, 1, and 2. |
Input |
comm |
MPI_Comm |
Communicator. |
Input |
options |
|
Flag of the 3D FFT decomposition algorithm and communication algorithm. |
Input |
Dependencies
C: "kfft-mpi.h"
Examples
C interface:
const int n0 = 4, n1 = 4, n2 = 4;
kml_fft_plan plan;
int provided;
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
MPI_Comm comm = MPI_COMM_WORLD;
kml_fft_complex *in = NULL;
double *out = NULL;
/* get local data size and allocate */
ptrdiff_t low[3] = {0};
ptrdiff_t high[3] = {0};
ptrdiff_t alloc_local = kml_fft_mpi_local_size_3d_ext(n0, n1, n2, comm, SCALFFT_DECOMPOSE_TYPE_PENCIL, low, high);
if (alloc_local == -1) {
printf("[%s][%d] allocate size fail.\n", __func__, __LINE__);
}
in = (kml_fft_complex *)kml_fft_malloc(sizeof(kml_fft_complex) * 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 */
kml_fft_mpi_options options = {
.a2a_algo = A2A_ALGO_AUTO_TUNING,
.decomp_type = SCALFFT_DECOMPOSE_TYPE_PENCIL
};
plan = kml_fft_mpi_plan_dft_c2r_3d_ext(n0, n1, n2, NULL, NULL, comm, options);
/* execute plan */
int scale = 0;
kml_fft_mpi_execute_dft_c2r_ext(plan, in, out, scale);
kml_fft_destroy_plan_ext(plan);
kml_fft_free(in);
kml_fft_free(out);
MPI_Finalize();