Block-Structured AMR Software Framework
AMReX_RandomEngine.H
Go to the documentation of this file.
1 #ifndef AMREX_RANDOM_ENGINE_H_
2 #define AMREX_RANDOM_ENGINE_H_
3 #include <AMReX_Config.H>
4 
5 #include <AMReX_GpuQualifiers.H>
6 #include <AMReX_Extension.H>
7 
8 #if defined(AMREX_USE_HIP)
9 #pragma clang diagnostic push
10 #pragma clang diagnostic ignored "-W#warnings"
11 #include <hiprand/hiprand.hpp>
12 #pragma clang diagnostic pop
13 #elif defined(AMREX_USE_CUDA)
14 #include <curand.h>
15 #include <curand_kernel.h>
16 #elif defined(AMREX_USE_SYCL)
17 #include <sycl/sycl.hpp>
18 #include <oneapi/mkl/rng.hpp>
19 #include <oneapi/mkl/rng/device.hpp>
20 namespace mkl = oneapi::mkl;
21 #endif
22 
23 namespace amrex
24 {
25 #ifdef AMREX_USE_GPU
26 
27 #ifdef AMREX_USE_SYCL
28 
29  using sycl_rng_engine = mkl::rng::device::philox4x32x10<>;
30  using sycl_rng_descr = mkl::rng::device::engine_descriptor<sycl_rng_engine>;
31  using sycl_rng_acc = mkl::rng::device::engine_accessor<sycl_rng_engine>;
32 
33  extern sycl_rng_descr* rand_engine_descr;
34 
36  sycl_rng_descr* getRandEngineDescriptor () { return rand_engine_descr; }
37 
38  struct RandomEngine {
39  sycl_rng_engine* engine;
40  };
41 
42 #else
43 
44 #ifdef AMREX_USE_HIP
45  using randState_t = hiprandState_t;
46  using randGenerator_t = hiprandGenerator_t;
47 #else
48  using randState_t = curandState_t;
49  using randGenerator_t = curandGenerator_t;
50 #endif
51 
53 
56 
57  struct RandomEngine {
59  };
60 
61 #endif
62 
63 #else
64 
65  struct RandomEngine {}; // CPU
66 
67 #endif
68 
69 }
70 
71 #endif
#define AMREX_FORCE_INLINE
Definition: AMReX_Extension.H:119
Definition: AMReX_Amr.cpp:49
curandGenerator_t randGenerator_t
Definition: AMReX_RandomEngine.H:49
AMREX_FORCE_INLINE randState_t * getRandState()
Definition: AMReX_RandomEngine.H:55
curandState_t randState_t
Definition: AMReX_RandomEngine.H:48
amrex::randState_t * gpu_rand_state
Definition: AMReX_Random.cpp:23
Definition: AMReX_RandomEngine.H:57
randState_t * rand_state
Definition: AMReX_RandomEngine.H:58