{"id":22126553,"url":"https://github.com/kiarashvosough1999/ompkmeans","last_synced_at":"2025-03-24T08:19:42.015Z","repository":{"id":38085211,"uuid":"486680738","full_name":"kiarashvosough1999/OMPKMeans","owner":"kiarashvosough1999","description":"KMeans With OMP Parallelization","archived":false,"fork":false,"pushed_at":"2022-10-06T20:48:29.000Z","size":4828,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-29T13:45:40.232Z","etag":null,"topics":["clustering","cpp","kmeans-algorithm","kmeans-clustering","kmeans-clustering-algorithm","omp","omp-parallel","parallel-computing","parallel-processing","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/kiarashvosough1999.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}},"created_at":"2022-04-28T17:03:36.000Z","updated_at":"2022-10-06T20:47:54.000Z","dependencies_parsed_at":"2023-01-19T18:18:53.358Z","dependency_job_id":null,"html_url":"https://github.com/kiarashvosough1999/OMPKMeans","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/kiarashvosough1999%2FOMPKMeans","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiarashvosough1999%2FOMPKMeans/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiarashvosough1999%2FOMPKMeans/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kiarashvosough1999%2FOMPKMeans/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kiarashvosough1999","download_url":"https://codeload.github.com/kiarashvosough1999/OMPKMeans/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245232931,"owners_count":20581704,"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":["clustering","cpp","kmeans-algorithm","kmeans-clustering","kmeans-clustering-algorithm","omp","omp-parallel","parallel-computing","parallel-processing","parallel-programming"],"created_at":"2024-12-01T16:58:55.304Z","updated_at":"2025-03-24T08:19:41.991Z","avatar_url":"https://github.com/kiarashvosough1999.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OMPKMeans\n\n![Swift](https://img.shields.io/badge/C++-14-orange?style=flat-square)\n![Platforms](https://img.shields.io/badge/Platforms-Linux-yellowgreen?style=flat-square)\n\nWe have implemented KMeans with the omp library to parallelize and decrease clustering time consumption. \n\n\n- [Requirements](#requirements)\n- [Features](#features)\n- [Implementation](#implementation)\n- [Installation](#installation)\n- [Output](#output)\n- [Contribution](#contribution)\n- [License](#license)\n\n\n## Requirements\n\n| Platform | Minimum g++ Version | Minimum CMake Version | Status |\n| --- | --- | --- | --- |\n| Linux | 5.0 | 3.21 | Tested |\n\n## Features\n\n- [x] Used 4 Approaches To Use OMP + 1 Serial Approach.\n- [x] Structured Implementation.\n- [x] Support Multi Dimension DataSets.\n- [x] Support Generic DataSets.\n- [x] Plotting Final Cluster. \n\n## Implementation\n\nWe Used 4 Approaches to use omp constructs 1 Serial and a simple one. Each of them is a class that implements an algorithm and specific constructs: \n\n- **SerialKMeans**\n- **CriticalKMeans**\n- **SPMDKMeans**\n- **ForKmeans**\n- **PadKmeans**\n\n## Serial KMeans\n\nSerialKMeans is the simple serial implementation of KMeans and uses no parallelism.\n\n## Critical KMeans\n\nIn this approach, We used `omp parallel` construction, and to avoid data-race, 'omp critical' was used to modify clusters.\n\n## SPMD KMeans\n\nIn computing, SPMD (single program, multiple data) is a technique employed to achieve parallelism; it is a subcategory of MIMD. Tasks are split up and run simultaneously on multiple processors with different inputs to obtain results faster. SPMD is the most common style of parallel programming.\n\nSo to achieve this approach, We used a 2D Array to store Clusters for each thread and modify each of them on its running thread; this way, we split up our tasks and avoided data races, but in the end, we should merge the results of each thread's cluster.\n\n## ForKmeans\n\nWe used `omp for` construct for several for loops inside the algorithm within this approach.\n\n## PadKmeans\n\nAs you may know, there is much going on in the back scene of omp and hardware to provide us parallelism.\nOne of them is **False-Sharing**, which puts lots of pressure on the parallelism process.\n\nTo avoid **False-Sharing**, we use Padding in our parallel constructions.\n\n## Installation\n\nTo see if GCC is already installed on your system, open a Terminal window and enter the following command:\n\n``` bash\nGCC -v\n```\n\nIf GCC is not installed, run the following command from the Terminal window to update the Ubuntu package lists. An out-of-date Linux distribution can interfere with getting the latest packages.\n\n``` bash\nsudo apt-get update\n```\n\nNext, install the GNU compiler, make, and the GDB debugger with this command:\n\n``` bash\nsudo apt-get install build-essential gdb\n```\n\n\n### CMake\n\nUse the following command to use GUI CMake for building project:\n\n``` bash\nmake-GUI\n```\n\nAlternatively, use the command line:\n\nFor example, from the command line, we could navigate to the main root of the project's directory of the CMake source code tree and create a build directory:\n\n``` bash\nmkdir Step1_build\n```\n\nNext, navigate to the build directory and run CMake to configure the project and generate a native build system:\n\n``` bash\ncd Step1_build\ncmake ../Step1\n```\n\nThen call that build system to compile/link the project:\n\n``` bash\nCMake --build .\n```\n\nFinally, try to use the newly built `1_3omp` with these commands:\n\n``` bash\n1_3omp\n```\n\n## Output\n\nAfter running the project and whenever it is finished, there will be a `outputResult.txt` file that logs every approach and the final centroid of clusters and more info.\n\nThe result of execution on 4-core cpu with 12 threads in seconds.\n\n| Type\\Thread  | 1 | 2 | 3 |\t4\t| 5 |\t6 |\t7 |\t8 |\t9 |\t10 | 11 |\t12 |\n|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|:----------|\n| SPMD\t    | 1.311\t| 1.54 | 1.92 | 2.71 | 2.61\t| 2.77 | 4.07\t| 7.18 | 7.02| **3.38** | 6.46 | 5.88 |\n| Serial\t  | 1.07 | - | -\t| -\t| - | -\t| -\t| -\t| -\t| -\t| -\t| - |\n| Critical\t| 0.75 | 0.63 | 0.33\t| 0.29 | 0.32\t| 0.46 | 0.3 | 0.29\t| 0.3\t| 0.43 | 0.4 | **0.21** |\n| Pad\t      | **1.21** | 1.56 | 1.97\t| 3.21 | 2.83\t| 4.37 | 4.61 | 3.81 | 4.39\t| 3.90 | 4.89 | 4.50 |\n| For\t      | 0.57 | 0.70 | 1.29\t| 0.75 | 0.93\t| 0.85 | **0.55**\t| 0.70 | 1.29\t| 0.75 | 0.93\t| 0.85 |\n\n\n## Contribution\n\nFeel free to share your ideas or any other problems. Pull requests are welcomed.\n\n## License\n\nOMPKMeans was released under an MIT license. See [LICENSE](https://github.com/kiarashvosough1999/OMPKMeans/blob/master/LICENSE) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiarashvosough1999%2Fompkmeans","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkiarashvosough1999%2Fompkmeans","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkiarashvosough1999%2Fompkmeans/lists"}