source: benchmark/readyQ/yield.cfa @ f835806

ADTast-experimentalpthread-emulationqualifiedEnum
Last change on this file since f835806 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
RevLine 
[9cf2b0f]1#include "rq_bench.hfa"
[2649ff9]2
[04b5cef]3thread __attribute__((aligned(128))) Yielder {
[8197ca5]4        unsigned long long count;
[2649ff9]5};
6void ?{}( Yielder & this ) {
[8197ca5]7        ((thread&)this){ "Yielder Thread", bench_cluster };
8        this.count = 0;
[2649ff9]9}
10
11void main( Yielder & this ) {
[e235429]12        park();
[8197ca5]13        for() {
[2649ff9]14                yield();
[8197ca5]15                this.count++;
16                if( clock_mode && stop) break;
17                if(!clock_mode && this.count >= stop_count) break;
[2649ff9]18        }
[8197ca5]19
20        __atomic_fetch_add(&threads_left, -1, __ATOMIC_SEQ_CST);
[2649ff9]21}
22
23int main(int argc, char * argv[]) {
[5bcdc8c]24        cfa_option opt[] = {
[9cf2b0f]25                BENCH_OPT
[5bcdc8c]26        };
[9cf2b0f]27        BENCH_OPT_PARSE("cforall yield benchmark");
[2649ff9]28
29        {
[8197ca5]30                unsigned long long global_counter = 0;
[2649ff9]31
32                Time start, end;
[9cf2b0f]33                BenchCluster bc = { nprocs };
[2649ff9]34                {
[8197ca5]35                        threads_left = nthreads;
[9cf2b0f]36                        Yielder threads[nthreads];
37                        printf("Starting\n");
[9791ab5]38
[9cf2b0f]39                        bool is_tty = isatty(STDOUT_FILENO);
40                        start = timeHiRes();
[2649ff9]41
[9cf2b0f]42                        for(i; nthreads) {
43                                unpark( threads[i] );
[2649ff9]44                        }
[9cf2b0f]45                        wait(start, is_tty);
46
[8197ca5]47                        stop = true;
[9cf2b0f]48                        end = timeHiRes();
49                        printf("\nDone\n");
[8197ca5]50
51                        for(i; nthreads) {
52                                Yielder & y = join( threads[i] );
53                                global_counter += y.count;
54                        }
[2649ff9]55                }
56
[9cf2b0f]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));
[b813f53]67                fflush(stdout);
[2649ff9]68        }
[e54d0c3]69}
Note: See TracBrowser for help on using the repository browser.