-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from ocaml-multicore/parallel_scan_bug_fix
Bug fix in `parallel_scan`
- Loading branch information
Showing
3 changed files
with
39 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
open Domainslib | ||
|
||
let print_array a = | ||
let b = Buffer.create 25 in | ||
Buffer.add_string b "[|"; | ||
Array.iter (fun elem -> Buffer.add_string b (string_of_int elem ^ "; ")) a; | ||
Buffer.add_string b "|]"; | ||
Buffer.contents b | ||
|
||
let r = Array.init 20 (fun i -> i + 1) | ||
|
||
let scan_task num_doms = | ||
let pool = Task.setup_pool ~num_additional_domains:num_doms () in | ||
let a = Task.run pool (fun () -> Task.parallel_scan pool (+) (Array.make 20 1)) in | ||
Task.teardown_pool pool; | ||
Printf.printf "%i: %s\n%!" num_doms (print_array a); | ||
assert (a = r) | ||
;; | ||
for num_dom=0 to 21 do | ||
scan_task num_dom; | ||
done |