Skip to content

Commit

Permalink
Move bench framework to multicore-bench project
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Jan 16, 2024
1 parent 0228553 commit 596c396
Show file tree
Hide file tree
Showing 22 changed files with 65 additions and 561 deletions.
13 changes: 0 additions & 13 deletions bench/barrier.ml

This file was deleted.

4 changes: 0 additions & 4 deletions bench/barrier.mli

This file was deleted.

174 changes: 0 additions & 174 deletions bench/bench.ml

This file was deleted.

27 changes: 0 additions & 27 deletions bench/bench.mli

This file was deleted.

25 changes: 5 additions & 20 deletions bench/bench_accumulator.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Kcas_data
open Bench
open Multicore_bench

let run_one ~budgetf ~n_domains ?(n_ops = 180 * Util.iter_factor) () =
let n_ops = n_ops * n_domains in
Expand Down Expand Up @@ -29,28 +29,13 @@ let run_one ~budgetf ~n_domains ?(n_ops = 180 * Util.iter_factor) () =

let after () = Atomic.set n_ops_todo n_ops in

let times = Times.record ~n_domains ~budgetf ~init ~work ~after () in

let name metric =
Printf.sprintf "%s/%d worker%s, 0%% reads" metric n_domains
let config =
Printf.sprintf "%d worker%s, 0%% reads" n_domains
(if n_domains = 1 then "" else "s")
in

List.concat
[
Stats.of_times times
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_ops)
|> Stats.to_json
~name:(name "time per operation")
~description:"Average time to increment accumulator" ~units:"ns";
Times.invert times |> Stats.of_times
|> Stats.scale (Float.of_int (n_ops * n_domains) /. 1_000_000.0)
|> Stats.to_json
~name:(name "operations over time")
~description:
"Number of operations performed over time using all domains"
~units:"M/s";
]
Times.record ~n_domains ~budgetf ~init ~work ~after ()
|> Util.thruput_metrics ~n:n_ops ~config ~singular:"operation"

let run_suite ~budgetf =
[ 1; 2; 4 ]
Expand Down
19 changes: 3 additions & 16 deletions bench/bench_atomic.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
open Bench
open Multicore_bench

module Atomic = struct
include Stdlib.Atomic
Expand Down Expand Up @@ -31,21 +31,8 @@ let run_one ~budgetf ?(n_iter = 500 * Util.iter_factor)
loop n_iter
in

let times = Times.record ~n_domains:1 ~budgetf ~init ~work () in

List.concat
[
Stats.of_times times
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_iter)
|> Stats.to_json
~name:(Printf.sprintf "time per op/%s" name)
~description:"Time to perform a single op" ~units:"ns";
Times.invert times |> Stats.of_times
|> Stats.scale (Float.of_int n_iter /. 1_000_000.0)
|> Stats.to_json
~name:(Printf.sprintf "ops over time/%s" name)
~description:"Number of operations performed over time" ~units:"M/s";
]
Times.record ~n_domains:1 ~budgetf ~init ~work ()
|> Util.thruput_metrics ~n:n_iter ~singular:"op" ~config:name

let run_suite ~budgetf =
[
Expand Down
48 changes: 7 additions & 41 deletions bench/bench_dllist.ml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
open Kcas_data
open Bench
open Multicore_bench

let run_single ~budgetf ?(n_msgs = 15 * Util.iter_factor) () =
let t = Dllist.create () in
Expand All @@ -12,26 +12,8 @@ let run_single ~budgetf ?(n_msgs = 15 * Util.iter_factor) () =
done
in

let times = Times.record ~n_domains:1 ~budgetf ~init ~work () in

let name metric = Printf.sprintf "%s/one domain" metric in

List.concat
[
Stats.of_times times
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_msgs)
|> Stats.to_json ~name:(name "time per message")
~description:
"Time to transmit one message from one domain to another"
~units:"ns";
Times.invert times |> Stats.of_times
|> Stats.scale (Float.of_int n_msgs /. 1_000_000.0)
|> Stats.to_json
~name:(name "messages over time")
~description:
"Number of messages transmitted over time using all domains"
~units:"M/s";
]
Times.record ~n_domains:1 ~budgetf ~init ~work ()
|> Util.thruput_metrics ~n:n_msgs ~singular:"message" ~config:"one domain"

let run_one ~budgetf ?(n_adders = 2) ?(n_takers = 2) ?(factor = 1)
?(n_msgs = 20 * factor * Util.iter_factor) () =
Expand Down Expand Up @@ -74,36 +56,20 @@ let run_one ~budgetf ?(n_adders = 2) ?(n_takers = 2) ?(factor = 1)
Atomic.set n_msgs_to_add n_msgs
in

let times = Times.record ~n_domains ~budgetf ~init ~work ~after () in

let name metric =
let config =
let format role blocking n =
Printf.sprintf "%d %s%s%s" n
(if blocking then "" else "nb ")
role
(if n = 1 then "" else "s")
in
Printf.sprintf "%s/%s, %s" metric
Printf.sprintf "%s, %s"
(format "adder" false n_adders)
(format "taker" false n_takers)
in

List.concat
[
Stats.of_times times
|> Stats.scale (1_000_000_000.0 /. Float.of_int n_msgs)
|> Stats.to_json ~name:(name "time per message")
~description:
"Time to transmit one message from one domain to another"
~units:"ns";
Times.invert times |> Stats.of_times
|> Stats.scale (Float.of_int (n_msgs * n_domains) /. 1_000_000.0)
|> Stats.to_json
~name:(name "messages over time")
~description:
"Number of messages transmitted over time using all domains"
~units:"M/s";
]
Times.record ~n_domains ~budgetf ~init ~work ~after ()
|> Util.thruput_metrics ~n:n_msgs ~singular:"message" ~config

let run_suite ~budgetf =
run_single ~budgetf ()
Expand Down
Loading

0 comments on commit 596c396

Please sign in to comment.