@@ -1920,9 +1920,11 @@ let rec perform_atomic ~progress_callback ?result (op : atomic)
1920
1920
debug " Ignoring error during best-effort operation: %s"
1921
1921
(Printexc. to_string e)
1922
1922
)
1923
- | Parallel (_id , description , atoms ) ->
1923
+ | Parallel (_id , description , atoms ) as atom ->
1924
+ check_nesting atom ;
1924
1925
parallel_atomic ~progress_callback ~description ~nested: false atoms t
1925
- | Nested_parallel (_id , description , atoms ) ->
1926
+ | Nested_parallel (_id , description , atoms ) as atom ->
1927
+ check_nesting atom ;
1926
1928
parallel_atomic ~progress_callback ~description ~nested: true atoms t
1927
1929
| Serial (_ , _ , atoms ) ->
1928
1930
List. iter (Fun. flip (perform_atomic ~progress_callback ) t) atoms
@@ -2352,6 +2354,30 @@ let rec perform_atomic ~progress_callback ?result (op : atomic)
2352
2354
debug " VM.soft_reset %s" id ;
2353
2355
B.VM. soft_reset t (VM_DB. read_exn id)
2354
2356
2357
+ and check_nesting atom =
2358
+ let msg_prefix = " Nested atomics error" in
2359
+ let rec check_nesting_inner found_parallel found_nested = function
2360
+ | Parallel (_ , _ , rem ) -> (
2361
+ if found_parallel then (
2362
+ warn " %s: Two or more Parallel atoms found, use Nested_parallel for the inner atom" msg_prefix;
2363
+ true
2364
+ ) else
2365
+ List. exists (check_nesting_inner true found_nested) rem
2366
+ )
2367
+ | Nested_parallel (_ , _ , rem ) -> (
2368
+ if found_nested then (
2369
+ warn " %s: Two or more Nested_parallel atoms found, there should only be one layer of nesting" msg_prefix ;
2370
+ true
2371
+ ) else
2372
+ List. exists (check_nesting_inner found_parallel true ) rem
2373
+ )
2374
+ | Serial (_ , _ , rem ) -> (
2375
+ List. exists (check_nesting_inner found_parallel found_nested) rem
2376
+ )
2377
+ | _ -> false
2378
+ in
2379
+ ignore @@ check_nesting_inner false false atom
2380
+
2355
2381
and parallel_atomic ~progress_callback ~description ~nested atoms t =
2356
2382
(* parallel_id is a unused unique name prefix for a parallel worker queue *)
2357
2383
let redirector =
0 commit comments