We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Domainslib.Task
BfsAlgorithms.parallel
module BfsAlgorithms : Bfs = struct (* ... other methods ... *) let parallel_map (f : 'a -> 'b) (task_pool : T.pool) (arr : 'a array) : 'b array = let len = Array.length arr in let res = Array.make len (f arr.(0)) in T.parallel_for task_pool ~start:0 ~finish:(len - 1) ~body:(fun i -> res.(i) <- f arr.(i)); res let parallel (graph : UnweightedGraph.t) (start_node : Node.t) ~(task_pool: T.pool) : NodeSet.t list = (* implementation details *) (* uses parallel_map *) end (* ... other code ... *)
Task.run
let task_pool = T.setup_pool ~num_domains:5 () let bfs_parallel_wrapper pool = BfsAlgorithms.parallel small_graph small_graph_start_node let result = Task.run task_pool (fun () -> bfs_parallel_wrapper task_pool) T.teardown_pool task_pool
let task_pool = T.setup_pool ~num_domains:5 () let result = Task.run task_pool (fun () -> BfsAlgorithms.parallel small_graph small_graph_start_node ~task_pool) T.teardown_pool task_pool
Both scenarios should exhibit the same behavior, as the only difference is the direct invocation of BfsAlgorithms.parallel in Scenario 2.
I was wondering if there is any known issue or subtlety with how Domainslib handles task pools and closures that could explain this discrepancy?
I'm new to parallel OCaml, so this could be fault on my side.
If any more context is needed, the full implementation may be found at https://github.com/tjazerzen/parallelisation-of-graph-algorithms-in-functional-programming-languages/blob/master/playground/graph/bfs.ml.
Best, Tjaz
The text was updated successfully, but these errors were encountered:
realized my problem, which doesn't have to do anything with parallelism. Closing...
Sorry, something went wrong.
No branches or pull requests
Description:
Context:
Domainslib.Task
for parallel computation.BfsAlgorithms.parallel
) is designed to use a task pool for parallel execution. I used naively defined parallel map, as discussed in Question: Does a parallel map function exist in Domainslib? #117.Code Overview:
Issue: Inconsistent Execution Behavior
BfsAlgorithms.parallel
via an intermediary function withinTask.run
, the parallel computation executes as expected.BfsAlgorithms.parallel
withinTask.run
leads to no apparent computation being performed.Expected Behavior:
Both scenarios should exhibit the same behavior, as the only difference is the direct invocation of
BfsAlgorithms.parallel
in Scenario 2.I was wondering if there is any known issue or subtlety with how Domainslib handles task pools and closures that could explain this discrepancy?
I'm new to parallel OCaml, so this could be fault on my side.
If any more context is needed, the full implementation may be found at https://github.com/tjazerzen/parallelisation-of-graph-algorithms-in-functional-programming-languages/blob/master/playground/graph/bfs.ml.
Best, Tjaz
The text was updated successfully, but these errors were encountered: