Changes in benchmark/readyQ/locality.cpp [56ac392:f03209d3]
- File:
-
- 1 edited
-
benchmark/readyQ/locality.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/locality.cpp
r56ac392 rf03209d3 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 } 11 54 }; 12 55 … … 244 287 245 288 bool is_tty = isatty(STDOUT_FILENO); 246 start = timeHiRes();289 start = getTimeNsec(); 247 290 248 291 for(size_t i = 0; i < nthreads; i++) { … … 252 295 253 296 stop = true; 254 end = timeHiRes();297 end = getTimeNsec(); 255 298 printf("\nDone\n"); 256 299
Note:
See TracChangeset
for help on using the changeset viewer.