Skip to main content

Easy routines for coding on sharedmem machines

Project description

Dispatch your trivially parallizable jobs with sharedmem.

Now also supports Python 3.

  • sharedmem.empty creates numpy arrays to child processes.

  • sharedmem.MapReduce dispatches work to child processes.

  • sharedmem.MapReduce.ordered and sharedmem.MapReduce.critical provides the equivlant concept of OpenMP ordered and OpenMP critical sections.

Functions and variables are inherited from a fork and copy-on-write. Pickability is not a concern.

Easier to use than multiprocessing.Pool, at the cost of not supporting Windows.

For documentation, please refer to http://rainwoodman.github.io/sharedmem .

>>>
>>> input = numpy.arange(1024 * 1024 * 128, dtype='f8')
>>> output = sharedmem.empty(1024 * 1024 * 128, dtype='f8')
>>> with MapReduce() as pool:
>>>    chunksize = 1024 * 1024
>>>    def work(i):
>>>        s = slice (i, i + chunksize)
>>>        output[s] = input[s]
>>>        return i, sum(input[s])
>>>    def reduce(i, r):
>>>        print('chunk', i, 'done')
>>>        return r
>>>    r = pool.map(work, range(0, len(input), chunksize), reduce=reduce)
>>> print numpy.sum(r)
>>>

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

sharedmem-0.3.tar.gz (13.2 kB view details)

Uploaded Source

File details

Details for the file sharedmem-0.3.tar.gz.

File metadata

  • Download URL: sharedmem-0.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sharedmem-0.3.tar.gz
Algorithm Hash digest
SHA256 638aa58d7ab6b2030c7aa2941faa00d298cb55480853f68bcdd49a9774646b1b
MD5 34d9e10b79619ba68ef9c5d62d1bcc46
BLAKE2b-256 8f724535d3b6ac0bc1b8e6556b65108f67ce1de0dea947b6a266fbb6eb5b4579

See more details on using hashes here.

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