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