save more
authorPeizhao Ou <peizhaoo@uci.edu>
Tue, 25 Mar 2014 00:01:30 +0000 (17:01 -0700)
committerPeizhao Ou <peizhaoo@uci.edu>
Tue, 25 Mar 2014 00:01:30 +0000 (17:01 -0700)
benchmark/chase-lev-deque-bugfix/deque.c
benchmark/chase-lev-deque-bugfix/main.c
benchmark/cliffc-hashtable/.cliffc_hashtable.h.swp [new file with mode: 0644]
benchmark/cliffc-hashtable/cliffc_hashtable.h
benchmark/cliffc-hashtable/main.cc
benchmark/mcs-lock/mcs-lock.cc
benchmark/mcs-lock/mcs-lock.h
benchmark/spsc-bugfix/queue.h
benchmark/spsc-bugfix/spsc-relacy.cc

index 9fbc426101362b6787a9c45bf42f359246224f4b..11e5e9916e3da3b46fdd560e7ba1c309903109ba 100644 (file)
@@ -82,7 +82,7 @@ void resize(Deque *q) {
        }
        /**** detected UL ****/
        atomic_store_explicit(&q->array, new_a, memory_order_release);
-       printf("resize\n");
+       //printf("resize\n");
 }
 
 /**
index 1906f1d66e4cc31857ff34bcf3bb895b2f7abb81..786aa3c9e975a6b013886887b3d375a98ba68560 100644 (file)
@@ -14,7 +14,7 @@ int b;
 int c;
 
 static void task(void * param) {
-       a=steal(q);
+       //a=steal(q);
        a=steal(q);
 }
 
@@ -34,7 +34,7 @@ int user_main(int argc, char **argv)
        b=take(q);
        c=take(q);
        thrd_join(t);
-
+/*
        bool correct=true;
        if (a!=1 && a!=2 && a!=4 && a!= EMPTY)
                correct=false;
@@ -46,6 +46,7 @@ int user_main(int argc, char **argv)
                correct=false;
        if (!correct)
                printf("a=%d b=%d c=%d\n",a,b,c);
+               */
        //MODEL_ASSERT(correct);
 
        return 0;
