Skip to main content

Python OpenMP library based on Numba

Project description

Documentation Status pypi conda Binder

PyOMP

OpenMP for Python CPU/GPU parallel programming, powered by Numba.

PyOMP provides a familiar interface for CPU/GPU programming using OpenMP abstractions adapted for Python. Besides effortless programmability, PyOMP generates fast code using Numba's JIT compiler based on LLVM, which is competitive with equivalent C/C++ implementations.

PyOMP is developed and distributed as an extension to Numba, so it uses Numba as a dependency. It is currently tested with several Numba versions on the following architecture and operating system combinations: linux-64 (x86_64), osx-arm64 (mac), and linux-arm64. The compatibility matrix with Numba versions records the possible combinations.

Installation is possible through pip or conda, detailed in the next section.

As PyOMP builds on top of the LLVM OpenMP infrastructure, it also inherits its limitations: GPU support is only available on Linux. Also, PyOMP currently supports only NVIDIA GPUs with AMD GPU support in development.

Installation

Pip

PyOMP is distributed through PyPI, installable using the following command:

pip install pyomp

Conda

PyOMP is also distributed through Conda, installable using the following command:

conda install -c python-for-hpc -c conda-forge pyomp

Compatibility matrix

PyOMP Numba
0.5.x 0.62.x - 0.63.x
0.4.x 0.61.x
0.3.x 0.57.x - 0.60.x

Besides a standard installation, we also provide the following options to quickly try out PyOMP online or through a container.

Trying it out

Binder

You can try it out for free on a multi-core CPU in JupyterLab at the following link:

https://mybinder.org/v2/gh/Python-for-HPC/binder/HEAD

Docker

We also provide pre-built containers for arm64 and amd64 architectures with PyOMP and Jupyter pre-installed. The following show how to access the container through the terminal or using Jupyter.

First pull the container

docker pull ghcr.io/python-for-hpc/pyomp:latest

To use the terminal, run a shell on the container

docker run -it ghcr.io/python-for-hpc/pyomp:latest /bin/bash

To use Jupyter, run without arguments and forward port 8888.

docker run -it -p 8888:8888 ghcr.io/python-for-hpc/pyomp:latest

Jupyter will start as a service on localhost with token authentication by default. Grep the url with the token from the output and copy it to the browser.

...
[I 2024-09-15 17:24:47.912 ServerApp]     http://127.0.0.1:8888/tree?token=<token>
...

Usage

From numba.openmp import the @njit decorator and the openmp_context. Decorate with njit the function you want to parallelize with OpenMP and describe parallelism in OpenMP directives using with contexts. Enjoy the simplicity of OpenMP with Python syntax and parallel performance.

For a list of supported OpenMP directives and more detailed information, check out the Documentation.

PyOMP supports both CPU and GPU programming. For GPU programming, PyOMP implements OpenMP's target directive for offloading and supports the device clause to select the offloading target device. For more information see the GPU Offloading section in the documentation.

Example

This is an example of calculating $\pi$ with PyOMP with a parallel for loop using CPU parallelism:

from numba.openmp import njit
from numba.openmp import openmp_context as openmp

@njit
def calc_pi(num_steps):
    step = 1.0 / num_steps
    red_sum = 0.0
    with openmp("parallel for reduction(+:red_sum) schedule(static)"):
        for j in range(num_steps):
            x = ((j-1) - 0.5) * step
            red_sum += 4.0 / (1.0 + x * x)

    pi = step * red_sum
    return pi

print("pi =", calc_pi(1000000))

and this is the same example using GPU offloading:

from numba.openmp import njit
from numba.openmp import openmp_context as openmp
from numba.openmp import omp_get_thread_num


@njit
def calc_pi(num_steps):
    step = 1.0 / num_steps
    red_sum = 0.0
    with openmp("target map(tofrom: red_sum)"):
        with openmp("loop private(x) reduction(+:red_sum)"):
            for i in range(num_steps):
                x = (i + 0.5) * step
                red_sum += 4.0 / (1.0 + x * x)

    pi = step * red_sum
    return pi


print("pi =", calc_pi(1000000))

Support

We welcome any feedback, bug reports, or feature requests. Please open an Issue or post in Discussions.

License

PyOMP is licensed under the BSD-2-Clause license (see LICENSE).

The package includes the LLVM OpenMP runtime library, which is distributed under the Apache License v2.0 with LLVM Exceptions. See LICENSE-OPENMP.txt for details.

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

