Changeset e57de69 for libcfa


Ignore:
Timestamp:
Jan 18, 2022, 8:47:27 PM (2 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
b5f17e1
Parents:
a77f25b
Message:

formatting

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
    116#pragma once
    217
    318#include <stdint.h>
    419
    5 // Pipelined to allow out-of-order overlap with reduced dependencies. Critically, return the current value, and compute
    6 // and store the next value.
     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.
    722
     23#if defined(__SIZEOF_INT128__)
    824//--------------------------------------------------
    9 #if defined(__SIZEOF_INT128__)
    1025        static inline uint64_t lehmer64( __uint128_t & state ) {
    1126                __uint128_t ret = state;
     
    5065} xorwow__state_t;
    5166
    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.
    5368static 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".
    5570        uint32_t ret = state.a + state.counter;
    5671        uint32_t t = state.d;
     
    8499#define D  (16_l64u)
    85100
     101// Bi-directional LCG random-number generator
    86102static inline uint32_t LCGBI_fwd( uint64_t & state ) {
    87103        state = (A * state + C) & (M - 1);
Note: See TracChangeset for help on using the changeset viewer.