From: Peizhao Ou Date: Thu, 15 Jan 2015 21:29:39 +0000 (-0800) Subject: additional_ordering_point for ms-queue X-Git-Url: http://plrg.eecs.uci.edu/git/?p=cdsspec-compiler.git;a=commitdiff_plain;h=a0721aba5feb313cce48120d4e98e0165bb476bc additional_ordering_point for ms-queue --- diff --git a/benchmark/ms-queue/my_queue.c b/benchmark/ms-queue/my_queue.c index f59d777..6d86c4a 100644 --- a/benchmark/ms-queue/my_queue.c +++ b/benchmark/ms-queue/my_queue.c @@ -164,6 +164,13 @@ void enqueue(queue_t *q, unsigned int val) &tail, MAKE_POINTER(node, get_count(tail) + 1), release, relaxed); + /** + @Begin + @Additional_ordering_point_define_check: true + @Label: Enqueue_Additional_Tail_LoadOrCAS + @End + */ + } /** @@ -198,7 +205,7 @@ bool dequeue(queue_t *q, int *retVal) * relaxed (it introduces a bug when there's two dequeuers and one * enqueuer) */ - tail = atomic_load_explicit(&q->tail, relaxed); + tail = atomic_load_explicit(&q->tail, acquire); /** @Begin @Potential_commit_point_define: true diff --git a/benchmark/ms-queue/my_queue.h b/benchmark/ms-queue/my_queue.h index 0768428..6618a52 100644 --- a/benchmark/ms-queue/my_queue.h +++ b/benchmark/ms-queue/my_queue.h @@ -88,7 +88,7 @@ void init_queue(queue_t *q, int num_threads); /** @Begin @Interface: Enqueue - @Commit_point_set: Enqueue_Read_Tail | Enqueue_UpdateNext + @Commit_point_set: Enqueue_Read_Tail | Enqueue_UpdateNext | Enqueue_Additional_Tail_LoadOrCAS @ID: get_and_inc(tag) @Action: # __ID__ is an internal macro that refers to the id of the current diff --git a/grammer/spec_compiler.jj b/grammer/spec_compiler.jj index 43faebf..575dcf3 100644 --- a/grammer/spec_compiler.jj +++ b/grammer/spec_compiler.jj @@ -50,19 +50,46 @@ @Begin @Potential_commit_point_define: ... @Label: ... + @End + + OR + + @Begin + @Potential_additional_ordering_point_define: ... + @Label: ... @End d) Commit point define construct @Begin @Commit_point_define_check: ... @Label: ... + @End + + OR + + # Addition ordering point is used to order operations when there are "equal" + # commit point operations on the same location and that we cannot decide + # which operation goes first, we will use additional ordering point to order + # them (it's just similar to commit points). In implementation, we can just + # treat them as commit points with a special flag. + + @Begin + @Additional_ordering_point_define: ... + @Potential_additional_ordering_point_label: ... + @Label: ... @End OR + + @Begin + @Additional_ordering_point_define: ... + @Label: ... + @End + + OR @Begin - @Commit_point_define: ... - @Potential_commit_point_label: ... + @Additional_ordering_point_define_check: ... @Label: ... @End @@ -375,16 +402,24 @@ SKIP : { | +| + | | +| + | +| + | | +| + } @@ -895,6 +930,9 @@ Construct ParseSpec() : LOOKAHEAD(2) res = Potential_commit_point_define() | LOOKAHEAD(2) res = Commit_point_define() | LOOKAHEAD(2) res = Commit_point_define_check() | + LOOKAHEAD(2) res = Potential_additional_ordering_point_define() | + LOOKAHEAD(2) res = Additional_ordering_point_define() | + LOOKAHEAD(2) res = Additional_ordering_point_define_check() | LOOKAHEAD(2) res = Commit_point_clear() | LOOKAHEAD(2) res = Entry_point() | LOOKAHEAD(2) res = Class_begin() | @@ -1110,6 +1148,26 @@ PotentialCPDefineConstruct Potential_commit_point_define() : } } +PotentialCPDefineConstruct Potential_additional_ordering_point_define() : +{ + PotentialCPDefineConstruct res; + String label, condition; + ArrayList content; +} +{ + + { res = null; } + + (content = C_CPP_CODE(null) { condition = stringArray2String(content); }) +