File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -4,21 +4,34 @@ module Multififo = Picos_mux_multififo
4
4
5
5
let run_one_multififo ~budgetf ~n_domains ~n () =
6
6
let context = ref (Obj. magic () ) in
7
+ let per_threads = Array. make n_domains (Obj. magic () ) in
8
+
9
+ let iters = if n < 1_000_000 then 1_000_000 / n else 1 in
7
10
8
11
let before _ = context := Multififo. context () in
9
12
let init _ = ! context in
10
- let work i context =
11
- if i <> 0 then Multififo. runner_on_this_thread context
12
- else ignore @@ Multififo. run ~context @@ fun () -> Run. for_n n ignore
13
+ let wrap i context action =
14
+ if i = 0 then Multififo. run ~context action
15
+ else
16
+ Multififo. with_per_thread context @@ fun per_thread ->
17
+ per_threads.(i) < - per_thread;
18
+ action ()
19
+ in
20
+ let work i _context =
21
+ if i <> 0 then Multififo. next per_threads.(i)
22
+ else
23
+ for _ = 1 to iters do
24
+ Run. for_n n ignore
25
+ done
13
26
in
14
27
15
28
let config =
16
29
Printf. sprintf " %d mfifo%s, run_n %d" n_domains
17
30
(if n_domains = 1 then " " else " s" )
18
31
n
19
32
in
20
- Times. record ~budgetf ~n_domains ~before ~init ~work ()
21
- |> Times. to_thruput_metrics ~n ~singular: " ignore" ~config
33
+ Times. record ~budgetf ~n_domains ~before ~init ~wrap ~ work ()
34
+ |> Times. to_thruput_metrics ~n: (n * iters) ~singular: " ignore" ~config
22
35
23
36
let run_suite ~budgetf =
24
37
Util. cross [ 1 ; 2 ; 4 ; 8 ]
Original file line number Diff line number Diff line change @@ -73,3 +73,10 @@ val run_on :
73
73
74
74
The optional [forbid] argument defaults to [false] and determines whether
75
75
propagation of cancelation is initially allowed. *)
76
+
77
+ (* */**)
78
+
79
+ type per_thread
80
+
81
+ val with_per_thread : t -> (per_thread -> 'a ) -> 'a
82
+ val next : per_thread -> unit
You can’t perform that action at this time.
0 commit comments