Skip to main content

charm4py Parallel Programming Framework

Project description

(NOTE: With release v0.11 we have changed the name of the project to charm4py. See the forum for more information.)

https://travis-ci.org/UIUC-PPL/charm4py.svg?branch=master http://readthedocs.org/projects/charm4py/badge/?version=latest https://img.shields.io/pypi/v/charm4py.svg

charm4py (Charm++ for Python -formerly CharmPy-) is a general-purpose parallel and distributed programming framework with a simple and powerful API, based on migratable Python objects and remote method invocation; built on top of an adaptive C++ runtime system providing speed, scalability and dynamic load balancing.

charm4py allows development of parallel applications that scale from laptops to supercomputers, using the Python language. It is built on top of Charm++.

Please see the Documentation.

Short Example

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

from charm4py import charm, Chare, Group, Reducer
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.contribute(s * h, Reducer.sum, pi_future)

def main(args):
    n_steps = 1000
    if len(args) > 1:
        n_steps = int(args[1])
    mypi = charm.createFuture()
    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 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 performance benefits. Please refer to the documentation for more information.

Contact

We want feedback from the community. If you have feature suggestions, support questions or general comments, please visit our forum.

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-0.12.3.tar.gz (3.3 MB view hashes)

Uploaded Source

Built Distributions

charm4py-0.12.3-py2.py3-none-win_amd64.whl (831.6 kB view hashes)

Uploaded Python 2 Python 3 Windows x86-64

charm4py-0.12.3-cp37-cp37m-win_amd64.whl (934.3 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

charm4py-0.12.3-cp37-cp37m-manylinux1_x86_64.whl (1.7 MB view hashes)

Uploaded CPython 3.7m

charm4py-0.12.3-cp37-cp37m-macosx_10_6_intel.whl (1.4 MB view hashes)

Uploaded CPython 3.7m macOS 10.6+ intel

charm4py-0.12.3-cp36-cp36m-win_amd64.whl (934.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

charm4py-0.12.3-cp36-cp36m-manylinux1_x86_64.whl (1.7 MB view hashes)

Uploaded CPython 3.6m

charm4py-0.12.3-cp36-cp36m-macosx_10_6_intel.whl (1.4 MB view hashes)

Uploaded CPython 3.6m macOS 10.6+ intel

charm4py-0.12.3-cp35-cp35m-win_amd64.whl (930.8 kB view hashes)

Uploaded CPython 3.5m Windows x86-64

charm4py-0.12.3-cp35-cp35m-manylinux1_x86_64.whl (1.7 MB view hashes)

Uploaded CPython 3.5m

charm4py-0.12.3-cp35-cp35m-macosx_10_6_intel.whl (1.4 MB view hashes)

Uploaded CPython 3.5m macOS 10.6+ intel

charm4py-0.12.3-cp34-cp34m-win_amd64.whl (930.7 kB view hashes)

Uploaded CPython 3.4m Windows x86-64

charm4py-0.12.3-cp34-cp34m-manylinux1_x86_64.whl (1.7 MB view hashes)

Uploaded CPython 3.4m

charm4py-0.12.3-cp34-cp34m-macosx_10_6_intel.whl (1.4 MB view hashes)

Uploaded CPython 3.4m macOS 10.6+ intel

charm4py-0.12.3-cp27-cp27mu-manylinux1_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 2.7mu

charm4py-0.12.3-cp27-cp27m-manylinux1_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 2.7m

charm4py-0.12.3-cp27-cp27m-macosx_10_6_intel.whl (1.3 MB view hashes)

Uploaded CPython 2.7m macOS 10.6+ intel

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