{"id":16323689,"url":"https://github.com/im-rises/cfloydwarshallparallel","last_synced_at":"2026-05-19T03:17:25.026Z","repository":{"id":107335619,"uuid":"573169844","full_name":"Im-Rises/cFloydWarshallParallel","owner":"Im-Rises","description":"Floyd-Washall algorithm implemented in parallel programming using OpenCL","archived":false,"fork":false,"pushed_at":"2023-04-09T04:42:41.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-14T15:16:43.107Z","etag":null,"topics":["c","c-plus-plus","cmake","cpp","floyd-warshall","floyd-warshall-algorithm","opencl","parallel-programming"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Im-Rises.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":"2022-12-01T21:13:19.000Z","updated_at":"2023-05-10T17:12:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"338cb5f6-1d71-45a4-82df-ea08678f50e4","html_url":"https://github.com/Im-Rises/cFloydWarshallParallel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Im-Rises/cFloydWarshallParallel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2FcFloydWarshallParallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2FcFloydWarshallParallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2FcFloydWarshallParallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2FcFloydWarshallParallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Im-Rises","download_url":"https://codeload.github.com/Im-Rises/cFloydWarshallParallel/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Im-Rises%2FcFloydWarshallParallel/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265429315,"owners_count":23763726,"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":["c","c-plus-plus","cmake","cpp","floyd-warshall","floyd-warshall-algorithm","opencl","parallel-programming"],"created_at":"2024-10-10T22:55:25.417Z","updated_at":"2026-05-19T03:17:24.997Z","avatar_url":"https://github.com/Im-Rises.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cFloydWarshallParallel\n\n\u003cp align=\"center\"\u003e\n      \u003cimg src=\"https://user-images.githubusercontent.com/59691442/183268126-b3d19e66-8f2d-463a-805e-ae6ef7cc6c01.png\" alt=\"cmakeLogo\" style=\"height:60px;\"/\u003e\n      \u003cimg src=\"https://img.shields.io/badge/C-00599C?style=for-the-badge\u0026logo=c\u0026logoColor=white\" alt=\"cppLogo\" style=\"height:60px;\"/\u003e\n      \u003cimg src=\"https://user-images.githubusercontent.com/59691442/206360390-76940955-0a28-43b5-83fb-46409c4324f7.png\" alt=\"openclLogo\" style=\"height:60px;\"/\u003e\n\u003c/p\u003e\n\n## Description\n\nThis is a parallel implementation of the Floyd-Warshall algorithm using OpenCL.\n\nThe algorithm is implemented in C and the OpenCL kernel is written in OpenCL C. The program is compiled using CMake.\n\n- [x] Sequential implementation\n- [x] Parallel implementation using OpenCL\n\nAvailable for Linux, macOS and Windows.\n\n## Dependencies\n\n- C17 compiler\n- CMake\n- Makefile\n- OpenCL\n\n## Table of Contents\n\n- [Description](#description)\n- [Dependencies](#Dependencies)\n- [Table of Contents](#table-of-contents)\n- [Quickstart](#Quick-start)\n- [Algorithm](#Algorithm)\n    - [Sequential algorithm](#Sequential-algorithm)\n    - [Parallel OpenCL algorithm](#Parallel-OpenCL-algorithm)\n- [Results](#Results)\n- [Compilation](#Compilation)\n    - [Compilation set up](#Compilation-set-up)\n    - [Makefile build](#Makefile-build)\n    - [CMake build](#CMake-build)\n- [How to use](#How-to-use)\n- [Project Architecture](#Project-Architecture)\n- [GitHub Actions](#GitHub-Actions)\n- [Documentations](#Documentation)\n- [Contributors](#Contributors)\n\n## Quick start\n\nThe project can be compiled using the Makefile or CMake, please refer to the [Compilation](#Compilation) section for\nmore details.\n\nYou can find details about the algorithms and the results in the [Algorithms](#Algorithms) and [Results](#Results)\nsections.\n\n\u003e **Note**  \n\u003e The builed project is an exemple of the Floyd-Warshall algorithm.\n\u003e If you want to use it in your program, you can find the functions in the [wfiOpenCl.h](wfiOpenCl/wfiOpenCl.h)\n\u003e and [wfiOpenCl.c](wfiOpenCl/wfiOpenCl.c) file. You can find more details about its use in\n\u003e the [How to use](#How-to-use) section.\n\n\u003e **Note**  \n\u003e A version of the Floyd-Warshall Parallel version also exist in the [oneFileVer/main.c](oneFileVer/main.c), \n\u003e It is exactly the same code but in a single file (for more readability).\n\n\u003e **Warning**  \n\u003e Be sure to set the working directory of your projet to the root. To correctely load the `program.cl` or simply change the path in your code.\n\n## Algorithm\n\nThe Floyd-Warshall algorithm is an algorithm for finding the shortest paths between all pairs of vertices in a weighted\ngraph. The algorithm is based on the idea of dynamic programming. The algorithm is implemented in a parallel way using\nOpenCL.\n\n### Sequential algorithm\n\n```algorithm\nfor k from 1 to n\n    for i from 1 to n\n        for j from 1 to n\n            if dist[i][j] \u003e dist[i][k] + dist[k][j]\n                dist[i][j] = dist[i][k] + dist[k][j]\n```\n\n### Parallel OpenCL algorithm\n\n```algorithm\nfor k from 1 to n\n    All threads in the work group with i = get_global_id(0) and j = get_global_id(1)\n        if dist[i][j] \u003e dist[i][k] + dist[k][j]\n        dist[i][j] = dist[i][k] + dist[k][j]\n```\n\n## Results\n\nThe results of the programs are shown in the following table:\n\n| Number of vertices (n) | Sequential Time (s) | Parallel OpenCL Time using GPU (s) |\n|------------------------|---------------------|------------------------------------|\n| 100                    | 0.002               | 0.016                              |\n| 500                    | 0.322               | 0.022                              |\n| 1000                   | 2.999               | 0.097                              |\n| 5000                   | 311.6               | 9.453                              |\n| 10000                  | $\\infty$            | 109.0                              |\n\n\u003e **Note**\n\u003e The results may vary depending on the hardware used.\n\u003e Do not use the sequential version for n \u003e 10000, it will take too long.\n\n## Compilation\n\n### Compilation set up\n\nFirst, you need to install the OpenCL SDK. You can download it from the following link:\n\u003chttps://www.khronos.org/opencl/sdk/\u003e\n\nIf you are using Windows, you need to install the OpenCL SDK from the link above. If you are using Linux, you can\ninstall the OpenCL SDK using the following command:\n\n```bash\nsudo apt install ocl-icd-opencl-dev\n```\n\nfor macOS, you can install the OpenCL SDK using the following command:\n\n```bash\nbrew install opencl-headers\n```\n\nThen, you need to install CMake. You can download it from the following link:\n\u003chttps://cmake.org/download/\u003e\n\nTo compile the program, you can use the makefile or the CMakelists.txt file.\nThe makefile is for the GNU compiler collection (GCC) and the CMakelists.txt file is for the CMake build system.\n\n### Makefile build\n\nTo compile the program using the makefile, you can use the following commands:\n\n```bash\nmake\n```\n\nYou can also compile separately the sequential and parallel programs:\n\n```bash\nmake wfiSeq\nmake wfiPar\nmake wfiParOneFile\n```\n\nThe output files are in the `buildMakeFile` folder.\n\n### CMake build\n\nTo compile the program using CMake, you can use the following commands:\n\n```bash\ncmake -B . -DCMAKE_BUILD_TYPE=Release\n```\n\n### How to use\n\nThe program is an example of the Floyd-Warshall algorithm. If you want to use it in your program, you can find the\nfunctions in the [wfiOpenCl.h](wfiOpenCl/wfiOpenCl.h) and [wfiOpenCl.c](wfiOpenCl/wfiOpenCl.c) file.\n\nThen in your program create a one dimensional array of size n * n and fill it with the values of the graph.\nYou can then call the function `wfiFloydWarshall` to get the shortest path between all pairs of vertices in the graph by\nreturning the input graph with the shortest path values.\n\nA complete example of the use of the function is shown in the [wfiOpenCl/main.c](wfiOpenCl/main.c) file.\n\nTo print the graph, you can use the functions in the [common/commonFiles.h](common/commonFiles.h)\nand [common/commonFiles.c](common/commonFiles.c) files.\n\nIt will only print the last and first 10 rows of the graph if the graph is too big (you can change the threashold in\nthe [common/commonFiles.c](common/commonFiles.c)).\n\n## Project Architecture\n\n~~~\ncFloydWarshallParallel\n├── .github\n│  ├── workflows\n│  │   |── c-cpp.yml\n│  │   |── cmake.yml\n│  │   |── codeql.yml\n│  │   |── cpp-linter.yml\n│  │   |── dependency-review.yml\n│  │   |── flawfinder.yml\n│  │   |── greetings.yml\n│  │   |── label.yml\n│  │   |── stale.yml\n|  ├── labels.yml\n|  ├── release.yml\n├── buildMakeFile\n│  ├── placeholder\n├── common\n|  ├── commonFunctions.c\n|  ├── commonFunctions.h\n├── data\n|  ├── program.cl\n├── test\n|  ├── CMakelists.txt\n|  ├── wfiOpenCLTest.c\n|  ├── wfiSequentialTest.c\n├── wfiOpenCL\n|  ├── CMakeLists.txt\n|  ├── main\n|  ├── wfiOpenCL.c\n|  ├── wfiOpenCL.h\n├── wfiOpenCLOneFile\n|  ├── main.c\n├── wfiSequential\n|  ├── CMakeLists.txt\n|  ├── main\n|  ├── wfiSequential.c\n|  ├── wfiSequential.h\n├── .clang-format\n├── .clang-tidy\n├── .editorconfig\n├── .gitattributes\n├── .gitignore\n├── CMakelists.txt\n├── CMakePresets.json\n├── CMakeSettings.json\n├── Makefile\n├── README.md\n~~~\n\n## GitHub Actions\n\n[![C/C++ CI](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/c-cpp.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/c-cpp.yml)\n[![CMake](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/cmake.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/cmake.yml)\n[![CodeQL](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/codeql.yml/badge.svg)](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/codeql.yml)\n[![cpp-linter](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/cpp-linter.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/cpp-linter.yml)\n[![flawfinder](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/flawfinder.yml/badge.svg?branch=main)](https://github.com/Im-Rises/cFloydWarshallParallel/actions/workflows/flawfinder.yml)\n\nThis project uses GitHub Actions to build and test the program.\n\nC/C++ CI : This workflow will build the program using the makefile.  \nCMake : This workflow will build the program using the CMake build system.  \nCodeQL : This workflow will analyze the code to find security vulnerabilities.  \ncpp-linter : This workflow will analyze the code to find bugs and potential vulnerabilities.  \nflawfinder : This workflow will analyze the code to find bugs and potential vulnerabilities.\n\n\u003e **Note:**  \n\u003e The CMake workflow is not working yet for Windows.\n\n## Documentation\n\nWikipedia:  \n\u003chttps://en.wikipedia.org/wiki/Floyd–Warshall_algorithm\u003e  \n\u003chttps://en.wikipedia.org/wiki/Parallel_all-pairs_shortest_path_algorithm#Parallelization\u003e\n\nprogramiz:  \n\u003chttps://www.programiz.com/dsa/floyd-warshall-algorithm\u003e\n\ngeekeforgeeks:  \n\u003chttps://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/\u003e\n\nmoorejs:  \n\u003chttps://moorejs.github.io/APSP-in-parallel/\u003e\n\n## Contributors\n\nQuentin MOREL:\n\n- @Im-Rises\n- \u003chttps://github.com/Im-Rises\u003e\n\n[![GitHub contributors](https://contrib.rocks/image?repo=Im-Rises/cTwinPrimeNumberParallel)](https://github.com/Im-Rises/cTwinPrimeNumberParallel/graphs/contributors)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Fcfloydwarshallparallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fim-rises%2Fcfloydwarshallparallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fim-rises%2Fcfloydwarshallparallel/lists"}