ERF
Energy Research and Forecasting: An Atmospheric Modeling Code
erf_hash_rng Namespace Reference

Functions

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t splitmix64 (std::uint64_t x) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t cell_key (int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real hash_uniform (int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
 
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real hash_symmetric (int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
 

Function Documentation

◆ cell_key()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t erf_hash_rng::cell_key ( int  i,
int  j,
int  k,
int  comp,
int  lev,
std::uint64_t  seed 
)
noexcept

Construct a decomposition-independent key for one indexed component.

Parameters
[in]
41 {
42  std::uint64_t key = splitmix64(seed ^ UINT64_C(0x243f6a8885a308d3));
43  key = splitmix64(key ^ (static_cast<std::uint64_t>(static_cast<std::uint32_t>(i)) +
44  UINT64_C(0x13198a2e03707344)));
45  key = splitmix64(key ^ (static_cast<std::uint64_t>(static_cast<std::uint32_t>(j)) +
46  UINT64_C(0xa4093822299f31d0)));
47  key = splitmix64(key ^ (static_cast<std::uint64_t>(static_cast<std::uint32_t>(k)) +
48  UINT64_C(0x082efa98ec4e6c89)));
49  key = splitmix64(key ^ (static_cast<std::uint64_t>(static_cast<std::uint32_t>(comp)) +
50  UINT64_C(0x452821e638d01377)));
51  return splitmix64(key ^ (static_cast<std::uint64_t>(static_cast<std::uint32_t>(lev)) +
52  UINT64_C(0xbe5466cf34e90c6c)));
53 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t splitmix64(std::uint64_t x) noexcept
Definition: ERF_HashRNG.H:19

Referenced by hash_uniform().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hash_symmetric()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_hash_rng::hash_symmetric ( int  i,
int  j,
int  k,
int  comp,
int  lev,
std::uint64_t  seed 
)
noexcept

Map an indexed cell key to a uniformly distributed value in [-1, 1).

Parameters
[in]
92 {
93  return amrex::Real(2.0) * hash_uniform(i, j, k, comp, lev, seed) -
94  amrex::Real(1.0);
95 }
amrex::Real Real
Definition: ERF_ShocInterface.H:19
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real hash_uniform(int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
Definition: ERF_HashRNG.H:68
Here is the call graph for this function:

◆ hash_uniform()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real erf_hash_rng::hash_uniform ( int  i,
int  j,
int  k,
int  comp,
int  lev,
std::uint64_t  seed 
)
noexcept

Map an indexed cell key to a uniformly distributed value in [0, 1).

Parameters
[in]
69 {
70  constexpr int mantissa_bits = (sizeof(amrex::Real) == sizeof(float)) ? 24 : 53;
71  constexpr std::uint64_t denominator = UINT64_C(1) << mantissa_bits;
72  const std::uint64_t numerator = cell_key(i, j, k, comp, lev, seed) >>
73  (64 - mantissa_bits);
74  return static_cast<amrex::Real>(numerator) /
75  static_cast<amrex::Real>(denominator);
76 }
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t cell_key(int i, int j, int k, int comp, int lev, std::uint64_t seed) noexcept
Definition: ERF_HashRNG.H:40

Referenced by hash_symmetric(), and ParallelForRNG().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ splitmix64()

AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE std::uint64_t erf_hash_rng::splitmix64 ( std::uint64_t  x)
noexcept

Apply the standard SplitMix64 integer avalanche to an input word.

Parameters
[in]
20 {
21  x += UINT64_C(0x9e3779b97f4a7c15);
22  x = (x ^ (x >> 30U)) * UINT64_C(0xbf58476d1ce4e5b9);
23  x = (x ^ (x >> 27U)) * UINT64_C(0x94d049bb133111eb);
24  return x ^ (x >> 31U);
25 }

Referenced by cell_key().

Here is the caller graph for this function: