Changeset 8197ca5


Ignore:
Timestamp:
May 4, 2022, 11:58:59 AM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
1f4fde5, 3b80db8, 7ad47df
Parents:
9cf2b0f
Message:

Update yield.cfa to be more consistent with other benchmarks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/yield.cfa

    r9cf2b0f r8197ca5  
    11#include "rq_bench.hfa"
    22
    3 extern bool traceHeapOn();
    4 
    5 
    6 volatile bool run = false;
    7 volatile unsigned long long global_counter;
    8 
    93thread __attribute__((aligned(128))) Yielder {
    10         unsigned long long counter;
     4        unsigned long long count;
    115};
    126void ?{}( Yielder & this ) {
    13         this.counter = 0;
    14         ((thread&)this){ "Yielder Thread" };
     7        ((thread&)this){ "Yielder Thread", bench_cluster };
     8        this.count = 0;
    159}
    1610
    1711void main( Yielder & this ) {
    1812        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        }
    2019
    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);
    2621}
    2722
     
    3328
    3429        {
    35                 printf("Running %d threads on %d processors for %f seconds\n", nthreads, nprocs, duration);
     30                unsigned long long global_counter = 0;
    3631
    3732                Time start, end;
    3833                BenchCluster bc = { nprocs };
    3934                {
     35                        threads_left = nthreads;
    4036                        Yielder threads[nthreads];
    4137                        printf("Starting\n");
     
    4339                        bool is_tty = isatty(STDOUT_FILENO);
    4440                        start = timeHiRes();
    45                         run = true;
    4641
    4742                        for(i; nthreads) {
     
    5045                        wait(start, is_tty);
    5146
    52                         run = false;
     47                        stop = true;
    5348                        end = timeHiRes();
    5449                        printf("\nDone\n");
     50
     51                        for(i; nthreads) {
     52                                Yielder & y = join( threads[i] );
     53                                global_counter += y.count;
     54                        }
    5555                }
    5656
Note: See TracChangeset for help on using the changeset viewer.