diff --git a/lib/task.ml b/lib/task.ml index 5745715..2239288 100644 --- a/lib/task.ml +++ b/lib/task.ml @@ -22,8 +22,8 @@ let do_task f p = | TasksActive -> raise e | _ -> () -let setup_pool ~num_domains = - let task_chan = Multi_channel.make (num_domains+1) in +let setup_pool ~num_additional_domains = + let task_chan = Multi_channel.make (num_additional_domains+1) in let rec worker () = match Multi_channel.recv task_chan with | Quit -> Multi_channel.clear_local_state (); @@ -31,7 +31,7 @@ let setup_pool ~num_domains = do_task t p; worker () in - let domains = Array.init num_domains (fun _ -> Domain.spawn worker) in + let domains = Array.init num_additional_domains (fun _ -> Domain.spawn worker) in {domains; task_chan} let async pool task = diff --git a/lib/task.mli b/lib/task.mli index 52947f1..3538193 100644 --- a/lib/task.mli +++ b/lib/task.mli @@ -7,8 +7,9 @@ type 'a promise type pool (** Type of task pool *) -val setup_pool : num_domains:int -> pool -(** Sets up a task execution pool with [num_domains]. *) +val setup_pool : num_additional_domains:int -> pool +(** Sets up a task execution pool with [num_additional_domains + 1] domains + * including the current domain *) exception TasksActive diff --git a/test/LU_decomposition_multicore.ml b/test/LU_decomposition_multicore.ml index 891b8e2..b47077d 100644 --- a/test/LU_decomposition_multicore.ml +++ b/test/LU_decomposition_multicore.ml @@ -54,7 +54,7 @@ let lup pool (a0 : float array) = a let () = - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in let a = parallel_create pool (fun _ _ -> (Random.State.float (Domain.DLS.get k) 100.0) +. 1.0 ) in let lu = lup pool a in diff --git a/test/enumerate_par.ml b/test/enumerate_par.ml index ee2ed4f..1567600 100644 --- a/test/enumerate_par.ml +++ b/test/enumerate_par.ml @@ -4,7 +4,7 @@ let n = try int_of_string Sys.argv.(2) with _ -> 100 module T = Domainslib.Task let _ = - let p = T.setup_pool ~num_domains:(num_domains - 1) in + let p = T.setup_pool ~num_additional_domains:(num_domains - 1) in T.parallel_for p ~start:0 ~finish:(n-1) ~chunk_size:16 ~body:(fun i -> print_string @@ Printf.sprintf "[%d] %d\n%!" (Domain.self () :> int) i); T.teardown_pool p diff --git a/test/fib_par.ml b/test/fib_par.ml index 66e9263..46e0a2e 100644 --- a/test/fib_par.ml +++ b/test/fib_par.ml @@ -15,7 +15,7 @@ let rec fib_par pool n = T.await pool a + T.await pool b let main = - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in let res = fib_par pool n in T.teardown_pool pool; Printf.printf "fib(%d) = %d\n" n res diff --git a/test/game_of_life_multicore.ml b/test/game_of_life_multicore.ml index eac22d3..57516a4 100644 --- a/test/game_of_life_multicore.ml +++ b/test/game_of_life_multicore.ml @@ -62,7 +62,7 @@ let rec repeat pool n = | _-> next pool; repeat pool (n-1) let ()= - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in print !rg; repeat pool n_times; print !rg; diff --git a/test/prefix_sum.ml b/test/prefix_sum.ml index 8ff4bd2..3f6792d 100644 --- a/test/prefix_sum.ml +++ b/test/prefix_sum.ml @@ -7,7 +7,7 @@ let gen n = Array.make n 1 (*(fun _ -> Random.int n)*) let prefix_sum pool = T.parallel_scan pool (+) let _ = - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in let arr = gen n in let t = Unix.gettimeofday() in let _ = prefix_sum pool arr in diff --git a/test/spectralnorm2_multicore.ml b/test/spectralnorm2_multicore.ml index 098e14f..e958b93 100644 --- a/test/spectralnorm2_multicore.ml +++ b/test/spectralnorm2_multicore.ml @@ -34,7 +34,7 @@ let eval_AtA_times_u pool u v = eval_A_times_u pool u w; eval_At_times_u pool w v let () = - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in let u = Array.make n 1.0 and v = Array.make n 0.0 in for _i = 0 to 9 do eval_AtA_times_u pool u v; eval_AtA_times_u pool v u diff --git a/test/sum_par.ml b/test/sum_par.ml index a74eb19..d65fbd3 100644 --- a/test/sum_par.ml +++ b/test/sum_par.ml @@ -5,7 +5,7 @@ module T = Domainslib.Task let _ = (* use parallel_for_reduce *) - let p = T.setup_pool ~num_domains:(num_domains - 1) in + let p = T.setup_pool ~num_additional_domains:(num_domains - 1) in let sum = T.parallel_for_reduce p (+) 0 ~chunk_size:(n/(4*num_domains)) ~start:0 ~finish:(n-1) ~body:(fun _i -> 1) @@ -16,7 +16,7 @@ let _ = let _ = (* explictly use empty pool and default chunk_size *) - let p = T.setup_pool ~num_domains:0 in + let p = T.setup_pool ~num_additional_domains:0 in let sum = Atomic.make 0 in T.parallel_for p ~start:0 ~finish:(n-1) ~body:(fun _i -> ignore (Atomic.fetch_and_add sum 1)); @@ -27,7 +27,7 @@ let _ = let _ = (* configured num_domains and default chunk_size *) - let p = T.setup_pool ~num_domains:(num_domains - 1) in + let p = T.setup_pool ~num_additional_domains:(num_domains - 1) in let sum = Atomic.make 0 in T.parallel_for p ~start:0 ~finish:(n-1) ~body:(fun _i -> ignore (Atomic.fetch_and_add sum 1)); diff --git a/test/summed_area_table.ml b/test/summed_area_table.ml index ec0aff7..4852b02 100644 --- a/test/summed_area_table.ml +++ b/test/summed_area_table.ml @@ -29,7 +29,7 @@ let calc_table pool mat = let _ = let m = Array.make_matrix size size 1 (*Array.init size (fun _ -> Array.init size (fun _ -> Random.int size))*) in - let pool = T.setup_pool ~num_domains:(num_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(num_domains - 1) in let _ = calc_table pool m in (* for i = 0 to size-1 do diff --git a/test/task_exn.ml b/test/task_exn.ml index 4b52de8..7a9e7da 100644 --- a/test/task_exn.ml +++ b/test/task_exn.ml @@ -3,7 +3,7 @@ module T = Domainslib.Task exception E let _ = - let pool = T.setup_pool ~num_domains:3 in + let pool = T.setup_pool ~num_additional_domains:3 in let p1 = T.async pool (fun () -> let p2 = T.async pool (fun () -> raise E) in diff --git a/test/task_throughput.ml b/test/task_throughput.ml index 8d59954..45a9466 100644 --- a/test/task_throughput.ml +++ b/test/task_throughput.ml @@ -53,7 +53,7 @@ let work _ = Domain.Sync.poll () let _ = Printf.printf "n_iterations: %d n_units: %d n_domains: %d\n" n_iterations n_tasks n_domains; - let pool = T.setup_pool ~num_domains:(n_domains - 1) in + let pool = T.setup_pool ~num_additional_domains:(n_domains - 1) in let hist = TimingHist.make 5 25 in for _ = 1 to n_iterations do