Changeset e57de69 for libcfa/src
- Timestamp:
- Jan 18, 2022, 8:47:27 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- b5f17e1
- Parents:
- a77f25b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/bits/random.hfa
ra77f25b re57de69 1 // 2 // Cforall Version 1.0.0 Copyright (C) 2022 University of Waterloo 3 // 4 // The contents of this file are covered under the licence agreement in the 5 // file "LICENCE" distributed with Cforall. 6 // 7 // random.hfa -- 8 // 9 // Author : Peter A. Buhr 10 // Created On : Fri Jan 14 07:18:11 2022 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Jan 14 07:18:58 2022 13 // Update Count : 1 14 // 15 1 16 #pragma once 2 17 3 18 #include <stdint.h> 4 19 5 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, return the current value, and compute6 // and store the nextvalue.20 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned 21 // (copied), and then compute and store the next random value. 7 22 23 #if defined(__SIZEOF_INT128__) 8 24 //-------------------------------------------------- 9 #if defined(__SIZEOF_INT128__)10 25 static inline uint64_t lehmer64( __uint128_t & state ) { 11 26 __uint128_t ret = state; … … 50 65 } xorwow__state_t; 51 66 52 / * The state array must be initialized to not be all zero in the first four words */67 // The state array must be initialized to not be all zero in the first four words. 53 68 static inline uint32_t xorwow( xorwow__state_t & state ) { 54 / * Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs" */69 // Algorithm "xorwow" from p. 5 of Marsaglia, "Xorshift RNGs". 55 70 uint32_t ret = state.a + state.counter; 56 71 uint32_t t = state.d; … … 84 99 #define D (16_l64u) 85 100 101 // Bi-directional LCG random-number generator 86 102 static inline uint32_t LCGBI_fwd( uint64_t & state ) { 87 103 state = (A * state + C) & (M - 1);
Note: See TracChangeset
for help on using the changeset viewer.