{"id":15902198,"url":"https://github.com/ericlbuehler/simd_matmul","last_synced_at":"2025-06-13T09:01:46.311Z","repository":{"id":222890681,"uuid":"758462610","full_name":"EricLBuehler/simd_matmul","owner":"EricLBuehler","description":"O(n^2) matmul with SIMD.","archived":false,"fork":false,"pushed_at":"2024-02-20T00:48:16.000Z","size":104,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-08T10:32:05.300Z","etag":null,"topics":[],"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/EricLBuehler.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":"2024-02-16T11:26:08.000Z","updated_at":"2024-03-05T00:37:01.000Z","dependencies_parsed_at":"2024-02-20T01:51:30.851Z","dependency_job_id":"fb211a16-bc78-41bf-bfbd-379603503cba","html_url":"https://github.com/EricLBuehler/simd_matmul","commit_stats":null,"previous_names":["ericlbuehler/simd_matmul"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLBuehler%2Fsimd_matmul","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLBuehler%2Fsimd_matmul/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLBuehler%2Fsimd_matmul/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EricLBuehler%2Fsimd_matmul/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EricLBuehler","download_url":"https://codeload.github.com/EricLBuehler/simd_matmul/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246884769,"owners_count":20849554,"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":[],"created_at":"2024-10-06T11:23:07.078Z","updated_at":"2025-04-02T20:11:41.884Z","avatar_url":"https://github.com/EricLBuehler.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SIMD Matmul\n\nThis is an optimization of the naive matmul algorithm which uses SIMD. \n\n## Asymptotic complexity analysis\nIt is $O(n^2)$. For $A = (m,n)$, $B = (n,p)$ and $A*B = C = (m,p)$, the exact running time for SIMD matmul including addition and multiplication operations is $mp(1+n-1) = mpn$ while the running time for Naive matmul is $mp(2n-1) = 2mpn-mp$. Therefore, the precise ratio is $$\\frac{n}{2n-1}$$\n\nHowever, when calculating the Big-O complexity we ignore addition operations and as such the running time is $mp$ or $O(n^2)$.\n\n## Mathematical Formulation\nFor $A = (m,n)$, $B = (n,p)$, I calculate $B^T$. This results in the inputs to the algorithm, $A = (m,n)$, $B = (p,n)$. I note that the transpose algorithm is also $O(n^2)$.\nThe output $C' = (m,p)$ and is equivalent to $C = A*B$.\n\n## Advantages\n- Far lower theoretical Big-O\n- Header-only library\n\n## Disadvantages\n- $n$ is constrained by SIMD lanes\n- Requires transpose or store matrices in transposed form\n- Requires conversion of matrix rows to SIMD vectors","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericlbuehler%2Fsimd_matmul","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericlbuehler%2Fsimd_matmul","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericlbuehler%2Fsimd_matmul/lists"}