edits
authorPeizhao Ou <peizhaoo@uci.edu>
Thu, 19 Nov 2015 23:36:16 +0000 (15:36 -0800)
committerPeizhao Ou <peizhaoo@uci.edu>
Thu, 19 Nov 2015 23:36:16 +0000 (15:36 -0800)
benchmark/mpmc-queue/mpmc-queue.h
benchmark/mpmc-queue/testcase1.cc

index ff6a168f1c248cc2db457f8fa7b7da8dc818f91a..046a248d0ef09e272b134c1c1be753eb7e7d37b9 100644 (file)
@@ -134,7 +134,7 @@ public:
                // (*1)
                rl::backoff bo;
                while (true) {
-                       /**** Inadmissibility ****/
+                       /**** Inadmissibility (testcase2.c) ****/
                        int written = m_written.load(mo_acquire);
                        if ((written & MASK) != wr) {
                                thrd_yield();
@@ -173,7 +173,7 @@ public:
                @End
        */
        void read_consume(t_element *bin) {
-               /**** Inadmissibility ****/
+               /**** Inadmissibility (testcase1.c) ****/
                m_read.fetch_add(1,mo_release);
                /**
                        @Begin
@@ -214,6 +214,14 @@ public:
                                return NULL;
                        }
                        
+                       // FIXME: Theoretically we have a bug here, it is not so likely to
+                       // happen!!! The following acq_rel can not guarantee that the load
+                       // acquire on m_read to read the most recent value. However, it can
+                       // decrease the chance of the load acquire of m_read to read a too
+                       // old value. Same as the case in read_fetch(). Maybe making things
+                       // SC can fix it. We can run testcase3.c to expose this bug (set the
+                       // array size  = 1, the MASK = 1).
+                       
                        /**** Inadmissibility (testcase3.cc, MASK = 1, size = 1) ****/
                        bool succ = m_rdwr.compare_exchange_weak(rdwr,(rd<<16) |
                                ((wr+1)&MASK),mo_acq_rel);
@@ -241,7 +249,7 @@ public:
                // (*1)
                rl::backoff bo;
                while (true) {
-                       /**** Inadmissibility ****/
+                       /**** Inadmissibility (testcase1.c) ****/
                        int read = m_read.load(mo_acquire);
                        if ((read & MASK) != rd)
                                thrd_yield();
@@ -273,19 +281,19 @@ public:
        /**
                @Begin
                @Interface: Publish 
-               @Commit_point_set: Publish_W_RMW
+               @Commit_point_set: PublishFetchAdd
                @ID: (call_id_t) bin 
                //@Action: model_print("Publish: %d\n", bin);
                @End
        */
        void write_publish(t_element *bin)
        {
-               /**** Inadmissibility ****/
+               /**** Inadmissibility (testcase2.c) ****/
                int tmp = m_written.fetch_add(1,mo_release);
                /**
                        @Begin
                        @Commit_point_define_check: true
-                       @Label: Publish_W_RMW
+                       @Label: PublishFetchAdd
                        @End
                */
                printf("publish: m_written=%d\n", tmp + 1);
index 594564ff5b0060e0f0f640af0ede3ca74c11f789..6a5e21c081f137473c58aee4e6dcbd92a1d4a693 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "mpmc-queue.h"
 
-void threadA(struct mpmc_boundq_1_alt<int32_t, 2> *queue)
+void threadA(struct mpmc_boundq_1_alt<int32_t, 1> *queue)
 {
        int32_t *bin;
        bin = queue->write_prepare();
@@ -21,7 +21,7 @@ void threadA(struct mpmc_boundq_1_alt<int32_t, 2> *queue)
        }
 }
 
-void threadB(struct mpmc_boundq_1_alt<int32_t, 2> *queue)
+void threadB(struct mpmc_boundq_1_alt<int32_t, 1> *queue)
 {
        int32_t *bin;
        bin = queue->read_fetch();
@@ -35,7 +35,7 @@ void threadB(struct mpmc_boundq_1_alt<int32_t, 2> *queue)
 
 int user_main(int argc, char **argv)
 {
-       struct mpmc_boundq_1_alt<int32_t, 2> queue;
+       struct mpmc_boundq_1_alt<int32_t, 1> queue(0xFFFF);
        thrd_t A, B;
 
        printf("Adding initial element\n");
@@ -45,11 +45,12 @@ int user_main(int argc, char **argv)
        printf("init_write_bin %d, val %d\n", bin, 17);
        queue.write_publish(bin);
 
+/*
        bin = queue.write_prepare();
        *bin = 27;
        printf("init_write_bin %d, val %d\n", bin, 27);
        queue.write_publish(bin);
-
+*/
 
        printf("Start threads\n");