Changeset 4d8fbf4 for benchmark


Ignore:
Timestamp:
Sep 16, 2021, 2:22:01 PM (3 years ago)
Author:
caparsons <caparson@…>
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.
Message:

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

Location:
benchmark
Files:
4 added
13 edited

Legend:

Unmodified
Added
Removed
  • benchmark/Cargo.toml.in

    ra8367eb r4d8fbf4  
    66
    77[[bin]]
    8 name = "cycle-tokio"
     8name = "rdq-cycle-tokio"
    99path = "@abs_srcdir@/readyQ/cycle.rs"
    1010
    1111[[bin]]
    12 name = "locality-tokio"
     12name = "rdq-locality-tokio"
    1313path = "@abs_srcdir@/readyQ/locality.rs"
     14
     15[[bin]]
     16name = "rdq-transfer-tokio"
     17path = "@abs_srcdir@/readyQ/transfer.rs"
     18
     19[[bin]]
     20name = "rdq-yield-tokio"
     21path = "@abs_srcdir@/readyQ/yield.rs"
    1422
    1523[features]
  • benchmark/Makefile.am

    ra8367eb r4d8fbf4  
    2121include $(top_srcdir)/tools/build/cfa.make
    2222
    23 AM_CFLAGS = -O2 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
     23AM_CFLAGS = -O3 -Wall -Wextra -I$(srcdir) -lrt -pthread # -Werror
    2424AM_CFAFLAGS = -quiet -nodebug
    2525AM_UPPFLAGS = -quiet -nodebug -multi -std=c++14
     
    612612## =========================================================================================================
    613613
    614 %-tokio$(EXEEXT): $(srcdir)/readyQ/%.rs $(srcdir)/bench.rs
    615         cd $(builddir) && cargo build --release
    616         cp $(builddir)/target/release/$(basename $@) $@
     614RDQBENCHES = \
     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
     632rdq-benches:
     633        +make $(RDQBENCHES)
     634
     635clean-rdq-benches:
     636        rm -rf $(RDQBENCHES) $(builddir)/target go.mod
     637
     638rdq-%-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
     644rdq-%-cfa$(EXEEXT): $(srcdir)/readyQ/%.cfa $(srcdir)/readyQ/rq_bench.hfa
     645        $(BENCH_V_CFA)$(CFACOMPILE) $< -o $@
     646
     647go.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
     654rdq-%-go$(EXEEXT): $(srcdir)/readyQ/%.go $(srcdir)/readyQ/bench.go go.mod
     655        $(BENCH_V_GOC)go build -o $@ $< $(srcdir)/readyQ/bench.go
     656
     657rdq-%-fibre$(EXEEXT): $(srcdir)/readyQ/%.cpp
     658        $(BENCH_V_CXX)$(CXXCOMPILE) $< -o $@ -lfibre -std=c++17 $(AM_CFLAGS)
     659
     660# ## =========================================================================================================
     661
     662CLEANFILES = $(RDQBENCHES) go.mod go.sum
     663
     664clean-local:
     665        -rm -rf target
  • benchmark/bench.rs

    ra8367eb r4d8fbf4  
    11use std::io::{self, Write};
     2use std::option;
    23use std::sync::atomic::{AtomicU64, AtomicBool, Ordering};
    34use std::time::{Instant,Duration};
     5use std::u128;
    46
    57use clap::{Arg, ArgMatches};
     
    2729
    2830impl BenchData {
    29         pub fn new(options: ArgMatches, nthreads: usize) -> BenchData {
     31        pub fn new(options: ArgMatches, nthreads: usize, default_it: option::Option<u64>) -> BenchData {
    3032                let (clock_mode, stop_count, duration) = if options.is_present("iterations") {
    3133                        (false,
    3234                        options.value_of("iterations").unwrap().parse::<u64>().unwrap(),
     35                        -1.0)
     36                } else if !default_it.is_none() {
     37                        (false,
     38                        default_it.unwrap(),
    3339                        -1.0)
    3440                } else {
     
    4854        }
    4955
     56        #[allow(dead_code)]
    5057        pub async fn wait(&self, start: &Instant) -> Duration{
    5158                loop {
     
    6976}
    7077
     78// ==================================================
     79pub 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  
    4141                        Fibre * threads[tthreads];
    4242                        Partner thddata[tthreads];
    43                         for(int i = 0; i < tthreads; i++) {
     43                        for(unsigned i = 0; i < tthreads; i++) {
    4444                                unsigned pi = (i + nthreads) % tthreads;
    4545                                thddata[i].next = &thddata[pi].self;
    4646                        }
    47                         for(int i = 0; i < tthreads; i++) {
     47                        for(unsigned i = 0; i < tthreads; i++) {
    4848                                threads[i] = new Fibre( reinterpret_cast<void (*)(void *)>(partner_main), &thddata[i] );
    4949                        }
     
    5353                        start = timeHiRes();
    5454
    55                         for(int i = 0; i < nthreads; i++) {
     55                        for(unsigned i = 0; i < nthreads; i++) {
    5656                                thddata[i].self.post();
    5757                        }
     
    6262                        printf("\nDone\n");
    6363
    64                         for(int i = 0; i < tthreads; i++) {
     64                        for(unsigned i = 0; i < tthreads; i++) {
    6565                                thddata[i].self.post();
    6666                                fibre_join( threads[i], nullptr );
  • benchmark/readyQ/cycle.go

    ra8367eb r4d8fbf4  
    6060        atomic.StoreInt32(&stop, 1)
    6161        end := time.Now()
    62         delta := end.Sub(start)
     62        duration := end.Sub(start)
    6363
    6464        fmt.Printf("\nDone\n")
     
    7474
    7575        p := message.NewPrinter(language.English)
    76         p.Printf("Duration (ms)        : %f\n", delta.Seconds());
     76        p.Printf("Duration (ms)        : %d\n", duration.Milliseconds())
    7777        p.Printf("Number of processors : %d\n", nprocs);
    7878        p.Printf("Number of threads    : %d\n", tthreads);
    7979        p.Printf("Cycle size (# thrds) : %d\n", ring_size);
    8080        p.Printf("Total Operations(ops): %15d\n", global_counter)
    81         p.Printf("Ops per second       : %18.2f\n", float64(global_counter) / delta.Seconds())
    82         p.Printf("ns per ops           : %18.2f\n", float64(delta.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))
    8383        p.Printf("Ops per threads      : %15d\n", global_counter / uint64(tthreads))
    8484        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)) / delta.Seconds())
    86         p.Printf("ns per ops/procs     : %18.2f\n", float64(delta.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)))
    8787
    8888}
  • benchmark/readyQ/cycle.rs

    ra8367eb r4d8fbf4  
    4646
    4747        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));
    4949
    5050        let s = (1000000 as u64).to_formatted_string(&Locale::en);
  • benchmark/readyQ/locality.go

    ra8367eb r4d8fbf4  
    286286        // Print with nice 's, i.e. 1'000'000 instead of 1000000
    287287        p := message.NewPrinter(language.English)
    288         p.Printf("Duration (s)           : %f\n", delta.Seconds());
     288        p.Printf("Duration (ms)          : %f\n", delta.Milliseconds());
    289289        p.Printf("Number of processors   : %d\n", nprocs);
    290290        p.Printf("Number of threads      : %d\n", nthreads);
  • benchmark/readyQ/locality.rs

    ra8367eb r4d8fbf4  
    124124                                                return (r as *mut MyData, true);
    125125                                        }
    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) {
    128128                                                break expected;// We got the seat
    129129                                        }
     
    285285        assert_eq!(&s, "1,000,000");
    286286
    287         let exp = Arc::new(bench::BenchData::new(options, nprocs));
     287        let exp = Arc::new(bench::BenchData::new(options, nprocs, None));
    288288        let mut results = Result::new();
    289289
  • benchmark/readyQ/transfer.cfa

    ra8367eb r4d8fbf4  
    3939                        Pause();
    4040                        if( (timeHiRes() - start) > 5`s ) {
     41                                print_stats_now( bench_cluster, CFA_STATS_READY_Q | CFA_STATS_IO );
    4142                                serr | "Programs has been blocked for more than 5 secs";
    4243                                exit(1);
     
    110111        cfa_option opt[] = {
    111112                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}
    113114        };
    114115        BENCH_OPT_PARSE("cforall transition benchmark");
     
    166167        }
    167168
    168         sout | "Duration                : " | ws(3, 3, unit(eng((end - start)`ds))) | 's';
     169        sout | "Duration (ms)           : " | ws(3, 3, unit(eng((end - start)`dms)));
    169170        sout | "Number of processors    : " | nprocs;
    170171        sout | "Number of threads       : " | nthreads;
  • benchmark/readyQ/transfer.cpp

    ra8367eb r4d8fbf4  
    173173        }
    174174
    175         std::cout << "Duration                : " << to_miliseconds(end - start) << "ms" << std::endl;
     175        std::cout << "Duration (ms)           : " << to_miliseconds(end - start) << std::endl;
    176176        std::cout << "Number of processors    : " << nprocs << std::endl;
    177177        std::cout << "Number of threads       : " << nthreads << std::endl;
  • benchmark/readyQ/yield.cfa

    ra8367eb r4d8fbf4  
    8080                }
    8181
    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);
    8386                printf("Yields per second   : %'18.2lf\n", ((double)global_counter) / (end - start)`s);
    8487                printf("ns per yields       : %'18.2lf\n", ((double)(end - start)`ns) / global_counter);
    85                 printf("Total yields        : %'15llu\n", global_counter);
    8688                printf("Yields per procs    : %'15llu\n", global_counter / nprocs);
    8789                printf("Yields/sec/procs    : %'18.2lf\n", (((double)global_counter) / nprocs) / (end - start)`s);
  • benchmark/readyQ/yield.cpp

    ra8367eb r4d8fbf4  
    154154
    155155                auto dur_nano = duration_cast<std::nano>(duration);
     156                auto dur_dms  = duration_cast<std::milli>(duration);
    156157
    157                 std::cout << "Took " << duration << " s\n";
     158                printf("Duration (ms)       : %'.2lf\n", dur_dms );
    158159                printf("Total yields        : %'15llu\n", global_counter );
    159160                printf("Yields per procs    : %'15llu\n", global_counter / nprocs );
  • benchmark/rmit.py

    ra8367eb r4d8fbf4  
    1616import random
    1717import re
     18import socket
    1819import subprocess
    1920import sys
     
    9596        return nopts
    9697
     98# returns the first option with key 'opt'
     99def 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
    97110def actions_eta(actions):
    98111        time = 0
    99112        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)
    107116        return time
     117
     118taskset_maps = None
     119
     120def 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
     140def 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
     157def settaskset(actions):
     158        return [settaskset_one(a) for a in actions]
    108159
    109160if __name__ == "__main__":
     
    115166        parser.add_argument('--file', nargs='?', type=argparse.FileType('w'), default=sys.stdout)
    116167        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')
    117169        parser.add_argument('command', metavar='command', type=str, nargs=1, help='the command prefix to run')
    118170        parser.add_argument('candidates', metavar='candidates', type=str, nargs='*', help='the candidate suffix to run')
     
    170222
    171223        # ================================================================================
    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
    173239        if options.list:
    174240                for a in actions:
     
    180246        # Prepare to run
    181247
    182         # find expected time
    183         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 
    186248        random.shuffle(actions)
    187249
     
    191253        first = True
    192254        for i, a in enumerate(actions):
    193                 sa = " ".join(a)
     255                sa = " ".join(a[3:] if withtaskset else a)
    194256                if first:
    195257                        first = False
     
    208270                                match = re.search("^(.*):(.*)$", s)
    209271                                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]))
    213278                options.file.flush()
    214279
Note: See TracChangeset for help on using the changeset viewer.