File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 44
55#include < AMReX_GpuQualifiers.H>
66#include < AMReX_Extension.H>
7+ #ifdef AMREX_USE_OMP
8+ # include < AMReX_BLassert.H>
9+ # include < omp.h>
10+ #endif
711
812#if defined(AMREX_USE_HIP)
913#pragma clang diagnostic push
@@ -32,8 +36,13 @@ namespace amrex
3236
3337 extern sycl_rng_descr* rand_engine_descr;
3438
35- AMREX_FORCE_INLINE
36- sycl_rng_descr* getRandEngineDescriptor () { return rand_engine_descr; }
39+ inline
40+ sycl_rng_descr* getRandEngineDescriptor () {
41+ #ifdef AMREX_USE_OMP
42+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (! omp_in_parallel (), " RNG on GPU is not OpenMP thread safe" );
43+ #endif
44+ return rand_engine_descr;
45+ }
3746
3847 struct RandomEngine {
3948 sycl_rng_engine* engine;
@@ -52,8 +61,13 @@ namespace amrex
5261
5362 extern randState_t* gpu_rand_state;
5463
55- AMREX_FORCE_INLINE
56- randState_t* getRandState () { return gpu_rand_state; }
64+ inline
65+ randState_t* getRandState () {
66+ #ifdef AMREX_USE_OMP
67+ AMREX_ALWAYS_ASSERT_WITH_MESSAGE (! omp_in_parallel (), " RNG on GPU is not OpenMP thread safe" );
68+ #endif
69+ return gpu_rand_state;
70+ }
5771
5872 struct RandomEngine {
5973 randState_t* rand_state;
You can’t perform that action at this time.
0 commit comments