Skip to content
New issue

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

Unhandled exception when executing programs that use the 'parallel_for' primitive. #11

Closed
H-N41K opened this issue Jan 25, 2022 · 3 comments

Comments

@H-N41K
Copy link

H-N41K commented Jan 25, 2022

open Domainslib

let num_domains = try int_of_string Sys.argv.(1) with _ -> 4
let n = try int_of_string Sys.argv.(2) with _ -> 100
let a = Array.create_float n

let _ =
let pool = Task.setup_pool ~num_additional_domains:(num_domains - 1) () in
try Task.parallel_for pool ~start:0
~finish:(n - 1) ~body:(fun i -> Array.set a i (Random.float 1000.)) with e -> (Printexc.default_uncaught_exception_handler e (Printexc.get_raw_backtrace ()));
Task.teardown_pool pool

I am getting the following error when I try to run the above code with num_domains > 1.

hemen@hemen-VirtualBox:~/Desktop/multicore_ocaml_practice$ dune exec ./float_init_par.exe
Fatal error: exception Unhandled

After tracing the stack I got the following:

hemen@hemen-VirtualBox:~/Desktop/multicore_ocaml_practice$ dune build ./float_init_par.ml

hemen@hemen-VirtualBox:~/Desktop/multicore_ocaml_practice$ OCAMLRUNPARAM=b ./_build/default/float_init_par.exe
Fatal error: exception Unhandled
Raised by primitive operation at Domainslib__Task.parallel_for.work in file "lib/task.ml", line 198, characters 6-26
Called from Domainslib__Task.parallel_for.work in file "lib/task.ml", line 198, characters 6-26
Called from Domainslib__Task.parallel_for.work in file "lib/task.ml", line 198, characters 6-26
Called from Dune__exe__Float_init_par in file "float_init_par.ml", line 9, characters 6-107

I am unable to resolve what caused the exception to be raised at Domainslib__Task.parallel_for.work
I am getting this issue when I set num_domains to be greater than 1 in every program that uses the parallel_for primitive.
I used ocamldebug to debug this , however the debugger crashes with a segmentation fault as shown below:

hemen@hemen-VirtualBox:~/Desktop/multicore_ocaml_practice$ dune build ./float_init_par.bc

hemen@hemen-VirtualBox:~/Desktop/multicore_ocaml_practice$ ocamldebug ./_build/default/float_init_par.bc
	OCaml Debugger version 4.12.0+domains+effects

(ocd) r
Loading program... done.
Lost connection with process 14884 (active process)
at time 0
Trying to recover...
Segmentation fault (core dumped)

Kindly suggest how to resolve this.

@Sudha247
Copy link
Collaborator

Thanks for reporting! This repo was a bit behind domainslib.0.4.0, I've fixed it in #12. The programs should now work with #12, please let me know otherwise.

Also, I'm afraid ocamldebug is currently not supported with Multicore. We recommend using gdb or rr for debugging Multicore OCaml programs.

@Sudha247
Copy link
Collaborator

Fixed by #12, I'm closing this. Feel free to make new issues for any other questions.

@H-N41K
Copy link
Author

H-N41K commented Jan 28, 2022

Thanks for resolving the issue. The programs work fine now. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants