Changeset 9fce2572 for libcfa/src/bits
- Timestamp:
- Nov 21, 2022, 5:52:57 PM (22 months ago)
- Branches:
- ADT, ast-experimental, master
- Children:
- 857081e
- Parents:
- 910e1d0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/random.hfa
r910e1d0 r9fce2572 10 10 // Created On : Fri Jan 14 07:18:11 2022 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Nov 19 17:47:43202213 // Update Count : 812 // Last Modified On : Mon Nov 21 17:50:12 2022 13 // Update Count : 15 14 14 // 15 15 … … 18 18 #include <stdint.h> 19 19 20 // Set default PRNG for architecture size. 20 21 #ifdef __x86_64__ // 64-bit architecture 21 22 #define LEHMER64 … … 24 25 #endif // __x86_64__ 25 26 27 // C/CFA PRNG name and random-state. 28 #ifdef LEHMER64 29 #define PRNG_NAME lehmer64 30 #define PRNG_ARG_T __uint128_t 31 #endif // LEHMER64 32 33 #ifdef XORSHIFT_6_21_7 34 #define PRNG_NAME xorshift_6_21_7 35 #define PRNG_ARG_T uint32_t 36 #endif // XORSHIFT_6_21_7 37 38 #ifdef __cforall // don't include in C code (invoke.h) 39 26 40 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned 27 41 // (copied), and then compute and store the next random value. … … 29 43 #if defined(__SIZEOF_INT128__) 30 44 //-------------------------------------------------- 31 #ifdef LEHMER6432 #define PRNG_ARG_T __uint128_t33 #define PRNG_NAME lehmer6434 #endif // LEHMER6435 36 45 static inline uint64_t lehmer64( __uint128_t & state ) { 37 46 __uint128_t ret = state; … … 62 71 63 72 //-------------------------------------------------- 64 65 #ifdef XORSHIFT_6_21_766 #define PRNG_ARG_T uint32_t67 #define PRNG_NAME xorshift_6_21_768 #endif // XORSHIFT_6_21_769 70 73 static inline uint32_t xorshift_6_21_7( uint32_t & state ) { 71 74 uint32_t ret = state; … … 78 81 //-------------------------------------------------- 79 82 typedef struct { 80 81 83 uint32_t a, b, c, d; 84 uint32_t counter; 82 85 } xorwow__state_t; 83 86 … … 133 136 #undef C 134 137 #undef D 138 139 #endif // __cforall
Note: See TracChangeset
for help on using the changeset viewer.