diff --git a/benchs/fib_rec.ml b/benchs/fib_rec.ml index b0f1623d..25291e8c 100644 --- a/benchs/fib_rec.ml +++ b/benchs/fib_rec.ml @@ -1,4 +1,7 @@ open Moonpool +module Trace = Trace_core + +let ( let@ ) = ( @@ ) let rec fib_direct x = if x <= 1 then @@ -10,7 +13,7 @@ let cutoff = ref 20 let rec fib ~on x : int Fut.t = if x <= !cutoff then - Fut.spawn ~on (fun () -> fib_direct x) + Fut.spawn ~name:"fib" ~on (fun () -> fib_direct x) else let open Fut.Infix in let+ t1 = fib ~on (x - 1) and+ t2 = fib ~on (x - 2) in @@ -27,14 +30,14 @@ let fib_fj ~on x : int Fut.t = n1 + n2 ) in - Fut.spawn ~on (fun () -> fib_rec x) + Fut.spawn ~name:"fib" ~on (fun () -> fib_rec x) let fib_await ~on x : int Fut.t = let rec fib_rec x : int Fut.t = if x <= !cutoff then - Fut.spawn ~on (fun () -> fib_direct x) + Fut.spawn ~name:"fib" ~on (fun () -> fib_direct x) else - Fut.spawn ~on (fun () -> + Fut.spawn ~name:"fib" ~on (fun () -> let n1 = fib_rec (x - 1) in let n2 = fib_rec (x - 2) in let n1 = Fut.await n1 in @@ -66,6 +69,7 @@ let str_of_int_opt = function | Some i -> Printf.sprintf "Some %d" i let run ~psize ~n ~seq ~dl ~fj ~await ~niter ~kind () : unit = + let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "fib.run" in let pool = lazy (create_pool ~kind ~psize ()) in let dl_pool = lazy @@ -108,6 +112,7 @@ let run ~psize ~n ~seq ~dl ~fj ~await ~niter ~kind () : unit = Ws_pool.shutdown (Lazy.force pool) let () = + let@ () = Trace_tef.with_setup () in let n = ref 40 in let psize = ref None in let seq = ref false in diff --git a/benchs/pi.ml b/benchs/pi.ml index c8ef57b5..7e0dfd91 100644 --- a/benchs/pi.ml +++ b/benchs/pi.ml @@ -7,6 +7,7 @@ let j = ref 0 let spf = Printf.sprintf let run_sequential (num_steps : int) : float = + let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "pi.seq" in let step = 1. /. float num_steps in let sum = ref 0. in for i = 0 to num_steps - 1 do @@ -42,6 +43,11 @@ let run_par1 ~kind (num_steps : int) : float = (* one chunk of the work *) let run_task _idx_task : unit = + let@ _sp = + Trace.with_span ~__FILE__ ~__LINE__ "pi.slice" ~data:(fun () -> + [ "i", `Int _idx_task ]) + in + let sum = ref 0. in let i = ref 0 in while !i < num_steps do @@ -69,7 +75,7 @@ let run_fork_join ~kind num_steps : float = let step = 1. /. float num_steps in let global_sum = Lock.create 0. in - Ws_pool.run_wait_block pool (fun () -> + Ws_pool.run_wait_block ~name:"pi.fj" pool (fun () -> Fork_join.for_ ~chunk_size:(3 + (num_steps / num_tasks)) num_steps @@ -99,6 +105,9 @@ type mode = let () = let@ () = Trace_tef.with_setup () in + Trace.set_thread_name "main"; + let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in + let mode = ref Sequential in let n = ref 1000 in let time = ref false in diff --git a/test/effect-based/t_fork_join_heavy.ml b/test/effect-based/t_fork_join_heavy.ml index a981bee1..bacb1d18 100644 --- a/test/effect-based/t_fork_join_heavy.ml +++ b/test/effect-based/t_fork_join_heavy.ml @@ -33,10 +33,12 @@ let run ~min () = let l1, l2 = Fork_join.both (fun () -> + let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "fj.left" in Fork_join.map_list ~chunk_size (Fork_join.map_list ~chunk_size neg) l) (fun () -> + let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "fj.right" in Fork_join.map_list ~chunk_size (Fork_join.map_list ~chunk_size neg) ref_l1)