Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f/h)_mpi_plan_dft

Create a plan for the n-dimensional C2C transform of a single contiguous data sequence.

Interface Definition

C interface:

kml_fft_plan kml_fft_mpi_plan_dft(int rank, const int *n, kml_fft_complex *in, kml_fft_complex *out, MPI_Comm comm, int sign, unsigned flags);

kml_fftf_plan kml_fftf_mpi_plan_dft(int rank, const int *n, kml_fftf_complex *in, kml_fftf_complex *out, MPI_Comm comm, int sign, unsigned flags);

kml_ffth_plan kml_ffth_mpi_plan_dft(int rank, const int *n, kml_ffth_complex *in, kml_ffth_complex *out, MPI_Comm comm, int sign, unsigned flags);

Return Value

The function returns a structure pointer of the kml_fft(f)_plan type. This object can be passed to the 4.1.7.3.5.1 kml_fft(f)_execute function as a parameter to perform FFT on the current input and output. It can also be passed to the 4.1.7.3.5.2 kml_fft(f)_execute_dft 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

rank

int

Dimension of FFT. Constraint: 1 ≤ rank ≤ 3

Input

n

const int *

Indicates an array whose dimension is rank, including the size of each dimension in the FFT sequence. Constraint: n[i] ≥1, for i in 0 to rank - 1

Input

in

  • Double precision: kml_fft_complex*
  • Single precision: kml_fftf_complex*
  • Half precision: kml_ffth_complex*

Inputs the data to be transformed.

Input

out

  • Double precision: kml_fft_complex*
  • Single precision: kml_fftf_complex*
  • Half precision: kml_ffth_complex*

Outputs the data generated using FFT.

Output

comm

MPI_Comm

MPI communicator handle.

Input

sign

int

Specifies forward or backward transform.

  • -1(KML_FFT_FORWARD): forward
  • +1(KML_FFT_BACKWARD): backward

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

    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_complex *in = NULL;
    kml_fft_complex *out = NULL;
    ptrdiff_t rank = 2;
    ptrdiff_t *n = (ptrdiff_t *)kml_fft_malloc(sizeof(ptrdiff_t) * rank);
    
    n[0] = 3;
    n[1] = 4;
 
    /* obtain local data size and allocate */
    alloc_local = kml_fft_mpi_local_size(rank, n, comm, &local_n0, &local_0_start);
    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 for in-place forward DFT */
    plan = kml_fft_mpi_plan_dft(rank, n, in, out, comm,
                                KML_FFT_FORWARD, KML_FFT_MPI_TRANSPOSED_IN);    
            
    /* compute transforms, in-place, as many times as desired */
    kml_fft_execute(plan);
 
    kml_fft_destroy_plan(plan);
    kml_fft_mpi_cleanup(); 
    MPI_Finalize();