Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f/h)_mpi_local_size_many_1d

Describe the size and location of the local process data and calculate the space to be allocated.

Interface Definition

C interface:

ptrdiff_t kml_fft_mpi_local_size_many_1d(ptrdiff_t n0, ptrdiff_t howmany, MPI_Comm comm, int sign, unsigned flags, ptrdiff_t *local_ni, ptrdiff_t *local_i_start, ptrdiff_t *local_no, ptrdiff_t *local_o_start);

ptrdiff_t kml_fftf_mpi_local_size_many_1d(ptrdiff_t n0, ptrdiff_t howmany, MPI_Comm comm, int sign, unsigned flags, ptrdiff_t *local_ni, ptrdiff_t *local_i_start, ptrdiff_t *local_no, ptrdiff_t *local_o_start);

ptrdiff_t kml_ffth_mpi_local_size_many_1d(ptrdiff_t n0, ptrdiff_t howmany, MPI_Comm comm, int sign, unsigned flags, ptrdiff_t *local_ni, ptrdiff_t *local_i_start, ptrdiff_t *local_no, ptrdiff_t *local_o_start);

Return Value

The function returns a value of the ptrdiff_t type, indicating the number of elements to be allocated (complex number for complex DFT). The local_ni and local_i_start parameters return a part of the stored input 1D array (local_i_start~local_i_start+local_ni-1). The local_no and local_o_start parameters return a part of the stored output 1D array (local_o_start~local_o_start+local_no-1).

Parameters

Parameter

Data Type

Description

Input/Output

n0

ptrdiff_t

Size of the 1D FFT data to be processed. Constraint: n0 ≥ 1.

Input

howmany

ptrdiff_t

Number of transforms, matching the parameter passed during plan creation.

Input

comm

MPI_Comm

MPI communicator handle.

Input

sign

int

Matches the parameter passed during plan creation.

Input

flags

unsigned int

Matches the parameter passed during plan creation.

Input

local_ni

ptrdiff_t*

Size of the input data of the local process.

Output

local_i_start

ptrdiff_t*

Offset of the input data of the local process relative to the start point of the global input data.

Output

local_no

ptrdiff_t*

Size of the output data of the local process.

Output

local_o_start

ptrdiff_t*

Offset of the output data of the local process relative to the start point of the global output data.

Output

Dependencies

C: "kfft-mpi.h"

Examples

    const ptrdiff_t N0 = 4;
    kml_fft_plan plan;
    ptrdiff_t alloc_local, local_ni, local_i_start, local_no, local_o_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 howmany = 1;
    /* get local data size and allocate */
    alloc_local = kml_fft_mpi_local_size_many_1d(N0, howmany, comm, KML_FFT_FORWARD, KML_FFT_MPI_TRANSPOSED_IN,
                                            &local_ni, &local_i_start, &local_no, &local_o_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_1d(N0, in, out, comm,
                                KML_FFT_FORWARD, KML_FFT_MPI_TRANSPOSED_IN);    
            
    /* compute transforms, in-place, as many times as desired */
    kml_fft_execute_dft(plan, int, out);
    kml_fft_destroy_plan(plan);
    MPI_Finalize();
    return 0;