Changeset 50f6afb for benchmark/readyQ/locality.cpp
- Timestamp:
- Apr 24, 2021, 11:32:49 AM (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:
- 424dfc4, 986cb99
- Parents:
- fec63b2 (diff), 8edbe40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/locality.cpp
rfec63b2 r50f6afb 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.