Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/random.hfa

    re57de69 r611f29d  
    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 
    161#pragma once
    172
    183#include <stdint.h>
    194
    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.
     5// Pipelined to allow out-of-order overlap with reduced dependencies. Critically, return the current value, and compute
     6// and store the next value.
    227
     8//--------------------------------------------------
    239#if defined(__SIZEOF_INT128__)
    24 //--------------------------------------------------
    2510        static inline uint64_t lehmer64( __uint128_t & state ) {
    2611                __uint128_t ret = state;
     
    6550} xorwow__state_t;
    6651
    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 */
    6853static 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" */
    7055        uint32_t ret = state.a + state.counter;
    7156        uint32_t t = state.d;
     
    9984#define D  (16_l64u)
    10085
    101 // Bi-directional LCG random-number generator
    10286static inline uint32_t LCGBI_fwd( uint64_t & state ) {
    10387        state = (A * state + C) & (M - 1);
Note: See TracChangeset for help on using the changeset viewer.