Changes in libcfa/src/bits/random.hfa [e57de69:611f29d]
- File:
-
- 1 edited
-
libcfa/src/bits/random.hfa (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/random.hfa
re57de69 r611f29d 1 //2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo3 //4 // The contents of this file are covered under the licence agreement in the5 // file "LICENCE" distributed with Cforall.6 //7 // random.hfa --8 //9 // Author : Peter A. Buhr10 // Created On : Fri Jan 14 07:18:11 202211 // Last Modified By : Peter A. Buhr12 // Last Modified On : Fri Jan 14 07:18:58 202213 // Update Count : 114 //15 16 1 #pragma once 17 2 18 3 #include <stdint.h> 19 4 20 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned21 // (copied), and then compute and store the next randomvalue.5 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, return the current value, and compute 6 // and store the next value. 22 7 8 //-------------------------------------------------- 23 9 #if defined(__SIZEOF_INT128__) 24 //--------------------------------------------------25 10 static inline uint64_t lehmer64( __uint128_t & state ) { 26 11 __uint128_t ret = state; … … 65 50 } xorwow__state_t; 66 51 67 / / The state array must be initialized to not be all zero in the first four words.52 /* The state array must be initialized to not be all zero in the first four words */ 68 53 static inline uint32_t xorwow( xorwow__state_t & state ) { 69 / / Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs".54 /* Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs" */ 70 55 uint32_t ret = state.a + state.counter; 71 56 uint32_t t = state.d; … … 99 84 #define D (16_l64u) 100 85 101 // Bi-directional LCG random-number generator102 86 static inline uint32_t LCGBI_fwd( uint64_t & state ) { 103 87 state = (A * state + C) & (M - 1);
Note:
See TracChangeset
for help on using the changeset viewer.