You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
416 B
20 lines
416 B
#ifndef _SYNC_UTILS_H_
|
|
#define _SYNC_UTILS_H_
|
|
|
|
static inline void sync_barrier(volatile int *counter, int all) {
|
|
|
|
int local;
|
|
|
|
asm volatile("amoadd.w %0, %2, (%1)\n"
|
|
: "=r"(local)
|
|
: "r"(counter), "r"(1)
|
|
: "memory");
|
|
|
|
if (local + 1 < all) {
|
|
do {
|
|
asm volatile("lw %0, (%1)\n" : "=r"(local) : "r"(counter) : "memory");
|
|
} while (local < all);
|
|
}
|
|
}
|
|
|
|
#endif |