| … | … | @@ -5,7 +5,8 @@ |
| 5 | 5 | This project shows how to implement a simple GPU hash table. Thanks to the high bandwidth and massive parallelism of |
| 6 | 6 | GPU's, the result is a high performance hash table capable of hundreds of millions of operations per second. |
| 7 | 7 | |
| 8 | | The code achieves an average insertion rate of 309 million key/second on my development laptop with an NVIDIA GTX 1060. |
| 8 | The code achieves an average insertion rate of 326 million key/second on my development laptop with an NVIDIA GTX 1060, |
| 9 | measured by inserting 64 million elements. |
| 9 | 10 | |
| 10 | 11 | The code implements a lock free hash table using linear probing. Concurrent inserts, deletes, and lookups are supported by |
| 11 | 12 | this hash table. The hash table works on 32 bit keys and 32 bit values (although 0xffffffff is reserved for both keys |
| … | … | @@ -26,6 +27,26 @@ For more information on the lock free hash table design, read: |
| 26 | 27 | Table](https://preshing.com/20130605/the-worlds-simplest-lock-free-hash-table/) |
| 27 | 28 | * Cliff Click's slides on [A Lock-Free Wait-Free Hash Table](https://web.stanford.edu/class/ee380/Abstracts/070221_LockFreeHash.pdf) |
| 28 | 29 | |
| 30 | # How To Use |
| 31 | |
| 32 | If you build and run the executable, it enters an infinite loop of inserting and deleting random numbers into the |
| 33 | GPU hash table and verifying that the results are correct. The seed used to generate random numbers changes every time |
| 34 | you run the executable, but you can set the seed to a specific value in code if you'd like to reproduce results across |
| 35 | runs. |
| 36 | |
| 37 | This is how you insert a vector of `KeyValue` pairs into the hash table and then retrieve all the `KeyValue` pairs back: |
| 38 | |
| 39 | ```cpp |
| 40 | std::vector<KeyValue> things_to_insert = { {0,1}, {1,2}, {2,3}, {3,4} }; |
| 41 | |
| 42 | KeyValue* pHashTable2 = create_hashtable(kHashTableCapacity); |
| 43 | insert_hashtable(pHashTable2, things_to_insert.data(), (uint32_t)things_to_insert.size()); |
| 44 | std::vector<KeyValue> result = iterate_hashtable(pHashTable2); |
| 45 | destroy_hashtable(pHashTable2); |
| 46 | ``` |
| 47 | |
| 48 | After that runs, the vectors `things_to_insert` and `result` should be the same, but possibly in a different order. |
| 49 | |
| 29 | 50 | # Prerequisites |
| 30 | 51 | |
| 31 | 52 | * CMake |