7 static void rehash(
tw_hash * hash_t,
int pe);
12 static tw_event **allocate_table(
int hash_size);
13 static int hash_(
tw_eventid event_id,
int hash_size);
20 static 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;
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);
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",
199 allocate_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);
void avlInsert(AvlTree *t, tw_event *key)
tw_lp * dest_lp
Destination LP ID.
tw_eventid event_id
Unique id assigned by src_lp->pe if remote.
void tw_error(const char *file, int line, const char *fmt,...) NORETURN
static int is_prime(int ptst)
tw_statistics stats
per PE counters
unsigned int g_tw_hash_size
static tw_clock tw_clock_read(void)
tw_event * avlDelete(AvlTree *t, tw_event *key)
unsigned int tw_nnodes(void)
tw_kp * kp
kp – Kernel process that we belong to (must match pe).
void tw_hash_insert(void *h, tw_event *event, long pe)
tw_event * hash_search(tw_event **hash_t, tw_event *evt, int size)
void hash_print(tw_hash *h)
uint32_t g_tw_avl_node_count
tw_event * tw_hash_remove(void *h, tw_event *event, long pe)
void * tw_calloc(const char *file, int line, const char *for_who, size_t e_sz, size_t n)
unsigned int * hash_sizes