{"id":13713498,"url":"https://github.com/nosferalatu/SimpleGPUHashTable","last_synced_at":"2025-05-06T23:32:11.711Z","repository":{"id":44724518,"uuid":"244062190","full_name":"nosferalatu/SimpleGPUHashTable","owner":"nosferalatu","description":"A simple GPU hash table implemented in CUDA using lock free techniques","archived":false,"fork":false,"pushed_at":"2024-02-07T14:40:18.000Z","size":304,"stargazers_count":381,"open_issues_count":3,"forks_count":41,"subscribers_count":10,"default_branch":"master","last_synced_at":"2024-11-14T00:33:55.797Z","etag":null,"topics":["cuda","cuda-programming","data-structures","gpu","gpu-cuda-programs"],"latest_commit_sha":null,"homepage":"","language":"Cuda","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nosferalatu.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":"2020-03-01T00:23:53.000Z","updated_at":"2024-11-13T03:33:07.000Z","dependencies_parsed_at":"2022-08-12T11:21:37.281Z","dependency_job_id":"978a42da-e2ee-4fc4-8aa5-802912e6f4b1","html_url":"https://github.com/nosferalatu/SimpleGPUHashTable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosferalatu%2FSimpleGPUHashTable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosferalatu%2FSimpleGPUHashTable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosferalatu%2FSimpleGPUHashTable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nosferalatu%2FSimpleGPUHashTable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nosferalatu","download_url":"https://codeload.github.com/nosferalatu/SimpleGPUHashTable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252787531,"owners_count":21804277,"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":["cuda","cuda-programming","data-structures","gpu","gpu-cuda-programs"],"created_at":"2024-08-02T23:01:37.891Z","updated_at":"2025-05-06T23:32:11.275Z","avatar_url":"https://github.com/nosferalatu.png","language":"Cuda","readme":"![](screenshot.png)\n\n# About\n\nThis project shows how to implement a simple GPU hash table. Thanks to the high bandwidth and massive parallelism of\nGPU's, the result is a high performance hash table capable of hundreds of millions of operations per second.\n\nThe code achieves an average insertion rate of 326 million key/second on my development laptop with an NVIDIA GTX 1060,\nmeasured by inserting 64 million elements.\n\n[Read my blog post about the code here](http://nosferalatu.com/SimpleGPUHashTable.html) for more information about the\nimplementation.\n\nThe code implements a lock free hash table using linear probing. Concurrent inserts, deletes, and lookups are supported by\nthis hash table. The hash table works on 32 bit keys and 32 bit values (although 0xffffffff is reserved for both keys\nand values). The load factor of the table is set to 50% in the code, and the table size must be a power of two.\n\nAtomic operations are used to insert key/value pairs into the hash table on multiple GPU threads. It uses CUDA for ease\nof development, but could easily be ported to HLSL or GLSL. 64 bit keys and/or values could be supported using 64 bit\natomics.\n\nResizing the hash table is not implemented (it's a *simple* hash table!) although this can be achieved by inserting the\ncontents of a table into another, larger table.\n\nThe code was kept simple for readability. There are many optimizations that can be done, but they muddy the waters. I\nwanted to illustrate the basic design of the lock free hash table and how it can be implemented on a GPU.\n\n# How To Use\n\nIf you build and run the executable, it enters an infinite loop of inserting and deleting random numbers into the\nGPU hash table and verifying that the results are correct. The seed used to generate random numbers changes every time\nyou run the executable, but you can set the seed to a specific value in code if you'd like to reproduce results across\nruns.\n\nThis is how you insert a vector of `KeyValue` pairs into the hash table and then retrieve all the `KeyValue` pairs back:\n\n```cpp\n    std::vector\u003cKeyValue\u003e things_to_insert = { {0,1}, {1,2}, {2,3}, {3,4} };\n\n    KeyValue* pHashTable = create_hashtable();\n    insert_hashtable(pHashTable, things_to_insert.data(), (uint32_t)things_to_insert.size());\n    std::vector\u003cKeyValue\u003e result = iterate_hashtable(pHashTable);\n    destroy_hashtable(pHashTable);\n```\n\nAfter that runs, the vectors `things_to_insert` and `result` should be the same, but possibly in a different order.\n\n# Prerequisites\n\n* CMake\n* CUDA\n\nThis has been tested on Windows with Visual Studio Community 2019 on a machine with an NVIDIA GTX 1060.\nAn easy way to get CMake is to open a Visual Studio command prompt (in Windows, run \"x64 Native Tools Command Prompt for\nVS 2019\"; that will put CMake in your path).\n\nThis should work on other CUDA-supported platforms, but I have not tested this.\n\n# Cloning\n\n```\ngit clone https://github.com/nosferalatu/SimpleConcurrentGPUHashTable.git SimpleConcurrentGPUHashTable\n```\n\n# Generating Build Files\n\nRun the following commands to generate .sln and .vcxproj's that can be opened in Visual Studio:\n\n```\ncd ConcurrentHashTables\nmd build\ncd build\ncmake ..\n```\n\nYou can now open `SimpleConcurrentGPUHashTable.sln` in Visual Studio.\n\nIf CMake fails to find CUDA above, then run a CMake generator for 64 bit builds:\n```\ncmake -G \"Visual Studio 16 2019 Win64\" ..\n```\n\n# Building\n\nYou can build within Visual Studio, or from the command line with:\n\n```\ncmake --build . --config Release\n```\n","funding_links":[],"categories":["Containers \u0026 Language Extentions \u0026 Linting"],"sub_categories":["For C++/C"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosferalatu%2FSimpleGPUHashTable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnosferalatu%2FSimpleGPUHashTable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnosferalatu%2FSimpleGPUHashTable/lists"}