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 286 of file rocm_smi/htable.h.
287{
290 char resize =
292
293 if (resize) {
294 uint64_t new_capacity = (resize & 0x2) ?
298 goto fn_fail;
299 }
300
303 goto fn_fail;
304 }
305
308 }
309
310 fn_exit:
311 return htable_errno;
312 fn_fail:
313 if (new_table) {
315 }
316 goto fn_exit;
317}
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 193 of file rocm_smi/htable.h.
194{
196
198 if (table == NULL) {
200 goto fn_exit;
201 }
202
203 (*table)->buckets =
papi_calloc(size,
sizeof(*(*table)->buckets));
204 if ((*table)->buckets == NULL) {
206 goto fn_exit;
207 }
208
209 (*table)->capacity = size;
210
211 fn_exit:
212 return htable_errno;
213}
#define papi_calloc(a, b)
◆ create_table_entry()
Definition at line 320 of file rocm_smi/htable.h.
321{
323
325 if (*entry == NULL) {
327 }
328 (*entry)->key = strdup(
key);
329 (*entry)->val = val;
330 (*entry)->next = NULL;
331
332 return htable_errno;
333}
◆ delete_table_entry()
Definition at line 362 of file rocm_smi/htable.h.
363{
365
367
368 if (table->
buckets[
id] == entry) {
371 goto fn_exit;
372 }
373
376
377 while (curr) {
378 if (curr == entry) {
381 break;
382 }
385 }
386
387 fn_exit:
389 return htable_errno;
390}
static uint64_t hash_func(const char *)
struct hash_table_entry * next
struct hash_table_entry ** buckets
◆ destroy_table()
Definition at line 216 of file rocm_smi/htable.h.
217{
219
222 }
223
224 if (table) {
226 }
227
228 return htable_errno;
229}
◆ destroy_table_entries()
Definition at line 265 of file rocm_smi/htable.h.
266{
269
273
274 while (entry) {
279 }
280 }
281
282 return htable_errno;
283}
static int destroy_table_entry(struct hash_table_entry *)
static int delete_table_entry(struct hash_table *, struct hash_table_entry *)
◆ destroy_table_entry()
◆ find_table_entry()
Definition at line 393 of file rocm_smi/htable.h.
395{
396 int htable_errno;
397
400 if (head == NULL) {
402 goto fn_exit;
403 }
404
406 while (curr && strcmp(curr->
key,
key)) {
408 }
409
410 *entry = curr;
412
413 fn_exit:
414 return htable_errno;
415}
◆ hash_func()
| uint64_t hash_func |
( |
const char * |
string | ) |
|
|
static |
djb2 hash function
Definition at line 182 of file rocm_smi/htable.h.
183{
184 uint64_t hash = 5381;
186 while ((
c = *
string++)) {
187 hash = ((hash << 5) + hash) +
c;
188 }
189 return hash;
190}
static double c[MATRIX_SIZE][MATRIX_SIZE]
◆ htable_delete()
| static int htable_delete |
( |
void * |
handle, |
|
|
const char * |
key |
|
) |
| |
|
inlinestatic |
Definition at line 128 of file rocm_smi/htable.h.
129{
132
133 if (table == NULL ||
key == NULL) {
135 }
136
140 return htable_errno;
141 }
142
144
147 return htable_errno;
148 }
149
152 return htable_errno;
153 }
154
156}
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 159 of file rocm_smi/htable.h.
160{
163
164 if (table == NULL ||
key == NULL || out == NULL) {
166 }
167
171 return htable_errno;
172 }
173
175 return htable_errno;
176}
◆ htable_init()
| static int htable_init |
( |
void ** |
handle | ) |
|
|
inlinestatic |
Definition at line 53 of file rocm_smi/htable.h.
54{
56
57#define HTABLE_MIN_SIZE (8)
61 goto fn_fail;
62 }
63
65
66 fn_exit:
67 return htable_errno;
68 fn_fail:
70 goto fn_exit;
71}
◆ htable_insert()
| static int htable_insert |
( |
void * |
handle, |
|
|
const char * |
key, |
|
|
void * |
in |
|
) |
| |
|
inlinestatic |
Definition at line 90 of file rocm_smi/htable.h.
91{
94
95 if (table == NULL ||
key == NULL) {
97 }
98
103 goto fn_exit;
104 }
105
108 goto fn_fail;
109 }
110
113 goto fn_fail;
114 }
115
117
118 fn_exit:
119 return htable_errno;
120 fn_fail:
121 if (entry) {
123 }
124 goto fn_exit;
125}
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 74 of file rocm_smi/htable.h.
75{
78
79 if (table == NULL) {
81 }
82
85
86 return htable_errno;
87}
static int destroy_table_entries(struct hash_table *)
◆ insert_table_entry()
Definition at line 345 of file rocm_smi/htable.h.
346{
348
350
353 }
354
357
358 return htable_errno;
359}
◆ move_table()
◆ rehash_table()
Definition at line 232 of file rocm_smi/htable.h.
233{
234 uint64_t old_id;
235 for (old_id = 0; old_id < old_table->
capacity; ++old_id) {
238 while (entry) {
243 }
244 }
245
247}