Changeset cb85603
- Timestamp:
- Jun 25, 2020, 2:57:39 PM (4 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
- Location:
- benchmark
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/benchcltr.hfa
r566fde0 rcb85603 4 4 #include <kernel.hfa> 5 5 #include <thread.hfa> 6 #include <stats.hfa> 6 7 8 #define BENCH_OPT_SHORT "d:p:t:SP" 9 #define BENCH_OPT_LONG \ 10 {"duration", required_argument, 0, 'd'}, \ 11 {"nthreads", required_argument, 0, 't'}, \ 12 {"nprocs", required_argument, 0, 'p'}, \ 13 {"nostats", no_argument , 0, 'S'}, \ 14 {"procstat", no_argument , 0, 'P'}, 15 16 #define BENCH_DECL \ 17 double duration = 5; \ 18 int nprocs = 1; \ 19 int nthreads = 1; 20 21 #define BENCH_OPT_CASE \ 22 case 'd': \ 23 duration = strtod(arg, &end); \ 24 if(*end != '\0') { \ 25 fprintf(stderr, "Duration must be a valid double, was %s\n", arg); \ 26 goto usage; \ 27 } \ 28 break; \ 29 case 't': \ 30 nthreads = strtoul(arg, &end, 10); \ 31 if(*end != '\0' || nthreads < 1) { \ 32 fprintf(stderr, "Number of threads must be a positive integer, was %s\n", arg); \ 33 goto usage; \ 34 } \ 35 break; \ 36 case 'p': \ 37 nprocs = strtoul(arg, &end, 10); \ 38 if(*end != '\0' || nprocs < 1) { \ 39 fprintf(stderr, "Number of processors must be a positive integer, was %s\n", arg); \ 40 goto usage; \ 41 } \ 42 break; \ 43 case 'S': \ 44 silent = true; \ 45 break; \ 46 case 'P': \ 47 procstats = true; \ 48 break; 49 50 bool silent = false; 51 bool procstats = false; 7 52 struct cluster * the_benchmark_cluster = 0p; 8 53 struct BenchCluster { 9 54 cluster self; 10 55 }; 11 56 12 void ?{}( BenchCluster & this, int flags ) {13 57 void ?{}( BenchCluster & this, int flags, int stats ) { 58 (this.self){ "Benchmark Cluster", flags }; 14 59 15 assert( the_benchmark_cluster == 0p ); 16 the_benchmark_cluster = &this.self; 60 assert( the_benchmark_cluster == 0p ); 61 the_benchmark_cluster = &this.self; 62 63 #if !defined(__CFA_NO_STATISTICS__) 64 if( !silent ) { 65 print_stats_at_exit( this.self, stats ); 66 } 67 #endif 17 68 } 18 69 … … 22 73 23 74 void ?{}( BenchProc & this ) { 24 75 assert( the_benchmark_cluster != 0p ); 25 76 (this.self){ "Benchmark Processor", *the_benchmark_cluster }; 77 78 #if !defined(__CFA_NO_STATISTICS__) 79 if( procstats ) { 80 print_stats_at_exit( this.self, the_benchmark_cluster->print_stats ); 81 } 82 #endif 26 83 } 27 84 28 85 void wait(double duration, Time & start, Time & end, bool is_tty) { 29 30 31 32 33 34 35 36 37 38 39 40 86 for() { 87 sleep(100`ms); 88 end = getTimeNsec(); 89 Duration delta = end - start; 90 if(is_tty) { 91 printf("\r%.1f", delta`ds); 92 fflush(stdout); 93 } 94 if( delta >= duration`s ) { 95 break; 96 } 97 } 41 98 } 99 100 void bench_usage( char * argv [] ) { 101 fprintf( stderr, "Usage: %s : [options]\n", argv[0] ); 102 fprintf( stderr, "\n" ); 103 fprintf( stderr, " -d, --duration=DURATION Duration of the experiment, in seconds\n" ); 104 fprintf( stderr, " -t, --nthreads=NTHREADS Number of user threads\n" ); 105 fprintf( stderr, " -p, --nprocs=NPROCS Number of kernel threads\n" ); 106 fprintf( stderr, " -S, --nostats Don't print cluster stats\n" ); 107 fprintf( stderr, " -P, --procstat Print processor stats" ); 108 } -
benchmark/io/readv.cfa
r566fde0 rcb85603 50 50 51 51 int 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 57 53 unsigned flags = 0; 58 54 unsigned sublen = 16; … … 61 57 for(;;) { 62 58 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 68 60 {"bufsize", required_argument, 0, 'b'}, 69 61 {"userthread", no_argument , 0, 'u'}, … … 74 66 75 67 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); 77 69 78 70 const char * arg = optarg ? optarg : ""; … … 82 74 case -1: 83 75 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 112 77 case 'b': 113 78 buflen = strtoul(arg, &end, 10); … … 131 96 flags |= (sublen << CFA_CLUSTER_IO_BUFFLEN_OFFSET); 132 97 break; 133 // Other cases134 98 default: /* ? */ 135 99 fprintf(stderr, "%d\n", opt); 136 100 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 ); 144 102 fprintf( stderr, " -b, --buflen=SIZE Number of bytes to read per request\n" ); 145 103 fprintf( stderr, " -u, --userthread If set, cluster uses user-thread to poll I/O\n" ); … … 155 113 } 156 114 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); 158 116 159 117 { 160 118 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 }; 167 120 { 168 121 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 #endif176 122 { 177 123 Reader threads[nthreads]; -
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.