Changeset 9791ab5 for benchmark/io


Ignore:
Timestamp:
Jun 24, 2020, 4:57:42 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8b58bae
Parents:
564148f
Message:

Harmonized readv and yield benchmark

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/readv.cfa

    r564148f r9791ab5  
    1717#include <time.hfa>
    1818
     19#include "../benchcltr.hfa"
     20
    1921extern bool traceHeapOn();
    2022extern ssize_t cfa_preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);
     
    2628unsigned long int buflen = 50;
    2729
    28 cluster * the_cluster;
    29 
    30 thread Reader {};
     30thread __attribute__((aligned(128))) Reader {};
    3131void ?{}( Reader & this ) {
    32         ((thread&)this){ "Reader Thread", *the_cluster };
    33 }
    34 
    35 struct my_processor {
    36         processor p;
    37 };
    38 
    39 void ?{}( my_processor & this ) {
    40         (this.p){ "I/O Processor", *the_cluster };
     32        ((thread&)this){ "Reader Thread", *the_benchmark_cluster };
    4133}
    4234
    4335void main( Reader & ) {
    44         while(!__atomic_load_n(&run, __ATOMIC_RELAXED)) yield();
     36        park( __cfaabi_dbg_ctx );
     37        /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) );
    4538
    4639        char data[buflen];
     
    153146        {
    154147                Time start, end;
    155                 cluster cl = { "IO Cluster", flags };
    156                 the_cluster = &cl;
     148                BenchCluster cl = { flags };
    157149                #if !defined(__CFA_NO_STATISTICS__)
    158                         print_stats_at_exit( cl );
     150                        print_stats_at_exit( cl.self );
    159151                #endif
    160152                {
    161                         my_processor procs[nprocs];
     153                        BenchProc procs[nprocs];
    162154                        {
    163155                                Reader threads[nthreads];
    164156
    165157                                printf("Starting\n");
     158                                bool is_tty = isatty(STDOUT_FILENO);
    166159                                start = getTime();
    167160                                run = true;
    168                                 do {
    169                                         sleep(500`ms);
    170                                         end = getTime();
    171                                 } while( (end - start) < duration`s );
     161
     162                                for(i; nthreads) {
     163                                        unpark( threads[i] __cfaabi_dbg_ctx2 );
     164                                }
     165                                wait(duration, start, end, is_tty);
     166
    172167                                run = false;
    173168                                end = getTime();
    174                                 printf("Done\n");
     169                                printf("\nDone\n");
    175170                        }
    176171                }
Note: See TracChangeset for help on using the changeset viewer.