38 #ifndef PRIVATE_PHILOX432_CH 39 #define PRIVATE_PHILOX432_CH 43 #define Philox432_NORM_cl_double 1.0 / 0x100000000L // 1.0 /2^32 44 #define Philox432_NORM_cl_float 2.32830644e-010f; 80 for (
size_t i = 0; i < count; i++)
81 destStreams[i] = srcStreams[i];
89 philox4x32_key_t k = { { currentState->
key[0], currentState->
key[1] } };
92 philox4x32_ctr_t c = { { 0 } };
93 c.v[0] = currentState->
ctr.
L.
lsb;
94 c.v[1] = currentState->
ctr.
L.
msb;
95 c.v[2] = currentState->
ctr.
H.
lsb;
96 c.v[3] = currentState->
ctr.
H.
msb;
100 currentState->
deck[3] = r.v[0];
101 currentState->
deck[2] = r.v[1];
102 currentState->
deck[1] = r.v[2];
103 currentState->
deck[0] = r.v[3];
116 cl_uint result = currentState->
deck[currentState->
deckIndex];
137 #define IMPLEMENT_GENERATE_FOR_TYPE(fptype) \ 139 fptype clrngPhilox432RandomU01_##fptype(clrngPhilox432Stream* stream) { \ 140 return (clrngPhilox432NextState(&stream->current) + 0.5) * Philox432_NORM_##fptype; \ 143 cl_int clrngPhilox432RandomInteger_##fptype(clrngPhilox432Stream* stream, cl_int i, cl_int j) { \ 144 return i + (cl_int)((j - i + 1) * clrngPhilox432RandomU01_##fptype(stream)); \ 147 clrngStatus clrngPhilox432RandomU01Array_##fptype(clrngPhilox432Stream* stream, size_t count, fptype* buffer) { \ 149 return clrngSetErrorString(CLRNG_INVALID_VALUE, "%s(): stream cannot be NULL", __func__); \ 151 return clrngSetErrorString(CLRNG_INVALID_VALUE, "%s(): buffer cannot be NULL", __func__); \ 152 for (size_t i = 0; i < count; i++) \ 153 buffer[i] = clrngPhilox432RandomU01_##fptype(stream); \ 154 return CLRNG_SUCCESS; \ 157 clrngStatus clrngPhilox432RandomIntegerArray_##fptype(clrngPhilox432Stream* stream, cl_int i, cl_int j, size_t count, cl_int* buffer) { \ 159 return clrngSetErrorString(CLRNG_INVALID_VALUE, "%s(): stream cannot be NULL", __func__); \ 161 return clrngSetErrorString(CLRNG_INVALID_VALUE, "%s(): buffer cannot be NULL", __func__); \ 162 for (size_t k = 0; k < count; k++) \ 163 buffer[k] = clrngPhilox432RandomInteger_##fptype(stream, i, j); \ 164 return CLRNG_SUCCESS; \ 169 #if defined(CLRNG_SINGLE_PRECISION) || !defined(__CLRNG_DEVICE_API) 172 #if !defined(CLRNG_SINGLE_PRECISION) || !defined(__CLRNG_DEVICE_API) 177 #undef IMPLEMENT_GENERATE_FOR_TYPE 187 for (
size_t j = 0; j < count; j++) {
188 #ifdef __CLRNG_DEVICE_API 189 #ifdef CLRNG_ENABLE_SUBSTREAMS 202 #if defined(CLRNG_ENABLE_SUBSTREAMS) || !defined(__CLRNG_DEVICE_API) 210 for (
size_t j = 0; j < count; j++) {
234 for (
size_t k = 0; k < count; k++) {
244 for (
size_t i = 0; i < count; i++) {
260 #endif // PRIVATE_Philox432_CH void clrngPhilox432GenerateDeck(clrngPhilox432StreamState *currentState)
Definition: philox432.c.h:86
clrngPhilox432Counter ctr
Definition: philox432.h:64
clrngPhilox432Counter clrngPhilox432Add(clrngPhilox432Counter a, clrngPhilox432Counter b)
Definition: philox432.c.h:46
#define philox4x32(c, k)
Definition: philox.h:352
clrngPhilox432StreamState initial
Definition: philox432.h:77
clrngPhilox432SB L
Definition: philox432.h:58
cl_uint key[2]
Definition: philox432.h:63
#define IMPLEMENT_GENERATE_FOR_TYPE(fptype)
Definition: philox432.c.h:137
enum clrngStatus_ clrngStatus
Error codes.
Definition: philox432.h:57
cl_uint lsb
Definition: philox432.h:54
clrngPhilox432SB H
Definition: philox432.h:58
void Philox432ResetNextSubStream(clrngPhilox432Stream *stream)
Definition: philox432.c.h:217
clrngStatus clrngPhilox432CopyOverStreams(size_t count, clrngPhilox432Stream *destStreams, const clrngPhilox432Stream *srcStreams)
Definition: philox432.c.h:72
clrngStatus clrngSetErrorString(cl_int err, const char *msg,...)
Set the current error string.
Definition: private.c:57
clrngStatus clrngPhilox432RewindSubstreams(size_t count, clrngPhilox432Stream *streams)
Definition: philox432.c.h:204
clrngStatus clrngPhilox432ForwardToNextSubstreams(size_t count, clrngPhilox432Stream *streams)
Definition: philox432.c.h:228
clrngPhilox432StreamState current
Definition: philox432.h:76
cl_uint msb
Definition: philox432.h:54
clrngPhilox432Counter clrngPhilox432Substract(clrngPhilox432Counter a, clrngPhilox432Counter b)
Definition: philox432.c.h:59
clrngPhilox432StreamState substream
Definition: philox432.h:78
cl_uint deck[4]
Definition: philox432.h:65
clrngStatus clrngPhilox432MakeOverSubstreams(clrngPhilox432Stream *stream, size_t count, clrngPhilox432Stream *substreams)
Definition: philox432.c.h:242
Definition: philox432.h:62
cl_uint deckIndex
Definition: philox432.h:66
clrngStatus clrngPhilox432RewindStreams(size_t count, clrngPhilox432Stream *streams)
Definition: philox432.c.h:181
Definition: philox432.h:70