From: Peizhao Ou Date: Thu, 19 Nov 2015 23:36:16 +0000 (-0800) Subject: edits X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=commitdiff_plain;h=d1aff50233aef12d3f8376bb4646de39f4112560;hp=7537757f9cbddcfa61076053bea0bddad28e37ad edits --- diff --git a/benchmark/mpmc-queue/mpmc-queue.h b/benchmark/mpmc-queue/mpmc-queue.h index ff6a168..046a248 100644 --- a/benchmark/mpmc-queue/mpmc-queue.h +++ b/benchmark/mpmc-queue/mpmc-queue.h @@ -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); diff --git a/benchmark/mpmc-queue/testcase1.cc b/benchmark/mpmc-queue/testcase1.cc index 594564f..6a5e21c 100644 --- a/benchmark/mpmc-queue/testcase1.cc +++ b/benchmark/mpmc-queue/testcase1.cc @@ -8,7 +8,7 @@ #include "mpmc-queue.h" -void threadA(struct mpmc_boundq_1_alt *queue) +void threadA(struct mpmc_boundq_1_alt *queue) { int32_t *bin; bin = queue->write_prepare(); @@ -21,7 +21,7 @@ void threadA(struct mpmc_boundq_1_alt *queue) } } -void threadB(struct mpmc_boundq_1_alt *queue) +void threadB(struct mpmc_boundq_1_alt *queue) { int32_t *bin; bin = queue->read_fetch(); @@ -35,7 +35,7 @@ void threadB(struct mpmc_boundq_1_alt *queue) int user_main(int argc, char **argv) { - struct mpmc_boundq_1_alt queue; + struct mpmc_boundq_1_alt 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");