From 8043f521300002874ed63598768fb6061382a1ba Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 18 Aug 2012 17:39:18 -0400 Subject: [PATCH] ck_pr: Add ck_pr_barrier for compiler barrier. CK_CC_BARRIER isn't idiomatic, roll this into PR memory model instead. --- include/ck_cc.h | 4 ---- include/gcc/ck_cc.h | 5 ----- include/gcc/ck_pr.h | 8 ++++++++ include/gcc/ppc/ck_pr.h | 8 ++++++++ include/gcc/ppc64/ck_pr.h | 8 ++++++++ include/gcc/sparcv9/ck_pr.h | 8 ++++++++ include/gcc/x86/ck_pr.h | 8 ++++++++ include/gcc/x86_64/ck_pr.h | 8 ++++++++ regressions/ck_hp/validate/ck_hp_fifo.c | 5 ++--- 9 files changed, 50 insertions(+), 12 deletions(-) diff --git a/include/ck_cc.h b/include/ck_cc.h index fc75025..c5f17a4 100644 --- a/include/ck_cc.h +++ b/include/ck_cc.h @@ -45,10 +45,6 @@ #define CK_CC_PAD(x) union { char pad[x]; } -#ifndef CK_CC_BARRIER -#define CK_CC_BARRIER() -#endif - #ifndef CK_CC_ALIASED #define CK_CC_ALIASED #endif diff --git a/include/gcc/ck_cc.h b/include/gcc/ck_cc.h index 0712a86..f7b13a7 100644 --- a/include/gcc/ck_cc.h +++ b/include/gcc/ck_cc.h @@ -68,11 +68,6 @@ */ #define CK_CC_CACHELINE CK_CC_ALIGN(CK_MD_CACHELINE) -/* - * Compiler barrier. - */ -#define CK_CC_BARRIER() __asm__ __volatile__("" ::: "memory") - /* * These are functions which should be avoided. */ diff --git a/include/gcc/ck_pr.h b/include/gcc/ck_pr.h index dbf2101..c16587c 100644 --- a/include/gcc/ck_pr.h +++ b/include/gcc/ck_pr.h @@ -109,6 +109,14 @@ CK_PR_FENCE(memory) #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + /* * Atomic compare and swap. */ diff --git a/include/gcc/ppc/ck_pr.h b/include/gcc/ppc/ck_pr.h index aaa9164..be2c46f 100644 --- a/include/gcc/ppc/ck_pr.h +++ b/include/gcc/ppc/ck_pr.h @@ -75,6 +75,14 @@ CK_PR_FENCE(memory, "sync") #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + #define CK_PR_LOAD(S, M, T, C, I) \ CK_CC_INLINE static T \ ck_pr_load_##S(M *target) \ diff --git a/include/gcc/ppc64/ck_pr.h b/include/gcc/ppc64/ck_pr.h index e0af716..f2dea45 100644 --- a/include/gcc/ppc64/ck_pr.h +++ b/include/gcc/ppc64/ck_pr.h @@ -74,6 +74,14 @@ CK_PR_FENCE(memory, "sync") #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + #define CK_PR_LOAD(S, M, T, C, I) \ CK_CC_INLINE static T \ ck_pr_load_##S(M *target) \ diff --git a/include/gcc/sparcv9/ck_pr.h b/include/gcc/sparcv9/ck_pr.h index 83c5af4..397c81c 100644 --- a/include/gcc/sparcv9/ck_pr.h +++ b/include/gcc/sparcv9/ck_pr.h @@ -71,6 +71,14 @@ CK_PR_FENCE(memory, "membar #MemIssue") #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + #define CK_PR_LOAD(S, M, T, C, I) \ CK_CC_INLINE static T \ ck_pr_load_##S(M *target) \ diff --git a/include/gcc/x86/ck_pr.h b/include/gcc/x86/ck_pr.h index 42fef71..687b050 100644 --- a/include/gcc/x86/ck_pr.h +++ b/include/gcc/x86/ck_pr.h @@ -87,6 +87,14 @@ CK_PR_FENCE(memory, "mfence") #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + /* * Atomic fetch-and-store operations. */ diff --git a/include/gcc/x86_64/ck_pr.h b/include/gcc/x86_64/ck_pr.h index 65ed929..3c40353 100644 --- a/include/gcc/x86_64/ck_pr.h +++ b/include/gcc/x86_64/ck_pr.h @@ -86,6 +86,14 @@ CK_PR_FENCE(memory, "mfence") #undef CK_PR_FENCE +static inline void +ck_pr_barrier(void) +{ + + __asm__ __volatile__("" ::: "memory"); + return; +} + /* * Atomic fetch-and-store operations. */ diff --git a/regressions/ck_hp/validate/ck_hp_fifo.c b/regressions/ck_hp/validate/ck_hp_fifo.c index a8404ac..9882798 100644 --- a/regressions/ck_hp/validate/ck_hp_fifo.c +++ b/regressions/ck_hp/validate/ck_hp_fifo.c @@ -81,16 +81,15 @@ test(void *c) entry->tid = context->tid; ck_hp_fifo_enqueue_mpmc(&record, &fifo, fifo_entry, entry); - CK_CC_BARRIER(); + ck_pr_barrier(); fifo_entry = ck_hp_fifo_dequeue_mpmc(&record, &fifo, &entry); if (fifo_entry == NULL) { fprintf(stderr, "ERROR [%u] Queue should never be empty.\n", context->tid); - pause(); exit(EXIT_FAILURE); } - CK_CC_BARRIER(); + ck_pr_barrier(); if (entry->tid < 0 || entry->tid >= nthr) { fprintf(stderr, "ERROR [%u] Incorrect value in entry.\n", entry->tid);