Skip to content

Commit 4c9da3e

Browse files
authored
Merge pull request #5 from ocaml-multicore/num_additional_domains
`num_domains` to `num_additional_domains`
2 parents 3f2c59b + 49f08ec commit 4c9da3e

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,17 @@ this on `utop`.
177177
```ocaml
178178
# open Domainslib
179179
180-
# let pool = Task.setup_pool ~num_domains:3
180+
# let pool = Task.setup_pool ~num_additional_domains:3
181181
val pool : Task.pool = <abstr>
182182
```
183183
We have created a new task pool with three new domains. The parent domain is
184-
also part of this pool, thus making it a pool of four domains. After the pool
185-
is setup, we can use this pool to execute all tasks we want to run in parallel.
186-
The `setup_pool` function requires us to specify the number of new domains to
187-
be spawned in the task pool. The ideal number of domains to initiate a task
188-
pool with is equal to the number of cores available. Since the parent domain
189-
also takes part in the pool, the `num_domains` parameter should be one less
190-
than the number of available cores.
184+
also part of this pool, thus making it a pool of four domains. After the pool is
185+
setup, we can use this pool to execute all tasks we want to run in parallel. The
186+
`setup_pool` function requires us to specify the number of new domains to be
187+
spawned in the task pool. The ideal number of domains to initiate a task pool
188+
with is equal to the number of cores available. Since the parent domain also
189+
takes part in the pool, the `num_additional_domains` parameter should be one
190+
less than the number of available cores.
191191

192192
Closing the task pool after execution of all tasks, though not strictly
193193
necessary, is highly recommended. This can be done as
@@ -704,7 +704,7 @@ let n = try int_of_string Sys.argv.(2) with _ -> 100000
704704
let a = Array.create_float n
705705
706706
let _ =
707-
let pool = Task.setup_pool ~num_domains:(num_domains - 1) in
707+
let pool = Task.setup_pool ~num_additional_domains:(num_domains - 1) in
708708
Task.parallel_for pool ~start:0
709709
~finish:(n - 1) ~body:(fun i -> Array.set a i (Random.float 1000.));
710710
Task.teardown_pool pool
@@ -751,7 +751,7 @@ let num_domains = try int_of_string Sys.argv.(1) with _ -> 4
751751
let arr = Array.create_float n
752752
753753
let _ =
754-
let domains = T.setup_pool ~num_domains:(num_domains - 1) in
754+
let domains = T.setup_pool ~num_additional_domains:(num_domains - 1) in
755755
let states = Array.init num_domains (fun _ -> Random.State.make_self_init()) in
756756
T.parallel_for domains ~start:0 ~finish:(n-1)
757757
~body:(fun i ->
@@ -813,7 +813,7 @@ let init_part s e arr =
813813
done
814814
815815
let _ =
816-
let domains = T.setup_pool ~num_domains:(num_domains - 1) in
816+
let domains = T.setup_pool ~num_additional_domains:(num_domains - 1) in
817817
T.parallel_for domains ~chunk_size:1 ~start:0 ~finish:(num_domains - 1)
818818
~body:(fun i -> init_part (i * n / num_domains) ((i+1) * n / num_domains - 1) arr);
819819
T.teardown_pool domains

code/profiling/float_init_par.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let n = try int_of_string Sys.argv.(2) with _ -> 100000
55
let a = Array.create_float n
66

77
let _ =
8-
let pool = Task.setup_pool ~num_domains:(num_domains-1) in
8+
let pool = Task.setup_pool ~num_additional_domains:(num_domains-1) in
99
Task.parallel_for pool ~chunk_size:(n/num_domains) ~start:0
1010
~finish:(n - 1) ~body:(fun i -> Array.set a i (Random.float 1000.));
1111
Task.teardown_pool pool

code/profiling/float_init_par2.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let num_domains = try int_of_string Sys.argv.(1) with _ -> 4
55
let arr = Array.create_float n
66

77
let _ =
8-
let domains = T.setup_pool ~num_domains:(num_domains - 1) in
8+
let domains = T.setup_pool ~num_additional_domains:(num_domains - 1) in
99
let states = Array.init num_domains (fun _ -> Random.State.make_self_init()) in
1010
T.parallel_for domains ~chunk_size:(n/num_domains) ~start:0 ~finish:(n-1)
1111
~body:(fun i ->

code/profiling/float_init_par3.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ let init_part s e arr =
1111
done
1212

1313
let _ =
14-
let domains = T.setup_pool ~num_domains:(num_domains - 1) in
14+
let domains = T.setup_pool ~num_additional_domains:(num_domains - 1) in
1515
T.parallel_for domains ~chunk_size:1 ~start:0 ~finish:(num_domains - 1)
1616
~body:(fun i -> init_part (i * n / num_domains) ((i+1) * n / num_domains - 1) arr);
1717
T.teardown_pool domains

code/task/fibonacci_multicore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ let rec fib_par pool n =
1515
Task.await pool a + Task.await pool b
1616

1717
let main =
18-
let pool = Task.setup_pool ~num_domains:(num_domains - 1) in
18+
let pool = Task.setup_pool ~num_additional_domains:(num_domains - 1) in
1919
let res = fib_par pool n in
2020
Task.teardown_pool pool;
2121
Printf.printf "fib(%d) = %d\n" n res

code/task/matrix_multiplication_multicore.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ let print_matrix m =
2727
done
2828

2929
let _ =
30-
let pool = Task.setup_pool ~num_domains:(num_domains - 1) in
30+
let pool = Task.setup_pool ~num_additional_domains:(num_domains - 1) in
3131
let m1 = Array.init n (fun _ -> Array.init n (fun _ -> Random.int 100)) in
3232
let m2 = Array.init n (fun _ -> Array.init n (fun _ -> Random.int 100)) in
3333
(* print_matrix m1;

code/task/three_matrix_multiplication.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ let print_matrix m =
3434
done
3535

3636
let _ =
37-
let pool = Task.setup_pool ~num_domains:(num_domains - 1) in
37+
let pool = Task.setup_pool ~num_additional_domains:(num_domains - 1) in
3838
let m1 = Array.init n (fun _ -> Array.init n (fun _ -> Random.int 100)) in
3939
let m2 = Array.init n (fun _ -> Array.init n (fun _ -> Random.int 100)) in
4040
let m3 = Array.init n (fun _ -> Array.init n (fun _ -> Random.int 100)) in

0 commit comments

Comments
 (0)