Changes in / [f55f110:a77f25b]
- Location:
- libcfa/src/concurrency
- Files:
-
- 2 edited
-
kernel.hfa (modified) (2 diffs)
-
ready_queue.cfa (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/kernel.hfa
rf55f110 ra77f25b 68 68 unsigned last; 69 69 signed cpu; 70 // unsigned long long int cutoff; 70 71 } rdq; 71 72 … … 153 154 }; 154 155 155 struct __attribute__((aligned(1 6))) __cache_id_t {156 struct __attribute__((aligned(128))) __cache_id_t { 156 157 volatile unsigned id; 157 158 }; -
libcfa/src/concurrency/ready_queue.cfa
rf55f110 ra77f25b 303 303 lanes.help[idx].dst = 0; 304 304 lanes.help[idx].tri = 0; 305 } 306 307 caches = alloc( cpu_info.llc_count ); 308 for( idx; (size_t)cpu_info.llc_count ) { 309 (caches[idx]){}; 305 310 } 306 311 #else … … 399 404 /* paranoid */ verify(cpu < cpu_info.hthrd_count); 400 405 unsigned this_cache = cpu_info.llc_map[cpu].cache; 401 402 // Super important: don't write the same value over and over again 403 // We want to maximise our chances that his particular values stays in cache 404 if(lanes.caches[this / READYQ_SHARD_FACTOR].id != this_cache) 405 __atomic_store_n(&lanes.caches[this / READYQ_SHARD_FACTOR].id, this_cache, __ATOMIC_RELAXED); 406 __atomic_store_n(&lanes.caches[this / READYQ_SHARD_FACTOR].id, this_cache, __ATOMIC_RELAXED); 406 407 407 408 const unsigned long long ctsc = rdtscl(); … … 505 506 } 506 507 508 static inline int pop_getcpu(processor * proc, __ready_queue_caches_t * caches) { 509 const int prv = proc->rdq.cpu; 510 const int cpu = __kernel_getcpu(); 511 if( prv != proc->rdq.cpu ) { 512 unsigned pidx = cpu_info.llc_map[prv].cache; 513 /* paranoid */ verify(pidx < cpu_info.llc_count); 514 515 unsigned nidx = cpu_info.llc_map[cpu].cache; 516 /* paranoid */ verify(pidx < cpu_info.llc_count); 517 518 depart(caches[pidx]); 519 arrive(caches[nidx]); 520 521 __STATS( /* cpu migs++ */ ) 522 } 523 return proc->rdq.cpu = cpu; 524 } 525 507 526 // Pop from the ready queue from a given cluster 508 527 __attribute__((hot)) thread$ * pop_fast(struct cluster * cltr) with (cltr->ready_queue) { … … 511 530 512 531 processor * const proc = kernelTLS().this_processor; 513 const int cpu = __kernel_getcpu(); 532 const int cpu = pop_getcpu( proc, caches ); 533 // const int cpu = __kernel_getcpu(); 514 534 /* paranoid */ verify(cpu >= 0); 515 535 /* paranoid */ verify(cpu < cpu_info.hthrd_count); … … 528 548 unsigned long long max = 0; 529 549 for(i; READYQ_SHARD_FACTOR) { 530 unsigned long long tsc = moving_average(ctsc ,ts(lanes.data[start + i]), lanes.tscs[start + i].ma);550 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma); 531 551 if(tsc > max) max = tsc; 532 552 } … … 549 569 unsigned long long max = 0; 550 570 for(i; READYQ_SHARD_FACTOR) { 551 unsigned long long tsc = moving_average(ctsc ,ts(lanes.data[start + i]), lanes.tscs[start + i].ma);571 unsigned long long tsc = moving_average(ctsc - ts(lanes.data[start + i]), lanes.tscs[start + i].ma); 552 572 if(tsc > max) max = tsc; 553 573 } … … 557 577 proc->rdq.target = MAX; 558 578 lanes.help[target / READYQ_SHARD_FACTOR].tri++; 559 if(moving_average(ctsc, lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) { 579 if(moving_average(ctsc - lanes.tscs[target].tv, lanes.tscs[target].ma) > cutoff) { 580 __STATS( __tls_stats()->ready.pop.helped[target]++; ) 560 581 thread$ * t = try_pop(cltr, target __STATS(, __tls_stats()->ready.pop.help)); 561 582 proc->rdq.last = target; … … 566 587 567 588 unsigned last = proc->rdq.last; 568 if(last != MAX && moving_average(ctsc, lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) { 589 if(last != MAX && moving_average(ctsc - lanes.tscs[last].tv, lanes.tscs[last].ma) > cutoff) { 590 __STATS( __tls_stats()->ready.pop.helped[last]++; ) 569 591 thread$ * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.help)); 570 592 if(t) return t;
Note:
See TracChangeset
for help on using the changeset viewer.