1 // helpful utility and synch functions
3 // relies on defining "ncores" before including this file...
8 #define rdcycle() ({ unsigned long _c; asm volatile ("rdcycle %0" : "=r"(_c) :: "memory"); _c; })
9 #define rdinstret() ({ unsigned long _c; asm volatile ("rdinstret %0" : "=r"(_c) :: "memory"); _c; })
11 void __attribute__((noinline
)) barrier()
13 static volatile int sense
;
14 static volatile int count
;
15 static __thread
int threadsense
;
19 threadsense
= !threadsense
;
20 if (__sync_fetch_and_add(&count
, 1) == ncores
-1)
25 else while(sense
!= threadsense
)