Changeset 4069faad for benchmark/io


Ignore:
Timestamp:
May 1, 2020, 12:37:30 PM (5 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:
d45ed83
Parents:
9987d79
Message:

Fix error in benchmark where the wrong fd was used.
Changed behcnmark to use seperate cluster for I/O.
Changed some debug prints to use new versions with groups.
Fixed halting race condition leading to deadlock.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified benchmark/io/readv.cfa

    r9987d79 r4069faad  
    3030unsigned long int buflen = 50;
    3131
     32cluster * the_cluster;
     33
    3234thread Reader {};
     35void ?{}( Reader & this ) {
     36        ((thread&)this){ "Reader Thread", *the_cluster };
     37}
     38
     39struct my_processor {
     40        processor p;
     41};
     42
     43void ?{}( my_processor & this ) {
     44        (this.p){ "I/O Processor", *the_cluster };
     45}
     46
    3347void main( Reader & ) {
    3448        while(!__atomic_load_n(&run, __ATOMIC_RELAXED)) yield();
     
    3852
    3953        while(__atomic_load_n(&run, __ATOMIC_RELAXED)) {
    40                 cfa_preadv2(fd, &iov, 1, 0, 0);
     54                int r = cfa_preadv2(fd, &iov, 1, 0, 0);
     55                if(r < 0) abort(strerror(-r));
     56
    4157                __atomic_fetch_add( &count, 1, __ATOMIC_SEQ_CST );
    4258        }
     
    4460
    4561int main(int argc, char * argv[]) {
    46         #if !defined(__CFA_NO_STATISTICS__)
    47                 print_stats_at_exit( *active_cluster() );
    48         #endif
    49 
    5062        double duration   = 5.0;
    5163        unsigned long int nthreads = 2;
     
    117129        }
    118130
    119         int fd = open(__FILE__, 0);
     131        fd = open(__FILE__, 0);
    120132        if(fd < 0) {
    121133                fprintf(stderr, "Could not open source file\n");
     
    125137        printf("Running %lu threads over %lu processors for %lf seconds\n", nthreads, nprocs, duration);
    126138
    127         Time start, end;
    128139        {
    129                 processor procs[nprocs - 1];
     140                Time start, end;
     141                cluster cl = { "IO Cluster" };
     142                the_cluster = &cl;
     143                #if !defined(__CFA_NO_STATISTICS__)
     144                        print_stats_at_exit( cl );
     145                #endif
    130146                {
    131                         Reader threads[nthreads];
     147                        my_processor procs[nprocs];
     148                        {
     149                                Reader threads[nthreads];
    132150
    133                         printf("Starting\n");
    134                         start = getTime();
    135                         run = true;
    136                         do {
    137                                 sleep(500`ms);
     151                                printf("Starting\n");
     152                                start = getTime();
     153                                run = true;
     154                                do {
     155                                        sleep(500`ms);
     156                                        end = getTime();
     157                                } while( (end - start) < duration`s );
     158                                run = false;
    138159                                end = getTime();
    139                         } while( (end - start) < duration`s );
    140                         run = false;
    141                         end = getTime();
     160                                printf("Done\n");
     161                        }
    142162                }
     163                printf("Took %ld ms\n", (end - start)`ms);
     164                printf("Total reads:      %'zu\n", count);
     165                printf("Reads per second: %'lf\n", ((double)count) / (end - start)`s);
    143166        }
    144         printf("Took %ld ms\n", (end - start)`ms);
    145         printf("Total reads:      %'zu\n", count);
    146         printf("Reads per second: %'lf\n", ((double)count) / (end - start)`s);
    147167
    148168        close(fd);
    149         printf("Done\n");
    150169}
Note: See TracChangeset for help on using the changeset viewer.