source: benchmark/readyQ/yield.cfa @ 9cf2b0f

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since 9cf2b0f was 9cf2b0f, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Updated yield benchmarks to be more consistents.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include "rq_bench.hfa"
2
3extern bool traceHeapOn();
4
5
6volatile bool run = false;
7volatile unsigned long long global_counter;
8
9thread __attribute__((aligned(128))) Yielder {
10        unsigned long long counter;
11};
12void ?{}( Yielder & this ) {
13        this.counter = 0;
14        ((thread&)this){ "Yielder Thread" };
15}
16
17void main( Yielder & this ) {
18        park();
19        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
20
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);
26}
27
28int main(int argc, char * argv[]) {
29        cfa_option opt[] = {
30                BENCH_OPT
31        };
32        BENCH_OPT_PARSE("cforall yield benchmark");
33
34        {
35                printf("Running %d threads on %d processors for %f seconds\n", nthreads, nprocs, duration);
36
37                Time start, end;
38                BenchCluster bc = { nprocs };
39                {
40                        Yielder threads[nthreads];
41                        printf("Starting\n");
42
43                        bool is_tty = isatty(STDOUT_FILENO);
44                        start = timeHiRes();
45                        run = true;
46
47                        for(i; nthreads) {
48                                unpark( threads[i] );
49                        }
50                        wait(start, is_tty);
51
52                        run = false;
53                        end = timeHiRes();
54                        printf("\nDone\n");
55                }
56
57                printf("Duration (ms)        : %'ld\n", (end - start)`dms);
58                printf("Number of processors : %'d\n", nprocs);
59                printf("Number of threads    : %'d\n", nthreads);
60                printf("Total Operations(ops): %'15llu\n", global_counter);
61                printf("Ops per second       : %'18.2lf\n", ((double)global_counter) / (end - start)`s);
62                printf("ns per ops           : %'18.2lf\n", (end - start)`dns / global_counter);
63                printf("Ops per threads      : %'15llu\n", global_counter / nthreads);
64                printf("Ops per procs        : %'15llu\n", global_counter / nprocs);
65                printf("Ops/sec/procs        : %'18.2lf\n", (((double)global_counter) / nprocs) / (end - start)`s);
66                printf("ns per ops/procs     : %'18.2lf\n", (end - start)`dns / (global_counter / nprocs));
67                fflush(stdout);
68        }
69}
Note: See TracBrowser for help on using the repository browser.