Skip to content

Commit f4e08c0

Browse files
authored
Merge pull request #112 from jmid/pbt-adjustments
Adjust PBTs based on recommended_domain_count
2 parents c8a19c5 + 781a033 commit f4e08c0

File tree

3 files changed

+72
-70
lines changed

3 files changed

+72
-70
lines changed

test/dune

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,127 @@
11
(test
22
(name test_chan)
33
(libraries domainslib)
4-
(modules test_chan)
5-
(modes native))
4+
(modules test_chan))
65

76
(test
87
(name fib)
9-
(modules fib)
10-
(modes native))
8+
(modules fib))
119

1210
(test
1311
(name fib_par)
1412
(libraries domainslib)
15-
(modules fib_par)
16-
(modes native))
13+
(modules fib_par))
1714

1815
(test
1916
(name kcas_integration)
2017
(libraries domainslib kcas)
21-
(modules kcas_integration)
22-
(modes native))
18+
(modules kcas_integration))
2319

2420
(test
2521
(name enumerate_par)
2622
(libraries domainslib)
27-
(modules enumerate_par)
28-
(modes native))
23+
(modules enumerate_par))
2924

3025
(test
3126
(name game_of_life)
32-
(modules game_of_life)
33-
(modes native))
27+
(modules game_of_life))
3428

3529
(test
3630
(name game_of_life_multicore)
3731
(libraries domainslib)
38-
(modules game_of_life_multicore)
39-
(modes native))
32+
(modules game_of_life_multicore))
4033

4134
(test
4235
(name LU_decomposition_multicore)
4336
(libraries domainslib)
4437
(flags (:standard -runtime-variant d))
4538
(modules LU_decomposition_multicore)
46-
(modes native))
39+
(enabled_if (or (= %{arch_sixtyfour} true) (<> %{architecture} arm))))
40+
;; disabled temporarily on arm32 due to failure: ocaml/ocaml#12267
4741

4842

4943
(test
5044
(name spectralnorm2)
51-
(modules spectralnorm2)
52-
(modes native))
45+
(modules spectralnorm2))
5346

5447
(test
55-
(name sum_par)
56-
(libraries domainslib)
57-
(modules sum_par)
58-
(modes native))
48+
(name sum_par)
49+
(libraries domainslib)
50+
(modules sum_par))
5951

6052
(test
6153
(name task_throughput)
6254
(libraries domainslib mirage-clock-unix)
63-
(modules task_throughput)
64-
(modes native))
55+
(modules task_throughput))
6556

6657
(test
6758
(name spectralnorm2_multicore)
6859
(libraries domainslib)
69-
(modules spectralnorm2_multicore)
70-
(modes native))
60+
(modules spectralnorm2_multicore))
7161

7262
(test
7363
(name summed_area_table)
7464
(libraries domainslib)
75-
(modules summed_area_table)
76-
(modes native))
65+
(modules summed_area_table))
7766

7867
(test
7968
(name prefix_sum)
8069
(libraries domainslib unix)
81-
(modules prefix_sum)
82-
(modes native))
70+
(modules prefix_sum))
8371

8472
(test
8573
(name test_task)
8674
(libraries domainslib)
87-
(modules test_task)
88-
(modes native))
75+
(modules test_task))
8976

9077
(test
9178
(name test_parallel_find)
9279
(libraries domainslib)
93-
(modules test_parallel_find)
94-
(modes native))
80+
(modules test_parallel_find))
9581

9682
(test
9783
(name test_deadlock)
9884
(libraries domainslib)
99-
(modules test_deadlock)
100-
(modes native))
85+
(modules test_deadlock))
10186

10287
(test
10388
(name test_task_crash)
10489
(libraries domainslib)
105-
(modules test_task_crash)
106-
(modes native))
90+
(modules test_task_crash))
10791

10892
(test
10993
(name test_task_empty)
11094
(libraries domainslib)
111-
(modules test_task_empty)
112-
(modes native))
95+
(modules test_task_empty))
11396

11497
(test
11598
(name backtrace)
11699
(libraries domainslib)
117100
(modules backtrace)
118-
(modes native))
101+
(enabled_if (and (= %{arch_sixtyfour} true) (<> %{architecture} power) (<> %{architecture} s390x))))
102+
;; disabled temporarily on bytecode switches https://github.com/ocaml/dune/issues/7845
119103

120104
(test
121105
(name off_by_one)
122106
(libraries domainslib)
123-
(modules off_by_one)
124-
(modes native))
107+
(modules off_by_one))
125108

126109
;; Custom property-based tests using QCheck
127110

128111
(test
129112
(name task_one_dep)
130113
(modules task_one_dep)
131114
(libraries qcheck-multicoretests-util qcheck-core qcheck-core.runner domainslib)
115+
(enabled_if (and (= %{arch_sixtyfour} true) (<> %{architecture} power) (<> %{architecture} s390x)))
116+
;; takes forever on bytecode
132117
(action (run %{test} --verbose)))
133118

134119
(test
135120
(name task_more_deps)
136121
(modules task_more_deps)
137122
(libraries qcheck-multicoretests-util qcheck-core qcheck-core.runner domainslib)
123+
(enabled_if (and (= %{arch_sixtyfour} true) (<> %{architecture} power) (<> %{architecture} s390x)))
124+
;; takes forever on bytecode
138125
(action (run %{test} --verbose)))
139126

