Changeset 04b5cef
- 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
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/yield.cfa
r37ba662 r04b5cef 22 22 volatile unsigned long long global_counter; 23 23 24 thread __attribute__((aligned( 64))) Yielder {24 thread __attribute__((aligned(128))) Yielder { 25 25 unsigned long long counter; 26 26 }; … … 113 113 { 114 114 Yielder threads[nthreads]; 115 bool is_tty = isatty(STDOUT_FILENO); 115 116 printf("Starting\n"); 116 117 start = getTime(); 117 118 run = true; 118 119 119 bool is_tty = isatty(STDOUT_FILENO);120 120 for(i; nthreads) { 121 121 unpark( threads[i] __cfaabi_dbg_ctx2 ); -
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 -
libcfa/src/containers/stackLockFree.hfa
r37ba662 r04b5cef 1 // 1 // 2 2 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 3 3 // The contents of this file are covered under the licence agreement in the 4 4 // file "LICENCE" distributed with Cforall. 5 5 // 6 // stackLockFree.hfa -- 7 // 6 // stackLockFree.hfa -- 7 // 8 8 // Author : Peter A. Buhr 9 9 // Created On : Wed May 13 20:58:58 2020 … … 11 11 // Last Modified On : Mon May 18 13:30:08 2020 12 12 // Update Count : 55 13 // 13 // 14 14 15 15 #pragma once … … 20 20 union Link { 21 21 struct { // 32/64-bit x 2 22 T * top; // pointer to stack top22 T * volatile top; // pointer to stack top 23 23 uintptr_t count; // count each push 24 24 };
Note: See TracChangeset
for help on using the changeset viewer.