Skip to content

Commit

Permalink
Add assert that we are not inside threaded region when InitRandom is …
Browse files Browse the repository at this point in the history
…called. (#3204)
  • Loading branch information
atmyers authored Mar 15, 2023
1 parent d54067a commit fdcbb7a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Src/Base/AMReX_Random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ InitRandom (ULong cpu_seed, int nprocs, ULong gpu_seed)
nthreads = OpenMP::get_max_threads();
generators.resize(nthreads);

#ifdef AMREX_USE_OMP
if (omp_in_parallel()) {
amrex::Abort("It is not safe to call amrex::InitRandom inside a threaded region.");
}
#endif

#ifdef AMREX_USE_OMP
#pragma omp parallel
#endif
Expand Down

0 comments on commit fdcbb7a

Please sign in to comment.