diff --git a/benchmark/cliffc-hashtable/.cliffc_hashtable.h.swp b/benchmark/cliffc-hashtable/.cliffc_hashtable.h.swp
new file mode 100644 (file)
index 0000000..a868efd
Binary files /dev/null and b/benchmark/cliffc-hashtable/.cliffc_hashtable.h.swp differ
index 1bbe1561f5d7a59e1c28e49b13f4518528c37fa7..5c32ca08ff9bdd9fd4a3a04d9cbb4fb99012f80d 100644 (file)
@@ -221,7 +221,7 @@ friend class CHM;
                }
        
                kvs_data* resize(cliffc_hashtable *topmap, kvs_data *kvs) {
-                       model_print("resizing...\n");
+                       //model_print("resizing...\n");
                        kvs_data *newkvs = _newkvs.load(memory_order_acquire);
                        if (newkvs != NULL)
                                return newkvs;
@@ -245,12 +245,12 @@ friend class CHM;
        
                        // Last check cause the 'new' below is expensive
                        newkvs = _newkvs.load(memory_order_acquire);
-                       model_print("hey1\n");
+                       //model_print("hey1\n");
                        if (newkvs != NULL) return newkvs;
        
                        newkvs = new kvs_data(newsz);
                        void *chm = (void*) new CHM(sz);
-                       model_print("hey2\n");
+                       //model_print("hey2\n");
                        newkvs->_data[0].store(chm, memory_order_relaxed);
        
                        kvs_data *cur_newkvs; 
@@ -432,8 +432,8 @@ friend class CHM;
                        if (!passed) {
                                int old = _Old_Val == NULL ? 0 : _Old_Val->_val;
                                int ret = __RET__ == NULL ? 0 : __RET__->_val;
-                               model_print("Get: key: %d, _Old_Val: %d, RET: %d\n",
-                               key->_val, old, ret);
+                               //model_print("Get: key: %d, _Old_Val: %d, RET: %d\n",
+                               //key->_val, old, ret);
                        }
                @Post_check:
                        //__RET__ == NULL ? true : equals_val(_Old_Val, __RET__)
@@ -464,8 +464,8 @@ friend class CHM;
                        if (!passed) {
                                int old = _Old_Val == NULL ? 0 : _Old_Val->_val;
                                int ret = __RET__ == NULL ? 0 : __RET__->_val;
-                               model_print("Put: key: %d, val: %d, _Old_Val: %d, RET: %d\n",
-                               key->_val, val->_val, old, ret);
+                               //model_print("Put: key: %d, val: %d, _Old_Val: %d, RET: %d\n",
+                               //      key->_val, val->_val, old, ret);
                        }
                @Post_check:
                        equals_val(__RET__, _Old_Val)
@@ -687,7 +687,7 @@ friend class CHM;
        static inline bool CAS_val(kvs_data *kvs, int idx, void *expected, void
                *desired) {
                bool res =  kvs->_data[2 * idx + 3].compare_exchange_strong(expected,
-                       desired, memory_order_release, memory_order_relaxed);
+                       desired, memory_order_acq_rel, memory_order_relaxed);
                /**
                        # If it is a successful put instead of a copy or any other internal
                        # operantions, expected != NULL
@@ -720,7 +720,7 @@ friend class CHM;
                        
 
                        if (K == NULL) {
-                               model_print("Key is null\n");
+                               //model_print("Key is null\n");
                                return NULL; // A miss
                        }
                        
index b6275ca63258434703ccd6d111aaf29299f9d387..3e527446dd267c9526c3959670e1a926dffb4f68 100644 (file)
@@ -55,7 +55,8 @@ IntWrapper *k0, *k1, *k2, *k3, *k4, *k5;
 IntWrapper *v0, *v1, *v2, *v3, *v4, *v5;
 
 void threadA(void *arg) {
-       table->put(k1, v1);
+       table->put(k3, v3);
+       table->put(k1, v4);
        //table->put(k2, v2);
        //table->put(k3, v3);
        /*
@@ -69,14 +70,15 @@ void threadA(void *arg) {
 }
 
 void threadB(void *arg) {
-       table->put(k1, v1);
-       table->put(k2, v4);
-       table->put(k3, v3);
+       //table->put(k1, v1);
+       //table->put(k2, v4);
+       //table->put(k3, v3);
 }
 
 void threadMain(void *arg) {
        val1 = table->get(k1);
-       val2 = table->get(k2);
+       //val2 = table->get(k2);
+       /*
        if (val1 != NULL)
                model_print("val1: %d\n", val1->_val);
        else
@@ -84,7 +86,7 @@ void threadMain(void *arg) {
        if (val2 != NULL)
                model_print("val2: %d\n", val2->_val);
        else
-               model_print("val2: NULL\n");
+               model_print("val2: NULL\n");*/
 }
 
 int user_main(int argc, char *argv[]) {
@@ -105,7 +107,7 @@ int user_main(int argc, char *argv[]) {
        v0 = new IntWrapper(2048);
        table->put(k1, v0);
        table->put(k2, v0);
-       model_print("hey\n");
+       //model_print("hey\n");
        thrd_create(&t1, threadA, NULL);
        thrd_create(&t2, threadB, NULL);
        threadMain(NULL);
index d43689411a2855e3c1866177ab4393877303f8d7..0be129f2ae4b1e67897decfacbc9f565657cd900 100644 (file)
@@ -17,18 +17,18 @@ void threadA(void *arg)
        //shared = 17;
        mutex->unlock(&g);
        mutex->lock(&g);
-       printf("load: %u\n", load_32(&shared));
+       //printf("load: %u\n", load_32(&shared));
        //printf("load: %u\n", shared);
 }
 
 void threadB(void *arg)
 {
        mcs_mutex::guard g(mutex);
-       printf("load: %u\n", load_32(&shared));
+       //printf("load: %u\n", load_32(&shared));
        //printf("load: %u\n", shared);
        mutex->unlock(&g);
        mutex->lock(&g);
-       printf("store: %d\n", 17);
+       //printf("store: %d\n", 17);
        //shared = 17;
        store_32(&shared, 17);
 }
index a165437bf320388f52a934feb4c28ba51d6ca645..d9165d124a5a517ce3d38570d7c3bac387e65df8 100644 (file)
@@ -94,9 +94,11 @@ public:
                        // unlock of pred can see me in the tail before I fill next
 
                        // publish me to previous lock-holder :
-                       // FIXME: detection miss, don't think it's necessary  
+                       // FIXME: detection miss, execution never ends
+                       // If this is relaxed, the store 0 to gate will be read before and
+                       // that lock will never ends.
                        pred->next.store(me, std::mo_release );
-                       printf("lock_miss1\n");
+                       //printf("lock_miss1\n");
 
                        // (*2) pred not touched any more       
 
@@ -106,8 +108,8 @@ public:
                        int my_gate = 1;
                        while (my_gate ) {
                                my_gate = me->gate.load(std::mo_acquire);
-                               if (my_gate == 0)
-                                       printf("lock at gate!\n");
+                               //if (my_gate == 0)
+                                       //printf("lock at gate!\n");
                                /**
                                        @Begin
                                        @Commit_point_define_check: my_gate == 0
@@ -133,9 +135,9 @@ public:
        void unlock(guard * I) {
                mcs_node * me = &(I->m_node);
 
-               // FIXME: detection miss, don't think it's necessary
+               // FIXME: detection miss, execution never ends
                mcs_node * next = me->next.load(std::mo_acquire);
-               printf("unlock_miss2\n");
+               //printf("unlock_miss2\n");
                if ( next == NULL )
                {
                        mcs_node * tail_was_me = me;
@@ -157,9 +159,9 @@ public:
                        // (*1) catch the race :
                        rl::linear_backoff bo;
                        for(;;) {
-                               // FIXME: detection miss, don't think it's necessary
+                               // FIXME: detection miss, execution never ends
                                next = me->next.load(std::mo_acquire);
-                               printf("unlock_miss3\n");
+                               //printf("unlock_miss3\n");
                                if ( next != NULL )
                                        break;
                                thrd_yield();
index b47452e5b61d0cc98bf1572524ce71f1189a7444..0a38e8fc555e5b1708fee434d8c044353dc7ce9e 100644 (file)
@@ -41,7 +41,7 @@ public:
 
        ~spsc_queue()
        {
-               RL_ASSERT(head == tail);
+               //RL_ASSERT(head == tail);
                delete ((node*)head($));
        }
 
index 8d4ad3ba66c3793ed902c96c760d0c8f7c6ee51f..fc594fbef68e59f13057ea618f1f7ec30f1e8a33 100644 (file)
@@ -15,7 +15,7 @@ struct spsc_queue_test : rl::test_suite<spsc_queue_test, 2>
                else
                {
                        int d = q.dequeue();
-                       RL_ASSERT(11 == d);
+                       //RL_ASSERT(11 == d);
                }
        }
 };