Changeset cb85603 for benchmark/readyQ
- Timestamp:
- Jun 25, 2020, 2:57:39 PM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/yield.cfa
r566fde0 rcb85603 43 43 44 44 int main(int argc, char * argv[]) { 45 double duration = 5; 46 int nprocs = 1; 47 int nthreads = 1; 48 bool silent = false; 49 bool procstats = false; 45 BENCH_DECL 50 46 51 47 for(;;) { 52 48 static struct option options[] = { 53 {"duration", required_argument, 0, 'd'}, 54 {"nprocs", required_argument, 0, 'p'}, 55 {"nthreads", required_argument, 0, 't'}, 56 {"nostats", no_argument , 0, 'S'}, 57 {"procstat", no_argument , 0, 'P'}, 49 BENCH_OPT_LONG 58 50 {0, 0, 0, 0} 59 51 }; 60 52 61 53 int idx = 0; 62 int opt = getopt_long(argc, argv, "d:p:t:SP", options, &idx);54 int opt = getopt_long(argc, argv, BENCH_OPT_SHORT, options, &idx); 63 55 64 char * arg = optarg ? optarg : ""; 65 size_t len = 0; 56 const char * arg = optarg ? optarg : ""; 66 57 char * end; 67 58 switch(opt) { 68 59 case -1: 69 60 goto run; 70 // Numeric Arguments 71 case 'd': 72 duration = strtod(arg, &end); 73 if(*end != '\0') { 74 fprintf(stderr, "Duration must be a valid double, was %s\n", arg); 75 goto usage; 76 } 77 break; 78 case 't': 79 nthreads = strtoul(arg, &end, 10); 80 if(*end != '\0' || nthreads < 1) { 81 fprintf(stderr, "Number of threads must be a positive integer, was %s\n", arg); 82 goto usage; 83 } 84 break; 85 case 'p': 86 nprocs = strtoul(arg, &end, 10); 87 if(*end != '\0' || nprocs < 1) { 88 fprintf(stderr, "Number of processors must be a positive integer, was %s\n", arg); 89 goto usage; 90 } 91 break; 92 case 'S': 93 silent = true; 94 break; 95 case 'P': 96 procstats = true; 97 break; 98 // Other cases 61 BENCH_OPT_CASE 99 62 default: /* ? */ 100 63 fprintf( stderr, "Unkown option '%c'\n", opt); 101 64 usage: 102 fprintf( stderr, "Usage: %s [options]\n", argv[0]); 103 fprintf( stderr, "\n" ); 104 fprintf( stderr, " -d, --duration=DURATION Duration of the experiment, in seconds\n" ); 105 fprintf( stderr, " -t, --nthreads=NTHREADS Number of kernel threads\n" ); 106 fprintf( stderr, " -q, --nqueues=NQUEUES Number of queues per threads\n" ); 107 fprintf( stderr, " -S, --nostats Don't print cluster stats\n" ); 108 fprintf( stderr, " -P, --procstat Print processor stats" ); 65 bench_usage( argv ); 109 66 exit(1); 110 67 } … … 113 70 114 71 { 115 printf("Running %d threads on %d processors for % lf seconds\n", nthreads, nprocs, duration);72 printf("Running %d threads on %d processors for %f seconds\n", nthreads, nprocs, duration); 116 73 117 74 Time start, end; 118 BenchCluster cl = { 0 }; 119 #if !defined(__CFA_NO_STATISTICS__) 120 if( !silent ) { 121 print_stats_at_exit( cl.self, CFA_STATS_READY_Q ); 122 } 123 #endif 75 BenchCluster cl = { 0, CFA_STATS_READY_Q }; 124 76 { 125 77 BenchProc procs[nprocs]; 126 #if !defined(__CFA_NO_STATISTICS__)127 if( procstats ) {128 for(i; nprocs) {129 print_stats_at_exit( procs[i].self, CFA_STATS_READY_Q );130 }131 }132 #endif133 78 { 134 79 Yielder threads[nthreads];
Note: See TracChangeset
for help on using the changeset viewer.