{"id":22155893,"url":"https://github.com/citiususc/mpi4all","last_synced_at":"2025-09-23T23:39:23.124Z","repository":{"id":223712144,"uuid":"513689647","full_name":"citiususc/mpi4all","owner":"citiususc","description":"MPI4All: Universal Binding Generation for MPI Parallel Programming","archived":false,"fork":false,"pushed_at":"2024-10-18T21:47:51.000Z","size":96,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T18:11:59.373Z","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.rst","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}},"created_at":"2022-07-13T22:34:52.000Z","updated_at":"2024-10-18T21:47:54.000Z","dependencies_parsed_at":"2024-02-21T18:01:44.155Z","dependency_job_id":null,"html_url":"https://github.com/citiususc/mpi4all","commit_stats":null,"previous_names":["citiususc/mpi4all"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fmpi4all","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fmpi4all/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fmpi4all/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/citiususc%2Fmpi4all/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/citiususc","download_url":"https://codeload.github.com/citiususc/mpi4all/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227660688,"owners_count":17800407,"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:47.565Z","updated_at":"2025-09-23T23:39:18.085Z","avatar_url":"https://github.com/citiususc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"==================================================================\nMPI4All: Universal Binding Generation for MPI Parallel Programming\n==================================================================\n\n--------\nOverview\n--------\n\nThis package provides a Python script to parse and generate bindings for the *Message Passing\nInterface* (`MPI \u003chttps://www.mpi-forum.org/\u003e`_) standard. The parser analyzes the MPI headers and generates a specification file with the defined macros, functions and types. The specification file is different for each version and implementation of MPI, which can be stored to generate bindings without using the parser.\n\nAs case studies, we can currently generate bindings for Java and Go. Java makes use of Foreign Linker API and Foreign Memory Access API so the performance is significantly better than Java Native Interface (JNI) implementations. Go use cgo, so MPI headers are needed to compile. More languages may be added in the future, so feel free to make a pull request.\n\nThe goal of the project is to create efficient bindings for MPI automatically. The project will never become an object oriented interface like `mpi4py \u003chttps://github.com/mpi4py/mpi4py/\u003e`_, although an equivalent library could be built using our bindings.\n\n\nMPI4All has been built in the field of the `IgnisHPC \u003chttps://github.com/ignishpc/\u003e`_ project for MPI usage.\n\nIf you use MPI4All, please cite:\n\n- César Piñeiro, Álvaro Vázquez and Juan C. Pichel. `Towards Universal MPI Bindings for Enhanced New Language Support \u003chttps://doi.org/10.1016/j.jocs.2025.102557\u003e`_. Journal of Computational Science, 2025.\n\n- César Piñeiro, Álvaro Vázquez and Juan C. Pichel. `MPI4All: Universal Binding Generation for MPI Parallel Programming \u003chttps://doi.org/10.1007/978-3-031-63749-0_14\u003e`_. 24th Int. Conference on Computational Science (ICCS). LNCS 14832, pp. 196–208, 2024.\n\n-------\nInstall\n-------\n\nYou can install MPI4All using pip::\n\n $ pip install mpi4all\n\n------------\nDependencies\n------------\n\n* `Python \u003chttps://www.python.org/\u003e`_ 3.9+\n\n* An MPI Library\n\nTested with:\n\n* `MPICH \u003chttps://www.mpich.org/\u003e`_: 3.2.1, 3.3.2, 3.4.3, 4.0, 4.1.3, 4.2.3\n\n* `Open MPI \u003chttps://www.open-mpi.org/\u003e`_: 4.0.7, 4.1.4, 5.0.5\n\n* `Intel MPI \u003chttps://www.intel.com/content/www/us/en/developer/tools/oneapi/mpi-library.html\u003e`_: 2021.10.0\n\n--------\nExamples\n--------\n\n\nMPI4All\n^^^^^^^\n\nMPI4All can generate the bindings for **Java** and **Go** with the default MPI library installed in the system::\n\n $ mpi4all --go --java\n\nor using a specification file::\n\n $ mpi4all --load mpich-4.0.json --go --java\n\nSpecification files can be generated with ``--dump`` or downloaded from the `releases \u003chttps://github.com/citiususc/mpi4all/releases\u003e`_ section.\n\nJava\n^^^^\n\nExternal functions cannot use data inside java heap. The example shows how to use ``ByteBuffer.allocateDirect`` and ``Arena`` to allocate memory outside the java heap.\n\n.. code-block:: java\n\n    import java.lang.foreign.*;\n    import java.nio.ByteBuffer;\n    import java.nio.IntBuffer;\n\n    import org.mpi.Mpi;\n\n    public class Main {\n        public static void main(String[] args) throws Throwable {\n            Mpi.MPI_Init(Mpi.C_pointer.NULL.cast(), Mpi.MPI_ARGVS_NULL);\n\n            int rank;\n            int size;\n\n            // When the buffer is interpreted by the MPI function, the native order must be used.\n            // If the MPI function only sends or receives the buffer, the order is indifferent.\n            ByteBuffer buffer = ByteBuffer.allocateDirect(Mpi.C_int.byteSize()).order(ByteOrder.nativeOrder());\n\n            Mpi.MPI_Comm_rank(Mpi.MPI_COMM_WORLD, new Mpi.C_pointer\u003c\u003e(MemorySegment.ofBuffer(buffer)));\n            rank = buffer.get(0);\n            try (Arena arena = Arena.ofConfined()) {// Using confined arena\n                Mpi.C_int c_size = Mpi.C_int.alloc(arena);\n                Mpi.MPI_Comm_size(Mpi.MPI_COMM_WORLD, c_size.pointer(arena));\n                size = c_size.get();\n            }\n\n            buffer = ByteBuffer.allocateDirect(Mpi.C_int.byteSize() * size);\n\n            Mpi.C_int c_rank = new Mpi.C_int(0); // Using auto gc arena\n            Mpi.MPI_Allgather(c_rank.pointer().cast(), 1, Mpi.MPI_INT,\n                    new Mpi.C_pointer\u003c\u003e(MemorySegment.ofBuffer(buffer)), 1, Mpi.MPI_INT, Mpi.MPI_COMM_WORLD);\n\n\n            for (int i = 0; i \u003c size; i++) {\n                if (i != buffer.get(i)) {\n                    throw new RuntimeException(\"Allgather error\");\n                }\n            }\n\n\n            Mpi.MPI_Finalize();\n        }\n    }\n\n\nGO\n^^\n\n``C_int`` and ``int`` data types are usually aliases but it is preferable to use ``C_int`` to avoid surprises. Functions with ``void *`` arguments use ``usafe.pointer`` instead, you can use the auxiliary functions ``mpi.P`` and ``mpi.PA`` to convert variables and array respectively to ``usafe.pointer``. All other pointers are converted to their equivalents in Go, ``\u0026var`` or ``\u0026array[0]`` is sufficient to send the memory address.\n\n.. code-block:: go\n\n    package main\n\n    import \"mpi\"\n\n    func main() {\n        if err := mpi.MPI_Init(nil, nil); err != nil {\n            panic(err)\n        }\n\n        var rank mpi.C_int\n        var size mpi.C_int\n\n        if err := mpi.MPI_Comm_rank(mpi.MPI_COMM_WORLD, \u0026rank); err != nil {\n            panic(err)\n        }\n\n        if err := mpi.MPI_Comm_size(mpi.MPI_COMM_WORLD, \u0026size); err != nil {\n            panic(err)\n        }\n\n        result := make([]mpi.C_int, int(size))\n\n        if err := mpi.MPI_Allgather(mpi.P(\u0026rank), 1, mpi.MPI_INT,\n            mpi.PA(\u0026result), mpi.C_int(len(result)), mpi.MPI_INT, mpi.MPI_COMM_WORLD); err != nil {\n            panic(err)\n        }\n\n        for i := 0; i \u003c int(size); i++ {\n            if i != int(result[i]) {\n                panic(\"Allgather error\")\n            }\n        }\n\n        if err := mpi.MPI_Finalize(); err != nil {\n            panic(err)\n        }\n\n    }\n\n-----\nUsage\n-----\n\n.. code-block::\n\n    usage: mpi4all [-h] [--out path] [--log lvl] [--cc path] [--cxx path]\n                   [--exclude str [str ...]] [--enable-fortran] [--dump path]\n                   [--load path] [--cache path] [--go] [--go-no-generic]\n                   [--go-package name] [--go-out name] [--java] [--jdk21]\n                   [--java-package name] [--java-class name] [--java-out name]\n                   [--java-lib-name name] [--java-lib-out name] [--version]\n\n    Universal Binding Generation for MPI Parallel Programming\n\n    options:\n      -h, --help            show this help message and exit\n      --out path, -o path   Place output in folder, by default is working\n                            directory\n      --log lvl             Log level, default error\n      --version             show program's version number and exit\n\n    Parser Arguments:\n      --cc path             MPI C compiler, by default search in PATH\n      --cxx path            MPI C++ compiler, by default search in PATH\n      --exclude str [str ...]\n                            Exclude functions and macros that match with any\n                            pattern\n      --enable-fortran      Parse MPI Fortran functions, which are disabled by\n                            default, to avoid linking errors if they are not\n                            available\n      --dump path           Save blueprint as json file, - for stdout\n      --load path           Disable parser and load a blueprint, - for stdin\n      --cache path          Make --dump if the blueprint does not exist and --load\n                            otherwise\n\n    Go Generator Arguments:\n      --go                  Enable Go Generator\n      --go-no-generic       Disable utility functions that require go 1.18+\n      --go-package name     Go package name, default mpi\n      --go-out name         Go output directory, by default \u003cout\u003e\n\n    Java Generator Arguments:\n      --java                Enable Java Generator\n      --jdk21               Use JDK 21 preview instead of Java 22+ Generator\n      --java-package name   Java package name, default org.mpi\n      --java-class name     Java class name, default Mpi\n      --java-out name       Java output directory, default \u003cout\u003e\n      --java-lib-name name  Java native library name without any extension,\n                            default mpi4all\n      --java-lib-out name   Java output directory for C library, default \u003cjava-\n                            out\u003e/\u003cjava-lib-name\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitiususc%2Fmpi4all","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcitiususc%2Fmpi4all","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcitiususc%2Fmpi4all/lists"}