Skip to main content

Charm4py Parallel Programming Framework

Project description

https://github.com/charmplusplus/charm4py/actions/workflows/charm4py.yml/badge.svg?event=push https://readthedocs.org/projects/charm4py/badge/?version=latest https://img.shields.io/pypi/v/charm4py.svg

Charm4py (Charm++ for Python -formerly CharmPy-) is a distributed computing and parallel programming framework for Python, for the productive development of fast, parallel and scalable applications. It is built on top of Charm++, a C++ adaptive runtime system that has seen extensive use in the scientific and high-performance computing (HPC) communities across many disciplines, and has been used to develop applications that run on a wide range of devices: from small multi-core devices up to the largest supercomputers.

Please see the Documentation for more information.

Short Example

The following computes Pi in parallel, using any number of machines and processors:

from charm4py import charm, Chare, Group, Reducer, Future
from math import pi
import time

class Worker(Chare):

    def work(self, n_steps, pi_future):
        h = 1.0 / n_steps
        s = 0.0
        for i in range(self.thisIndex, n_steps, charm.numPes()):
            x = h * (i + 0.5)
            s += 4.0 / (1.0 + x**2)
        # perform a reduction among members of the group, sending the result to the future
        self.reduce(pi_future, s * h, Reducer.sum)

def main(args):
    n_steps = 1000
    if len(args) > 1:
        n_steps = int(args[1])
    mypi = Future()
    workers = Group(Worker)  # create one instance of Worker on every processor
    t0 = time.time()
    workers.work(n_steps, mypi)  # invoke 'work' method on every worker
    print('Approximated value of pi is:', mypi.get(),  # 'get' blocks until result arrives
          'Error is', abs(mypi.get() - pi), 'Elapsed time=', time.time() - t0)
    exit()

charm.start(main)

This is a simple example and demonstrates only a few features of Charm4py. Some things to note from this example:

  • Chares (pronounced chars) are distributed Python objects.

  • A Group is a type of distributed collection where one instance of the specified chare type is created on each processor.

  • Remote method invocation in Charm4py is asynchronous.

In this example, there is only one chare per processor, but multiple chares (of the same or different type) can exist on any given processor, which can bring flexibility and also performance benefits (like dynamic load balancing). Please refer to the documentation for more information.

Contact

We would like feedback from the community. If you have feature suggestions, support questions or general comments, please visit the repository’s discussion page or email us at <charm@cs.illinois.edu>.

Main author at <jjgalvez@illinois.edu>

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

charm4py-1.1.tar.gz (353.3 kB view hashes)

Uploaded Source

Built Distributions

charm4py-1.1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

charm4py-1.1-pp310-pypy310_pp73-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

charm4py-1.1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl (1.8 MB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

charm4py-1.1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

charm4py-1.1-pp39-pypy39_pp73-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

charm4py-1.1-pp39-pypy39_pp73-macosx_10_15_x86_64.whl (1.8 MB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

charm4py-1.1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

charm4py-1.1-pp38-pypy38_pp73-macosx_11_0_arm64.whl (1.6 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

charm4py-1.1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (1.8 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

charm4py-1.1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

charm4py-1.1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (1.8 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

charm4py-1.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp313-cp313-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.13 macOS 11.0+ ARM64

charm4py-1.1-cp313-cp313-macosx_10_13_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.13 macOS 10.13+ x86-64

charm4py-1.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp312-cp312-macosx_11_0_arm64.whl (1.9 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

charm4py-1.1-cp312-cp312-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

charm4py-1.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp311-cp311-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

charm4py-1.1-cp311-cp311-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

charm4py-1.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp310-cp310-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

charm4py-1.1-cp310-cp310-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

charm4py-1.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp39-cp39-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

charm4py-1.1-cp39-cp39-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

charm4py-1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.8 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp38-cp38-macosx_11_0_arm64.whl (1.8 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

charm4py-1.1-cp38-cp38-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

charm4py-1.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

charm4py-1.1-cp37-cp37m-macosx_10_9_x86_64.whl (2.0 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

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