pyomp-0.5.1.tar.gz (6.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyomp-0.5.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyomp-0.5.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pyomp-0.5.1-cp314-cp314-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

pyomp-0.5.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyomp-0.5.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pyomp-0.5.1-cp313-cp313-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyomp-0.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyomp-0.5.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pyomp-0.5.1-cp312-cp312-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyomp-0.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyomp-0.5.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pyomp-0.5.1-cp311-cp311-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyomp-0.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (38.5 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyomp-0.5.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (37.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

pyomp-0.5.1-cp310-cp310-macosx_11_0_arm64.whl (15.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file pyomp-0.5.1.tar.gz.

File metadata

  • Download URL: pyomp-0.5.1.tar.gz
  • Upload date:
  • Size: 6.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyomp-0.5.1.tar.gz
Algorithm Hash digest
SHA256 3e97d4057461370ab67f6d7e0e1dfdb31b414e922f3a5ed269315aa7cdff3d4e
MD5 60850d3d44fc7a25e0e7880ba8903950
BLAKE2b-256 e510343164b5d33e46a0ad882e0e0078b01bb29f4bcf29c39b1548fb5a13bdc1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1.tar.gz:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7228b332ad9fcc6cfa80c64422ce289ee9a60a44142fe064b481a642bc59df6d
MD5 297b5853656882fea60bb862a59c5c61
BLAKE2b-256 40e15d732d953e0555ce489755a5571dbc467562cab4c2eb666ee21849a811f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ba6b579c07af1eebc96c55c3ef283176d6be708b0bac2ec0356be071fdbcc72f
MD5 c9abe6c9e3aaa1dda4493e825a2a0b9f
BLAKE2b-256 f3d95a710ad03bfd9396faa86cde269d042afb99f327257a3e6343d6816bbc1a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp314-cp314-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2e11ab57d684aa4e3a004b4719133b92c5af7e6ab6c445fd4363c737938237ca
MD5 b0aef54dad502d2fdad9cfc51a8cbf9c
BLAKE2b-256 88a89decf320b993ca401981395b8d1fe067db28e1ab5a989d13de9e2bfe75c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9942dc92cbcf0629b35ceb2a35a8797f18acce8e2bb778a9376c06272c504fc9
MD5 667d720d997c4eb15a8ea46f77203e9b
BLAKE2b-256 a0e0e03f0dabb342d7eca0b98d56b2aba6a2fd3e2c0441e0f893ec62217ab4d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 b34aa9c73715130dda7f4acec6aa6dd4fa4657f8b6b67a16a9820bf12eebc721
MD5 2040bc36faced989bd707c68d660561c
BLAKE2b-256 2305f53aeb8f8589d0ddc50e84b720f446755b97a47b3ebc27e110121a06268f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp313-cp313-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c30be5c0158f724ef8383af4870812af053f25e82efc690e6846e6f6db4aeb23
MD5 9379b8ab02b7551c86b6bf89f07e4b5c
BLAKE2b-256 a7ab47f544b6727f8fe1feace61b7db93713020f76b8223fe1f04e6df0a3b687

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 93a6da0165e14e7d664868bf56548df3a7bfcdded93c1cf9649fee12ffec46f1
MD5 0447c45058a1926f4b57fc77556a5b60
BLAKE2b-256 77ae9ca019e94109c2f38edea1901bb05accb67724f1da509ea8ae73230e63a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 8ed7aeb68b8c5c044d4dc48b2be5a8aea00008ea1fa6db2fd6ba1ed9be3d3c84
MD5 3e74bf7919630f851f816b95c93fb982
BLAKE2b-256 93be994a158b3bb596758d7b68d79d24e475cdc67231155cb9e0d17eeb0d61fc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 46dfba58e64b6240b4d353c803e6bfc688a1e60a8c983bf74874305fdc045af8
MD5 ee1216b7e0f5b4abdf716f96ac182063
BLAKE2b-256 97f005e935d34ad970b1e9dfd476505930ee9d2fd3492d62e28f620a78b65119

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9c394fcdbe84223c27ec8e6ace66df71901b883d04a660e90d7c75b067dd97da
MD5 419d7315550bd93d74b05ed9b7e3bd29
BLAKE2b-256 d4f4f985c4bbc9fb3e7839e8f6f3fc179ccd49aa8a0a2288d0d07f11a7b2229d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 a585a628d8a09d22dc1346b8e27d3d8a8a482115cc5d2e2571cd2f838d91858e
MD5 c91a5000c9676b15c6a7a3b07650dcc5
BLAKE2b-256 27c5ea3dd8efdc6fd2ef7e56335ad255c889693ee2b53ce803ba25e3057e3960

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b98db088c30f8dcbd1d196877e33ee0d33ab33924dd5e0b32cf51840c578433
MD5 a8b572a6bf00c18d611be680f17162be
BLAKE2b-256 1b654a852a8fa674f2b3327c926191884de43ce1ab5cdd48d84a2ae5ac6fc124

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e0fb42fa249624f087bb1423e5ac55b24e0a76e931ffba01614cfe15590c6788
MD5 66222895c74ee46f0c09a3c05be4aacf
BLAKE2b-256 8f3a82371db6b7f10a6cbd2e8da7fb5deb285ef07d78384e56e7ef23caf1a955

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2537d2e4d31f71b04972810c18d5e76b6707e376b4c96959d58389bf825e3412
MD5 20e825e334f91f04ded9654c6a08b4e3
BLAKE2b-256 7ee301b2b31c079fb762f2fc0db53b77feacc3d09d47b09c6751afbf7b2a22ae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyomp-0.5.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyomp-0.5.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 710324f53db26d01937a7bc80d0a3af9f1cd3df44a6686b4a888c9cf5fd3198a
MD5 516b9ef9601bb873b3bcf7ac96a98263
BLAKE2b-256 3a17793e32c42e27c17b962beacec5446997b2fb13fd14c9dcad643189a9b4f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyomp-0.5.1-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build-upload-wheels.yml on Python-for-HPC/PyOMP

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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