Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f/h)_ mpi_plan_r2r_2d

Create a plan for the two-dimensional R2R transform of a single contiguous data sequence.

Interface Definition

C interface:

kml_fft_plan kml_fft_mpi_plan_r2r_2d(ptrdiff_t n0, ptrdiff_t n1, double *in, double *out, kml_fft_r2r_kind kind0, kml_fft_r2r_kind kind1, MPI_Comm comm, unsigned flags);

kml_fftf_plan kml_fftf_mpi_plan_r2r_2d(ptrdiff_t n0, ptrdiff_t n1, float *in, float *out, kml_fftf_r2r_kind kind0, kml_fftf_r2r_kind kind1, MPI_Comm comm, unsigned flags);

kml_ffth_plan kml_ffth_mpi_plan_r2r_2d(ptrdiff_t n0, ptrdiff_t n1, __fp16 *in, __fp16 *out, kml_ffth_r2r_kind kind0, kml_ffth_r2r_kind kind1, MPI_Comm comm, unsigned flags);

Return Value

The function returns a structure pointer of the kml_fft(f)_plan type. This object can be passed to the kml_fft(f)_execute function as a parameter to perform FFT on the current input and output. It can also be passed to the kml_fft(f)_execute_r2r function as a parameter to perform FFT on new input and output.

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

ptrdiff_t

Inputs the size of the first dimension in the FFT sequence. The constraint is n0 ≥ 1.

Input

n1

ptrdiff_t

Inputs the size of the second dimension in the FFT sequence. The constraint is n1 ≥ 1.

Input

in

  • Double precision: double*
  • Single precision: float*
  • Half precision: __fp16*

Inputs the data to be transformed.

Input

out

  • Double precision: double*
  • Single precision: float*
  • Half precision: __fp16*

Outputs the data generated using FFT.

Output

kind0

  • Double precision: kml_fft_r2r_kind*
  • Single precision: kml_fftf_r2r_kind*
  • Half precision: kml_ffth_r2r_kind*

kind0 indicates the R2R transform type in the first dimension of an FFT sequence. 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: kml_fft_r2r_kind*
  • Single precision: kml_fftf_r2r_kind*

kind1 indicates the R2R transform type in the second dimension of an FFT sequence. 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

MPI communicator handle.

Input

flags

unsigned int

Planning option, which can be set to:

KML_FFT_ESTIMATE: ESTIMATE mode

KML_FFT_PATIENT: PATIENT mode

KML_FFT_MPI_SCRAMBLED_[IN|OUT]: The input/output is in scrambled format. This option takes effect only for one-dimensional transform.

KML_FFT_MPI_TRANSPOSED_[IN|OUT]: The input/output is transposed from n0 × n1 × n2 ×... × nd-1 to n1 × n0 × n2 ×…× nd-1.

Input

Dependencies

C: "kfft-mpi.h"

Examples

C interface:

    const ptrdiff_t N0 = 4, N1 = 4;
    kml_fft_plan plan;
    ptrdiff_t alloc_local, local_n0, local_0_start;
 
    MPI_Init(&argc, &argv);
    MPI_Comm comm = MPI_COMM_WORLD;
    kml_fft_mpi_init();
    kml_fft_r2r_kind kind0 = KML_FFT_R2HC;
    kml_fft_r2r_kind kind1 = KML_FFT_R2HC;
    double *in = NULL;
    double *out = NULL;
 
    /* get local data size and allocate */
    alloc_local = kml_fft_mpi_local_size_2d(N0, N1, comm, &local_n0, &local_0_start);
    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 for in-place forward DFT */
    plan = kml_fft_mpi_plan_r2r_2d(N0, N1, in, out, comm, kind0, kind1, KML_FFT_MPI_TRANSPOSED_IN);    
            
    /* compute transforms, in-place, as many times as desired */
    kml_fft_execute_r2r(plan, in, out);
 
    kml_fft_destroy_plan(plan);
    kml_fft_mpi_cleanup();
 
    MPI_Finalize();