Changeset 04b5cef for libcfa/src/concurrency
- Timestamp:
- Jun 19, 2020, 11:22:32 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:
- 64a7146
- Parents:
- 37ba662
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.cfa
r37ba662 r04b5cef 342 342 /* paranoid */ verifyf( readyThread->state == Ready || readyThread->preempted != __NO_PREEMPTION, "state : %d, preempted %d\n", readyThread->state, readyThread->preempted); 343 343 /* paranoid */ verifyf( readyThread->link.next == 0p, "Expected null got %p", readyThread->link.next ); 344 __builtin_prefetch( readyThread->context.SP ); 344 345 345 346 // We found a thread run it -
libcfa/src/concurrency/ready_queue.cfa
r37ba662 r04b5cef 24 24 #include "math.hfa" 25 25 26 #include <unistd.h> 27 26 28 static const size_t cache_line_size = 64; 27 29 … … 31 33 #define __CFA_MAX_PROCESSORS__ 1024 32 34 #endif 35 36 #define BIAS 64 33 37 34 38 // returns the maximum number of processors the RWLock support … … 568 572 do { 569 573 // Pick the index of a lane 570 i = __tls_rand() % lanes.count; 574 #if defined(BIAS) 575 unsigned r = __tls_rand(); 576 unsigned rlow = r % BIAS; 577 unsigned rhigh = r / BIAS; 578 if(0 != (rlow % BIAS) && kernelTLS.this_processor) { 579 // (BIAS - 1) out of BIAS chances 580 // Use perferred queues 581 i = (kernelTLS.this_processor->id * 4) + (rhigh % 4); 582 } 583 else { 584 // 1 out of BIAS chances 585 // Use all queues 586 i = rhigh; 587 } 588 #else 589 i = __tls_rand(); 590 #endif 591 592 i %= __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); 571 593 572 594 #if !defined(__CFA_NO_STATISTICS__) … … 666 688 while( query(snzi) ) { 667 689 // Pick two lists at random 668 int i = __tls_rand() % __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); 669 int j = __tls_rand() % __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); 690 #if defined(BIAS) 691 unsigned i = __tls_rand(); 692 unsigned j = __tls_rand(); 693 694 if(0 == (i % BIAS)) { 695 i = i / BIAS; 696 } 697 else { 698 i = ((kernelTLS.this_processor->id * 4) + ((i / BIAS) % 4)); 699 j = ((kernelTLS.this_processor->id * 4) + ((j / BIAS) % 4)); 700 } 701 #else 702 unsigned i = __tls_rand(); 703 unsigned j = __tls_rand(); 704 #endif 705 706 i %= __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); 707 j %= __atomic_load_n( &lanes.count, __ATOMIC_RELAXED ); 670 708 671 709 // try popping from the 2 picked lists
Note: See TracChangeset
for help on using the changeset viewer.