Changeset 953827a
- Timestamp:
- Jun 21, 2021, 3:42:47 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 6ba6846, 929d925
- Parents:
- 5614552a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/ready_queue.cfa
r5614552a r953827a 20 20 21 21 22 #define USE_RELAXED_FIFO22 // #define USE_RELAXED_FIFO 23 23 // #define USE_WORK_STEALING 24 #define USE_CPU_WORK_STEALING 24 25 25 26 #include "bits/defs.hfa" … … 341 342 } 342 343 proc->rdq.cutoff = min; 343 proc->rdq.target = (map.start * READYQ_SHARD_FACTOR) + (__tls_rand() % (map.count* READYQ_SHARD_FACTOR)); 344 345 /* paranoid */ verify(lanes.count < 65536); // The following code assumes max 65536 cores. 346 /* paranoid */ verify(map.count < 65536); // The following code assumes max 65536 cores. 347 uint64_t chaos = __tls_rand(); 348 uint64_t high_chaos = (chaos >> 32); 349 uint64_t mid_chaos = (chaos >> 16) & 0xffff; 350 uint64_t low_chaos = chaos & 0xffff; 351 352 unsigned me = map.self; 353 unsigned cpu_chaos = map.start + (mid_chaos % map.count); 354 bool global = cpu_chaos == me; 355 356 if(global) { 357 proc->rdq.target = high_chaos % lanes.count; 358 } else { 359 proc->rdq.target = (cpu_chaos * READYQ_SHARD_FACTOR) + (low_chaos % READYQ_SHARD_FACTOR); 360 /* paranoid */ verify(proc->rdq.target >= (map.start * READYQ_SHARD_FACTOR)); 361 /* paranoid */ verify(proc->rdq.target < ((map.start + map.count) * READYQ_SHARD_FACTOR)); 362 } 363 364 /* paranoid */ verify(proc->rdq.target != -1u); 344 365 } 345 366 else { … … 378 399 processor * const proc = kernelTLS().this_processor; 379 400 unsigned last = proc->rdq.last; 401 if(last != -1u) { 402 struct $thread * t = try_pop(cltr, last __STATS(, __tls_stats()->ready.pop.steal)); 403 if(t) return t; 404 proc->rdq.last = -1u; 405 } 380 406 381 407 unsigned i = __tls_rand() % lanes.count;
Note: See TracChangeset
for help on using the changeset viewer.