Changeset 2b4daf2 for benchmark


Ignore:
Timestamp:
Jan 7, 2021, 5:06:22 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5ad381b
Parents:
42f6e07 (diff), 58fe85a (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
benchmark
Files:
8 added
9 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Makefile.am

    r42f6e07 r2b4daf2  
    522522size-cfa$(EXEEXT):
    523523        $(BENCH_V_CFA)$(CFACOMPILE) $(srcdir)/size/size.cfa
     524
     525## =========================================================================================================
     526
     527%-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs
     528        cd $(builddir) && cargo build --release
     529        cp $(builddir)/target/release/$(basename $@) $@
  • benchmark/creation/node_cor.js

    r42f6e07 r2b4daf2  
    66function * coroutine() { yield }
    77
    8 for ( var i = 0; i < times; i += 1 ) { // warm jit
     8for ( var i = 0; i < times; i += 1 ) { // warm JIT
    99        cor = coroutine()
    1010}
  • benchmark/ctxswitch/node_cor.js

    r42f6e07 r2b4daf2  
    1111cor = coroutine()
    1212
    13 for ( var i = 0; i < times; i += 1 ) { // warm git
     13for ( var i = 0; i < times; i += 1 ) { // warm JIT
    1414        cor.next();
    1515}
  • benchmark/readyQ/bench.go

    r42f6e07 r2b4daf2  
    55        "flag"
    66        "fmt"
     7        "log"
    78        "os"
    89        "runtime"
     10        "runtime/pprof"
    911        "sync/atomic"
    1012        "time"
     
    4345}
    4446
    45 func bench_init() {
     47func bench_init() func() {
    4648        nprocsOpt := flag.Int("p", 1, "The number of processors")
    4749        nthreadsOpt := flag.Int("t", 1, "The number of threads")
    4850        durationOpt := flag.Float64("d", 0, "Duration of the experiment in seconds")
    4951        stopOpt := flag.Uint64("i", 0, "Duration of the experiment in iterations")
     52        cpuprofile := flag.String("cpuprofile", "", "write cpu profile to file")
    5053
    5154        flag.Parse()
     
    7275
    7376        runtime.GOMAXPROCS(nprocs)
     77
     78        if (*cpuprofile) != "" {
     79                f, err := os.Create(*cpuprofile)
     80                if err != nil {
     81                    log.Fatal(err)
     82                }
     83                pprof.StartCPUProfile(f)
     84        }
     85
     86        return func() {
     87                if (*cpuprofile) != "" {
     88                        pprof.StopCPUProfile()
     89                }
     90        }
    7491}
  • benchmark/readyQ/cycle.cpp

    r42f6e07 r2b4daf2  
    7171                { 'r', "ringsize", "Number of threads in a cycle", ring_size }
    7272        };
    73         BENCH_OPT_PARSE("cforall cycle benchmark");
     73        BENCH_OPT_PARSE("libfibre cycle benchmark");
    7474
    7575        {
  • benchmark/readyQ/cycle.rs

    r42f6e07 r2b4daf2  
    1 #[cfg(any(
    2         feature = "sync time rt-threaded",
    3   ))]
    4 
    5 extern crate tokio;
    6 
    7 use std::io::{self, Write};
    81use std::sync::Arc;
    9 use std::sync::atomic::{AtomicU64, AtomicBool,Ordering};
    10 use std::time::{Instant,Duration};
     2use std::sync::atomic::Ordering;
     3use std::time::Instant;
    114
    125use tokio::runtime::Builder;
    136use tokio::sync;
    14 use tokio::time;
    157
    16 extern crate isatty;
    17 use isatty::stdout_isatty;
    18 
    19 extern crate num_format;
     8use clap::{Arg, App};
    209use num_format::{Locale, ToFormattedString};
    2110
    22 extern crate clap;
    23 use clap::{Arg, App};
     11#[path = "../bench.rs"]
     12mod bench;
    2413
    25 use std::cell::UnsafeCell;
    26 use std::mem::MaybeUninit;
    27 use std::ops;
    28 
    29 pub struct InitializeCell<T> {
    30     inner: UnsafeCell<MaybeUninit<T>>,
    31 }
    32 
    33 unsafe impl<T> Sync for InitializeCell<T> {}
    34 
    35 impl<T> InitializeCell<T> {
    36     pub const unsafe fn new_uninitialized() -> InitializeCell<T> {
    37           InitializeCell {
    38                 inner: UnsafeCell::new(MaybeUninit::uninit()),
    39           }
    40     }
    41     pub const fn new(init: T) -> InitializeCell<T> {
    42           InitializeCell {
    43                 inner: UnsafeCell::new(MaybeUninit::new(init)),
    44           }
    45     }
    46     pub unsafe fn init(&self, init: T) {
    47           (*self.inner.get()) = MaybeUninit::new(init);
    48     }
    49 }
    50 
    51 impl<T> ops::Deref for InitializeCell<T> {
    52     type Target = T;
    53     fn deref(&self) -> &T {
    54           unsafe {
    55                 &*(*self.inner.get()).as_ptr()
    56           }
    57     }
    58 }
    59 
    60 static CLOCK_MODE: InitializeCell<bool> = unsafe { InitializeCell::new_uninitialized() };
    61 static STOP_COUNT: InitializeCell<u64>  = unsafe { InitializeCell::new_uninitialized() };
    62 static DURATION: InitializeCell<f64>    = unsafe { InitializeCell::new_uninitialized() };
    63 static STOP         : AtomicBool = AtomicBool::new(false);
    64 static THREADS_LEFT : AtomicU64  = AtomicU64 ::new(10);
    65 
     14// ==================================================
    6615struct Partner {
    6716        sem: sync::Semaphore,
     
    6918}
    7019
    71 async fn partner_main(result: sync::oneshot::Sender<u64>, idx: usize, others: Arc<Vec<Arc<Partner>>> ) {
     20async fn partner_main(idx: usize, others: Arc<Vec<Arc<Partner>>>, exp: Arc<bench::BenchData> ) -> u64 {
    7221        let this = &others[idx];
    7322        let mut count:u64 = 0;
     
    7726                count += 1;
    7827
    79                 if  *CLOCK_MODE && STOP.load(Ordering::Relaxed) { break; }
    80                 if !*CLOCK_MODE && count >= *STOP_COUNT { break; }
     28                if  exp.clock_mode && exp.stop.load(Ordering::Relaxed) { break; }
     29                if !exp.clock_mode && count >= exp.stop_count { break; }
    8130        }
    8231
    83         THREADS_LEFT.fetch_sub(1, Ordering::SeqCst);
    84         result.send( count ).unwrap();
     32        exp.threads_left.fetch_sub(1, Ordering::SeqCst);
     33        count
    8534}
    8635
    87 fn prep(nthreads: usize, tthreads: usize) -> Vec<Arc<Partner>> {
    88         let mut thddata = Vec::with_capacity(tthreads);
    89         for i in 0..tthreads {
    90                 let pi = (i + nthreads) % tthreads;
    91                 thddata.push(Arc::new(Partner{
    92                         sem: sync::Semaphore::new(0),
    93                         next: pi,
    94                 }));
    95         }
    96         return thddata;
    97 }
    98 
    99 async fn wait(start: &Instant, is_tty: bool) {
    100         loop {
    101                 time::sleep(Duration::from_micros(100000)).await;
    102                 let delta = start.elapsed();
    103                 if is_tty {
    104                         print!(" {:.1}\r", delta.as_secs_f32());
    105                         io::stdout().flush().unwrap();
    106                 }
    107                 if *CLOCK_MODE && delta >= Duration::from_secs_f64(*DURATION)  {
    108                         break;
    109                 }
    110                 else if !*CLOCK_MODE && THREADS_LEFT.load(Ordering::Relaxed) == 0 {
    111                         break;
    112                 }
    113         }
    114 }
    115 
     36// ==================================================
    11637fn main() {
    11738        let options = App::new("Cycle Tokio")
    118                 .arg(Arg::with_name("duration")  .short("d").long("duration")  .takes_value(true).default_value("5").help("Duration of the experiments in seconds"))
    119                 .arg(Arg::with_name("iterations").short("i").long("iterations").takes_value(true).conflicts_with("duration").help("Number of iterations of the experiments"))
    120                 .arg(Arg::with_name("nthreads")  .short("t").long("nthreads")  .takes_value(true).default_value("1").help("Number of threads to use"))
    121                 .arg(Arg::with_name("nprocs")    .short("p").long("nprocs")    .takes_value(true).default_value("1").help("Number of processors to use"))
     39                .args(&bench::args())
    12240                .arg(Arg::with_name("ringsize")  .short("r").long("ringsize")  .takes_value(true).default_value("1").help("Number of threads in a cycle"))
    12341                .get_matches();
     
    12745        let nprocs    = options.value_of("nprocs").unwrap().parse::<usize>().unwrap();
    12846
    129         if options.is_present("iterations") {
    130                 unsafe{
    131                         CLOCK_MODE.init( false );
    132                         STOP_COUNT.init( options.value_of("iterations").unwrap().parse::<u64>().unwrap() );
    133                 }
    134         }
    135         else {
    136                 unsafe{
    137                         CLOCK_MODE.init(true);
    138                         DURATION  .init(options.value_of("duration").unwrap().parse::<f64>().unwrap());
    139                 }
    140         }
     47        let tthreads = nthreads * ring_size;
     48        let exp = Arc::new(bench::BenchData::new(options, tthreads));
    14149
    14250        let s = (1000000 as u64).to_formatted_string(&Locale::en);
    14351        assert_eq!(&s, "1,000,000");
    14452
    145 
    146         let tthreads = nthreads * ring_size;
    147         THREADS_LEFT.store(tthreads as u64, Ordering::SeqCst);
    148         let thddata = Arc::new(prep(nthreads, tthreads));
     53        let thddata : Arc<Vec<Arc<Partner>>> = Arc::new(
     54                (0..tthreads).map(|i| {
     55                        let pi = (i + nthreads) % tthreads;
     56                        Arc::new(Partner{
     57                                sem: sync::Semaphore::new(0),
     58                                next: pi,
     59                        })
     60                }).collect()
     61        );
    14962
    15063        let mut global_counter :u64 = 0;
     
    15770
    15871        runtime.block_on(async {
    159                 let mut result  : Vec<sync::oneshot::Receiver::<u64>> = Vec::with_capacity(tthreads);
    160                 {
    161                         let mut threads = Vec::with_capacity(tthreads);
    162                         for i in 0..tthreads {
    163                                 let (s, r) = sync::oneshot::channel::<u64>();
    164                                 result.push(r);
    165                                 threads.push(tokio::spawn(partner_main(s, i, thddata.clone())));
    166                         }
    167                         println!("Starting");
     72                let threads: Vec<_> = (0..tthreads).map(|i| {
     73                        tokio::spawn(partner_main(i, thddata.clone(), exp.clone()))
     74                }).collect();
     75                println!("Starting");
    16876
    169                         let is_tty = stdout_isatty();
    170                         let start = Instant::now();
     77                let start = Instant::now();
    17178
    172                         for i in 0..nthreads {
    173                                 thddata[i].sem.add_permits(1);
    174                         }
     79                for i in 0..nthreads {
     80                        thddata[i].sem.add_permits(1);
     81                }
    17582
    176                         wait(&start, is_tty).await;
     83                duration = exp.wait(&start).await;
    17784
    178                         STOP.store(true, Ordering::SeqCst);
    179                         duration = start.elapsed();
     85                println!("\nDone");
    18086
    181                         println!("\nDone");
     87                for i in 0..tthreads {
     88                        thddata[i].sem.add_permits(1);
     89                }
    18290
    183                         for i in 0..tthreads {
    184                                 thddata[i].sem.add_permits(1);
    185                         }
    186 
    187                         for _ in 0..tthreads {
    188                                 global_counter += result.pop().unwrap().await.unwrap();
    189                         }
     91                for t in threads {
     92                        global_counter += t.await.unwrap();
    19093                }
    19194        });
  • benchmark/readyQ/locality.go

    r42f6e07 r2b4daf2  
    22
    33import (
     4        "context"
    45        "flag"
    56        "fmt"
    67        "math/rand"
    78        "os"
     9        "syscall"
    810        "sync/atomic"
    911        "time"
     12        "unsafe"
     13        "golang.org/x/sync/semaphore"
    1014        "golang.org/x/text/language"
    1115        "golang.org/x/text/message"
    1216)
    1317
    14 func handshake(stop chan struct {}, c chan [] uint64, data [] uint64, share bool) (bool, [] uint64) {
    15         var s [] uint64 = data
    16         if !share {
    17                 s = nil
    18         }
    19 
    20         // send the data
    21         select {
    22         case <- stop:
    23                 return true, nil
    24         case c <- s:
    25         }
    26 
    27         // get the new data chunk
    28         select {
    29         case <- stop:
    30                 return true, nil
    31         case n := <- c:
    32                 if share {
    33                         return false, n
    34                 }
    35                 return false, data
    36         }
    37 }
    38 
    39 func local(result chan uint64, start chan struct{}, stop chan struct{}, size uint64, cnt uint64, channels []chan [] uint64, chan_cnt uint64, share bool) {
     18// ==================================================
     19type MyData struct {
     20        _p1 [16]uint64 // padding
     21        ttid int
     22        id int
     23        data [] uint64
     24        _p2 [16]uint64 // padding
     25}
     26
     27func NewData(id int, size uint64) (*MyData) {
    4028        var data [] uint64
    4129        data = make([]uint64, size)
     
    4331                data[i] = 0
    4432        }
    45         count := uint64(0)
     33        return &MyData{[16]uint64{0}, syscall.Gettid(), id, data,[16]uint64{0}}
     34}
     35
     36func (this * MyData) moved( ttid int ) (uint64) {
     37        if this.ttid == ttid {
     38                return 0
     39        }
     40        this.ttid = ttid
     41        return 1
     42}
     43
     44func (this * MyData) access( idx uint64 ) {
     45        this.data[idx % uint64(len(this.data))] += 1
     46}
     47
     48// ==================================================
     49type MyCtx struct {
     50        _p1 [16]uint64 // padding
     51        s * semaphore.Weighted
     52        d unsafe.Pointer
     53        c context.Context
     54        ttid int
     55        id int
     56        _p2 [16]uint64 // padding
     57}
     58
     59func NewCtx( data * MyData, id int ) (MyCtx) {
     60        r := MyCtx{[16]uint64{0},semaphore.NewWeighted(1), unsafe.Pointer(data), context.Background(), syscall.Gettid(), id,[16]uint64{0}}
     61        r.s.Acquire(context.Background(), 1)
     62        return r
     63}
     64
     65func (this * MyCtx) moved( ttid int ) (uint64) {
     66        if this.ttid == ttid {
     67                return 0
     68        }
     69        this.ttid = ttid
     70        return 1
     71}
     72
     73// ==================================================
     74// Atomic object where a single thread can wait
     75// May exchanges data
     76type Spot struct {
     77        _p1 [16]uint64 // padding
     78        ptr uintptr // atomic variable use fo MES
     79        id int      // id for debugging
     80        _p2 [16]uint64 // padding
     81}
     82
     83// Main handshake of the code
     84// Single seat, first thread arriving waits
     85// Next threads unblocks current one and blocks in its place
     86// if share == true, exchange data in the process
     87func (this * Spot) put( ctx * MyCtx, data * MyData, share bool) (* MyData, bool) {
     88        new := uintptr(unsafe.Pointer(ctx))
     89        // old_d := ctx.d
     90
     91        // Attempt to CAS our context into the seat
     92        var raw uintptr
     93        for true {
     94                raw = this.ptr
     95                if raw == uintptr(1) { // Seat is closed, return
     96                        return nil, true
     97                }
     98                if atomic.CompareAndSwapUintptr(&this.ptr, raw, new) {
     99                        break // We got the seat
     100                }
     101        }
     102
     103        // If we aren't the fist in, wake someone
     104        if raw != uintptr(0) {
     105                var val *MyCtx
     106                val = (*MyCtx)(unsafe.Pointer(raw))
     107
     108                // If we are sharing, give them our data
     109                if share {
     110                        // fmt.Printf("[%d] - %d update %d: %p -> %p\n", this.id, ctx.id, val.id, val.d, data)
     111                        atomic.StorePointer(&val.d, unsafe.Pointer(data))
     112                }
     113
     114                // Wake them up
     115                // fmt.Printf("[%d] - %d release %d\n", this.id, ctx.id, val.id)
     116                val.s.Release(1)
     117        }
     118
     119        // fmt.Printf("[%d] - %d enter\n", this.id, ctx.id)
     120
     121        // Block once on the seat
     122        ctx.s.Acquire(ctx.c, 1)
     123
     124        // Someone woke us up, get the new data
     125        ret := (* MyData)(atomic.LoadPointer(&ctx.d))
     126        // fmt.Printf("[%d] - %d leave: %p -> %p\n", this.id, ctx.id, ret, old_d)
     127
     128        return ret, false
     129}
     130
     131// Shutdown the spot
     132// Wake current thread and mark seat as closed
     133func (this * Spot) release() {
     134        val := (*MyCtx)(unsafe.Pointer(atomic.SwapUintptr(&this.ptr, uintptr(1))))
     135        if val == nil {
     136                return
     137        }
     138
     139        // Someone was there, release them
     140        val.s.Release(1)
     141}
     142
     143// ==================================================
     144// Struct for result, Go doesn't support passing tuple in channels
     145type Result struct {
     146        count uint64
     147        gmigs uint64
     148        dmigs uint64
     149}
     150
     151func NewResult() (Result) {
     152        return Result{0, 0, 0}
     153}
     154
     155// ==================================================
     156// Random number generator, Go's native one is to slow and global
     157func __xorshift64( state * uint64 ) (uint64) {
     158        x := *state
     159        x ^= x << 13
     160        x ^= x >> 7
     161        x ^= x << 17
     162        *state = x
     163        return x
     164}
     165
     166// ==================================================
     167// Do some work by accessing 'cnt' cells in the array
     168func work(data * MyData, cnt uint64, state * uint64) {
     169        for i := uint64(0); i < cnt; i++ {
     170                data.access(__xorshift64(state))
     171        }
     172}
     173
     174// Main body of the threads
     175func local(result chan Result, start chan struct{}, size uint64, cnt uint64, channels [] Spot, share bool, id int) {
     176        // Initialize some data
     177        state := rand.Uint64()    // RNG state
     178        data := NewData(id, size) // Starting piece of data
     179        ctx := NewCtx(data, id)   // Goroutine local context
     180
     181        // Prepare results
     182        r := NewResult()
     183
     184        // Wait for start
    46185        <- start
     186
     187        // Main loop
    47188        for true {
    48                 for i := uint64(0); i < cnt; i++ {
    49                         data[rand.Uint64() % size] += 1
    50                 }
    51 
    52                 i := rand.Uint64() % chan_cnt
     189                // Touch our current data, write to invalidate remote cache lines
     190                work(data, cnt, &state)
     191
     192                // Wait on a random spot
     193                i := __xorshift64(&state) % uint64(len(channels))
    53194                var closed bool
    54                 closed, data = handshake(stop, channels[i], data, share)
    55                 count += 1
    56 
    57                 if  closed { break }
    58                 if !clock_mode && count >= stop_count { break }
    59         }
    60 
     195                data, closed = channels[i].put(&ctx, data, share)
     196
     197                // Check if the experiment is over
     198                if closed { break }                                       // yes, spot was closed
     199                if  clock_mode && atomic.LoadInt32(&stop) == 1 { break }  // yes, time's up
     200                if !clock_mode && r.count >= stop_count { break }         // yes, iterations reached
     201
     202                // Check everything is consistent
     203                if uint64(len(data.data)) != size { panic("Data has weird size") }
     204
     205                // write down progress and check migrations
     206                ttid := syscall.Gettid()
     207                r.count += 1
     208                r.gmigs += ctx .moved(ttid)
     209                r.dmigs += data.moved(ttid)
     210        }
     211
     212        // Mark goroutine as done
    61213        atomic.AddInt64(&threads_left, -1);
    62         result <- count
    63 }
    64 
     214
     215        // return result
     216        result <- r
     217}
     218
     219// ==================================================
     220// Program main
    65221func main() {
    66 
    67         work_sizeOpt := flag.Uint64("w", 2    , "Number of words (uint64) per threads")
    68         countOpt     := flag.Uint64("c", 2    , "Number of words (uint64) to touch")
     222        // Benchmark specific command line arguments
     223        nspotsOpt    := flag.Int   ("n", 0    , "Number of spots where threads sleep (nthreads - nspots are active at the same time)")
     224        work_sizeOpt := flag.Uint64("w", 2    , "Size of the array for each threads, in words (64bit)")
     225        countOpt     := flag.Uint64("c", 2    , "Number of words to touch when working (random pick, cells can be picked more than once)")
    69226        shareOpt     := flag.Bool  ("s", false, "Pass the work data to the next thread when blocking")
    70227
    71         bench_init()
    72 
     228        // General benchmark initialization and deinitialization
     229        defer bench_init()()
     230
     231        // Eval command line arguments
     232        nspots:= *nspotsOpt
    73233        size  := *work_sizeOpt
    74234        cnt   := *countOpt
    75235        share := *shareOpt
    76236
     237        if nspots == 0 { nspots = nthreads - nprocs; }
     238
     239        // Check params
    77240        if ! (nthreads > nprocs) {
    78241                fmt.Fprintf(os.Stderr, "Must have more threads than procs\n")
     
    80243        }
    81244
    82         barrierStart := make(chan struct{})
    83         barrierStop  := make(chan struct{})
    84         threads_left = int64(nthreads)
    85         result  := make(chan uint64)
    86         channels := make([]chan [] uint64, nthreads - nprocs)
     245        // Make global data
     246        barrierStart := make(chan struct{})         // Barrier used at the start
     247        threads_left = int64(nthreads - nspots)                // Counter for active threads (not 'nthreads' because at all times 'nthreads - nprocs' are blocked)
     248        result  := make(chan Result)                // Channel for results
     249        channels := make([]Spot, nspots) // Number of spots
    87250        for i := range channels {
    88                 channels[i] = make(chan [] uint64, 1)
    89         }
    90 
     251                channels[i] = Spot{[16]uint64{0},uintptr(0), i,[16]uint64{0}}     // init spots
     252        }
     253
     254        // start the goroutines
    91255        for i := 0; i < nthreads; i++ {
    92                 go local(result, barrierStart, barrierStop, size, cnt, channels, uint64(nthreads - nprocs), share)
     256                go local(result, barrierStart, size, cnt, channels, share, i)
    93257        }
    94258        fmt.Printf("Starting\n");
    95259
     260        atomic.StoreInt32(&stop, 0)
    96261        start := time.Now()
    97         close(barrierStart)
    98 
    99         wait(start, true);
    100 
    101         close(barrierStop)
     262        close(barrierStart) // release barrier
     263
     264        wait(start, true);  // general benchmark wait
     265
     266        atomic.StoreInt32(&stop, 1)
    102267        end := time.Now()
    103268        delta := end.Sub(start)
     
    105270        fmt.Printf("\nDone\n")
    106271
    107         global_counter := uint64(0)
     272        // release all the blocked threads
     273        for i := range channels {
     274                channels[i].release()
     275        }
     276
     277        // Join and accumulate results
     278        results := NewResult()
    108279        for i := 0; i < nthreads; i++ {
    109                 global_counter += <- result
    110         }
    111 
     280                r := <- result
     281                results.count += r.count
     282                results.gmigs += r.gmigs
     283                results.dmigs += r.dmigs
     284        }
     285
     286        // Print with nice 's, i.e. 1'000'000 instead of 1000000
    112287        p := message.NewPrinter(language.English)
    113         p.Printf("Duration (ms)          : %f\n", delta.Seconds());
     288        p.Printf("Duration (s)           : %f\n", delta.Seconds());
    114289        p.Printf("Number of processors   : %d\n", nprocs);
    115290        p.Printf("Number of threads      : %d\n", nthreads);
    116291        p.Printf("Work size (64bit words): %d\n", size);
    117         p.Printf("Total Operations(ops)  : %15d\n", global_counter)
    118         p.Printf("Ops per second         : %18.2f\n", float64(global_counter) / delta.Seconds())
    119         p.Printf("ns per ops             : %18.2f\n", float64(delta.Nanoseconds()) / float64(global_counter))
    120         p.Printf("Ops per threads        : %15d\n", global_counter / uint64(nthreads))
    121         p.Printf("Ops per procs          : %15d\n", global_counter / uint64(nprocs))
    122         p.Printf("Ops/sec/procs          : %18.2f\n", (float64(global_counter) / float64(nprocs)) / delta.Seconds())
    123         p.Printf("ns per ops/procs       : %18.2f\n", float64(delta.Nanoseconds()) / (float64(global_counter) / float64(nprocs)))
    124 }
     292        p.Printf("Total Operations(ops)  : %15d\n", results.count)
     293        p.Printf("Total G Migrations     : %15d\n", results.gmigs)
     294        p.Printf("Total D Migrations     : %15d\n", results.dmigs)
     295        p.Printf("Ops per second         : %18.2f\n", float64(results.count) / delta.Seconds())
     296        p.Printf("ns per ops             : %18.2f\n", float64(delta.Nanoseconds()) / float64(results.count))
     297        p.Printf("Ops per threads        : %15d\n", results.count / uint64(nthreads))
     298        p.Printf("Ops per procs          : %15d\n", results.count / uint64(nprocs))
     299        p.Printf("Ops/sec/procs          : %18.2f\n", (float64(results.count) / float64(nprocs)) / delta.Seconds())
     300        p.Printf("ns per ops/procs       : %18.2f\n", float64(delta.Nanoseconds()) / (float64(results.count) / float64(nprocs)))
     301}
  • benchmark/readyQ/rq_bench.hfa

    r42f6e07 r2b4daf2  
    3939                } else if(stop_count > 0) { \
    4040                        clock_mode = false; \
    41                         printf("Running for %lu iterations\n", stop_count); \
     41                        printf("Running for %llu iterations\n", stop_count); \
    4242                } else { \
    4343                        duration = 5; clock_mode = true;\
  • benchmark/readyQ/rq_bench.hpp

    r42f6e07 r2b4daf2  
    9797}
    9898
     99bool parse_truefalse(const char * arg, bool & value) {
     100        if(strcmp(arg, "true") == 0) {
     101                value = true;
     102                return true;
     103        }
     104
     105        if(strcmp(arg, "false") == 0) {
     106                value = false;
     107                return true;
     108        }
     109
     110        return false;
     111}
     112
    99113bool parse_settrue (const char *, bool & value ) {
    100114        value = true;
     
    226240        {
    227241                int idx = 0;
    228                 for(int i = 0; i < opt_count; i++) {
     242                for(size_t i = 0; i < opt_count; i++) {
    229243                        if(options[i].long_name) {
    230244                                optarr[idx].name = options[i].long_name;
     
    256270        {
    257271                int idx = 0;
    258                 for(int i = 0; i < opt_count; i++) {
     272                for(size_t i = 0; i < opt_count; i++) {
    259273                        optstring[idx] = options[i].short_name;
    260274                        idx++;
     
    279293                        case 'h':
    280294                                out = stdout;
     295                                [[fallthrough]];
    281296                        case '?':
    282297                                usage(argv[0], options, opt_count, usage_msg, out);
    283298                        default:
    284                                 for(int i = 0; i < opt_count; i++) {
     299                                for(size_t i = 0; i < opt_count; i++) {
    285300                                        if(opt == options[i].short_name) {
    286301                                                const char * arg = optarg ? optarg : "";
     302                                                if( arg[0] == '=' ) { arg++; }
    287303                                                bool success = options[i].parse_fun( arg, options[i].variable );
    288304                                                if(success) goto NEXT_ARG;
     
    319335        int width = 0;
    320336        {
    321                 for(int i = 0; i < opt_count; i++) {
     337                for(size_t i = 0; i < opt_count; i++) {
    322338                        if(options[i].long_name) {
    323339                                int w = strlen(options[i].long_name);
     
    338354        fprintf(out, "Usage:\n  %s %s\n", cmd, help);
    339355
    340         for(int i = 0; i < opt_count; i++) {
     356        for(size_t i = 0; i < opt_count; i++) {
    341357                printopt(out, width, max_width, options[i].short_name, options[i].long_name, options[i].help);
    342358        }
Note: See TracChangeset for help on using the changeset viewer.