Changes in benchmark/readyQ/transfer.rs [65c9208:ebb6158]
- File:
-
- 1 edited
-
benchmark/readyQ/transfer.rs (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/readyQ/transfer.rs
r65c9208 rebb6158 6 6 use std::hint; 7 7 use std::sync::Arc; 8 use std::sync::atomic::{Atomic Bool, AtomicUsize, Ordering};8 use std::sync::atomic::{AtomicUsize, Ordering}; 9 9 use std::time::{Instant,Duration}; 10 10 … … 44 44 match val { 45 45 "yes" => true, 46 "Y" => true,47 "y" => true,48 46 "no" => false, 49 "N" => false,50 "n" => false,51 47 "maybe" | "I don't know" | "Can you repeat the question?" => { 52 48 eprintln!("Lines for 'Malcolm in the Middle' are not acceptable values of parameter 'exhaust'"); … … 68 64 id: AtomicUsize, 69 65 idx: AtomicUsize, 70 estop: AtomicBool,71 66 seed: u128, 72 67 } … … 77 72 id: AtomicUsize::new(nthreads), 78 73 idx: AtomicUsize::new(0), 79 estop: AtomicBool::new(false),80 74 seed: process::id() as u128 81 75 }; … … 106 100 } 107 101 108 fn waitgroup( leader: &LeaderInfo, idx: usize, threads: &Vec<Arc<MyThread>>, main_sem: &sync::Semaphore) {102 fn waitgroup(idx: usize, threads: &Vec<Arc<MyThread>>) { 109 103 let start = Instant::now(); 110 'outer:for t in threads {104 for t in threads { 111 105 debug!( "Waiting for :{} ({})", t.id, t.idx.load(Ordering::Relaxed) ); 112 106 while t.idx.load(Ordering::Relaxed) != idx { … … 114 108 if start.elapsed() > Duration::from_secs(5) { 115 109 eprintln!("Programs has been blocked for more than 5 secs"); 116 leader.estop.store(true, Ordering::Relaxed); 117 main_sem.add_permits(1); 118 break 'outer; 110 std::process::exit(1); 119 111 } 120 112 } … … 139 131 leader.idx.store(nidx, Ordering::Relaxed); 140 132 141 if nidx as u64 > exp.stop_count || leader.estop.load(Ordering::Relaxed){133 if nidx as u64 > exp.stop_count { 142 134 debug!( "Leader {} done", this.id); 143 135 main_sem.add_permits(1); … … 147 139 debug!( "====================\nLeader no {} : {}", nidx, this.id); 148 140 149 waitgroup( leader, nidx, threads, main_sem);141 waitgroup(nidx, threads); 150 142 151 143 leader.next( threads.len() ); … … 200 192 wait( exhaust, &leader, &threads[me], &mut rechecks ).await; 201 193 } 202 if leader.idx.load(Ordering::Relaxed) as u64 > exp.stop_count || leader.estop.load(Ordering::Relaxed){ break; }194 if leader.idx.load(Ordering::Relaxed) as u64 > exp.stop_count { break; } 203 195 } 204 196 … … 281 273 println!("Number of processors : {}", (nprocs).to_formatted_string(&Locale::en)); 282 274 println!("Number of threads : {}", (nthreads).to_formatted_string(&Locale::en)); 283 println!("Total Operations(ops) : {:>15}", ( leader.idx.load(Ordering::Relaxed) - 1).to_formatted_string(&Locale::en));275 println!("Total Operations(ops) : {:>15}", (exp.stop_count).to_formatted_string(&Locale::en)); 284 276 println!("Threads parking on wait : {}", if exhaust { "yes" } else { "no" }); 285 277 println!("Rechecking : {}", rechecks ); 286 println!("ns per transfer : {}", ((duration.as_nanos() as f64) / leader.idx.load(Ordering::Relaxed) as f64)); 287 288 } 278 }
Note:
See TracChangeset
for help on using the changeset viewer.