Changeset 9791ab5
- Timestamp:
- Jun 24, 2020, 4:57:42 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:
- 8b58bae
- Parents:
- 564148f
- Location:
- benchmark
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/benchcltr.hfa
r564148f r9791ab5 10 10 }; 11 11 12 void ?{}( BenchCluster & this ) {13 (this.self){ "Benchmark Cluster" };12 void ?{}( BenchCluster & this, int flags ) { 13 (this.self){ "Benchmark Cluster", flags }; 14 14 15 15 assert( the_benchmark_cluster == 0p ); … … 26 26 } 27 27 28 28 void wait(double duration, Time & start, Time & end, bool is_tty) { 29 for() { 30 sleep(500`ms); 31 end = getTime(); 32 if( (end - start) >= duration`s ) { 33 break; 34 } 35 if(is_tty) { 36 printf("\r%.4lf", (double)(end - start)`s); 37 fflush(stdout); 38 } 39 } 40 } -
benchmark/io/readv.cfa
r564148f r9791ab5 17 17 #include <time.hfa> 18 18 19 #include "../benchcltr.hfa" 20 19 21 extern bool traceHeapOn(); 20 22 extern ssize_t cfa_preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags); … … 26 28 unsigned long int buflen = 50; 27 29 28 cluster * the_cluster; 29 30 thread Reader {}; 30 thread __attribute__((aligned(128))) Reader {}; 31 31 void ?{}( Reader & this ) { 32 ((thread&)this){ "Reader Thread", *the_cluster }; 33 } 34 35 struct my_processor { 36 processor p; 37 }; 38 39 void ?{}( my_processor & this ) { 40 (this.p){ "I/O Processor", *the_cluster }; 32 ((thread&)this){ "Reader Thread", *the_benchmark_cluster }; 41 33 } 42 34 43 35 void main( Reader & ) { 44 while(!__atomic_load_n(&run, __ATOMIC_RELAXED)) yield(); 36 park( __cfaabi_dbg_ctx ); 37 /* paranoid */ assert( true == __atomic_load_n(&run, __ATOMIC_RELAXED) ); 45 38 46 39 char data[buflen]; … … 153 146 { 154 147 Time start, end; 155 cluster cl = { "IO Cluster", flags }; 156 the_cluster = &cl; 148 BenchCluster cl = { flags }; 157 149 #if !defined(__CFA_NO_STATISTICS__) 158 print_stats_at_exit( cl );150 print_stats_at_exit( cl.self ); 159 151 #endif 160 152 { 161 my_processorprocs[nprocs];153 BenchProc procs[nprocs]; 162 154 { 163 155 Reader threads[nthreads]; 164 156 165 157 printf("Starting\n"); 158 bool is_tty = isatty(STDOUT_FILENO); 166 159 start = getTime(); 167 160 run = true; 168 do { 169 sleep(500`ms); 170 end = getTime(); 171 } while( (end - start) < duration`s ); 161 162 for(i; nthreads) { 163 unpark( threads[i] __cfaabi_dbg_ctx2 ); 164 } 165 wait(duration, start, end, is_tty); 166 172 167 run = false; 173 168 end = getTime(); 174 printf(" Done\n");169 printf("\nDone\n"); 175 170 } 176 171 } -
benchmark/readyQ/yield.cfa
r564148f r9791ab5 105 105 106 106 Time start, end; 107 BenchCluster cl ;107 BenchCluster cl = { 0 }; 108 108 #if !defined(__CFA_NO_STATISTICS__) 109 109 print_stats_at_exit( cl.self ); … … 113 113 { 114 114 Yielder threads[nthreads]; 115 printf("Starting\n"); 116 115 117 bool is_tty = isatty(STDOUT_FILENO); 116 printf("Starting\n");117 118 start = getTime(); 118 119 run = true; … … 121 122 unpark( threads[i] __cfaabi_dbg_ctx2 ); 122 123 } 123 for() { 124 sleep(500`ms); 125 end = getTime(); 126 if( (end - start) >= duration`s ) { 127 break; 128 } 129 if(is_tty) { 130 printf("\r%.4lf", (double)(end - start)`s); 131 fflush(stdout); 132 } 133 } 124 wait(duration, start, end, is_tty); 134 125 135 126 run = false; 136 127 end = getTime(); 137 printf(" Done\n");128 printf("\nDone\n"); 138 129 } 139 130 }
Note: See TracChangeset
for help on using the changeset viewer.