-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Silence Thread Sanitizer in InitRandom
#4281
Conversation
Either making the shared variables constant (not sensible in the function signature) or using `firstprivate` should silence the warnings we see.
It does not seem to make thread sanitizer happy. Another thing you can try is to turn |
Src/Base/AMReX_Random.cpp
Outdated
#ifdef AMREX_USE_OMP | ||
#pragma omp parallel | ||
#pragma omp parallel for | ||
#endif | ||
for (int tid = 0; tid < nthreads; tid++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#ifdef AMREX_USE_OMP | |
#pragma omp parallel | |
#pragma omp parallel for | |
#endif | |
for (int tid = 0; tid < nthreads; tid++) { | |
for (int tid = 0; tid < nthreads; tid++) |
With the for loop, the parallel region isn't even required anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was thinking the same. Not sure it matters...
I think it's a false positive. In the past on our own machines, we had to compile gcc from source with certain flags to make thread sanitizer work for OpenMP. For the WarpX CI, maybe similar things need to be done for clang. Not sure if this old stackoverflow post is still relevant. https://stackoverflow.com/questions/33004809/can-i-use-thread-sanitizer-for-openmp-programs For this particular case, we could simply not using openmp. However, this is probably the first OMP parallel region in the code. I believe the later ones would fail too even if we remove OMP here. |
Agreed, I would not change it and rather make sure an OpenMP-enabled sanitizer is used. |
Summary
Either making the shared variables constant (not sensible in the function signature) or using
firstprivate
should silence the warnings we see.Additional background
Fix #4279
cc @EZoni
Checklist
The proposed changes: