Skip to main content

A RemoteChannel implementation built on top of MPI RMA

Project description

Remote Channels via MPI RMA (One Sided Communication)

Use one-sided MPI communication (built on mpi4py) to coordinate task-based parallelism via channels. The RemoteChannel class is a message queue. "Producer" tasks can place messages into the queue using the (blocking) put -- or the (non-blocking) putf -- methods. "Consumer" task can take messages from the queue using the (blocking) take -- or the (non-blocking) takef -- methods.

Installation

pip install mpi-channels

Usage

  • Create a RemoteChannel and ensure it knows how many messages to expect:
from mpi_channels import RemoteChannel

# Make a Remote Channel (on MPI rank 0)
inputs = RemoteChannel(buff_size, message_size)
inputs.claim(data_size)

The claim method increments the expected number of messages (a counter used to determine of a take call should wait for more data).

  • Place data into the channel:
# Put data into channel
if rank == 0:
    data = np.random.rand(data_size, vector_size)
    
    p_sum = 0.
    for elt in data:
        inputs.putf(elt)

The data elt must be a python object with a len (hint: scalars should be wrapped in a single-item tuple: inputs.putf((val,)) -- the trailing comman ensures that len((val,)) = 1). The putf method returns a concurrent.Futures.Future object and does not block execution if the channel is full.

  • Take data from the channel:
# Take data from the channel
if rank > 0:
    res = 0
    p_sum = 0.
    for i in range(data_size):
        p = inputs.take()

The take method blocks until data can be taken from the channel. If the channel is empty (that is more data have been taken from it than the sum of all inputs.claim(N) calls until that point), then take returns None. Note that p is an object with lenght. If p is a scalar with value val then p=[val].

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpi-channels-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

File details

Details for the file mpi-channels-0.1.0.tar.gz.

File metadata

  • Download URL: mpi-channels-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.1 CPython/3.8.11

File hashes

Hashes for mpi-channels-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d5b7e94afedb7b51ce22991f2af9583ba25a0f0c4718ba0dd7eae0645f3d8ca4
MD5 f27e20dcb724829b4715ad8d3cf11169
BLAKE2b-256 61f18d4b29f2ab1af75318807a490d02e03d7436b220ecaf9e889ed9410247bd

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page