save
[cdsspec-compiler.git] / benchmark / cliffc-hashtable / cliffc_hashtable.h
index 738201cea156b98161bbc5b4d389b1f59553e359..3830eed081ad302ff912a57541074ac4401370e5 100644 (file)
@@ -138,16 +138,15 @@ class cliffc_hashtable {
                        # Update the tag for the current key slot if the corresponding tag
                        # is NULL, otherwise just return that tag. It will update the next
                        # available tag too if it requires a new tag for that key slot.
-                       id_tag_t getKeyTag(TypeK *key) {
-                               if (spec_table_contains(id_map, key)) {
-                                       id_tag_t *cur_tag = MODEL_MALLOC(sizeof(id_tag_t));
-                                       *cur_tag = current(tag);
-                                       spec_table_put(id_map, key, cur_tag);
+                       call_id_t getKeyTag(TypeK *key) {
+                               if (!spec_table_contains(id_map, key)) {
+                                       call_id_t cur_id = current(tag);
+                                       spec_table_put(id_map, key, (void*) cur_id);
                                        next(tag);
-                                       return cur_tag;
+                                       return cur_id;
                                } else {
-                                       id_tag_t *res = (id_tag_t*) spec_table_get(id_map, key);
-                                       return *res;
+                                       call_id_t res = (call_id_t) spec_table_get(id_map, key);
+                                       return res;
                                }
                        }
                
@@ -390,25 +389,27 @@ friend class CHM;
                // Should initialize the CHM for the construction of the table
                // For other CHM in kvs_data, they should be initialzed in resize()
                // because the size is determined dynamically
+               /**
+                       @Begin
+                       @Entry_point
+                       @End
+               */
                kvs_data *kvs = new kvs_data(Default_Init_Size);
-               
-               /*
                void *chm = (void*) new CHM(0);
                kvs->_data[0].store(chm, memory_order_relaxed);
                _kvs.store(kvs, memory_order_release);
-               */
        }
 
        cliffc_hashtable(int init_size) {
                // Should initialize the CHM for the construction of the table
                // For other CHM in kvs_data, they should be initialzed in resize()
                // because the size is determined dynamically
+
                /**
                        @Begin
                        @Entry_point
                        @End
                */
-
                kvs_data *kvs = new kvs_data(init_size);
                void *chm = (void*) new CHM(0);
                kvs->_data[0].store(chm, memory_order_relaxed);
@@ -793,6 +794,7 @@ friend class CHM;
                        if (++reprobe_cnt >= reprobe_limit(len) ||
                                K == TOMBSTONE) { // Found a Tombstone key, no more keys
                                newkvs = chm->resize(topmap, kvs);
+                               model_print("resize1\n");
                                // Help along an existing copy
                                if (expVal != NULL) topmap->help_copy(newkvs);
                                return putIfMatch(topmap, newkvs, key_slot, val_slot, expVal);
@@ -807,8 +809,10 @@ friend class CHM;
                // its progress (eagerly try to resize soon)
                newkvs = chm->_newkvs.load(memory_order_acquire);
                if (newkvs == NULL &&
-                       ((V == NULL && chm->table_full(reprobe_cnt, len)) || is_prime(V)))
+                       ((V == NULL && chm->table_full(reprobe_cnt, len)) || is_prime(V))) {
+                       model_print("resize2\n");
                        newkvs = chm->resize(topmap, kvs); // Force the copy to start
+               }
                
                // Finish the copy and then put it in the new table
                if (newkvs != NULL)
@@ -842,7 +846,7 @@ friend class CHM;
                                */
                                /**
                                        @Begin
-                                       @Commit_point_define: !valeq(expVal, V)
+                                       @Commit_point_define: expVal != NULL && !valeq(expVal, V)
                                        @Potential_commit_point_label: Read_Val_Point
                                        @Label: ReplaceIfMatch_Fail_Point
                                        @End