kml_fft(f)_mpi_plan_create
建立单个连续数据序列3维C2C变换的plan。
接口定义
C interface:
kml_fft_plan kml_fft_mpi_plan_create(int backend, const int *inbox_low, const int *inbox_high, const int *inbox_order, const int *outbox_low, const int *outbox_high, const int *outbox_order, MPI_Comm comm, const kml_fft_mpi_options options);
kml_fftf_plan kml_fftf_mpi_plan_create(int backend, const int *inbox_low, const int *inbox_high, const int *inbox_order, const int *outbox_low, const int *outbox_high, const int *outbox_order, MPI_Comm comm, const kml_fftf_mpi_options options);
返回值
函数返回一个kml_fft(f)_plan类型的结构体指针。将该对象作为参数传入kml_fft(f)_ mpi_execute_dft_ext函数、 kml_fft(f)_mpi_forward_c2c函数、kml_fft(f)_mpi_backward_c2c函数中使用,支持forward及backward方向复用,且不需要在plan创建阶段指定in、out buffer。
如果函数返回非空指针,则表示plan执行成功,否则表示执行失败。
参数
参数名 |
数据类型 |
描述 |
输入/输出 |
---|---|---|---|
backend |
int |
底层库类型,当前仅支持BACKEND_KFFT。 |
输入 |
inbox_low |
const int * |
是长度为3的一维数组,输入数据在三个维度的切分范围下限,-1≤inbox_low[i]≤n[i]-1 for i in 0、1、2。 |
输入 |
inbox_high |
const int * |
是长度为3的一维数组,输入数据在三个维度的切分范围上限,-1≤inbox_high[i]≤n[i]-1 for i in 0、1、2,且0≤(inbox_high[i]-inbox_low[i]+1)≤n[i] for i in 0、1、2。 |
输入 |
inbox_order |
const int * |
是长度为3的一维数组,输入数据维度的顺序,取值为0、1、2的任意顺序组合,输入NULL,默认order为0、1、2。 |
输入 |
outbox_low |
const int * |
是长度为3的一维数组,输出数据在三个维度的切分范围下限,-1≤outbox_low[i]≤n[i]-1 for i in 0、1、2。 |
输入 |
outbox_high |
const int * |
是长度为3的一维数组,输出数据在三个维度的切分范围上限,-1≤outbox_high[i]≤n[i]-1 for i in 0、1、 2,且 0≤(outbox_high[i] - outbox_low[i] + 1)≤n[i] for i in 0、1、2。 |
输入 |
outbox_order |
const int * |
是长度为3的一维数组,输出数据维度的顺序,取值为0、1、2的任意顺序组合,输入NULL,默认order为0、1、2。 |
输入 |
comm |
MPI_Comm |
通信域。 |
输入 |
options |
|
3DFFT分解算法、通信算法flag。 |
输入 |
依赖
C: "kfft-mpi.h"
示例
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; kml_fft_complex *out = NULL; /* get local data size and allocate */ ptrdiff_t low[3] = {0}; ptrdiff_t high[3] = {0}; ptrdiff_t n[3] = {n0, n1, n2}; ptrdiff_t alloc_local = kml_fft_mpi_local_size_ext(3, n, 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); if (in == NULL) { printf("[%s][%d] malloc memory fail!!!\n", __func__, __LINE__); } out = (kml_fft_complex *)kml_fft_malloc(sizeof(kml_fft_complex) * alloc_local); if (out == NULL) { printf("[%s][%d] malloc memory fail!!!\n", __func__, __LINE__); } /* create plan */ int low_int[3] = {low[0], low[1], low[2]}; int high_int[3] = {high[0], high[1], high[2]}; kml_fft_mpi_options options = { .a2a_algo = A2A_ALGO_AUTO_TUNING, .decomp_type = SCALFFT_DECOMPOSE_TYPE_PENCIL }; plan = kml_fft_mpi_plan_create(BACKEND_KFFT, low_int, high_int, NULL, low_int, high_int, NULL, comm, options); /* execute plan */ int scale = 0; kml_fft_mpi_execute_dft_ext(plan, in, out, scale, KML_FFT_FORWARD); kml_fft_mpi_execute_dft_ext(plan, out, in, scale, KML_FFT_BACKWARD); // kml_fft_mpi_forward_c2c(plan, in, out, scale); // kml_fft_mpi_backward_c2c(plan, out, in, scale); kml_fft_destroy_plan_ext(plan); kml_fft_free(in); kml_fft_free(out); MPI_Finalize();