Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/readyQ/transfer.rs

    r65c9208 rebb6158  
    66use std::hint;
    77use std::sync::Arc;
    8 use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
     8use std::sync::atomic::{AtomicUsize, Ordering};
    99use std::time::{Instant,Duration};
    1010
     
    4444                        match val {
    4545                                "yes" => true,
    46                                 "Y" => true,
    47                                 "y" => true,
    4846                                "no"  => false,
    49                                 "N"  => false,
    50                                 "n"  => false,
    5147                                "maybe" | "I don't know" | "Can you repeat the question?" => {
    5248                                        eprintln!("Lines for 'Malcolm in the Middle' are not acceptable values of parameter 'exhaust'");
     
    6864        id: AtomicUsize,
    6965        idx: AtomicUsize,
    70         estop: AtomicBool,
    7166        seed: u128,
    7267}
     
    7772                        id: AtomicUsize::new(nthreads),
    7873                        idx: AtomicUsize::new(0),
    79                         estop: AtomicBool::new(false),
    8074                        seed: process::id() as u128
    8175                };
     
    106100}
    107101
    108 fn waitgroup(leader: &LeaderInfo, idx: usize, threads: &Vec<Arc<MyThread>>, main_sem: &sync::Semaphore) {
     102fn waitgroup(idx: usize, threads: &Vec<Arc<MyThread>>) {
    109103        let start = Instant::now();
    110         'outer: for t in threads {
     104        for t in threads {
    111105                debug!( "Waiting for :{} ({})", t.id, t.idx.load(Ordering::Relaxed) );
    112106                while t.idx.load(Ordering::Relaxed) != idx {
     
    114108                        if start.elapsed() > Duration::from_secs(5) {
    115109                                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);
    119111                        }
    120112                }
     
    139131        leader.idx.store(nidx, Ordering::Relaxed);
    140132
    141         if nidx as u64 > exp.stop_count || leader.estop.load(Ordering::Relaxed) {
     133        if nidx as u64 > exp.stop_count {
    142134                debug!( "Leader {} done", this.id);
    143135                main_sem.add_permits(1);
     
    147139        debug!( "====================\nLeader no {} : {}", nidx, this.id);
    148140
    149         waitgroup(leader, nidx, threads, main_sem);
     141        waitgroup(nidx, threads);
    150142
    151143        leader.next( threads.len() );
     
    200192                        wait( exhaust, &leader, &threads[me], &mut rechecks ).await;
    201193                }
    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; }
    203195        }
    204196
     
    281273        println!("Number of processors    : {}", (nprocs).to_formatted_string(&Locale::en));
    282274        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));
    284276        println!("Threads parking on wait : {}", if exhaust { "yes" } else { "no" });
    285277        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.