- Timestamp:
- Apr 21, 2021, 3:39:14 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b39e6566
- Parents:
- 665edf40 (diff), 7711064 (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. - Location:
- benchmark/readyQ
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/cycle.cpp
r665edf40 r73d0c54a 3 3 #include <libfibre/fibre.h> 4 4 5 class __attribute__((aligned(128))) bench_sem {6 Fibre * volatile ptr = nullptr;7 public:8 inline bool wait() {9 static Fibre * const ready = reinterpret_cast<Fibre * const>(1ull);10 for(;;) {11 Fibre * expected = this->ptr;12 if(expected == ready) {13 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {14 return false;15 }16 }17 else {18 /* paranoid */ assert( expected == nullptr );19 if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {20 fibre_park();21 return true;22 }23 }24 25 }26 }27 28 inline bool post() {29 static Fibre * const ready = reinterpret_cast<Fibre * const>(1ull);30 for(;;) {31 Fibre * expected = this->ptr;32 if(expected == ready) return false;33 if(expected == nullptr) {34 if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {35 return false;36 }37 }38 else {39 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) {40 fibre_unpark( expected );41 return true;42 }43 }44 }45 }46 };47 5 struct Partner { 48 6 unsigned long long count = 0; -
benchmark/readyQ/locality.cpp
r665edf40 r73d0c54a 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 -
benchmark/readyQ/rq_bench.hfa
r665edf40 r73d0c54a 4 4 #include <stdio.h> 5 5 #include <stdlib.hfa> 6 #include <stats.hfa> 6 7 #include <thread.hfa> 7 8 #include <time.hfa> … … 63 64 (*p){ "Benchmark Processor", this.cl }; 64 65 } 66 #if !defined(__CFA_NO_STATISTICS__) 67 print_stats_at_exit( this.cl, CFA_STATS_READY_Q ); 68 #endif 65 69 } 66 70 -
benchmark/readyQ/rq_bench.hpp
r665edf40 r73d0c54a 6 6 #include <time.h> // timespec 7 7 #include <sys/time.h> // timeval 8 9 typedef __uint128_t __lehmer64_state_t; 10 static inline uint64_t __lehmer64( __lehmer64_state_t & state ) { 11 state *= 0xda942042e4dd58b5; 12 return state >> 64; 13 } 8 14 9 15 enum { TIMEGRAN = 1000000000LL }; // nanosecond granularity, except for timeval … … 75 81 } 76 82 83 class Fibre; 84 int fibre_park(); 85 int fibre_unpark( Fibre * ); 86 Fibre * fibre_self(); 87 88 class __attribute__((aligned(128))) bench_sem { 89 Fibre * volatile ptr = nullptr; 90 public: 91 inline bool wait() { 92 static Fibre * const ready = reinterpret_cast<Fibre *>(1ull); 93 for(;;) { 94 Fibre * expected = this->ptr; 95 if(expected == ready) { 96 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 97 return false; 98 } 99 } 100 else { 101 /* paranoid */ assert( expected == nullptr ); 102 if(__atomic_compare_exchange_n(&this->ptr, &expected, fibre_self(), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 103 fibre_park(); 104 return true; 105 } 106 } 107 108 } 109 } 110 111 inline bool post() { 112 static Fibre * const ready = reinterpret_cast<Fibre *>(1ull); 113 for(;;) { 114 Fibre * expected = this->ptr; 115 if(expected == ready) return false; 116 if(expected == nullptr) { 117 if(__atomic_compare_exchange_n(&this->ptr, &expected, ready, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 118 return false; 119 } 120 } 121 else { 122 if(__atomic_compare_exchange_n(&this->ptr, &expected, nullptr, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST)) { 123 fibre_unpark( expected ); 124 return true; 125 } 126 } 127 } 128 } 129 }; 130 77 131 // ========================================================================================== 78 132 #include <cstdlib> … … 188 242 this->help = help; 189 243 this->variable = reinterpret_cast<void*>(&variable); 190 this->parse_fun = reinterpret_cast<bool (*)(const char *, void * )>(static_cast<bool (*)(const char *, T & )>(parse)); 244 #pragma GCC diagnostic push 245 #pragma GCC diagnostic ignored "-Wcast-function-type" 246 this->parse_fun = reinterpret_cast<bool (*)(const char *, void * )>(static_cast<bool (*)(const char *, T & )>(parse)); 247 #pragma GCC diagnostic pop 191 248 } 192 249 … … 197 254 this->help = help; 198 255 this->variable = reinterpret_cast<void*>(&variable); 199 this->parse_fun = reinterpret_cast<bool (*)(const char *, void * )>(parse); 256 #pragma GCC diagnostic push 257 #pragma GCC diagnostic ignored "-Wcast-function-type" 258 this->parse_fun = reinterpret_cast<bool (*)(const char *, void * )>(parse); 259 #pragma GCC diagnostic pop 200 260 } 201 261 };
Note: See TracChangeset
for help on using the changeset viewer.