{"id":22155890,"url":"https://github.com/citiususc/omp4py","last_synced_at":"2025-10-12T15:31:41.941Z","repository":{"id":263995214,"uuid":"803318854","full_name":"citiususc/omp4py","owner":"citiususc","description":"OMP4Py: a pure Python implementation of OpenMP","archived":false,"fork":false,"pushed_at":"2024-11-26T10:26:25.000Z","size":3149,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-02T15:46:37.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/citiususc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-20T13:50:34.000Z","updated_at":"2024-12-22T13:56:22.000Z","dependencies_parsed_at":"2024-11-21T12:38:35.756Z","dependency_job_id":"f6797f0f-1b68-41cc-a2fd-4087351c0c6a","html_url":"https://github.com/citiususc/omp4py","commit_stats":null,"previous_names":["citiususc/omp4py"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fomp4py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fomp4py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fomp4py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fomp4py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/citiususc","download_url":"https://codeload.github.com/citiususc/omp4py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236239838,"owners_count":19117272,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-02T02:32:37.967Z","updated_at":"2025-10-12T15:31:36.528Z","avatar_url":"https://github.com/citiususc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OMP4Py: a pure Python implementation of OpenMP\n\n**OMP4Py** is a Python library that provides an implementation of OpenMP, which is widely recognized as the standard \nprogramming model for exploiting multithreading parallelism in HPC. OMP4Py brings OpenMP’s familiar directive-based \nparallelization paradigm to Python, allowing developers to write parallel code with the same level of control and \nflexibility as in C, C++, or Fortran.\n\nOMP4Py, as a pure Python implementation, provides greater flexibility compared to the Numba-based [PyOMP](https://github.com/Python-for-HPC/PyOMP) \nsolution. Unlike PyOMP, it does not impose restrictions on using functions from non-Numba-optimized libraries or \ncertain Python objects and data structures. Additionally, OMP4Py code can be combined with [mpi4py](https://github.com/mpi4py/mpi4py) to develop \nparallel applications that exploit both intra-node and inter-node parallelism.\n\n## Features\n\n- Native Python library\n- Simplified parallelization of loops and code sections\n- Efficient thread management and synchronization\n- API compliant with [OpenMP 3.0 standard](https://www.openmp.org/wp-content/uploads/spec30.pdf)\n\n## Installation\n\nYou can install omp4py via pip:\n\n```bash\npip install omp4py\n```\n**Note**: OMP4Py is compatible with Python versions 3.10 and later, which include the Global Interpreter Lock (GIL). \nHowever, to fully exploit multithreading for scaling applications, it is necessary to use Python 3.13 (free threading) \nor later, which offers a no-GIL option.\n\n## Usage\n\nOMP4Py defines a function `omp` that operates similarly to OpenMP directives in C/C++, maintaining the same syntax and \nfunctionality. The function itself has no effect when executed; it serves solely as a container for the OpenMP \ndirectives. Note that when a OpenMP directive must be used within structured blocks, the `omp` function is used together \nas part of a `with` block; otherwise, it is used as a standalone function call. Note that functions or classes \ncontaining the OpenMP directives must be decorated with the `@omp` decorator.\n\nHere's a basic example of how to use OMP4Py to calculate $\\pi$:\n\n```python\nfrom omp4py import *\nimport random \n    \n@omp\ndef pi(num_points):\n    count = 0\n    with omp(\"parallel for reduction(+:count)\"):\n        for i in range(num_points):\n            x = random.random()\n            y = random.random()\n            if x * x + y * y \u003c= 1.0:\n                count += 1\n    pi = 4 * (count / num_points)\n    return pi\n\nprint(pi(10000000))  \n```\n\n## Tests\n\nTo run the unit tests and check the coverage, you can use the following commands with Poetry*:\n\n1. **Run the unit tests:**\n\n    ```bash\n     poetry run coverage run\n    ```\n\n2. **Generate a coverage report:**\n\n    ```bash\n     poetry run coverage html\n    ```\n\\* Test dependencies are required, and pip only installs project dependencies. Use ``poetry install`` to install them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitiususc%2Fomp4py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitiususc%2Fomp4py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitiususc%2Fomp4py/lists"}