{"id":25736868,"url":"https://github.com/masterskepticista/parallel_reductions_cuda","last_synced_at":"2025-10-16T12:28:04.024Z","repository":{"id":279081058,"uuid":"937656790","full_name":"MasterSkepticista/parallel_reductions_cuda","owner":"MasterSkepticista","description":"Iteratively optimizing parallel reductions in CUDA.","archived":false,"fork":false,"pushed_at":"2025-05-30T07:22:18.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-30T09:17:10.116Z","etag":null,"topics":["cuda","reduce-sum","reductions"],"latest_commit_sha":null,"homepage":"","language":"Cuda","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/MasterSkepticista.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,"publiccode":null,"codemeta":null}},"created_at":"2025-02-23T15:46:51.000Z","updated_at":"2025-05-30T07:22:22.000Z","dependencies_parsed_at":"2025-02-23T17:24:39.878Z","dependency_job_id":"f4ebc275-23a8-4e93-b411-ed0e1433c773","html_url":"https://github.com/MasterSkepticista/parallel_reductions_cuda","commit_stats":null,"previous_names":["masterskepticista/parallel_reductions_cuda"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MasterSkepticista/parallel_reductions_cuda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasterSkepticista%2Fparallel_reductions_cuda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasterSkepticista%2Fparallel_reductions_cuda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasterSkepticista%2Fparallel_reductions_cuda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasterSkepticista%2Fparallel_reductions_cuda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MasterSkepticista","download_url":"https://codeload.github.com/MasterSkepticista/parallel_reductions_cuda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MasterSkepticista%2Fparallel_reductions_cuda/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272150885,"owners_count":24882246,"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","status":"online","status_checked_at":"2025-08-25T02:00:12.092Z","response_time":1107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["cuda","reduce-sum","reductions"],"created_at":"2025-02-26T06:22:40.521Z","updated_at":"2025-10-16T12:27:58.986Z","avatar_url":"https://github.com/MasterSkepticista.png","language":"Cuda","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Parallel Reductions in CUDA\n\nIteratively optimizing a `reduce_sum` operation in CUDA until we reach \u003e95% of GPU performance. This code accompanies the blog post [Embarrasingly Parallel Reduction in CUDA](https://masterskepticista.github.io/posts/reduce-sum/).\n\n### Results\n\nEffective bandwidth achieved on an RTX-3090 (`N=1\u003c\u003c25` elements):\n\n\u003cdiv style=\"width: 70%; margin: auto; align: left\"\u003e\n  \u003ctable style=\"font-size: 0.9em;\"\u003e\n    \u003cthead\u003e\n      \u003ctr\u003e\n        \u003cth\u003e#\u003c/th\u003e\n        \u003cth\u003eKernel\u003c/th\u003e\n        \u003cth\u003eBandwidth (GB/s)\u003c/th\u003e\n        \u003cth\u003eRelative to \u003ccode\u003ejnp.sum\u003c/code\u003e\u003c/th\u003e\n      \u003c/tr\u003e\n    \u003c/thead\u003e\n    \u003ctbody\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e1\u003c/td\u003e\n        \u003ctd\u003eVector Loads\u003c/td\u003e\n        \u003ctd\u003e9.9\u003c/td\u003e\n        \u003ctd\u003e1.1%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e2\u003c/td\u003e\n        \u003ctd\u003eInterleaved Addressing\u003c/td\u003e\n        \u003ctd\u003e223\u003c/td\u003e\n        \u003ctd\u003e24.7%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e3\u003c/td\u003e\n        \u003ctd\u003eNon-divergent Threads\u003c/td\u003e\n        \u003ctd\u003e317\u003c/td\u003e\n        \u003ctd\u003e36.3%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e4\u003c/td\u003e\n        \u003ctd\u003eSequential Addressing\u003c/td\u003e\n        \u003ctd\u003e331\u003c/td\u003e\n        \u003ctd\u003e38.0%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e5\u003c/td\u003e\n        \u003ctd\u003eReduce on First Loads\u003c/td\u003e\n        \u003ctd\u003e618\u003c/td\u003e\n        \u003ctd\u003e70.9%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e6\u003c/td\u003e\n        \u003ctd\u003eWarp Unrolling\u003c/td\u003e\n        \u003ctd\u003e859\u003c/td\u003e\n        \u003ctd\u003e98.6%\u003c/td\u003e\n      \u003c/tr\u003e\n      \u003ctr\u003e\n        \u003ctd\u003e0\u003c/td\u003e\n        \u003ctd\u003e\u003ccode\u003ejnp.sum\u003c/code\u003e reference\u003c/td\u003e\n        \u003ctd\u003e871\u003c/td\u003e\n        \u003ctd\u003e100%\u003c/td\u003e\n      \u003c/tr\u003e\n    \u003c/tbody\u003e\n  \u003c/table\u003e\n\u003c/div\u003e\n\n### Run benchmarks\n\n```bash\n# Compile\nnvcc -arch=native -O3 --use_fast_math reduce_sum.cu -lcublas -lcublasLt -o ./reduce_sum \n\n# Run\n./reduce_sum \u003c1...6\u003e\n```\n\n### Acknowledgements\nBenchmarking setup borrowed from [karpathy/llm.c](https://github.com/karpathy/llm.c/).\n\n\n### License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterskepticista%2Fparallel_reductions_cuda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasterskepticista%2Fparallel_reductions_cuda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasterskepticista%2Fparallel_reductions_cuda/lists"}