numba_mpi.api.send

MPI_Send() implementation

 1"""MPI_Send() implementation"""
 2
 3import ctypes
 4
 5import numba
 6import numpy as np
 7
 8from numba_mpi.common import _MPI_Comm_World_ptr, libmpi, send_recv_args
 9from numba_mpi.utils import _mpi_addr, _mpi_dtype
10
11_MPI_Send = libmpi.MPI_Send
12_MPI_Send.restype = ctypes.c_int
13_MPI_Send.argtypes = send_recv_args
14
15
16@numba.njit
17def send(data, dest, tag=0):
18    """Wrapper for MPI_Send. Returns integer status code (0 == MPI_SUCCESS).
19    Mimicking `mpi4py`, default value for `tag` is set to zero.
20    """
21    data = np.ascontiguousarray(data)
22    status = _MPI_Send(
23        data.ctypes.data,
24        data.size,
25        _mpi_dtype(data),
26        dest,
27        tag,
28        _mpi_addr(_MPI_Comm_World_ptr),
29    )
30
31    # The following no-op prevents numba from too aggressive optimizations
32    # This looks like a bug in numba (tested for version 0.55)
33    data[0]  # pylint: disable=pointless-statement
34
35    return status
@numba.njit
def send(data, dest, tag=0):
17@numba.njit
18def send(data, dest, tag=0):
19    """Wrapper for MPI_Send. Returns integer status code (0 == MPI_SUCCESS).
20    Mimicking `mpi4py`, default value for `tag` is set to zero.
21    """
22    data = np.ascontiguousarray(data)
23    status = _MPI_Send(
24        data.ctypes.data,
25        data.size,
26        _mpi_dtype(data),
27        dest,
28        tag,
29        _mpi_addr(_MPI_Comm_World_ptr),
30    )
31
32    # The following no-op prevents numba from too aggressive optimizations
33    # This looks like a bug in numba (tested for version 0.55)
34    data[0]  # pylint: disable=pointless-statement
35
36    return status

Wrapper for MPI_Send. Returns integer status code (0 == MPI_SUCCESS). Mimicking mpi4py, default value for tag is set to zero.