...
 
Commits (2)
......@@ -2248,10 +2248,9 @@ struct kmp_dephash_entry {
typedef struct kmp_dephash {
kmp_dephash_entry_t **buckets;
size_t size;
size_t generation;
kmp_uint32 nelements;
#ifdef KMP_DEBUG
kmp_uint32 nconflicts;
#endif
} kmp_dephash_t;
#if OMP_50_ENABLED
......
......@@ -56,6 +56,8 @@ static inline kmp_depnode_t *__kmp_node_ref(kmp_depnode_t *node) {
enum { KMP_DEPHASH_OTHER_SIZE = 97, KMP_DEPHASH_MASTER_SIZE = 997 };
size_t sizes[] = { 997, 2003, 4001, 8191, 16001, 32003, 64007, 131071, 270029 };
static inline kmp_int32 __kmp_dephash_hash(kmp_intptr_t addr, size_t hsize) {
// TODO alternate to try: set = (((Addr64)(addrUsefulBits * 9.618)) %
// m_num_sets );
......@@ -66,7 +68,14 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
kmp_dephash_t *current_dephash) {
kmp_dephash_t *h;
size_t gen = current_dephash->generation + 1;
#if 1
if (gen >= 9)
return current_dephash;
size_t new_size = sizes[gen];
#else
size_t new_size = current_dephash->size * 2;
#endif
kmp_int32 size_to_allocate =
new_size * sizeof(kmp_dephash_entry_t *) + sizeof(kmp_dephash_t);
......@@ -80,19 +89,32 @@ static kmp_dephash_t *__kmp_dephash_extend(kmp_info_t *thread,
h->size = new_size;
h->nelements = current_dephash->nelements;
h->buckets = (kmp_dephash_entry **)(h + 1);
h->generation = gen;
fprintf(stderr, "%i", current_dephash->size);
// insert existing elements in the new table
for (size_t i = 0; i < current_dephash->size; i++) {
kmp_dephash_entry_t *next;
int nelems = 0;
for (kmp_dephash_entry_t *entry = current_dephash->buckets[i]; entry; entry = next) {
next = entry->next_in_bucket;
// Compute the new hash using the new size, and insert the entry in
// the new bucket.
kmp_int32 new_bucket = __kmp_dephash_hash(entry->addr, h->size);
nelems++;
if (entry->next_in_bucket) {
h->nconflicts++;
}
entry->next_in_bucket = h->buckets[new_bucket];
h->buckets[new_bucket] = entry;
}
fprintf(stderr, ",%2i", nelems);
//if (i%45==44) {
//fprintf(stderr, "\n");
//;
//}
}
fprintf(stderr, "\n");
// Free old hash table
#if USE_FAST_MEMORY
......@@ -125,10 +147,9 @@ static kmp_dephash_t *__kmp_dephash_create(kmp_info_t *thread,
#endif
h->size = h_size;
h->generation = 0;
h->nelements = 0;
#ifdef KMP_DEBUG
h->nconflicts = 0;
#endif
h->buckets = (kmp_dephash_entry **)(h + 1);
for (size_t i = 0; i < h_size; i++)
......@@ -144,7 +165,8 @@ static kmp_dephash_entry *
__kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t **hash, kmp_intptr_t addr) {
kmp_dephash_t *h = *hash;
if (h->nelements != 0
&& h->nelements >= h->size) {
&& h->nconflicts/h->size >= 1) {
//&& h->nelements >= h->size) {
//fprintf(stderr, "Resizing hashtable\n");
*hash = __kmp_dephash_extend(thread, h);
h = *hash;
......@@ -174,10 +196,8 @@ __kmp_dephash_find(kmp_info_t *thread, kmp_dephash_t **hash, kmp_intptr_t addr)
entry->next_in_bucket = h->buckets[bucket];
h->buckets[bucket] = entry;
h->nelements++;
#ifdef KMP_DEBUG
if (entry->next_in_bucket)
h->nconflicts++;
#endif
}
return entry;
}
......