Changes in / [298fe57:4cb1a24]
- Location:
- benchmark
- Files:
-
- 1 added
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Cargo.toml.in
r298fe57 r4cb1a24 4 4 authors = ["Cforall"] 5 5 edition = "2018" 6 7 [[bin]] 8 name = "rdq-churn-tokio" 9 path = "@abs_srcdir@/readyQ/churn.rs" 6 10 7 11 [[bin]] -
benchmark/Makefile.am
r298fe57 r4cb1a24 614 614 RDQBENCHES = \ 615 615 rdq-churn-cfa \ 616 rdq-churn-tokio \ 617 rdq-churn-go \ 618 rdq-churn-fibre \ 616 619 rdq-cycle-cfa \ 617 620 rdq-cycle-tokio \ -
benchmark/readyQ/churn.cfa
r298fe57 r4cb1a24 1 1 #include "rq_bench.hfa" 2 2 3 #include <locks.hfa> 4 3 5 unsigned spot_cnt = 2; 4 bench_sem * volatile * spots;6 semaphore * spots; 5 7 6 8 thread BThrd { 7 9 unsigned long long count; 8 10 unsigned long long blocks; 9 b ench_sem sem;11 bool skip; 10 12 }; 11 13 … … 14 16 this.count = 0; 15 17 this.blocks = 0; 18 this.skip = false; 16 19 } 17 20 … … 19 22 20 23 void main( BThrd & this ) with( this ) { 21 wait( sem);24 park(); 22 25 for() { 23 uint32_t r = prng(); 24 bench_sem * next = __atomic_exchange_n(&spots[r % spot_cnt], &sem, __ATOMIC_SEQ_CST); 25 if(next) post( *next ); 26 blocks += wait( sem ); 26 uint32_t r = prng(this); 27 semaphore & sem = spots[r % spot_cnt]; 28 if(!skip) V( sem ); 29 blocks += P( sem ); 30 skip = false; 31 27 32 count ++; 28 33 if( clock_mode && stop) break; … … 49 54 spots = aalloc(spot_cnt); 50 55 for(i; spot_cnt) { 51 spots[i] = 0p;56 (spots[i]){ 0 }; 52 57 } 53 58 … … 55 60 BThrd * threads[nthreads]; 56 61 for(i; nthreads ) { 57 threads[i] = malloc(); 58 (*threads[i]){}; 62 BThrd & t = *(threads[i] = malloc()); 63 (t){}; 64 t.skip = i < spot_cnt; 59 65 } 60 66 printf("Starting\n"); … … 64 70 65 71 for(i; nthreads) { 66 post( threads[i]->sem);72 unpark( *threads[i] ); 67 73 } 68 74 wait(start, is_tty); … … 72 78 printf("\nDone\n"); 73 79 80 for(i; spot_cnt) { 81 for(10000) V( spots[i] ); 82 } 83 74 84 for(i; nthreads) { 75 post( threads[i]->sem );76 85 BThrd & thrd = join( *threads[i] ); 77 86 global_counter += thrd.count;
Note: See TracChangeset
for help on using the changeset viewer.