Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_mpi_plan_create_r2r

Create a plan for the three-dimensional R2R transform of a single contiguous data array.

Interface Definition

C interface:

kml_fft_plan kml_fft_mpi_plan_create_r2r(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, const kml_fft_r2r_kind *kind, MPI_Comm comm, const kml_fft_mpi_options options);

kml_fftf_plan kml_fftf_mpi_plan_create_r2r(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, const kml_fftf_r2r_kind *kind, 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_r2r_ext 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

backend

int

Underlying library type. Currently, only BACKEND_KFFT is supported.

Input

inbox_low

const int *

It is a one-dimensional array with a length of 3. The lower limit of the input data in three dimensions is -1 ≤ inbox_low[i] ≤ n[i]-1 for i in 0, 1, and 2.

Input

inbox_high

const int *

It is a one-dimensional array with a length of 3. The upper limit of the input data in three dimensions is -1 ≤ inbox_high[i] ≤ n[i]-1 for i in 0, 1, 2, and 0 ≤ (inbox_high[i]-inbox_low[i]+1) ≤ n[i] for i in 0, 1, 2.

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_low

const int *

It is a one-dimensional array with a length of 3. The lower limit of the output data in three dimensions is -1 ≤ outbox_low[i] ≤ n[i]-1 for i in 0, 1, and 2.

Input

outbox_high

const int *

It is a one-dimensional array with a length of 3. The upper limit of the output data in three dimensions is -1 ≤ outbox_high[i] ≤ n[i]-1 for i in 0, 1, and 2, and 0 ≤ (outbox_high[i] - outbox_low[i] + 1) ≤ n[i] for i in 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

kind

  • Double precision: const kml_fft_r2r_kind*
  • Single precision: const kml_fftf_r2r_kind*

kind is an array of size 3, containing the R2R transform type of each dimension in the FFT array. kind[i] (for i in 0, 1, 2) can be:

  • KML_FFT_R2HC
  • KML_FFT_HC2R
  • KML_FFT_DHT
  • KML_FFT_REDFT00
  • KML_FFT_REDFT01
  • KML_FFT_REDFT10
  • KML_FFT_REDFT11
  • KML_FFT_RODFT00
  • KML_FFT_RODFT01
  • KML_FFT_RODFT10
  • KML_FFT_RODFT11

Input

comm

MPI_Comm

Communicator.

Input

options

  • Double precision: const kml_fft_mpi_options
  • Single precision: const kml_fftf_mpi_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;
    double *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 = (double *)kml_fft_malloc(sizeof(double) * alloc_local);
    if (in == NULL) {
        printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
    }
    out = (double *)kml_fft_malloc(sizeof(double) * 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
    };
    kml_fft_r2r_kind kind[3] = {KML_FFT_DHT, KML_FFT_DHT, KML_FFT_DHT};
    plan = kml_fft_mpi_plan_create_r2r(BACKEND_KFFT, low_int, high_int, NULL, low_int, high_int, NULL, kind, comm, options);    

    /* execute plan */
    int scale = 0;
    kml_fft_mpi_execute_r2r_ext(plan, in, out, scale);

    kml_fft_destroy_plan_ext(plan);

    kml_fft_free(in);
    kml_fft_free(out);
    MPI_Finalize();