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. (AMReX-Codes#3204)
  • Loading branch information
atmyers authored and guj committed Jul 13, 2023
1 parent fffde2f commit c16e452
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 c16e452

Please sign in to comment.