Go to the source code of this file.
|
| static uint64_t | hash_func (const char *) |
| |
| static int | create_table (uint64_t, struct hash_table **) |
| |
| static int | destroy_table (struct hash_table *) |
| |
| static int | rehash_table (struct hash_table *, struct hash_table *) |
| |
| static int | move_table (struct hash_table *, struct hash_table *) |
| |
| static int | check_n_resize_table (struct hash_table *) |
| |
| static int | destroy_table_entries (struct hash_table *) |
| |
| static int | create_table_entry (const char *, void *, struct hash_table_entry **) |
| |
| static int | destroy_table_entry (struct hash_table_entry *) |
| |
| static int | insert_table_entry (struct hash_table *, struct hash_table_entry *) |
| |
| static int | delete_table_entry (struct hash_table *, struct hash_table_entry *) |
| |
| static int | find_table_entry (struct hash_table *, const char *, struct hash_table_entry **) |
| |
| static int | htable_init (void **handle) |
| |
| static int | htable_shutdown (void *handle) |
| |
| static int | htable_insert (void *handle, const char *key, void *in) |
| |
| static int | htable_delete (void *handle, const char *key) |
| |
| static int | htable_find (void *handle, const char *key, void **out) |
| |
◆ HTABLE_EINVAL
| #define HTABLE_EINVAL (-2) |
◆ HTABLE_ENOMEM
| #define HTABLE_ENOMEM (-3) |
◆ HTABLE_ENOVAL
| #define HTABLE_ENOVAL (-1) |
◆ HTABLE_MIN_SIZE
| #define HTABLE_MIN_SIZE (8) |
◆ HTABLE_NEEDS_TO_GROW
| #define HTABLE_NEEDS_TO_GROW |
( |
|
table | ) |
(table->size > 0 && table->capacity / table->size < 2) |
◆ HTABLE_NEEDS_TO_SHRINK
| #define HTABLE_NEEDS_TO_SHRINK |
( |
|
table | ) |
(table->size > 0 && table->capacity / table->size > 8) |
◆ HTABLE_SUCCESS
| #define HTABLE_SUCCESS ( 0) |
◆ check_n_resize_table()
Definition at line 287 of file cuda/htable.h.
288{
291 char resize =
293
294 if (resize) {
295 uint64_t new_capacity = (resize & 0x2) ?
299 goto fn_fail;
300 }
301
304 goto fn_fail;
305 }
306
309 }
310
311 fn_exit:
312 return htable_errno;
313 fn_fail:
314 if (new_table) {
316 }
317 goto fn_exit;
318}
static int destroy_table(struct hash_table *)
static int rehash_table(struct hash_table *, struct hash_table *)
static int create_table(uint64_t, struct hash_table **)
#define HTABLE_NEEDS_TO_SHRINK(table)
#define HTABLE_NEEDS_TO_GROW(table)
static int move_table(struct hash_table *, struct hash_table *)
◆ create_table()
Definition at line 195 of file cuda/htable.h.
196{
198
200 if (table == NULL) {
202 goto fn_exit;
203 }
204
205 (*table)->buckets =
papi_calloc(size,
sizeof(*(*table)->buckets));
206 if ((*table)->buckets == NULL) {
208 goto fn_exit;
209 }
210
211 (*table)->capacity = size;
212
213 fn_exit:
214 return htable_errno;
215}
#define papi_calloc(a, b)
◆ create_table_entry()
Definition at line 321 of file cuda/htable.h.
322{
324
326 if (*entry == NULL) {
328 }
329 (*entry)->key = strdup(
key);
330 (*entry)->val = val;
331 (*entry)->next = NULL;
332
333 return htable_errno;
334}
◆ delete_table_entry()
Definition at line 363 of file cuda/htable.h.
364{
366
368
369 if (table->
buckets[
id] == entry) {
372 goto fn_exit;
373 }
374
377
378 while (curr) {
379 if (curr == entry) {
382 break;
383 }
386 }
387
388 fn_exit:
390 return htable_errno;
391}
static uint64_t hash_func(const char *)
struct hash_table_entry * next
struct hash_table_entry ** buckets
◆ destroy_table()
Definition at line 218 of file cuda/htable.h.
219{
221
224 }
225
226 if (table) {
228 }
229
230 return htable_errno;
231}
◆ destroy_table_entries()
Definition at line 267 of file cuda/htable.h.
268{
271
275
276 while (entry) {
281 }
282 }
283
284 return htable_errno;
285}
static int destroy_table_entry(struct hash_table_entry *)
static int delete_table_entry(struct hash_table *, struct hash_table_entry *)
◆ destroy_table_entry()
Definition at line 337 of file cuda/htable.h.
338{
342 return htable_errno;
343}
◆ find_table_entry()
Definition at line 394 of file cuda/htable.h.
396{
397 int htable_errno;
398
401 if (head == NULL) {
403 goto fn_exit;
404 }
405
407 while (curr && strcmp(curr->
key,
key)) {
409 }
410
411 *entry = curr;
413
414 fn_exit:
415 return htable_errno;
416}
◆ hash_func()
| uint64_t hash_func |
( |
const char * |
string | ) |
|
|
static |
djb2 hash function
Definition at line 184 of file cuda/htable.h.
185{
186 uint64_t hash = 5381;
188 while ((
c = *
string++)) {
189 hash = ((hash << 5) + hash) +
c;
190 }
191 return hash;
192}
static double c[MATRIX_SIZE][MATRIX_SIZE]
◆ htable_delete()
| static int htable_delete |
( |
void * |
handle, |
|
|
const char * |
key |
|
) |
| |
|
inlinestatic |
Definition at line 130 of file cuda/htable.h.
131{
134
135 if (table == NULL ||
key == NULL) {
137 }
138
142 return htable_errno;
143 }
144
146
149 return htable_errno;
150 }
151
154 return htable_errno;
155 }
156
158}
static papi_handle_t handle
static int find_table_entry(struct hash_table *, const char *, struct hash_table_entry **)
static int check_n_resize_table(struct hash_table *)
◆ htable_find()
| static int htable_find |
( |
void * |
handle, |
|
|
const char * |
key, |
|
|
void ** |
out |
|
) |
| |
|
inlinestatic |
Definition at line 161 of file cuda/htable.h.
162{
165
166 if (table == NULL ||
key == NULL || out == NULL) {
168 }
169
173 return htable_errno;
174 }
175
177 return htable_errno;
178}
◆ htable_init()
| static int htable_init |
( |
void ** |
handle | ) |
|
|
inlinestatic |
Definition at line 55 of file cuda/htable.h.
56{
58
59#define HTABLE_MIN_SIZE (8)
63 goto fn_fail;
64 }
65
67
68 fn_exit:
69 return htable_errno;
70 fn_fail:
72 goto fn_exit;
73}
◆ htable_insert()
| static int htable_insert |
( |
void * |
handle, |
|
|
const char * |
key, |
|
|
void * |
in |
|
) |
| |
|
inlinestatic |
Definition at line 92 of file cuda/htable.h.
93{
96
97 if (table == NULL ||
key == NULL) {
99 }
100
105 goto fn_exit;
106 }
107
110 goto fn_fail;
111 }
112
115 goto fn_fail;
116 }
117
119
120 fn_exit:
121 return htable_errno;
122 fn_fail:
123 if (entry) {
125 }
126 goto fn_exit;
127}
static int create_table_entry(const char *, void *, struct hash_table_entry **)
static int insert_table_entry(struct hash_table *, struct hash_table_entry *)
◆ htable_shutdown()
| static int htable_shutdown |
( |
void * |
handle | ) |
|
|
inlinestatic |
Definition at line 76 of file cuda/htable.h.
77{
80
81 if (table == NULL) {
83 }
84
87
88 return htable_errno;
89}
static int destroy_table_entries(struct hash_table *)
◆ insert_table_entry()
Definition at line 346 of file cuda/htable.h.
347{
349
351
354 }
355
358
359 return htable_errno;
360}
◆ move_table()
Definition at line 252 of file cuda/htable.h.
253{
256
262
263 return htable_errno;
264}
◆ rehash_table()
Definition at line 234 of file cuda/htable.h.
235{
236 uint64_t old_id;
237 for (old_id = 0; old_id < old_table->
capacity; ++old_id) {
240 while (entry) {
245 }
246 }
247
249}