33 #define R123_USE_MULHILO64_MULHI_INTRIN 0
34 #define R123_USE_GNU_UINT128 1
39 #include <Random123/philox.h>
47 #if defined(CORENEURON_ENABLE_GPU) && !defined(DISABLE_OPENACC)
48 #define CORENRN_RAN123_USE_UNIFIED_MEMORY true
50 #define CORENRN_RAN123_USE_UNIFIED_MEMORY false
82 inline std::size_t nrnran123_state_size() {
83 return sizeof(nrnran123_State);
91 inline nrnran123_State* nrnran123_newstream(
101 constexpr
void nrnran123_getseq(nrnran123_State* s, uint32_t* seq,
char* which) {
105 constexpr
void nrnran123_getids(nrnran123_State* s, uint32_t* id1, uint32_t* id2) {
109 constexpr
void nrnran123_getids3(nrnran123_State* s, uint32_t* id1, uint32_t* id2, uint32_t* id3) {
116 inline uint32_t nrnran123_ipick(nrnran123_State* s) {
117 char which = s->which_;
118 uint32_t rval{s->r.v[
int{which++}]};
128 constexpr
double nrnran123_uint2dbl(uint32_t u) {
129 constexpr
double SHIFT32 = 1.0 / 4294967297.0;
132 return (
static_cast<double>(u) + 1.0) * SHIFT32;
136 inline double nrnran123_dblpick(nrnran123_State* s) {
137 return nrnran123_uint2dbl(nrnran123_ipick(s));
141 inline void nrnran123_setseq(nrnran123_State* s, uint32_t seq,
char which) {
152 inline double nrnran123_negexp(nrnran123_State* s) {
153 return -std::log(nrnran123_dblpick(s));
157 inline double nrnran123_normal(nrnran123_State* s) {
160 u1 = nrnran123_dblpick(s);
161 double u2{nrnran123_dblpick(s)};
164 w = (u1 * u1) + (u2 * u2);
166 double y{std::sqrt((-2. * std::log(w)) / w)};