Changes in / [92b9958:a0e7d3c]
- Location:
- libcfa/src/concurrency
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
r92b9958 ra0e7d3c 145 145 void ^?{}(__intrusive_lane_t & this); 146 146 147 // Counter used for wether or not the lanes are all empty148 struct __attribute__((aligned(128))) __snzi_node_t;149 struct __snzi_t {150 unsigned mask;151 int root;152 __snzi_node_t * nodes;153 };154 155 void ?{}( __snzi_t & this, unsigned depth );156 void ^?{}( __snzi_t & this );157 158 147 //TODO adjust cache size to ARCHITECTURE 159 148 // Structure holding the relaxed ready queue 160 149 struct __ready_queue_t { 161 // Data tracking how many/which lanes are used162 // Aligned to 128 for cache locality163 __snzi_t snzi;164 165 150 // Data tracking the actual lanes 166 151 // On a seperate cacheline from the used struct since -
libcfa/src/concurrency/kernel_private.hfa
r92b9958 ra0e7d3c 284 284 // Ready-Queue API 285 285 //----------------------------------------------------------------------- 286 // pop thread from the ready queue of a cluster287 // returns 0p if empty288 __attribute__((hot)) bool query(struct cluster * cltr);289 290 //-----------------------------------------------------------------------291 286 // push thread onto a ready queue for a cluster 292 287 // returns true if the list was previously empty, false otherwise -
libcfa/src/concurrency/ready_queue.cfa
r92b9958 ra0e7d3c 17 17 // #define __CFA_DEBUG_PRINT_READY_QUEUE__ 18 18 19 // #define USE_SNZI20 19 // #define USE_MPSC 21 20 … … 29 28 #include <unistd.h> 30 29 31 #include "snzi.hfa"32 30 #include "ready_subqueue.hfa" 33 31 … … 202 200 void ^?{}(__ready_queue_t & this) with (this) { 203 201 verify( 1 == lanes.count ); 204 #ifdef USE_SNZI205 verify( !query( snzi ) );206 #endif207 202 free(lanes.data); 208 203 } 209 204 210 205 //----------------------------------------------------------------------- 211 __attribute__((hot)) bool query(struct cluster * cltr) {212 #ifdef USE_SNZI213 return query(cltr->ready_queue.snzi);214 #endif215 return true;216 }217 218 206 static inline [unsigned, bool] idx_from_r(unsigned r, unsigned preferred) { 219 207 unsigned i; … … 293 281 294 282 // Actually push it 295 #ifdef USE_SNZI296 bool lane_first =297 #endif298 299 283 push(lanes.data[i], thrd); 300 301 #ifdef USE_SNZI302 // If this lane used to be empty we need to do more303 if(lane_first) {304 // Check if the entire queue used to be empty305 first = !query(snzi);306 307 // Update the snzi308 arrive( snzi, i );309 }310 #endif311 284 312 285 #if !defined(USE_MPSC) … … 351 324 352 325 // As long as the list is not empty, try finding a lane that isn't empty and pop from it 353 #ifdef USE_SNZI 354 while( query(snzi) ) { 355 #else 356 for(25) { 357 #endif 326 for(25) { 358 327 // Pick two lists at random 359 328 // unsigned ri = __tls_rand(); … … 447 416 /* paranoid */ verify(lane.lock); 448 417 449 #ifdef USE_SNZI450 // If this was the last element in the lane451 if(emptied) {452 depart( snzi, w );453 }454 #endif455 456 418 // Unlock and return 457 419 __atomic_unlock(&lane.lock); … … 484 446 485 447 removed = true; 486 #ifdef USE_SNZI487 if(emptied) {488 depart( snzi, i );489 }490 #endif491 448 } 492 449 __atomic_unlock(&lane.lock); … … 571 528 // grow the ready queue 572 529 with( cltr->ready_queue ) { 573 #ifdef USE_SNZI574 ^(snzi){};575 #endif576 577 530 // Find new count 578 531 // Make sure we always have atleast 1 list … … 598 551 // Update original 599 552 lanes.count = ncount; 600 601 #ifdef USE_SNZI602 // Re-create the snzi603 snzi{ log2( lanes.count / 8 ) };604 for( idx; (size_t)lanes.count ) {605 if( !is_empty(lanes.data[idx]) ) {606 arrive(snzi, idx);607 }608 }609 #endif610 553 } 611 554 … … 631 574 632 575 with( cltr->ready_queue ) { 633 #ifdef USE_SNZI634 ^(snzi){};635 #endif636 637 576 // Remember old count 638 577 size_t ocount = lanes.count; … … 685 624 fix(lanes.data[idx]); 686 625 } 687 688 #ifdef USE_SNZI689 // Re-create the snzi690 snzi{ log2( lanes.count / 8 ) };691 for( idx; (size_t)lanes.count ) {692 if( !is_empty(lanes.data[idx]) ) {693 arrive(snzi, idx);694 }695 }696 #endif697 626 } 698 627
Note: See TracChangeset
for help on using the changeset viewer.