Last active
April 28, 2020 08:58
-
-
Save Sudha247/17f96f31dcebbbfa7486e4f27f107660 to your computer and use it in GitHub Desktop.
Parallel float array initialization
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
module T = Domainslib.Task | |
let n = try int_of_string Sys.argv.(2) with _ -> 10000 | |
let cs = try int_of_string Sys.argv.(3) with _ -> 32 | |
let num_domains = try int_of_string Sys.argv.(1) with _ -> 4 | |
let _ = | |
let arr = Array.create_float n in | |
(*init with random number*) | |
let pool = T.setup_pool ~num_domains:(num_domains - 1) in | |
T.parallel_for pool ~chunk_size:cs ~start:0 ~finish:(pred n) ~body:(fun i -> | |
Domain.Sync.poll (); | |
Array.unsafe_set arr i (Random.float 100.) | |
); | |
Printf.printf "%d" (Array.length arr); | |
T.teardown_pool |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment