- Timestamp:
- May 26, 2020, 11:43:13 AM (4 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:
- 0092853
- Parents:
- 3bf812b
- Location:
- doc/theses/thierry_delisle_PhD/code
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/code/relaxed_list.cpp
r3bf812b r8e1b1bb 918 918 919 919 std::cout << "Running " << nthreads << " threads (" << (nthreads * nqueues) << " queues) for " << duration << " seconds" << std::endl; 920 std::cout << "Relaxed list variant: " << relaxed_list<Node>::name() << std::endl; 920 921 switch(benchmark) { 921 922 case Churn: -
doc/theses/thierry_delisle_PhD/code/relaxed_list.hpp
r3bf812b r8e1b1bb 1 1 #pragma once 2 3 enum VARIANTS { 4 VANILLA, 5 SNZI, 6 BITMASK, 7 DISCOVER 8 }; 9 10 #ifndef VARIANT 11 #define VARIANT VANILLA 12 #endif 2 13 3 14 #ifndef NO_STATS … … 13 24 #include "utils.hpp" 14 25 #include "snzi.hpp" 26 27 #define MACRO_XSTR(s) MACRO_STR(s) 28 #define MACRO_STR(s) #s 15 29 16 30 using namespace std; … … 54 68 55 69 public: 70 static const char * name() { 71 return MACRO_XSTR(VARIANT); 72 } 73 56 74 relaxed_list(unsigned numLists) 57 75 : lists(new intrusive_queue_t[numLists]) 58 76 , numLists(numLists) 59 #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)77 #if VARIANT == SNZI || VARIANT == DISCOVER 60 78 , snzi( std::log2( numLists / 8 ) ) 61 79 #endif … … 90 108 if( !lists[i].lock.try_lock() ) continue; 91 109 92 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)110 #if VARIANT != SNZI && VARIANT != DISCOVER 93 111 __attribute__((unused)) int num = numNonEmpty; 94 112 #endif … … 96 114 // Actually push it 97 115 if(lists[i].push(node)) { 98 #if defined(DISCOVER_BITMASK)116 #if VARIANT == DISCOVER 99 117 size_t qword = i >> 6ull; 100 118 size_t bit = i & 63ull; … … 102 120 bts(tls.mask, bit); 103 121 snzi.arrive(i); 104 #elif defined(SIMPLE_SNZI)122 #elif VARIANT == SNZI 105 123 snzi.arrive(i); 106 #elif !defined(NO_BITMASK)124 #elif VARIANT == BITMASK 107 125 numNonEmpty++; 108 126 size_t qword = i >> 6ull; … … 116 134 #endif 117 135 } 118 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)136 #if VARIANT != SNZI && VARIANT != DISCOVER 119 137 assert(numNonEmpty <= (int)numLists); 120 138 #endif … … 125 143 #ifndef NO_STATS 126 144 tls.pick.push.success++; 127 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)145 #if VARIANT != SNZI && VARIANT != DISCOVER 128 146 tls.empty.push.value += num; 129 147 tls.empty.push.count += 1; … … 135 153 136 154 __attribute__((noinline, hot)) node_t * pop() { 137 #if defined(DISCOVER_BITMASK)155 #if VARIANT == DISCOVER 138 156 assert(numLists <= 64); 139 157 while(snzi.query()) { … … 164 182 if(auto node = try_pop(i, j)) return node; 165 183 } 166 #elif defined(SIMPLE_SNZI)184 #elif VARIANT == SNZI 167 185 while(snzi.query()) { 168 186 // Pick two lists at random … … 172 190 if(auto node = try_pop(i, j)) return node; 173 191 } 174 #elif !defined(NO_BITMASK)192 #elif VARIANT == BITMASK 175 193 int nnempty; 176 194 while(0 != (nnempty = numNonEmpty)) { … … 226 244 #endif 227 245 228 #if defined(DISCOVER_BITMASK)246 #if VARIANT == DISCOVER 229 247 if(lists[i].ts() > 0) bts(tls.mask, i); else btr(tls.mask, i); 230 248 if(lists[j].ts() > 0) bts(tls.mask, j); else btr(tls.mask, j); … … 244 262 if( !list.lock.try_lock() ) return nullptr; 245 263 246 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)264 #if VARIANT != SNZI && VARIANT != DISCOVER 247 265 __attribute__((unused)) int num = numNonEmpty; 248 266 #endif … … 261 279 262 280 if(emptied) { 263 #if defined(DISCOVER_BITMASK)281 #if VARIANT == DISCOVER 264 282 size_t qword = w >> 6ull; 265 283 size_t bit = w & 63ull; … … 267 285 __attribute__((unused)) bool ret = btr(tls.mask, bit); 268 286 snzi.depart(w); 269 #elif defined(SIMPLE_SNZI)287 #elif VARIANT == SNZI 270 288 snzi.depart(w); 271 #elif !defined(NO_BITMASK)289 #elif VARIANT == BITMASK 272 290 numNonEmpty--; 273 291 size_t qword = w >> 6ull; … … 284 302 // Unlock and return 285 303 list.lock.unlock(); 286 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)304 #if VARIANT != SNZI && VARIANT != DISCOVER 287 305 assert(numNonEmpty >= 0); 288 306 #endif 289 307 #ifndef NO_STATS 290 308 tls.pick.pop.success++; 291 #if !defined(SIMPLE_SNZI) && !defined(DISCOVER_BITMASK)309 #if VARIANT != SNZI && VARIANT != DISCOVER 292 310 tls.empty.pop.value += num; 293 311 tls.empty.pop.count += 1; … … 435 453 const unsigned numLists; 436 454 private: 437 #if defined(SIMPLE_SNZI) || defined(DISCOVER_BITMASK)455 #if VARIANT == SNZI || VARIANT == DISCOVER 438 456 snzi_t snzi; 439 457 #else 440 458 std::atomic_int numNonEmpty = { 0 }; // number of non-empty lists 459 #endif 460 #if VARIANT == BITMASK 441 461 std::atomic_size_t list_mask[7] = { {0}, {0}, {0}, {0}, {0}, {0}, {0} }; // which queues are empty 442 462 #endif
Note: See TracChangeset
for help on using the changeset viewer.