numba_mpi.api.isend

MPI_Isend() implementation

 1# pylint: disable=duplicate-code
 2
 3"""MPI_Isend() implementation"""
 4
 5import ctypes
 6
 7import numba
 8import numpy as np
 9
10from numba_mpi.api.requests import _allocate_numpy_array_of_request_handles
11from numba_mpi.common import _MPI_Comm_World_ptr, libmpi, send_recv_async_args
12from numba_mpi.utils import _mpi_addr, _mpi_dtype
13
14_MPI_Isend = libmpi.MPI_Isend
15_MPI_Isend.restype = ctypes.c_int
16_MPI_Isend.argtypes = send_recv_async_args
17
18
19@numba.njit
20def isend(data, dest, tag=0):
21    """Wrapper for MPI_Send. If successful (i.e. result is MPI_SUCCESS),
22    returns c-style pointer to valid MPI_Request handle that may be used
23    with appropriate wait and test functions. Mimicking `mpi4py`, default
24    value for `tag` is set to zero.
25    """
26    data = np.ascontiguousarray(data)
27
28    request_buffer = _allocate_numpy_array_of_request_handles()
29
30    status = _MPI_Isend(
31        data.ctypes.data,
32        data.size,
33        _mpi_dtype(data),
34        dest,
35        tag,
36        _mpi_addr(_MPI_Comm_World_ptr),
37        request_buffer.ctypes.data,
38    )
39
40    return status, request_buffer
@numba.njit
def isend(data, dest, tag=0):
20@numba.njit
21def isend(data, dest, tag=0):
22    """Wrapper for MPI_Send. If successful (i.e. result is MPI_SUCCESS),
23    returns c-style pointer to valid MPI_Request handle that may be used
24    with appropriate wait and test functions. Mimicking `mpi4py`, default
25    value for `tag` is set to zero.
26    """
27    data = np.ascontiguousarray(data)
28
29    request_buffer = _allocate_numpy_array_of_request_handles()
30
31    status = _MPI_Isend(
32        data.ctypes.data,
33        data.size,
34        _mpi_dtype(data),
35        dest,
36        tag,
37        _mpi_addr(_MPI_Comm_World_ptr),
38        request_buffer.ctypes.data,
39    )
40
41    return status, request_buffer

Wrapper for MPI_Send. If successful (i.e. result is MPI_SUCCESS), returns c-style pointer to valid MPI_Request handle that may be used with appropriate wait and test functions. Mimicking mpi4py, default value for tag is set to zero.