From cadfbb1eefa08c88c528d005ba6c5978fba57c9a Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Sat, 2 Mar 2019 19:46:03 +0100 Subject: [PATCH] Warn when nested parallel regions are found --- CI/CI.ml | 3 ++- Parallel_mpi/Farm.ml | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/CI/CI.ml b/CI/CI.ml index 9c696ce..8661b59 100644 --- a/CI/CI.ml +++ b/CI/CI.ml @@ -198,7 +198,8 @@ let make ?(n_states=1) det_space = let mo_basis = Ds.mo_basis det_space in (* While in a sequential region, initiate the parallel - 4-idx transformation *) + 4-idx transformation + *) ignore @@ MOBasis.two_e_ints mo_basis; let f = diff --git a/Parallel_mpi/Farm.ml b/Parallel_mpi/Farm.ml index cb95481..7da1fbe 100644 --- a/Parallel_mpi/Farm.ml +++ b/Parallel_mpi/Farm.ml @@ -210,15 +210,31 @@ let run_parallel_client f = -let run_parallel ~ordered f stream = - match Mpi.comm_rank Mpi.comm_world with - | 0 -> run_parallel_server ~ordered stream - | _ -> run_parallel_client f +let run_parallel ~ordered f stream = + match Mpi.comm_rank Mpi.comm_world with + | 0 -> run_parallel_server ~ordered stream + | _ -> run_parallel_client f + + +let nested = ref false let run ?(ordered=true) ~f stream = - match Mpi.comm_size Mpi.comm_world with - | 1 -> run_sequential f stream - | _ -> run_parallel ~ordered f stream + if !nested then + begin + let message = + "Nested parallel regions are not supported by Farm.ml" + in + Printf.eprintf "%s\n%!" message ; + exit 1 + end; + nested := true; + let result = + match Mpi.comm_size Mpi.comm_world with + | 1 -> run_sequential f stream + | _ -> run_parallel ~ordered f stream + in + nested := false; + result