7static void rehash(
tw_hash * hash_t,
int pe);
12static tw_event **allocate_table(
int hash_size);
13static int hash_(
tw_eventid event_id,
int hash_size);
20static unsigned int ncpu = 1;
27 return event_id % hash_size;
44 avl_list[i].
next = &avl_list[i + 1];
46 avl_list[i].
next = NULL;
48 g_tw_pe->avl_list_head = &avl_list[0];
68 for (pi = 0; pi <
ncpu; pi++)
113 key = find_empty(hash_t, event, hash_size);
133 for (i = 0; i < old_size; i++)
135 if (old_list[i] != NULL)
146 printf(
"\nHASH TABLE RESIZED: old size = %d, new size = %d \n\n", old_size,
158 key = hash_(event->
event_id, hash_size);
165 key += 2 * (++i) - 1;
166 if (key >= hash_size)
180 key = hash_(event->
event_id, hash_size);
182 while (hash_t[key] == NULL || event->
event_id != hash_t[key]->event_id)
184 key += 2 * (++i) - 1;
185 if (key >= hash_size)
190 tw_error(
TW_LOC,
"Cannot find event in hash table: PE %d, key %d, size %d\n",
199allocate_table(
int hash_size)
268 pmaxseek = (long)sqrt((
double)ptst) + 1;
270 for (a = 3; a <= pmaxseek; a++, a++)
288 for (empty = 0, j = 0; j < size; j++)
294 printf(
"Found event in hash: %d\n", j);
300 printf(
"%ld: HASH has %d empty cells. \n",
g_tw_mynode, empty);
308 unsigned int i, j, empty;
314 for (i = 0; i <
ncpu; i++)
316 printf(
"PE %d: \n", i);
317 printf(
"table size: %d \n", sizes[i]);
318 printf(
"num_stored: %d \n\n", stored[i]);
322 for (empty = 0, j = 0; j < sizes[i]; j++)
333 printf(
"PE %d has %d empty cells. \n", i, empty);
tw_event * avlDelete(AvlTree *t, tw_event *key)
void avlInsert(AvlTree *t, tw_event *key)
static tw_clock tw_clock_read(void)
unsigned int g_tw_hash_size
void * tw_calloc(const char *file, int line, const char *for_who, size_t e_sz, size_t n)
void tw_error(const char *file, int line, const char *fmt,...)
uint32_t g_tw_avl_node_count
tw_event * hash_search(tw_event **hash_t, tw_event *evt, int size)
void tw_hash_insert(void *h, tw_event *event, long pe)
static int is_prime(int ptst)
tw_event * tw_hash_remove(void *h, tw_event *event, long pe)
void hash_print(tw_hash *h)
tw_lp * dest_lp
Destination LP ID.
tw_eventid event_id
Unique id assigned by src_lp->pe if remote.
unsigned int * hash_sizes
tw_kp * kp
kp – Kernel process that we belong to (must match pe).