- Timestamp:
- May 22, 2020, 4:00:01 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 3bf812b
- Parents:
- 95cb63b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp
r95cb63b r8f4f3e0 5 5 #endif 6 6 7 #include <cmath> 7 8 #include <memory> 8 9 #include <mutex> … … 56 57 : lists(new intrusive_queue_t[numLists]) 57 58 , numLists(numLists) 58 #if defined(SIMPLE_SNZI) 59 , snzi( 4)59 #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK) 60 , snzi( std::log2( numLists / 8 ) ) 60 61 #endif 61 62 { … … 89 90 if( !lists[i].lock.try_lock() ) continue; 90 91 91 #if !defined(SIMPLE_SNZI) 92 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 92 93 __attribute__((unused)) int num = numNonEmpty; 93 94 #endif … … 100 101 assert(qword == 0); 101 102 bts(tls.mask, bit); 103 snzi.arrive(i); 102 104 #elif defined(SIMPLE_SNZI) 103 105 snzi.arrive(i); … … 114 116 #endif 115 117 } 116 #if !defined(SIMPLE_SNZI) 118 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 117 119 assert(numNonEmpty <= (int)numLists); 118 120 #endif … … 123 125 #ifndef NO_STATS 124 126 tls.pick.push.success++; 125 #if !defined(SIMPLE_SNZI) 127 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 126 128 tls.empty.push.value += num; 127 129 tls.empty.push.count += 1; … … 135 137 #if defined(DISCOVER_BITMASK) 136 138 assert(numLists <= 64); 137 while( true) {139 while(snzi.query()) { 138 140 tls.pick.pop.mask_attempt++; 139 141 unsigned i, j; 140 142 { 141 // Pick two lists at random142 unsigned num = ((numLists - 1) >> 6) + 1;143 144 143 // Pick first list totally randomly 145 144 i = tls.rng.next() % numLists; … … 245 244 if( !list.lock.try_lock() ) return nullptr; 246 245 247 #if !defined(SIMPLE_SNZI) 246 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 248 247 __attribute__((unused)) int num = numNonEmpty; 249 248 #endif … … 267 266 assert(qword == 0); 268 267 __attribute__((unused)) bool ret = btr(tls.mask, bit); 268 snzi.depart(w); 269 269 #elif defined(SIMPLE_SNZI) 270 270 snzi.depart(w); … … 284 284 // Unlock and return 285 285 list.lock.unlock(); 286 #if !defined(SIMPLE_SNZI) 286 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 287 287 assert(numNonEmpty >= 0); 288 288 #endif 289 289 #ifndef NO_STATS 290 290 tls.pick.pop.success++; 291 #if !defined(SIMPLE_SNZI) 291 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK) 292 292 tls.empty.pop.value += num; 293 293 tls.empty.pop.count += 1; … … 435 435 const unsigned numLists; 436 436 private: 437 #if defined(SIMPLE_SNZI) 437 #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK) 438 438 snzi_t snzi; 439 439 #else
Note: See TracChangeset
for help on using the changeset viewer.