- Timestamp:
- Sep 16, 2021, 2:22:01 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 432bffe, 7e7a076
- Parents:
- a8367eb (diff), 140eb16 (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. - Location:
- benchmark
- Files:
-
- 4 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/Cargo.toml.in
ra8367eb r4d8fbf4 6 6 7 7 [[bin]] 8 name = " cycle-tokio"8 name = "rdq-cycle-tokio" 9 9 path = "@abs_srcdir@/readyQ/cycle.rs" 10 10 11 11 [[bin]] 12 name = " locality-tokio"12 name = "rdq-locality-tokio" 13 13 path = "@abs_srcdir@/readyQ/locality.rs" 14 15 [[bin]] 16 name = "rdq-transfer-tokio" 17 path = "@abs_srcdir@/readyQ/transfer.rs" 18 19 [[bin]] 20 name = "rdq-yield-tokio" 21 path = "@abs_srcdir@/readyQ/yield.rs" 14 22 15 23 [features] -
benchmark/Makefile.am
ra8367eb r4d8fbf4 21 21 include $(top_srcdir)/tools/build/cfa.make 22 22 23 AM_CFLAGS = -O 2-Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror23 AM_CFLAGS = -O3 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror 24 24 AM_CFAFLAGS = -quiet -nodebug 25 25 AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14 … … 612 612 ## ========================================================================================================= 613 613 614 %-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs 615 cd $(builddir) && cargo build --release 616 cp $(builddir)/target/release/$(basename $@) $@ 614 RDQBENCHES = \ 615 rdq-cycle-cfa \ 616 rdq-cycle-tokio \ 617 rdq-cycle-go \ 618 rdq-cycle-fibre \ 619 rdq-yield-cfa \ 620 rdq-yield-tokio \ 621 rdq-yield-go \ 622 rdq-yield-fibre \ 623 rdq-locality-cfa \ 624 rdq-locality-tokio \ 625 rdq-locality-go \ 626 rdq-locality-fibre \ 627 rdq-transfer-cfa \ 628 rdq-transfer-tokio \ 629 rdq-transfer-go \ 630 rdq-transfer-fibre 631 632 rdq-benches: 633 +make $(RDQBENCHES) 634 635 clean-rdq-benches: 636 rm -rf $(RDQBENCHES) $(builddir)/target go.mod 637 638 rdq-%-tokio$(EXEEXT): $(builddir)/target/release/rdq-%-tokio$(EXEEXT) 639 $(BENCH_V_RUSTC)cp $(builddir)/target/release/$(basename $@) $@ 640 641 $(builddir)/target/release/rdq-%-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs 642 $(BENCH_V_RUSTC)cd $(builddir) && cargo build --release 643 644 rdq-%-cfa$(EXEEXT): $(srcdir)/readyQ/%.cfa $(srcdir)/readyQ/rq_bench.hfa 645 $(BENCH_V_CFA)$(CFACOMPILE) $< -o $@ 646 647 go.mod: 648 touch $@ 649 go mod edit -module=rdq.bench 650 go get golang.org/x/sync/semaphore 651 go get golang.org/x/text/language 652 go get golang.org/x/text/message 653 654 rdq-%-go$(EXEEXT): $(srcdir)/readyQ/%.go $(srcdir)/readyQ/bench.go go.mod 655 $(BENCH_V_GOC)go build -o $@ $< $(srcdir)/readyQ/bench.go 656 657 rdq-%-fibre$(EXEEXT): $(srcdir)/readyQ/%.cpp 658 $(BENCH_V_CXX)$(CXXCOMPILE) $< -o $@ -lfibre -std=c++17 $(AM_CFLAGS) 659 660 # ## ========================================================================================================= 661 662 CLEANFILES = $(RDQBENCHES) go.mod go.sum 663 664 clean-local: 665 -rm -rf target -
benchmark/bench.rs
ra8367eb r4d8fbf4 1 1 use std::io::{self, Write}; 2 use std::option; 2 3 use std::sync::atomic::{AtomicU64, AtomicBool, Ordering}; 3 4 use std::time::{Instant,Duration}; 5 use std::u128; 4 6 5 7 use clap::{Arg, ArgMatches}; … … 27 29 28 30 impl BenchData { 29 pub fn new(options: ArgMatches, nthreads: usize ) -> BenchData {31 pub fn new(options: ArgMatches, nthreads: usize, default_it: option::Option<u64>) -> BenchData { 30 32 let (clock_mode, stop_count, duration) = if options.is_present("iterations") { 31 33 (false, 32 34 options.value_of("iterations").unwrap().parse::<u64>().unwrap(), 35 -1.0) 36 } else if !default_it.is_none() { 37 (false, 38 default_it.unwrap(), 33 39 -1.0) 34 40 } else { … … 48 54 } 49 55 56 #[allow(dead_code)] 50 57 pub async fn wait(&self, start: &Instant) -> Duration{ 51 58 loop { … … 69 76 } 70 77 78 // ================================================== 79 pub fn _lehmer64( state: &mut u128 ) -> u64 { 80 *state = state.wrapping_mul(0xda942042e4dd58b5); 81 return (*state >> 64) as u64; 82 } -
benchmark/readyQ/cycle.cpp
ra8367eb r4d8fbf4 41 41 Fibre * threads[tthreads]; 42 42 Partner thddata[tthreads]; 43 for( inti = 0; i < tthreads; i++) {43 for(unsigned i = 0; i < tthreads; i++) { 44 44 unsigned pi = (i + nthreads) % tthreads; 45 45 thddata[i].next = &thddata[pi].self; 46 46 } 47 for( inti = 0; i < tthreads; i++) {47 for(unsigned i = 0; i < tthreads; i++) { 48 48 threads[i] = new Fibre( reinterpret_cast<void (*)(void *)>(partner_main), &thddata[i] ); 49 49 } … … 53 53 start = timeHiRes(); 54 54 55 for( inti = 0; i < nthreads; i++) {55 for(unsigned i = 0; i < nthreads; i++) { 56 56 thddata[i].self.post(); 57 57 } … … 62 62 printf("\nDone\n"); 63 63 64 for( inti = 0; i < tthreads; i++) {64 for(unsigned i = 0; i < tthreads; i++) { 65 65 thddata[i].self.post(); 66 66 fibre_join( threads[i], nullptr ); -
benchmark/readyQ/cycle.go
ra8367eb r4d8fbf4 60 60 atomic.StoreInt32(&stop, 1) 61 61 end := time.Now() 62 d elta:= end.Sub(start)62 duration := end.Sub(start) 63 63 64 64 fmt.Printf("\nDone\n") … … 74 74 75 75 p := message.NewPrinter(language.English) 76 p.Printf("Duration (ms) : % f\n", delta.Seconds());76 p.Printf("Duration (ms) : %d\n", duration.Milliseconds()) 77 77 p.Printf("Number of processors : %d\n", nprocs); 78 78 p.Printf("Number of threads : %d\n", tthreads); 79 79 p.Printf("Cycle size (# thrds) : %d\n", ring_size); 80 80 p.Printf("Total Operations(ops): %15d\n", global_counter) 81 p.Printf("Ops per second : %18.2f\n", float64(global_counter) / d elta.Seconds())82 p.Printf("ns per ops : %18.2f\n", float64(d elta.Nanoseconds()) / float64(global_counter))81 p.Printf("Ops per second : %18.2f\n", float64(global_counter) / duration.Seconds()) 82 p.Printf("ns per ops : %18.2f\n", float64(duration.Nanoseconds()) / float64(global_counter)) 83 83 p.Printf("Ops per threads : %15d\n", global_counter / uint64(tthreads)) 84 84 p.Printf("Ops per procs : %15d\n", global_counter / uint64(nprocs)) 85 p.Printf("Ops/sec/procs : %18.2f\n", (float64(global_counter) / float64(nprocs)) / d elta.Seconds())86 p.Printf("ns per ops/procs : %18.2f\n", float64(d elta.Nanoseconds()) / (float64(global_counter) / float64(nprocs)))85 p.Printf("Ops/sec/procs : %18.2f\n", (float64(global_counter) / float64(nprocs)) / duration.Seconds()) 86 p.Printf("ns per ops/procs : %18.2f\n", float64(duration.Nanoseconds()) / (float64(global_counter) / float64(nprocs))) 87 87 88 88 } -
benchmark/readyQ/cycle.rs
ra8367eb r4d8fbf4 46 46 47 47 let tthreads = nthreads * ring_size; 48 let exp = Arc::new(bench::BenchData::new(options, tthreads ));48 let exp = Arc::new(bench::BenchData::new(options, tthreads, None)); 49 49 50 50 let s = (1000000 as u64).to_formatted_string(&Locale::en); -
benchmark/readyQ/locality.go
ra8367eb r4d8fbf4 286 286 // Print with nice 's, i.e. 1'000'000 instead of 1000000 287 287 p := message.NewPrinter(language.English) 288 p.Printf("Duration ( s) : %f\n", delta.Seconds());288 p.Printf("Duration (ms) : %f\n", delta.Milliseconds()); 289 289 p.Printf("Number of processors : %d\n", nprocs); 290 290 p.Printf("Number of threads : %d\n", nthreads); -
benchmark/readyQ/locality.rs
ra8367eb r4d8fbf4 124 124 return (r as *mut MyData, true); 125 125 } 126 let got = self.ptr.compare_ and_swap(expected, ctx as *mut MyCtx as u64, Ordering::SeqCst);127 if got == expected{126 let got = self.ptr.compare_exchange_weak(expected, ctx as *mut MyCtx as u64, Ordering::SeqCst, Ordering::SeqCst); 127 if got == Ok(expected) { 128 128 break expected;// We got the seat 129 129 } … … 285 285 assert_eq!(&s, "1,000,000"); 286 286 287 let exp = Arc::new(bench::BenchData::new(options, nprocs ));287 let exp = Arc::new(bench::BenchData::new(options, nprocs, None)); 288 288 let mut results = Result::new(); 289 289 -
benchmark/readyQ/transfer.cfa
ra8367eb r4d8fbf4 39 39 Pause(); 40 40 if( (timeHiRes() - start) > 5`s ) { 41 print_stats_now( bench_cluster, CFA_STATS_READY_Q | CFA_STATS_IO ); 41 42 serr | "Programs has been blocked for more than 5 secs"; 42 43 exit(1); … … 110 111 cfa_option opt[] = { 111 112 BENCH_OPT, 112 { 'e', "exhaust", "Whether or not threads that have seen the new epoch should yield or park.", exhaust, parse_yesno}113 { 'e', "exhaust", "Whether or not threads that have seen the new epoch should park instead of yielding.", exhaust, parse_yesno} 113 114 }; 114 115 BENCH_OPT_PARSE("cforall transition benchmark"); … … 166 167 } 167 168 168 sout | "Duration : " | ws(3, 3, unit(eng((end - start)`ds))) | 's';169 sout | "Duration (ms) : " | ws(3, 3, unit(eng((end - start)`dms))); 169 170 sout | "Number of processors : " | nprocs; 170 171 sout | "Number of threads : " | nthreads; -
benchmark/readyQ/transfer.cpp
ra8367eb r4d8fbf4 173 173 } 174 174 175 std::cout << "Duration : " << to_miliseconds(end - start) << "ms"<< std::endl;175 std::cout << "Duration (ms) : " << to_miliseconds(end - start) << std::endl; 176 176 std::cout << "Number of processors : " << nprocs << std::endl; 177 177 std::cout << "Number of threads : " << nthreads << std::endl; -
benchmark/readyQ/yield.cfa
ra8367eb r4d8fbf4 80 80 } 81 81 82 printf("Took %'ld ms\n", (end - start)`ms); 82 printf("Duration (ms) : %'ld\n", (end - start)`dms); 83 printf("Number of processors: %'d\n", nprocs); 84 printf("Number of threads : %'d\n", nthreads); 85 printf("Total yields : %'15llu\n", global_counter); 83 86 printf("Yields per second : %'18.2lf\n", ((double)global_counter) / (end - start)`s); 84 87 printf("ns per yields : %'18.2lf\n", ((double)(end - start)`ns) / global_counter); 85 printf("Total yields : %'15llu\n", global_counter);86 88 printf("Yields per procs : %'15llu\n", global_counter / nprocs); 87 89 printf("Yields/sec/procs : %'18.2lf\n", (((double)global_counter) / nprocs) / (end - start)`s); -
benchmark/readyQ/yield.cpp
ra8367eb r4d8fbf4 154 154 155 155 auto dur_nano = duration_cast<std::nano>(duration); 156 auto dur_dms = duration_cast<std::milli>(duration); 156 157 157 std::cout << "Took " << duration << " s\n";158 printf("Duration (ms) : %'.2lf\n", dur_dms ); 158 159 printf("Total yields : %'15llu\n", global_counter ); 159 160 printf("Yields per procs : %'15llu\n", global_counter / nprocs ); -
benchmark/rmit.py
ra8367eb r4d8fbf4 16 16 import random 17 17 import re 18 import socket 18 19 import subprocess 19 20 import sys … … 95 96 return nopts 96 97 98 # returns the first option with key 'opt' 99 def search_option(action, opt): 100 i = 0 101 while i < len(action): 102 if action[i] == opt: 103 i += 1 104 if i != len(action): 105 return action[i] 106 i += 1 107 108 return None 109 97 110 def actions_eta(actions): 98 111 time = 0 99 112 for a in actions: 100 i = 0 101 while i < len(a): 102 if a[i] == '-d': 103 i += 1 104 if i != len(a): 105 time += int(a[i]) 106 i += 1 113 o = search_option(a, '-d') 114 if o : 115 time += int(o) 107 116 return time 117 118 taskset_maps = None 119 120 def init_taskset_maps(): 121 global taskset_maps 122 known_hosts = { 123 "jax": { 124 range( 1, 24) : "48-71", 125 range( 25, 48) : "48-71,144-167", 126 range( 49, 96) : "48-95,144-191", 127 range( 97, 144) : "24-95,120-191", 128 range(145, 192) : "0-95,96-191", 129 }, 130 } 131 132 if (host := socket.gethostname()) in known_hosts: 133 taskset_maps = known_hosts[host] 134 return True 135 136 print("Warning unknown host '{}', disable taskset usage".format(host), file=sys.stderr) 137 return False 138 139 140 def settaskset_one(action): 141 o = search_option(action, '-p') 142 if not o: 143 return action 144 try: 145 oi = int(o) 146 except ValueError: 147 return action 148 149 m = "Not found" 150 for key in taskset_maps: 151 if oi in key: 152 return ['taskset', '-c', taskset_maps[key], *action] 153 154 print("Warning no mapping for {} cores".format(oi), file=sys.stderr) 155 return action 156 157 def settaskset(actions): 158 return [settaskset_one(a) for a in actions] 108 159 109 160 if __name__ == "__main__": … … 115 166 parser.add_argument('--file', nargs='?', type=argparse.FileType('w'), default=sys.stdout) 116 167 parser.add_argument('--trials', help='Number of trials to run per combinaison', type=int, default=3) 168 parser.add_argument('--notaskset', help='If specified, the trial will not use taskset to match the -p option', action='store_true') 117 169 parser.add_argument('command', metavar='command', type=str, nargs=1, help='the command prefix to run') 118 170 parser.add_argument('candidates', metavar='candidates', type=str, nargs='*', help='the candidate suffix to run') … … 170 222 171 223 # ================================================================================ 172 # Figure out all the combinations to run 224 # Fixup the different commands 225 226 # Add tasksets 227 withtaskset = False 228 if not options.notaskset and init_taskset_maps(): 229 withtaskset = True 230 actions = settaskset(actions) 231 232 # ================================================================================ 233 # Now that we know what to run, print it. 234 # find expected time 235 time = actions_eta(actions) 236 print("Running {} trials{}".format(len(actions), "" if time == 0 else " (expecting to take {})".format(str(datetime.timedelta(seconds=int(time)))) )) 237 238 # dry run if options ask for it 173 239 if options.list: 174 240 for a in actions: … … 180 246 # Prepare to run 181 247 182 # find expected time183 time = actions_eta(actions)184 print("Running {} trials{}".format(len(actions), "" if time == 0 else " (expecting to take {})".format(str(datetime.timedelta(seconds=int(time)))) ))185 186 248 random.shuffle(actions) 187 249 … … 191 253 first = True 192 254 for i, a in enumerate(actions): 193 sa = " ".join(a )255 sa = " ".join(a[3:] if withtaskset else a) 194 256 if first: 195 257 first = False … … 208 270 match = re.search("^(.*):(.*)$", s) 209 271 if match: 210 fields[match.group(1).strip()] = float(match.group(2).strip().replace(',','')) 211 212 options.file.write(json.dumps([a[0][2:], sa, fields])) 272 try: 273 fields[match.group(1).strip()] = float(match.group(2).strip().replace(',','')) 274 except: 275 pass 276 277 options.file.write(json.dumps([a[3 if withtaskset else 0][2:], sa, fields])) 213 278 options.file.flush() 214 279
Note: See TracChangeset
for help on using the changeset viewer.