AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
503 stars 336 forks source link

Random number generator exception in multithread #3920

Open pkufourier opened 2 months ago

pkufourier commented 2 months ago

When I use amrex::Random(), the code like amrex::ParallelFor(box, [=] AMREX_GPU_DEVICE(int i, int j, int k) { Real udist = amrex::Random(rd), vdist = amrex::Random(rd); }); I find that it will throw out exception as 0::Assertion `i < (this->std::vector<T, Allocator>::size())' failed, file "...../amrex-24.01/Src/Base/AMReX_Vector.H", line 35 !!!

However, after several tests, I find that this exception ONLY happens when enabled the OpenMP and the debug mode (compiled with -g) simultaneously. I also find this post stated that the ParallelForRNG may helps(https://github.com/AMReX-Codes/amrex/discussions/3693), but in my tests it suffers from the exception also when compiled in the OpenMP+debug mode.

WeiqunZhang commented 2 months ago

Could you please provide more details on how to reproduce the issue? Maybe you are using an amrex library that was not compiled with OpenMP?