- Timestamp:
- May 4, 2022, 11:58:59 AM (3 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 1f4fde5, 3b80db8, 7ad47df
- Parents:
- 9cf2b0f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/yield.cfa
r9cf2b0f r8197ca5 1 1 #include "rq_bench.hfa" 2 2 3 extern bool traceHeapOn();4 5 6 volatile bool run = false;7 volatile unsigned long long global_counter;8 9 3 thread __attribute__((aligned(128))) Yielder { 10 unsigned long long count er;4 unsigned long long count; 11 5 }; 12 6 void ?{}( Yielder & this ) { 13 this.counter = 0;14 ((thread&)this){ "Yielder Thread" };7 ((thread&)this){ "Yielder Thread", bench_cluster }; 8 this.count = 0; 15 9 } 16 10 17 11 void main( Yielder & this ) { 18 12 park(); 19 /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) ); 13 for() { 14 yield(); 15 this.count++; 16 if( clock_mode && stop) break; 17 if(!clock_mode && this.count >= stop_count) break; 18 } 20 19 21 while(__atomic_load_n(&run, __ATOMIC_RELAXED)) { 22 yield(); 23 this.counter++; 24 } 25 __atomic_fetch_add(&global_counter, this.counter, __ATOMIC_SEQ_CST); 20 __atomic_fetch_add(&threads_left, -1, __ATOMIC_SEQ_CST); 26 21 } 27 22 … … 33 28 34 29 { 35 printf("Running %d threads on %d processors for %f seconds\n", nthreads, nprocs, duration);30 unsigned long long global_counter = 0; 36 31 37 32 Time start, end; 38 33 BenchCluster bc = { nprocs }; 39 34 { 35 threads_left = nthreads; 40 36 Yielder threads[nthreads]; 41 37 printf("Starting\n"); … … 43 39 bool is_tty = isatty(STDOUT_FILENO); 44 40 start = timeHiRes(); 45 run = true;46 41 47 42 for(i; nthreads) { … … 50 45 wait(start, is_tty); 51 46 52 run = false;47 stop = true; 53 48 end = timeHiRes(); 54 49 printf("\nDone\n"); 50 51 for(i; nthreads) { 52 Yielder & y = join( threads[i] ); 53 global_counter += y.count; 54 } 55 55 } 56 56
Note: See TracChangeset
for help on using the changeset viewer.