140127
(test

test/off_by_one.ml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@ let print_array a =
1010
let r = Array.init 20 (fun i -> i + 1)
1111

1212
let scan_task num_doms =
13-
let pool = Task.setup_pool ~num_domains:num_doms () in
14-
let a = Task.run pool (fun () -> Task.parallel_scan pool (+) (Array.make 20 1)) in
15-
Task.teardown_pool pool;
16-
Printf.printf "%i: %s\n%!" num_doms (print_array a);
17-
assert (a = r)
13+
try
14+
let pool = Task.setup_pool ~num_domains:num_doms () in
15+
let a = Task.run pool (fun () -> Task.parallel_scan pool (+) (Array.make 20 1)) in
16+
Task.teardown_pool pool;
17+
Printf.printf "%i: %s\n%!" num_doms (print_array a);
18+
assert (a = r)
19+
with Failure msg ->
20+
begin
21+
assert (msg = "failed to allocate domain");
22+
Printf.printf "Failed to allocate %i domains, recommended_domain_count: %i\n%!"
23+
num_doms (Domain.recommended_domain_count ());
24+
end
1825
;;
1926
for num_dom=0 to 21 do
2027
scan_task num_dom;

test/task_one_dep.ml

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -111,37 +111,45 @@ let test_two_pools_sync_last ~domain_bound ~promise_bound =
111111
(pair gen gen)
112112
(Util.repeat 10 @@
113113
fun (input1,input2) ->
114-
let pool1 = Task.setup_pool ~num_domains:input1.num_domains () in
115-
let pool2 = Task.setup_pool ~num_domains:input2.num_domains () in
116-
let ps1 = build_dep_graph pool1 input1 in
117-
let ps2 = build_dep_graph pool2 input2 in
118-
Task.run pool1 (fun () -> List.iter (fun p -> Task.await pool1 p) ps1);
119-
Task.run pool2 (fun () -> List.iter (fun p -> Task.await pool2 p) ps2);
120-
Task.teardown_pool pool1;
121-
Task.teardown_pool pool2;
122-
true)
114+
try
115+
let pool1 = Task.setup_pool ~num_domains:input1.num_domains () in
116+
let pool2 = Task.setup_pool ~num_domains:input2.num_domains () in
117+
let ps1 = build_dep_graph pool1 input1 in
118+
let ps2 = build_dep_graph pool2 input2 in
119+
Task.run pool1 (fun () -> List.iter (fun p -> Task.await pool1 p) ps1);
120+
Task.run pool2 (fun () -> List.iter (fun p -> Task.await pool2 p) ps2);
121+
Task.teardown_pool pool1;
122+
Task.teardown_pool pool2;
123+
true
124+
with
125+
Failure err -> err = "failed to allocate domain")
123126

124127
let test_two_nested_pools ~domain_bound ~promise_bound =
125128
let gen = arb_deps domain_bound promise_bound in
126129
Test.make ~name:"Domainslib.Task.async/await, one dep, w.2 nested pools" ~count:100
127130
(pair gen gen)
128131
(Util.repeat 10 @@
129132
fun (input1,input2) ->
130-
let pool1 = Task.setup_pool ~num_domains:input1.num_domains () in
131-
let pool2 = Task.setup_pool ~num_domains:input2.num_domains () in
132-
Task.run pool1 (fun () ->
133-
Task.run pool2 (fun () ->
134-
let ps1 = build_dep_graph pool1 input1 in
135-
let ps2 = build_dep_graph pool2 input2 in
136-
List.iter (fun p -> Task.await pool1 p) ps1;
137-
List.iter (fun p -> Task.await pool2 p) ps2));
138-
Task.teardown_pool pool1;
139-
Task.teardown_pool pool2;
140-
true)
133+
try
134+
let pool1 = Task.setup_pool ~num_domains:input1.num_domains () in
135+
let pool2 = Task.setup_pool ~num_domains:input2.num_domains () in
136+
Task.run pool1 (fun () ->
137+
Task.run pool2 (fun () ->
138+
let ps1 = build_dep_graph pool1 input1 in
139+
let ps2 = build_dep_graph pool2 input2 in
140+
List.iter (fun p -> Task.await pool1 p) ps1;
141+
List.iter (fun p -> Task.await pool2 p) ps2));
142+
Task.teardown_pool pool1;
143+
Task.teardown_pool pool2;
144+
true
145+
with
146+
Failure err -> err = "failed to allocate domain")
141147

142148
let () =
149+
let domain_bound = max 1 (Domain.recommended_domain_count () / 2) in
150+
let promise_bound = max 2 domain_bound in
143151
QCheck_base_runner.run_tests_main [
144-
test_one_pool ~domain_bound:8 ~promise_bound:10;
145-
test_two_pools_sync_last ~domain_bound:2 ~promise_bound:2;
146-
test_two_nested_pools ~domain_bound:8 ~promise_bound:10;
152+
test_one_pool ~domain_bound ~promise_bound;
153+
test_two_pools_sync_last ~domain_bound ~promise_bound;
154+
test_two_nested_pools ~domain_bound ~promise_bound;
147155
]

0 commit comments

Comments
 (0)