Ignore:
Timestamp:
Jun 25, 2020, 2:57:39 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:
ec21f13
Parents:
566fde0
Message:

Moved common code of benchmarks to benchcltr.hfa

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/io/readv.cfa

    r566fde0 rcb85603  
    5050
    5151int main(int argc, char * argv[]) {
    52         double duration   = 5.0;
    53         unsigned long int nthreads = 2;
    54         unsigned long int nprocs   = 1;
    55         bool silent = false;
    56         bool procstats = false;
     52        BENCH_DECL
    5753        unsigned flags = 0;
    5854        unsigned sublen = 16;
     
    6157        for(;;) {
    6258                static struct option options[] = {
    63                         {"duration",     required_argument, 0, 'd'},
    64                         {"nthreads",     required_argument, 0, 't'},
    65                         {"nprocs",       required_argument, 0, 'p'},
    66                         {"nostats",      no_argument      , 0, 'S'},
    67                         {"procstat",     no_argument      , 0, 'P'},
     59                        BENCH_OPT_LONG
    6860                        {"bufsize",      required_argument, 0, 'b'},
    6961                        {"userthread",   no_argument      , 0, 'u'},
     
    7466
    7567                int idx = 0;
    76                 int opt = getopt_long(argc, argv, "d:t:p:SPb:usl:", options, &idx);
     68                int opt = getopt_long(argc, argv, BENCH_OPT_SHORT "b:usl:", options, &idx);
    7769
    7870                const char * arg = optarg ? optarg : "";
     
    8274                        case -1:
    8375                                break arg_loop;
    84                         // Numeric Arguments
    85                         case 'd':
    86                                 duration = strtod(arg, &end);
    87                                 if(*end != '\0') {
    88                                         fprintf(stderr, "Duration must be a valid double, was %s\n", arg);
    89                                         goto usage;
    90                                 }
    91                                 break;
    92                         case 't':
    93                                 nthreads = strtoul(arg, &end, 10);
    94                                 if(*end != '\0' || nthreads < 1) {
    95                                         fprintf(stderr, "Number of threads must be a positive integer, was %s\n", arg);
    96                                         goto usage;
    97                                 }
    98                                 break;
    99                         case 'p':
    100                                 nprocs = strtoul(arg, &end, 10);
    101                                 if(*end != '\0' || nprocs < 1) {
    102                                         fprintf(stderr, "Number of processors must be a positive integer, was %s\n", arg);
    103                                         goto usage;
    104                                 }
    105                                 break;
    106                         case 'S':
    107                                 silent = true;
    108                                 break;
    109                         case 'P':
    110                                 procstats = true;
    111                                 break;
     76                        BENCH_OPT_CASE
    11277                        case 'b':
    11378                                buflen = strtoul(arg, &end, 10);
     
    13196                                flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET);
    13297                                break;
    133                         // Other cases
    13498                        default: /* ? */
    13599                                fprintf(stderr, "%d\n", opt);
    136100                        usage:
    137                                 fprintf( stderr, "Usage: %s : [options]\n", argv[0] );
    138                                 fprintf( stderr, "\n" );
    139                                 fprintf( stderr, "  -d, --duration=DURATION  Duration of the experiment, in seconds\n" );
    140                                 fprintf( stderr, "  -t, --nthreads=NTHREADS  Number of user threads\n" );
    141                                 fprintf( stderr, "  -p, --nprocs=NPROCS      Number of kernel threads\n" );
    142                                 fprintf( stderr, "  -S, --nostats            Don't print cluster stats\n" );
    143                                 fprintf( stderr, "  -P, --procstat           Print processor stats" );
     101                                bench_usage( argv );
    144102                                fprintf( stderr, "  -b, --buflen=SIZE        Number of bytes to read per request\n" );
    145103                                fprintf( stderr, "  -u, --userthread         If set, cluster uses user-thread to poll I/O\n" );
     
    155113        }
    156114
    157         printf("Running %lu threads, reading %lu bytes each, over %lu processors for %lf seconds\n", nthreads, buflen, nprocs, duration);
     115        printf("Running %d threads, reading %lu bytes each, over %d processors for %f seconds\n", nthreads, buflen, nprocs, duration);
    158116
    159117        {
    160118                Time start, end;
    161                 BenchCluster cl = { flags };
    162                 #if !defined(__CFA_NO_STATISTICS__)
    163                         if( !silent ) {
    164                                 print_stats_at_exit( cl.self, CFA_STATS_READY_Q | CFA_STATS_IO );
    165                         }
    166                 #endif
     119                BenchCluster cl = { flags, CFA_STATS_READY_Q | CFA_STATS_IO };
    167120                {
    168121                        BenchProc procs[nprocs];
    169                         #if !defined(__CFA_NO_STATISTICS__)
    170                                 if( procstats ) {
    171                                         for(i; nprocs) {
    172                                                 print_stats_at_exit( procs[i].self, CFA_STATS_READY_Q | CFA_STATS_IO );
    173                                         }
    174                                 }
    175                         #endif
    176122                        {
    177123                                Reader threads[nthreads];
Note: See TracChangeset for help on using the changeset viewer.