Changeset 56ac392 for benchmark/readyQ/locality.cpp
- Timestamp:
- Apr 21, 2021, 3:02:42 PM (3 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 7711064
- Parents:
- b374dbc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/locality.cpp
rb374dbc r56ac392 9 9 uint64_t dmigs = 0; 10 10 uint64_t gmigs = 0; 11 };12 13 class __attribute__((aligned(128))) bench_sem {14 Fibre * volatile ptr = nullptr;15 public:16 inline bool wait() {17 static Fibre * const ready = reinterpret_cast<Fibre * const>(1ull);18 for(;;) {19 Fibre * expected = this->ptr;20 if(expected == ready) {21 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {22 return false;23 }24 }25 else {26 /* paranoid */ assert( expected == nullptr );27 if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {28 fibre_park();29 return true;30 }31 }32 33 }34 }35 36 inline bool post() {37 static Fibre * const ready = reinterpret_cast<Fibre * const>(1ull);38 for(;;) {39 Fibre * expected = this->ptr;40 if(expected == ready) return false;41 if(expected == nullptr) {42 if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {43 return false;44 }45 }46 else {47 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {48 fibre_unpark( expected );49 return true;50 }51 }52 }53 }54 11 }; 55 12
Note: See TracChangeset
for help on using the changeset viewer.