Skip to content

Commit 780fca5

Browse files
committed
Change the Op bench to more closely match the Xt bench
1 parent bac19d5 commit 780fca5

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

bench/bench_op.ml

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,26 @@ let run_one ?(n_locs = 2) ?(factor = 1)
55
?(n_iter = 10 * factor * Util.iter_factor) () =
66
let locs = Loc.make_array n_locs 0 in
77

8-
let to_1 =
9-
locs |> Array.map (fun loc -> Op.make_cas loc 0 1) |> Array.to_list
8+
let rec make_incr cass i n =
9+
if i < n then
10+
let loc = Array.unsafe_get locs i in
11+
let x = Loc.fenceless_get loc in
12+
let cas = Op.make_cas loc x (x + 1) in
13+
make_incr (cas :: cass) (i + 1) n
14+
else cass
1015
in
11-
let to_0 =
12-
locs |> Array.map (fun loc -> Op.make_cas loc 1 0) |> Array.to_list
16+
17+
let rec incr () =
18+
let cass = make_incr [] 0 n_locs in
19+
if not (Op.atomically cass) then incr ()
1320
in
1421

1522
let init _ = () in
1623
let work _ () =
1724
let rec loop i =
1825
if i > 0 then begin
19-
Op.atomically to_1 |> ignore;
20-
Op.atomically to_0 |> ignore;
21-
loop (i - 2)
26+
incr ();
27+
loop (i - 1)
2228
end
2329
in
2430
loop n_iter

0 commit comments

Comments
 (0)