Skip to main content

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.

This illustrates how you can use the RemoteChannel workflow to perform parallel work: RemoteChannel

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 by iterating over data source and putting each element
# into the channel one-by-one. `putf` is non-blocking.
if rank == 0:
    # data = data source
    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:
    # data_size is the expected data size -- make sure that it's big enough.
    for i in range(data_size):
        p = inputs.take()
        # if there is no more data, p = None
        if p is None:
            break
        # Do some work with p

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].

Metadata

Release files for mpi-channels 0.1.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mpi-channels 0.1.4
File Size Uploaded Provenance Actions
mpi-channels-0.1.4.tar.gz 6.8 kB Without provenance Details for mpi-channels-0.1.4.tar.gz

Release files / mpi-channels-0.1.4.tar.gz

Download URL mpi-channels-0.1.4.tar.gz
Size 6.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a5ad357b79685bed3db40877d420e1fd9fd8604d5a057adbf9203143e2b428b2
BLAKE2b-256 checksum
How to use checksums
12ee3a008d5bdb9155c4b409b965c1b42aaef3e96fa6cef5858cb235e1fe4783
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Security for mpi-channels 0.1.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page