Changeset d3261710 for libcfa/src/bits


Ignore:
Timestamp:
Jan 20, 2022, 11:18:15 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
224916b
Parents:
6117fc0 (diff), 6a33e40 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

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

    r6117fc0 rd3261710  
     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.