Changeset 762fbc1 for benchmark/benchcltr.hfa
- Timestamp:
- Aug 15, 2020, 12:20:44 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:
- 36de20d
- Parents:
- 7f51b9d (diff), 5715d43 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/benchcltr.hfa
r7f51b9d r762fbc1 1 1 #pragma once 2 #include <assert.h> 3 #include <stdint.h> 2 4 3 #include <assert.h> 4 #include <kernel.hfa> 5 #include <thread.hfa> 6 #include <stats.hfa> 5 #ifdef __cforall 6 #include <kernel.hfa> 7 #include <thread.hfa> 8 #include <stats.hfa> 9 #else 10 #include <time.h> // timespec 11 #include <sys/time.h> // timeval 12 13 enum { TIMEGRAN = 1000000000LL }; // nanosecond granularity, except for timeval 14 #endif 7 15 8 16 #define BENCH_OPT_SHORT "d:p:t:SPV" … … 14 22 {"procstat", no_argument , 0, 'P'}, \ 15 23 {"viewhalts", no_argument , 0, 'V'}, 16 17 #define BENCH_DECL \18 double duration = 5; \19 int nprocs = 1; \20 int nthreads = 1;21 24 22 25 #define BENCH_OPT_CASE \ … … 52 55 break; 53 56 57 double duration = 5; 58 int nprocs = 1; 59 int nthreads = 1; 54 60 bool silent = false; 61 bool continuous = false; 55 62 bool procstats = false; 56 63 bool viewhalts = false; 64 65 #define BENCH_OPT_CFA \ 66 {'d', "duration", "Duration of the experiments in seconds", duration }, \ 67 {'t', "nthreads", "Number of threads to use", nthreads }, \ 68 {'p', "nprocs", "Number of processors to use", nprocs }, \ 69 {'S', "nostats", "Don't print statistics", silent, parse_settrue }, \ 70 {'C', "constats", "Regularly print statistics", continuous, parse_settrue }, \ 71 {'P', "procstat", "Print statistics for each processors", procstats, parse_settrue }, \ 72 {'V', "viewhalts", "Visualize halts, prints timestamp and Processor id for each halt.", viewhalts, parse_settrue }, 73 74 #ifdef __cforall 75 #include <parseargs.hfa> 76 57 77 struct cluster * the_benchmark_cluster = 0p; 58 78 struct BenchCluster { … … 60 80 }; 61 81 62 void ?{}( BenchCluster & this, int flags, int stats ) {63 (this.self){ "Benchmark Cluster", flags };82 void ?{}( BenchCluster & this, int num_io, const io_context_params & io_params, int stats ) { 83 (this.self){ "Benchmark Cluster", num_io, io_params }; 64 84 65 85 assert( the_benchmark_cluster == 0p ); … … 105 125 } 106 126 } 127 #else 128 uint64_t getTimeNsec() { 129 timespec curr; 130 clock_gettime( CLOCK_REALTIME, &curr ); 131 return (int64_t)curr.tv_sec * TIMEGRAN + curr.tv_nsec; 132 } 133 134 uint64_t to_miliseconds( uint64_t durtn ) { return durtn / (TIMEGRAN / 1000LL); } 135 double to_fseconds(uint64_t durtn ) { return durtn / (double)TIMEGRAN; } 136 uint64_t from_fseconds(double sec) { return sec * TIMEGRAN; } 137 138 139 void wait_duration(double duration, uint64_t & start, uint64_t & end, bool is_tty) { 140 for(;;) { 141 usleep(100000); 142 end = getTimeNsec(); 143 uint64_t delta = end - start; 144 /*if(is_tty)*/ { 145 printf(" %.1f\r", to_fseconds(delta)); 146 fflush(stdout); 147 } 148 if( delta >= from_fseconds(duration) ) { 149 break; 150 } 151 } 152 } 153 #endif 154 107 155 108 156 void bench_usage( char * argv [] ) {
Note: See TracChangeset
for help on using the changeset viewer.