{"id":20513396,"url":"https://github.com/bruce-lee-ly/cuda_hgemm","last_synced_at":"2025-04-05T15:04:41.620Z","repository":{"id":176735583,"uuid":"656952305","full_name":"Bruce-Lee-LY/cuda_hgemm","owner":"Bruce-Lee-LY","description":"Several optimization methods of half-precision general matrix multiplication (HGEMM) using tensor core with WMMA API and MMA PTX instruction. ","archived":false,"fork":false,"pushed_at":"2024-09-08T01:07:45.000Z","size":1153,"stargazers_count":374,"open_issues_count":0,"forks_count":76,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-29T14:06:45.675Z","etag":null,"topics":["cublas","cuda","gemm","gpu","hgemm","matrix-multiply","nvidia","tensor-core"],"latest_commit_sha":null,"homepage":"","language":"Cuda","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/Bruce-Lee-LY.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":"2023-06-22T02:00:21.000Z","updated_at":"2025-03-28T09:52:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"a91a769a-47de-4c48-94d5-22805b240579","html_url":"https://github.com/Bruce-Lee-LY/cuda_hgemm","commit_stats":null,"previous_names":["bruce-lee-ly/cuda_hgemm"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_hgemm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_hgemm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_hgemm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bruce-Lee-LY%2Fcuda_hgemm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bruce-Lee-LY","download_url":"https://codeload.github.com/Bruce-Lee-LY/cuda_hgemm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353729,"owners_count":20925329,"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":["cublas","cuda","gemm","gpu","hgemm","matrix-multiply","nvidia","tensor-core"],"created_at":"2024-11-15T21:10:48.429Z","updated_at":"2025-04-05T15:04:41.589Z","avatar_url":"https://github.com/Bruce-Lee-LY.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA HGEMM\nSeveral optimization methods of half-precision general matrix multiplication (HGEMM) using tensor core with WMMA API and MMA PTX instruction. The calculation expression is as follows, where the precision of matrix A (M * K), B (K * N) and C (M * N) is FP16. Through exploring various matrix tiling and optimization methods, the current performance between 256 to 16384 dimensions is not less than 95% of the performance of cublas, and in many scenarios, it exceeds the performance of cublas.\n```\nC (M * N) = A (M * K) * B (K * N)\n```\n\n![hgemm](./media/images/hgemm.png)\n\n# Optimization Method\n- Tiling: 256 * 128 for block tiling size and 64 * 64 for warp tiling size\n- Coalescing Access: using wide instruction access to global memory\n- Data Reuse: using shared memory to reuse data of matrix A and B\n- Async Copy: using asynchronous copy operation with non-blocking instruction\n- Bank Conflict: using padding method for WMMA API and permuted method for MMA PTX instruction to eliminate bank conflict\n- L2 Cache: using swizzle access mode to increase L2 cache hit ratio\n- Register Reuse: calculating as \"Right Left Right Left\" for the internal tile of warp\n- Pg2s: double-buffer algorithm using prefetching global memory to shared memory\n- Ps2r: double-buffer algorithm using prefetching shared memory to register\n- Stage: multi-buffer algorithm using prefetching global memory to shared memory\n\n# Compile\n## Environment\n- OS: Linux\n- Cmake Version: \u003e= 3.12\n- GCC Version: \u003e= 4.8\n- CUDA Version: \u003e= 11.0\n- Others: gflags, ccache\n```\nsudo apt-get install libgflags-dev ccache\n```\n\n## Clone\n```\ngit clone https://github.com/Bruce-Lee-LY/cuda_hgemm.git\n```\n\n## Build\n### NVIDIA A100\n```\ncd cuda_hgemm\n./build.sh -a 80 -t Release -b OFF\n./build.sh -a 80 -t Debug -b OFF\n```\n\n### RTX3080Ti / RTX3090 / RTX A6000\n```\ncd cuda_hgemm\n./build.sh -a 86 -t Release -b OFF\n./build.sh -a 86 -t Debug -b OFF\n```\n\n# Run Sample\n```\n./run_sample.sh\n```\n\n# Performance\nProcess the data in the log and plot it as a line chart.\n\n```\ncd tools/performance\n./performance.sh\n```\n\n## RTX3090\n- CUDA Version: 11.3\n\nThe best performance that can be achieved.\n\n![best_throughput](./performance/RTX3090/best_throughput.png)\n\nPerformance achieved by current optimization methods.\n\n![throughput](./performance/RTX3090/throughput.png)\n\n## RTX A6000\n- CUDA Version: 11.3\n\nThe best performance that can be achieved.\n\n![best_throughput](./performance/RTXA6000/best_throughput.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-lee-ly%2Fcuda_hgemm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbruce-lee-ly%2Fcuda_hgemm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbruce-lee-ly%2Fcuda_hgemm/lists"}