Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_mpi_plan_r2r_3d_ext

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_r2r_3d_ext(int n0, int n1, int n2, const int *inbox_order, const int *outbox_order, const kml_fft_r2r_kind kind0, const kml_fft_r2r_kind kind1, const kml_fft_r2r_kind kind2, MPI_Comm comm, const kml_fft_mpi_options options);

kml_fftf_plan kml_fftf_mpi_plan_r2r_3d_ext(int n0, int n1, int n2, const int *inbox_order, const int *outbox_order, const kml_fftf_r2r_kind kind0, const kml_fftf_r2r_kind kind1, const kml_fftf_r2r_kind kind2, 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

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

kind0

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

kind0 indicates the R2R transform type in the first dimension of an FFT array. It has the following options:

  • 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

kind1

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

kind1 indicates the R2R transform type in the second dimension of an FFT array. It has the following options:

  • 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

kind2

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

kind2 indicates the R2R transform type in the third dimension of an FFT array. It has the following options:

  • 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 */
    kml_fft_mpi_options options = {
        .a2a_algo    = A2A_ALGO_AUTO_TUNING,
        .decomp_type = SCALFFT_DECOMPOSE_TYPE_PENCIL
    };
    kml_fft_r2r_kind kind0 = KML_FFT_DHT;
    kml_fft_r2r_kind kind1 = KML_FFT_DHT;
    kml_fft_r2r_kind kind2 = KML_FFT_DHT;
    plan = kml_fft_mpi_plan_r2r_3d_ext(n0, n1, n2, NULL, NULL, kind0, kind1, kind2,  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();