{"id":20977247,"url":"https://github.com/technologicat/mpi_shim","last_synced_at":"2025-12-28T13:54:34.698Z","repository":{"id":129171980,"uuid":"89474071","full_name":"Technologicat/mpi_shim","owner":"Technologicat","description":"MPI support wrapper for optional dependency on mpi4py","archived":false,"fork":false,"pushed_at":"2017-04-26T11:40:34.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T06:14:07.830Z","etag":null,"topics":["mpi","mpi4py","numpy","optional","python","python2","python27","python3","python34","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Technologicat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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":"2017-04-26T11:38:23.000Z","updated_at":"2017-04-27T12:44:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"d093161f-bba0-458e-a1e6-35f07d6c39e6","html_url":"https://github.com/Technologicat/mpi_shim","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Technologicat%2Fmpi_shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Technologicat%2Fmpi_shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Technologicat%2Fmpi_shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Technologicat%2Fmpi_shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Technologicat","download_url":"https://codeload.github.com/Technologicat/mpi_shim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243381936,"owners_count":20281996,"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":["mpi","mpi4py","numpy","optional","python","python2","python27","python3","python34","wrapper"],"created_at":"2024-11-19T04:57:57.971Z","updated_at":"2025-12-28T13:54:34.657Z","avatar_url":"https://github.com/Technologicat.png","language":"Python","readme":"## mpi_shim\n\nMPI support wrapper for optional dependency on mpi4py\n\n### Introduction\n\nThis module is designed to be copied into projects that optionally depend on MPI, to unify handling of MPI and non-MPI cases.\n\nTo load MPI, import this module. The module can always be imported, regardless of whether `mpi4py` is installed. The availability of the `mpi4py` library can then be queried at runtime using `mpi_shim.has_mpi()`.\n\nSome rudimentary wrappers (`get_size()`, `get_rank()`, `get_comm_world()`) are provided; all the rest should be done directly via `mpi4py`, and only if `has_mpi()` returns True. This way, the same code can run both with and without MPI.\n\nAlso provided is `gather_varlength_array()`, a buffer-based fast gather for rank-1 NumPy arrays of varying lengths (like `gatherv`, but determining the sizes automatically).\n\n### Example\n\nBased on [http://mpi4py.scipy.org/docs/usrman/tutorial.html](http://mpi4py.scipy.org/docs/usrman/tutorial.html):\n\n```python\nimport mpi_shim\n\nMPI    = mpi_shim.get_mpi()         # either a reference to mpi4py.MPI, or None if n/a\nnprocs = mpi_shim.get_size()        # actual value from mpi4py, or 1    if n/a\nmy_id  = mpi_shim.get_rank()        # actual value from mpi4py, or 0    if n/a\ncomm   = mpi_shim.get_comm_world()  # actual value from mpi4py, or None if n/a\n\n# The rest works as usual:\n\ndata = (my_id+1)**2  # \u003cinsert meaningful calculation here\u003e\nif MPI is not None:\n   data = comm.gather(data, root=0)\n\nif my_id == 0:\n   for i in range(nprocs):\n       assert data[i] == (i+1)**2\nelse:\n   assert data is None\n```\n\n### License\n\n[BSD](LICENSE.md). Copyright 2012-2017 Juha Jeronen and University of Jyväskylä.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnologicat%2Fmpi_shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechnologicat%2Fmpi_shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechnologicat%2Fmpi_shim/lists"}