{"id":21872111,"url":"https://github.com/hanzhi713/bitonic-sort","last_synced_at":"2026-02-09T17:01:25.885Z","repository":{"id":172147250,"uuid":"641643224","full_name":"hanzhi713/bitonic-sort","owner":"hanzhi713","description":"In-place GPU sort with bitonic sort","archived":false,"fork":false,"pushed_at":"2023-06-24T22:53:48.000Z","size":292,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-25T06:32:21.665Z","etag":null,"topics":["bitonic-sort","cuda","gpu","in-place","sorting"],"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/hanzhi713.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,"zenodo":null}},"created_at":"2023-05-16T21:39:43.000Z","updated_at":"2024-09-08T04:05:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"976dcbb8-edff-413d-afd5-abc28a0a2d6e","html_url":"https://github.com/hanzhi713/bitonic-sort","commit_stats":null,"previous_names":["hanzhi713/bitonic-sort"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hanzhi713/bitonic-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fbitonic-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fbitonic-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fbitonic-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fbitonic-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanzhi713","download_url":"https://codeload.github.com/hanzhi713/bitonic-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhi713%2Fbitonic-sort/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29273139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-09T13:47:44.167Z","status":"ssl_error","status_checked_at":"2026-02-09T13:47:43.721Z","response_time":56,"last_error":"SSL_read: 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":["bitonic-sort","cuda","gpu","in-place","sorting"],"created_at":"2024-11-28T06:18:59.649Z","updated_at":"2026-02-09T17:01:25.868Z","avatar_url":"https://github.com/hanzhi713.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CUDA Bitonic Sort\n\nIf you're looking for a in-place GPU comparison based sorting library that requires zero extra GPU memory, this might be what you're looking for. This repository contains a header-only implementation of bitonic sort. It is not the fastest sorting algorithm, but it might be good enough for your application in which GPU memory is more precious. \n\nThe code is adapted from https://github.com/darkobozidar/sequential-vs-parallel-sort and is refactored to be concise and support arbitrary types and comparators. \n\n## Basic usage\n\n```cpp\n#include \"bitonic_sort.h\"\n\n...\n\nint* keys;\nint* values;\nint num_items;\n...\n\n// sort keys only\nbitonic::sort(keys, num_items);\n\n// sort key-value pairs\nbitonic::sort_by_key(keys, values, num_items);\n```\n\nSince this algorithm operates in-place, we only support pointer types. So no fancy iterators. \n\n## Custom comparator\n\nExample: sort pointers by their pointed-to value\n\n```cpp\nstruct Compare {\n  __device__ __host__ bool operator()(float* a, float* b) const {\n    return *a \u003c *b;\n  }\n};\n...\nfloat** data;\nint N;\n...\n// here 0 means we're using the default stream\nbitonic::sort(data, N, 0, Compare());\n```\n\n## Performance benchmark\n\nWe compared the performance of bitonic sort with state-of-the-art implementations of sorting algorithns in CUB on Tesla V100 and Tesla A100, and produced the graphs below. \n\nThe main takeaway is that if performance is all you need, then CUB/thrust might be a better choice. Bitonic sort is only comparable to other sorting methods for small array sizes (\u003c 10^5 elements). The advantage of bitonic sort is that, unlike CUB merge sort or radix sort, it does not require an extra copy of keys and values during the sorting process, which halves the memory usage. \n\n\n### V100 SXM2 32GB\n\n![bench](benchmark-v100.png)\n\n### A100 SXM4 80GB\n\n![bench](benchmark-a100.png)\n\n### H100 80GB\n\n![bench](benchmark-h100.png)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhi713%2Fbitonic-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanzhi713%2Fbitonic-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhi713%2Fbitonic-sort/lists"}