{"id":25155434,"url":"https://github.com/ranimeshehata/matrix-multiplication","last_synced_at":"2026-05-08T10:35:38.780Z","repository":{"id":228264934,"uuid":"772381095","full_name":"ranimeshehata/Matrix-Multiplication","owner":"ranimeshehata","description":"C program that performs matrix multiplication using three approaches as an application on multi-threading.","archived":false,"fork":false,"pushed_at":"2024-03-15T04:52:38.000Z","size":879,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T08:49:12.459Z","etag":null,"topics":["cpp","linux","multithreading","operating-system","threads","ubuntu"],"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/ranimeshehata.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,"dei":null}},"created_at":"2024-03-15T04:35:36.000Z","updated_at":"2024-03-22T19:02:09.000Z","dependencies_parsed_at":"2024-03-17T23:27:42.310Z","dependency_job_id":"153e476d-871f-4268-9399-ba4b9fe08ae2","html_url":"https://github.com/ranimeshehata/Matrix-Multiplication","commit_stats":null,"previous_names":["ranimeshehata/matrix-multiplication"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ranimeshehata/Matrix-Multiplication","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FMatrix-Multiplication","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FMatrix-Multiplication/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FMatrix-Multiplication/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FMatrix-Multiplication/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ranimeshehata","download_url":"https://codeload.github.com/ranimeshehata/Matrix-Multiplication/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ranimeshehata%2FMatrix-Multiplication/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32776910,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"ssl_error","status_checked_at":"2026-05-08T08:22:45.650Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","linux","multithreading","operating-system","threads","ubuntu"],"created_at":"2025-02-09T00:51:48.547Z","updated_at":"2026-05-08T10:35:38.760Z","avatar_url":"https://github.com/ranimeshehata.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matrix Multiplication (Multi-Threading)\n\n![MatMul](https://github.com/ranimeshehata/Matrix-Multiplication/assets/121239735/5f105905-a1ba-480e-a1a8-f901938012dc)\n\n\n## 1. Objectives\n\n* Gettin familiar with thread programming using the [Pthread library](https://hpc-tutorials.llnl.gov/posix/).\n* To better understand processes and threads.\n## 2. Overview\n\nA multi-threaded [matrix multiplication](https://www.mathsisfun.com/algebra/matrix-multiplying.html) implementation program.\n\nThe input to the program is two matrixes A(x*y) and B(y*z) that are read from corresponding text files. The output is a matrix C(x*z) that is written to an output text file.\n\nA parallelized version of matrix multiplication can be done using one of these three methods:\n\n1. A thread computes the output C matrix i.e. without multi-threading. (A thread per matrix).\n![per_matrix](https://github.com/ranimeshehata/Matrix-Multiplication/assets/121239735/c31f353f-b5a2-4fe3-b71d-76700c424b57)\n2. A thread computes each row in the output C matrix. (A thread per row).\n![per_row](https://github.com/ranimeshehata/Matrix-Multiplication/assets/121239735/fe8f5bed-3fb7-4df1-90af-24a061fcb827)\n3. A thread computes each element in the output C matrix. (A thread per element).\n![per_element](https://github.com/ranimeshehata/Matrix-Multiplication/assets/121239735/ec61f5a7-d692-435e-9004-2a4dc5ecfaeb)\n\n## 3. Comparing the three implementations according to the following:\n    Number of threads created and Execution time taken:\n    Creating and handling threads requires extra overhead and lots of computation, so, it's not always the ideal solution to go for multi-threading, and there's always a tradeoff.\n![WhatsApp Image 2024-03-15 at 5 50 42 AM](https://github.com/ranimeshehata/Matrix-Multiplication/assets/121239735/c53101a5-88ad-4ee1-8d56-4dd52e3ec49d)\n\nThe program does the following:\n\n* If the user does not enter the file name, the default is a.txt and b.txt, for input matrixes A and B, and c for output matrices (of all three methods) C. The following example should clarify inputs/outputs files.\n\n    Arguments\n\n        Example: \n            ./exe a b c\n        Input files: \n            a.txt \n            b.txt\n        Output files: \n            c_per_matrix.txt\n            c_per_row.txt\n            c_per_element.txt\n\n    No Arguments:\n\n        Example: \n            ./exe\n        Input files: \n            a.txt \n            b.txt\n        Output files: \n            c_per_matrix.txt\n            c_per_row.txt\n            c_per_element.txt\n\n    Custom Arguments:\n\n        Example: \n            ./exe x y z\n        Input files: \n            x.txt \n            y.txt\n        Output files: \n            z_per_matrix.txt\n            z_per_row.txt\n            z_per_element.txt\n\n* Read the number of rows and columns of the input matrices. They are written in the first line of the file as ”row=x col=y”. The following is an example of the format on an input file.\n\n        row=3 col=5\n        1 2 3 4 5\n        6 7 8 9 10\n        11 12 13 14 15\n\n* Read the input matrices from their corresponding files. Each row is on a separate line, columns are separated by spaces.\n* Use threads to calculate the matrix that results from multiplying the input two matrixes.\n* Output the resulting matrices in three files (each file represents one method). The following is an example of the format of the three output files.\n\n    c_per_matrix.txt\n\n        Method: A thread per matrix\n        row=2 col=2\n        1 2\n        3 4\n\n    c_per_row.txt\n\n        Method: A thread per row\n        row=2 col=2\n        1 2\n        3 4\n\n    c_per_element.txt\n\n        Method: A thread per element\n        row=2 col=2\n        1 2\n        3 4\n\n    The output matrices are all be the same for all three methods.\n\n* **The number of threads created and the time taken for all the three methods (three different outputs) is printed on the console.**\n* Assuming matrix size is no larger than 20 x 20.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franimeshehata%2Fmatrix-multiplication","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Franimeshehata%2Fmatrix-multiplication","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Franimeshehata%2Fmatrix-multiplication/lists"}