Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/cycle.cfa

    rb5d51b0 r7a2a3af  
    11#include "rq_bench.hfa"
    22
    3 struct Partner {
     3thread Partner {
     4        Partner * partner;
    45        unsigned long long count;
    5         unsigned long long blocks;
    6         bench_sem self;
    7         bench_sem * next;
    86};
    97
    108void ?{}( Partner & this ) {
    11         this.count = this.blocks = 0;
     9        ((thread&)this){ bench_cluster };
    1210}
    1311
    14 thread BThrd {
    15         Partner & partner;
    16 };
    17 
    18 void ?{}( BThrd & this, Partner * partner ) {
    19         ((thread&)this){ bench_cluster };
    20         &this.partner = partner;
    21 }
    22 
    23 void ^?{}( BThrd & mutex this ) {}
    24 
    25 void main( BThrd & thrd ) with(thrd.partner) {
    26         count = 0;
     12void main( Partner & this ) {
     13        this.count = 0;
    2714        for() {
    28                 blocks += wait( self );
    29                 post( *next );
    30                 count ++;
     15                park();
     16                unpark( *this.partner );
     17                this.count ++;
    3118                if( clock_mode && stop) break;
    32                 if(!clock_mode && count >= stop_count) break;
     19                if(!clock_mode && this.count >= stop_count) break;
    3320        }
    3421
     
    4633        {
    4734                unsigned long long global_counter = 0;
    48                 unsigned long long global_blocks  = 0;
    4935                unsigned tthreads = nthreads * ring_size;
    5036                Time start, end;
     
    5238                {
    5339                        threads_left = tthreads;
    54                         BThrd * threads[tthreads];
    55                         Partner thddata[tthreads];
     40                        Partner threads[tthreads];
    5641                        for(i; tthreads) {
    5742                                unsigned pi = (i + nthreads) % tthreads;
    58                                 thddata[i].next = &thddata[pi].self;
    59                         }
    60                         for(int i = 0; i < tthreads; i++) {
    61                                 threads[i] = malloc();
    62                                 (*threads[i]){ &thddata[i] };
     43                                threads[i].partner = &threads[pi];
    6344                        }
    6445                        printf("Starting\n");
     
    6849
    6950                        for(i; nthreads) {
    70                                 post( thddata[i].self );
     51                                unpark( threads[i] );
    7152                        }
    7253                        wait(start, is_tty);
     
    7758
    7859                        for(i; tthreads) {
    79                                 Partner & partner = join( *threads[i] ).partner;
    80                                 global_counter += partner.count;
    81                                 global_blocks  += partner.blocks;
    82                                 delete(threads[i]);
     60                                global_counter += join( threads[i] ).count;
    8361                        }
    8462                }
    8563
    86                 printf("Duration (ms)        : %'ld\n", (end - start)`dms);
    87                 printf("Number of processors : %'d\n", nprocs);
    88                 printf("Number of threads    : %'d\n", tthreads);
    89                 printf("Cycle size (# thrds) : %'d\n", ring_size);
    90                 printf("Total Operations(ops): %'15llu\n", global_counter);
    91                 printf("Total blocks         : %'15llu\n", global_blocks);
    92                 printf("Ops per second       : %'18.2lf\n", ((double)global_counter) / (end - start)`ds);
    93                 printf("ns per ops           : %'18.2lf\n", (end - start)`dns / global_counter);
    94                 printf("Ops per threads      : %'15llu\n", global_counter / tthreads);
    95                 printf("Ops per procs        : %'15llu\n", global_counter / nprocs);
    96                 printf("Ops/sec/procs        : %'18.2lf\n", (((double)global_counter) / nprocs) / (end - start)`ds);
    97                 printf("ns per ops/procs     : %'18.2lf\n", (end - start)`dns / (global_counter / nprocs));
     64                printf("Duration (ms)       : %'ld\n", (end - start)`ms);
     65                printf("Number of processors: %'d\n", nprocs);
     66                printf("Number of threads   : %'d\n", tthreads);
     67                printf("Cycle size (# thrds): %'d\n", ring_size);
     68                printf("Yields per second   : %'18.2lf\n", ((double)global_counter) / (end - start)`s);
     69                printf("ns per yields       : %'18.2lf\n", ((double)(end - start)`ns) / global_counter);
     70                printf("Total yields        : %'15llu\n", global_counter);
     71                printf("Yields per threads  : %'15llu\n", global_counter / tthreads);
     72                printf("Yields per procs    : %'15llu\n", global_counter / nprocs);
     73                printf("Yields/sec/procs    : %'18.2lf\n", (((double)global_counter) / nprocs) / (end - start)`s);
     74                printf("ns per yields/procs : %'18.2lf\n", ((double)(end - start)`ns) / (global_counter / nprocs));
    9875                fflush(stdout);
    9976        }
Note: See TracChangeset for help on using the changeset viewer.