Rate This Document
Findability
Accuracy
Completeness
Readability

kml_fft(f)_mpi_local_size_many_transposed

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_transposed(int rank, const ptrdiff_t *n, ptrdiff_t howmany, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start);

ptrdiff_t kml_fftf_mpi_local_size_many_transposed(int rank, const ptrdiff_t *n, ptrdiff_t howmany, MPI_Comm comm, ptrdiff_t *local_n0, ptrdiff_t *local_0_start, ptrdiff_t *local_n1, ptrdiff_t *local_1_start);

Return Value

The function returns a value of the ptrdiff_t type, indicating the number of elements to be allocated.

Parameters

Parameter

Data Type

Description

Input/Output

rank

  • int

Number of dimensions of the data to be processed. Constraint: rank ≥ 1.

Input

n

  • n

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

Input

howmany

  • ptrdiff_t

Indicates how many transforms are needed.

Input

comm

  • MPI_Comm

MPI communicator handle.

Input

local_n0

  • ptrdiff_t*

Size of local process data.

Output

local_0_start

  • ptrdiff_t*

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

Output

local_n1

  • ptrdiff_t*

Size of the output data of the local process.

Output

local_1_start

  • ptrdiff_t*

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

Output

Dependencies

C: "kfft-mpi.h"

Examples

    const ptrdiff_t N0 = 4, N1 = 4;
    kml_fft_plan plan;
    ptrdiff_t alloc_local, local_n0, local_0_start, local_n1, local_1_start;
 
    MPI_Init(&argc, &argv);
    MPI_Comm comm = MPI_COMM_WORLD;
    kml_fft_mpi_init();
    ptrdiff_t *n = (ptrdiff_t *)kml_fft_malloc(sizeof(ptrdiff_t) * 2);
    if (n == NULL) {
        printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
    }
    
    n[0] = N0;
    n[1] = N1;
    ptrdiff_t howmany = 1;
    ptrdiff_t block0 = 0;
    ptrdiff_t block1 = 0;
    double *in = NULL;
    double *out = NULL;
 
    /* get local data size and allocate */
    alloc_local = kml_fft_mpi_local_size_many_transposed(2, n, howmany, comm, 
                                                        &local_n0, &local_0_start,
                                                        &local_n1, &local_1_start);
    if (alloc_local == -1) {
        printf("[%s][%d] allocate size fail.\n", __func__, __LINE__);
    }
    in = (double *)kml_fft_malloc(sizeof(double) * alloc_local * 2);
    if (in == NULL) {
        printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
    }
    out = (double *)kml_fft_malloc(sizeof(double) * alloc_local * 2);
    if (out == NULL) {
        printf("[%s][%d] malloc memory fail.\n", __func__, __LINE__);
    }
 
    /* create plan for in-place forward DFT */
    plan = kml_fft_mpi_plan_many_transpose(n[0], n[1], howmany, block0, block1, in, out, comm, KML_FFT_ESTIMATE);    
            
    /* compute transforms, in-place, as many times as desired */
    kml_fft_execute(plan);
 
    kml_fft_destroy_plan(plan);
    kml_fft_mpi_cleanup();
 
    MPI_Finalize();