Fermat
|
This class implements a device-side Hash Set, 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:
Before starting to use the HashSet, the array of hash slots has to be initialized to INVALID_KEY.
The class provides two methods:
- HashSet::insert - HashSet::has
It's important to notice that calls to the two methods cannot be mixed without interposing a global synchronization between them.
#include <hash.h>
Public Methods | |
CUGAR_DEVICE | HashSet () |
CUGAR_DEVICE | HashSet (const uint32 _table_size, KeyT *_hash, KeyT *_unique, uint32 *_count) |
CUGAR_DEVICE void | insert (const KeyT key, const HashT hash_code) |
CUGAR_DEVICE uint32 | size () const |
CUGAR_DEVICE KeyT | get_unique (const uint32 i) const |
Public Members | |
uint32 | table_size |
KeyT * | hash |
KeyT * | unique |
uint32 * | count |
|
inline |
empty constructor
|
inline |
HashSet constructor
_table_size | the size of the hash table (needs to be a power of 2) |
_hash | a pointer to the array of _table_size hashed keys - needs to be initialized to INVALID_KEY before first use |
_unique | a pointer to the array where inserted entries will be stored - needs to be appropriately sized to contain all unique entries |
_count | a pointer to a single counter, used to keep track of how many unique entries have been inserted |
|
inline |
return the i-th unique element in the set
|
inline |
insert an element with its hashing value
key | the element to insert |
hash_code | the hashing value |
|
inline |
return the size of the hash set