{"id":17358620,"url":"https://github.com/babak2/mpi-matrix-processing","last_synced_at":"2025-03-27T15:22:38.771Z","repository":{"id":215534817,"uuid":"729559783","full_name":"babak2/MPI-Matrix-Processing","owner":"babak2","description":null,"archived":false,"fork":false,"pushed_at":"2024-01-05T20:02:57.000Z","size":4,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T19:14:24.694Z","etag":null,"topics":["cpp","mpi","multiprocessing","parrallel-computing"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/babak2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2023-12-09T16:04:31.000Z","updated_at":"2024-01-13T23:02:04.000Z","dependencies_parsed_at":"2024-01-05T01:44:26.910Z","dependency_job_id":"6ae62028-ec5d-4fc4-b245-4e0cbab1fe93","html_url":"https://github.com/babak2/MPI-Matrix-Processing","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"6b956f3d8a3a6983fafe9d2d08bd87b0efd70b6f"},"previous_names":["babak2/mpi-matrix-processing"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babak2%2FMPI-Matrix-Processing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babak2%2FMPI-Matrix-Processing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babak2%2FMPI-Matrix-Processing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/babak2%2FMPI-Matrix-Processing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/babak2","download_url":"https://codeload.github.com/babak2/MPI-Matrix-Processing/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245868503,"owners_count":20685662,"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":["cpp","mpi","multiprocessing","parrallel-computing"],"created_at":"2024-10-15T19:06:13.252Z","updated_at":"2025-03-27T15:22:38.745Z","avatar_url":"https://github.com/babak2.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MPI Matrix Processing \n\n## Description\n\nThis program demonstrates the use of MPI (Message Passing Interface) to parallelize a computationally heavy task, specifically the computation of the sum of elements in a matrix. The program is designed to compare the execution time of the task with and without MPI, showcasing the potential speedup achieved through parallelization. Additionally, it calculates and prints the speedup factor and percentage improvement.\n\n## Demo Features\n\n- MPI Parallelization: Utilizes MPI to distribute the matrix elements among multiple processes, enabling parallel computation.\n\n- The execution time for both non-MPI and MPI (for each number of processes used) versions is printed to the console for performance analysis.\n\nUsing these printouts, we can manually do the following:\n\n- Execution Time Comparison: Measures and compares the execution time of the matrix sum computation with and without MPI.\n\n- Speedup Factor Calculation: Computes the speedup factor achieved through parallelization.\n\n- Percentage Improvement: Calculates and prints the percentage improvement in execution time when using MPI.\n\n# Requirements\n\n- MPI (Message Passing Interface) library\n- C++ compiler with MPI support (for compiling MPI version)\n- C++ compiler (for compiling non-MPI version)\n\n\n# Usage\n\n## MPI Compilation\n\nTo compile the program with MPI support, use the following command:\n\n```mpic++ -g mpi-matrix-processing.cpp -o mpi-matrix-processing```\n\nOr, with macro definition:\n\n```mpic++ -DUSE_MPI -g mpi-matrix-processing.cpp -o mpi-matrix-processing```\n\n## MPI Execution\n\nTo execute the MPI version, use the following command:\n\n`mpirun --oversubscribe -np \u003cnumber_of_processes\u003e ./mpi-matrix-processing`\n\n\nFor example:\n\n```mpirun --oversubscribe -np 4 ./mpi-matrix-processing```\n\n\n## Non-MPI Compilation\n\nTo compile the program without MPI support, use the following command:\n\n```g++ -g mpi-matrix-processing.cpp -o matrix-processing-no-mpi```\n\n\n## Non-MPI Execution\n\nTo execute the non-MPI version, use the following command:\n\n```./matrix-processing-no-mpi```\n\n\n# Output examples \n\nFirst MPI run, using 4 parallel processes: \n\n`mpirun --oversubscribe -np 4 ./mpi-matrix-processing`\n\nOutput: \n\nExecution Time (MPI): 7.55e-07 seconds\n\nExecution Time (MPI): 2.03e-07 seconds\n\nExecution Time (MPI): 1.42e-07 seconds\n\nExecution Time (MPI): 2.02e-07 seconds\n\n\nSecondly, no-MP run:\n\n`./matrix-processing-no-mpi`\n\nOutput: \n\nExecution Time (Non-MPI): 8e-06 seconds\n\n## Speed up calculation\n\nCalculating speedup (performance) gaind using MPI parallel computation: \n\n\nSpeedup = Execution Time (Non-MPI)​ / Total Execution Time (MPI)\n\nTotal Execution Time (MPI) = Execution Time1 ​+ Execution Time2 ​+ Execution Time3 ​+ Execution Time4​\n\nSo: \n\nTotal Execution Time (MPI) = (7.55e−07 + 2.03e−07 + 1.42e−07 + 2.02e−07) seconds\n\nTotal Execution Time (MPI) ~ 1.4e−06 seconds\n\nSpeedup = 8e−06 / 1.4e−06  ~ 5.71\n\nSo, the overall speedup achieved by using MPI compared to the non-MPI version in this example was approximately 5.71 times.\n\n\n# Matrix Size Configuration\n\nThe program generates a random matrix for demonstration purposes, and the initial matrix size is set to a smaller value (const int matrix_size = 10) for debugging convenience. If you wish to work with larger matrices, you can modify the matrix_size constant in the source code to adjust the size accordingly.\n\nconst int matrix_size = 10;  // Adjust the matrix size for debugging\n\n\n# Notes\n\n- The MPI code section is marked with #ifdef USE_MPI. Ensure to define the macro USE_MPI during compilation to enable MPI features.\n            \n- The MPI-related code is enclosed within preprocessor directives, allowing easy switching between MPI and non-MPI versions during compilation.\n\n\n# License\n\nThe mpi-matrix-processing program is licensed under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/).\n\n![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png)\n\n\n# Author \n\nBabak Mahdavi Ardestani\n\nbabak.m.ardestani@gmail.com\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabak2%2Fmpi-matrix-processing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbabak2%2Fmpi-matrix-processing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbabak2%2Fmpi-matrix-processing/lists"}