Ignore:
Timestamp:
May 20, 2022, 10:36:45 AM (4 years ago)
Author:
m3zulfiq <m3zulfiq@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
25fa20a
Parents:
29d8c02 (diff), 7831e8fb (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/churn.cfa

    r29d8c02 r74ec742  
    11#include "rq_bench.hfa"
    22
     3#include <locks.hfa>
     4
    35unsigned spot_cnt = 2;
    4 bench_sem * volatile * spots;
     6semaphore * spots;
    57
    68thread BThrd {
    79        unsigned long long count;
    810        unsigned long long blocks;
    9         bench_sem sem;
     11        bool skip;
    1012};
    1113
     
    1416        this.count  = 0;
    1517        this.blocks = 0;
     18        this.skip = false;
    1619}
    1720
     
    1922
    2023void main( BThrd & this ) with( this ) {
    21         wait( sem );
     24        park();
    2225        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
    2732                count ++;
    2833                if( clock_mode && stop) break;
     
    3944                { 's', "spots", "Number of spots in the system", spot_cnt }
    4045        };
    41         BENCH_OPT_PARSE("cforall cycle benchmark");
     46        BENCH_OPT_PARSE("cforall churn benchmark");
    4247
    4348        {
     
    4954                        spots = aalloc(spot_cnt);
    5055                        for(i; spot_cnt) {
    51                                 spots[i] = 0p;
     56                                (spots[i]){ 0 };
    5257                        }
    5358
     
    5560                        BThrd * threads[nthreads];
    5661                        for(i; nthreads ) {
    57                                 threads[i] = malloc();
    58                                 (*threads[i]){};
     62                                BThrd & t = *(threads[i] = malloc());
     63                                (t){};
     64                                t.skip = i < spot_cnt;
    5965                        }
    6066                        printf("Starting\n");
     
    6470
    6571                        for(i; nthreads) {
    66                                 post( threads[i]->sem );
     72                                unpark( *threads[i] );
    6773                        }
    6874                        wait(start, is_tty);
     
    7278                        printf("\nDone\n");
    7379
     80                        for(i; spot_cnt) {
     81                                for(10000) V( spots[i] );
     82                        }
     83
    7484                        for(i; nthreads) {
    75                                 post( threads[i]->sem );
    7685                                BThrd & thrd = join( *threads[i] );
    7786                                global_counter += thrd.count;
Note: See TracChangeset for help on using the changeset viewer.