template<typename KeyT, typename HashT, KeyT INVALID_KEY = 0xFFFFFFFF>
struct cugar::cuda::SyncFreeDoubleKeyHashMap< KeyT, HashT, INVALID_KEY >
This class implements a device-side Hash Map, allowing arbitrary threads from potentially different CTAs of a cuda kernel to add new entries at the same time.
The constructor of the class accepts pointers to the arrays representing the underlying data structure:
- an array of hashed keys
- an array of unique set entries
- an array of slots keeping track of the unique position where each inserted key has been mapped
- a pointer to a counter, keeping track of the number of set entries
Before starting to use the SynchronousHashMap, the array of hash slots has to be initialized to INVALID_KEY.
The difference between this class and the HashMap is that this class allows to call both insert() and find() at the same time, without interposing a global synchronization between them: the price is higher overhead (due to the need to use volatile writes and add memory fences).
|
CUGAR_HOST_DEVICE | SyncFreeDoubleKeyHashMap () |
|
CUGAR_HOST_DEVICE | SyncFreeDoubleKeyHashMap (const uint32 _table_size, KeyT *_hash1, KeyT *_hash2, KeyT *_unique, uint32 *_slots, uint32 *_count) |
|
CUGAR_DEVICE void | insert (const KeyT key1, const KeyT key2, const HashT hash_code) |
|
CUGAR_DEVICE bool | insert (const KeyT key1, const KeyT key2, const HashT hash_code, uint32 *pos) |
|
CUGAR_DEVICE uint32 | find (const KeyT key1, const KeyT key2, const HashT hash_code) |
|
uint32 | size () const |
|
pair_type | get_unique (const uint32 i) const |
|