OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-SimpleGPUHashTable commits / 450895f

Updated screenshot, README, and fixed unused param in create_hashtable
450895f27123ad45261eed784e659a0ef6c0645b
by David Farrell <nosferalatu@gmail.com> · 2020-03-10T18:39:01.000Z

Changed files (5) +26 -6

README.md +22 -1
……@@ -5,7 +5,8 @@
55This project shows how to implement a simple GPU hash table. Thanks to the high bandwidth and massive parallelism of
66GPU's, the result is a high performance hash table capable of hundreds of millions of operations per second.
77
8The code achieves an average insertion rate of 309 million key/second on my development laptop with an NVIDIA GTX 1060.
8The code achieves an average insertion rate of 326 million key/second on my development laptop with an NVIDIA GTX 1060,
9measured by inserting 64 million elements.
910
1011The code implements a lock free hash table using linear probing. Concurrent inserts, deletes, and lookups are supported by
1112this 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:
2627Table](https://preshing.com/20130605/the-worlds-simplest-lock-free-hash-table/)
2728* Cliff Click's slides on [A Lock-Free Wait-Free Hash Table](https://web.stanford.edu/class/ee380/Abstracts/070221_LockFreeHash.pdf)
2829
30# How To Use
31
32If you build and run the executable, it enters an infinite loop of inserting and deleting random numbers into the
33GPU hash table and verifying that the results are correct. The seed used to generate random numbers changes every time
34you run the executable, but you can set the seed to a specific value in code if you'd like to reproduce results across
35runs.
36
37This 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
48After that runs, the vectors `things_to_insert` and `result` should be the same, but possibly in a different order.
49
2950# Prerequisites
3051
3152* CMake
screenshot.png +0 -0
(no content changes — binary or rename)
src/linearprobing.cu +2 -3
……@@ -14,9 +14,8 @@ __device__ uint32_t hash(uint32_t k)
1414 return k & (kHashTableCapacity-1);
1515}
1616
17// Create a hash table. For linear probing, this is just an array
18// of KeyValues. The hash table is
19KeyValue* create_hashtable(uint32_t capacity)
17// Create a hash table. For linear probing, this is just an array of KeyValues
18KeyValue* create_hashtable()
2019{
2120 // Allocate memory
2221 KeyValue* hashtable;
src/linearprobing.h +1 -1
……@@ -12,7 +12,7 @@ const uint32_t kNumKeyValues = kHashTableCapacity / 2;
1212
1313const uint32_t kEmpty = 0xffffffff;
1414
15KeyValue* create_hashtable(uint32_t initialCapacity);
15KeyValue* create_hashtable();
1616
1717void insert_hashtable(KeyValue* hashtable, const KeyValue* kvs, uint32_t num_kvs);
1818
src/main.cpp +1 -1
……@@ -107,7 +107,7 @@ int main()
107107
108108 Time timer = start_timer();
109109
110 KeyValue* pHashTable = create_hashtable(kHashTableCapacity);
110 KeyValue* pHashTable = create_hashtable();
111111
112112 // Insert items into the hash table
113113 const uint32_t num_insert_batches = 16;