{"id":32573406,"url":"https://github.com/yaozhenghangma/messaging","last_synced_at":"2025-10-29T10:52:09.379Z","repository":{"id":177200290,"uuid":"656598823","full_name":"yaozhenghangma/Messaging","owner":"yaozhenghangma","description":"Messaging is a modern C++20 MPI wrapper.","archived":false,"fork":false,"pushed_at":"2023-06-29T07:59:51.000Z","size":28,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-01-27T07:42:29.889Z","etag":null,"topics":["cpp","mpi"],"latest_commit_sha":null,"homepage":"https://github.com/yaozhenghangma/Messaging/","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yaozhenghangma.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}},"created_at":"2023-06-21T09:06:06.000Z","updated_at":"2023-06-29T08:20:21.000Z","dependencies_parsed_at":"2023-06-30T06:48:33.706Z","dependency_job_id":null,"html_url":"https://github.com/yaozhenghangma/Messaging","commit_stats":{"total_commits":15,"total_committers":1,"mean_commits":15.0,"dds":0.0,"last_synced_commit":"fa9cd184d38a38b99ec68b16dfc9f98958c10e64"},"previous_names":["yaozhenghangma/messaging"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/yaozhenghangma/Messaging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaozhenghangma%2FMessaging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaozhenghangma%2FMessaging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaozhenghangma%2FMessaging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaozhenghangma%2FMessaging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yaozhenghangma","download_url":"https://codeload.github.com/yaozhenghangma/Messaging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yaozhenghangma%2FMessaging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281608610,"owners_count":26530372,"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","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cpp","mpi"],"created_at":"2025-10-29T10:50:58.077Z","updated_at":"2025-10-29T10:52:09.367Z","avatar_url":"https://github.com/yaozhenghangma.png","language":"C++","readme":"# Messaging\n[![Open MPI](https://github.com/yaozhenghangma/Messaging/actions/workflows/Open-MPI.yml/badge.svg)](https://github.com/yaozhenghangma/Messaging/actions/workflows/Open-MPI.yml)\n[![MPICH](https://github.com/yaozhenghangma/Messaging/actions/workflows/MPICH.yml/badge.svg)](https://github.com/yaozhenghangma/Messaging/actions/workflows/MPICH.yml)\n[![Intel MPI](https://github.com/yaozhenghangma/Messaging/actions/workflows/Intel-MPI.yml/badge.svg)](https://github.com/yaozhenghangma/Messaging/actions/workflows/Intel-MPI.yml)\n\nMessaging is a modern C++20 MPI wrapper, inspired by Boost.MPI and mpi4py.\n\n## Abstract\n\nMultiprocess paralleling using MPI is the standard approach in high-performance\ncomputing. However, implementing message passing can be a tedious task due to the\nlimited support for data types in MPI. Although there's library like Boost.MPI\nthat offers high-level interfaces, it necessitates building the entire Boost library,\nwhich can be burdensome for users. In light of this, I decide to\ndevelop this simple library to wrap the basic operators in MPI.\n\nThe data serialization part of this library is based on \n[zpp_bits](https://github.com/eyalz800/zpp_bits), which is serialization library\nonly supports C++20 and newer standard. Consequently, to utilize this library, your\nproject must be set to C++20 or a newer standard.\n\nSince this library is build with CMake toolkit, you can use this library by\nsimply adding it to subdirectory and linking it. For example:\n```cmake\nadd_subdirectory(lib/Messaging)\ntarget_link_libraries(project_name PUBLIC Messaging)\n```\n\n## Usage\n### MPI environment\nA C++ object named `CommWorld` is provided to set up the environment and communicator.\n```c++\n#include \u003ciostream\u003e\n#include \u003cmessaging.hpp\u003e\n\nint main() {\n    messaging::CommWorld comm;\n    int rank = comm.Rank();\n    int size = comm.Size();\n    \n    std::cout \u003c\u003c \"This is the number \" \u003c\u003c rank \u003c\u003c \"process of \" \u003c\u003c size \u003c\u003c \"processes.\" \n    \u003c\u003c std::endl;\n    return 0;\n}\n```\n\n### Point-to-point communication\n#### Blocking communication\nThe blocking communication is realized by two methods named `Send` and `Recv`.\n```c++\ntemplate\u003ctypename T\u003e\nmessaging::CommWorld::Send(T \u0026data, int dest, int tag);\n```\n```c++\ntemplate\u003ctypename T\u003e\nmessaging::CommWorld::Recv(T \u0026data, int source, int tag);\n```\nParameters:\n* data: data to be sent or saved\n* dest: rank of processor where the data will be sent to\n* source: rank of processor where the data will be sent from\n* tag: tag labeling the message\n```c++\n#include \u003cmessaging.hpp\u003e\n\nclass Coordinate {\npublic:\n    double x;\n    double y;\n    double z;\n};\n\nint main() {\n    Coordinate coord;\n    messaging::CommWorld comm;\n    if(comm.Rank() == 0) {\n        coord.x = 0;\n        coord.y = 1;\n        coord.z = 2;\n        comm.Send(coord, 1, 99);\n    } else if(comm.Rank() == 1) {\n        comm.Recv(coord, 0, 99);\n    }\n}\n```\n\n### Collective communication\n#### Broadcast\n```c++\ntemplate\u003ctypename T\u003e\nmessaging::CommWorld::Broadcast(T \u0026data, int root);\n```\nParameters:\n* data: data to be broadcast\n* root: rank of the processor that will broadcast data\n\n```c++\n#include \u003cmessaging.hpp\u003e\n\nclass Coordinate {\npublic:\n    double x;\n    double y;\n    double z;\n};\n\nint main() {\n    messaging::CommWorld comm;\n    Coordinate coord;\n    std::vector\u003cCoordinate\u003e coord_vec;\n    int rank = comm.Rank();\n    int size = comm.Size();\n    \n    if(rank == 0) {\n        coord.x = 1;\n        coord.y = 2;\n        coord.z = 3;\n    }\n    comm.Broadcast(coord, 0);\n    return 0;\n}\n```\n\n#### Gather\n```c++\ntemplate\u003ctypename T\u003e\nmessaging::CommWorld::Gather(T \u0026data, std::vector\u003cT\u003e \u0026all_data, int root);\n```\nParameters:\n* data: data to be sent\n* all_data: vector to save the gathered data (stored in root processor)\n* root: rank of root processor\n\n```c++\n#include \u003cmessaging.hpp\u003e\n\nclass Coordinate {\npublic:\n    double x;\n    double y;\n    double z;\n};\n\nint main() {\n    messaging::CommWorld comm;\n    Coordinate coord;\n    std::vector\u003cCoordinate\u003e coord_vec;\n    int rank = comm.Rank();\n    int size = comm.Size();\n    \n    coord.x = rank;\n    coord.y = rank+10;\n    coord.z = rank+100;\n    comm.Gather(coord, coord_vec, 0);\n    return 0;\n}\n```\n\n#### Scatter\n```c++\ntemplate\u003ctypename T\u003e\nmessaging::CommWorld::Scatter(std::vector\u003cT\u003e \u0026all_data, T \u0026data, int root);\n```\nParameters:\n* all_data: data to be scattered from root processor\n* data: received data\n* root: rank of root processor\n\n```c++\n#include \u003cmessaging.hpp\u003e\n\nclass Coordinate {\npublic:\n    double x;\n    double y;\n    double z;\n};\n\nint main() {\n    messaging::CommWorld comm;\n    Coordinate coord;\n    std::vector\u003cCoordinate\u003e coord_vec;\n    int rank = comm.Rank();\n    int size = comm.Size();\n    \n    if(rank == 0) {\n        for(int i=0; i\u003csize; i++) {\n            coord_vec[i].x = i;\n            coord_vec[i].y = i+100;\n            coord_vec[i].z = i+1000;\n        }\n    }\n    comm.Scatter(coord_vec, coord, 0);\n    return 0;\n}\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaozhenghangma%2Fmessaging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyaozhenghangma%2Fmessaging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyaozhenghangma%2Fmessaging/lists"}