source: benchmark/readyQ/yield.cfa @ c715e5f

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since c715e5f was 8197ca5, checked in by Thierry Delisle <tdelisle@…>, 2 years ago

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

  • Property mode set to 100644
File size: 1.8 KB
Line 
1#include "rq_bench.hfa"
2
3thread __attribute__((aligned(128))) Yielder {
4        unsigned long long count;
5};
6void ?{}( Yielder & this ) {
7        ((thread&)this){ "Yielder Thread", bench_cluster };
8        this.count = 0;
9}
10
11void main( Yielder & this ) {
12        park();
13        for() {
14                yield();
15                this.count++;
16                if( clock_mode && stop) break;
17                if(!clock_mode && this.count >= stop_count) break;
18        }
19
20        __atomic_fetch_add(&threads_left, -1, __ATOMIC_SEQ_CST);
21}
22
23int main(int argc, char * argv[]) {
24        cfa_option opt[] = {
25                BENCH_OPT
26        };
27        BENCH_OPT_PARSE("cforall yield benchmark");
28
29        {
30                unsigned long long global_counter = 0;
31
32                Time start, end;
33                BenchCluster bc = { nprocs };
34                {
35                        threads_left = nthreads;
36                        Yielder threads[nthreads];
37                        printf("Starting\n");
38
39                        bool is_tty = isatty(STDOUT_FILENO);
40                        start = timeHiRes();
41
42                        for(i; nthreads) {
43                                unpark( threads[i] );
44                        }
45                        wait(start, is_tty);
46
47                        stop = true;
48                        end = timeHiRes();
49                        printf("\nDone\n");
50
51                        for(i; nthreads) {
52                                Yielder & y = join( threads[i] );
53                                global_counter += y.count;
54                        }
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.