Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_mpi_local_size_transposed_ext

Describes the size and location of the local process data and calculates the space to be allocated after box_order is enabled.

Interface Definition

C interface:

ptrdiff_t kml_fft_mpi_local_size_transposed_ext(int rank, const ptrdiff_t *n, MPI_Comm comm, enum SCALFFT_DECOMPOSE_TYPE_E decomp_type, const int *order, ptrdiff_t *low, ptrdiff_t *high);

ptrdiff_t kml_fftf_mpi_local_size_transposed_ext(int rank, const ptrdiff_t *n, MPI_Comm comm, enum SCALFFT_DECOMPOSE_TYPE_E decomp_type, const int *order, ptrdiff_t *low, ptrdiff_t *high);

Return Value

The function returns a value of the ptrdiff_t type, indicating the number of buffer elements to be allocated. Return value: 0 if the operation is successful; -1 otherwise.

Parameters

Table 1 Parameter definition

Parameter

Data Type

Description

Input/Output

rank

int

Process ID.

Input

n

ptrdiff_t *

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

Input

comm

MPI_Comm

Communicator.

Input

decomp_type

enum SCALFFT_DECOMPOSE_TYPE_E

Decomposition algorithm, SCALFFT_DECOMPOSE_TYPE_SLAB, SCALFFT_DECOMPOSE_TYPE_PENCIL, or SCALFFT_DECOMPOSE_TYPE_BRICK

Input

order

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

low

ptrdiff_t *

Start point of local data

Output

high

ptrdiff_t *

End point of local data

Output

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;
    kml_fft_complex *in = NULL;
    kml_fft_complex *out = NULL;
 
    /* get local data size and allocate */
    ptrdiff_t in_low[3] = {0};
    ptrdiff_t in_high[3] = {0};
    ptrdiff_t out_low[3] = {0};
    ptrdiff_t out_high[3] = {0};
    ptrdiff_t n[3] = {n0, n1, n2};
    int in_order[3] = {0, 1, 2};
    int out_order[3] = {1, 2, 0};
    ptrdiff_t in_alloc_local = kml_fft_mpi_local_size_transposed_ext(3, n, comm, SCALFFT_DECOMPOSE_TYPE_PENCIL, in_order, in_low, in_high);
    if (in_alloc_local == -1) {
        printf("[%s][%d] allocate size fail.\n", __func__, __LINE__);
    }
    ptrdiff_t out_alloc_local = kml_fft_mpi_local_size_transposed_ext(3, n, comm, SCALFFT_DECOMPOSE_TYPE_PENCIL, out_order, out_low, out_high);
    if (out_alloc_local == -1) {
        printf("[%s][%d] allocate size fail.\n", __func__, __LINE__);
    }
    in = (kml_fft_complex *)kml_fft_malloc(sizeof(kml_fft_complex) * in_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) * out_alloc_local);
    if (out == NULL) {
        printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
    }
 
    /* create plan */
    int in_low_int[3] = {in_low[0], in_low[1], in_low[2]};
    int in_high_int[3] = {in_high[0], in_high[1], in_high[2]};
    int out_low_int[3] = {out_low[0], out_low[1], out_low[2]};
    int out_high_int[3] = {out_high[0], out_high[1], out_high[2]};
    kml_fft_mpi_options options = {
            .a2a_algo    = A2A_ALGO_AUTO_TUNING,
            .decomp_type = SCALFFT_DECOMPOSE_TYPE_PENCIL
    };
    plan = kml_fft_mpi_plan_create(BACKEND_KFFT, in_low_int, in_high_int, in_order, out_low_int, out_high_int, out_order, comm, options);
 
    /* execute plan */
    int scale = 0;
    kml_fft_mpi_execute_dft_ext(plan, in, out, scale, KML_FFT_FORWARD);
    kml_fft_mpi_execute_dft_ext(plan, out, in, scale, KML_FFT_BACKWARD);
    // kml_fft_mpi_forward_c2c(plan, in, out, scale);
    // kml_fft_mpi_backward_c2c(plan, out, in, scale);
 
    kml_fft_destroy_plan_ext(plan);
 
    kml_fft_free(in);
    kml_fft_free(out);
    MPI_Finalize();