Changeset 9fce2572


Ignore:
Timestamp:
Nov 21, 2022, 5:52:57 PM (17 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
857081e
Parents:
910e1d0
Message:

32-bit update of PRNG

Files:
2 added
1 deleted
2 edited

Legend:

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

    r910e1d0 r9fce2572  
    1010// Created On       : Fri Jan 14 07:18:11 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Nov 19 17:47:43 2022
    13 // Update Count     : 8
     12// Last Modified On : Mon Nov 21 17:50:12 2022
     13// Update Count     : 15
    1414//
    1515
     
    1818#include <stdint.h>
    1919
     20// Set default PRNG for architecture size.
    2021#ifdef __x86_64__                                                                               // 64-bit architecture
    2122#define LEHMER64
     
    2425#endif // __x86_64__
    2526
     27// C/CFA PRNG name and random-state.
     28#ifdef LEHMER64
     29#define PRNG_NAME lehmer64
     30#define PRNG_ARG_T __uint128_t
     31#endif // LEHMER64
     32
     33#ifdef XORSHIFT_6_21_7
     34#define PRNG_NAME xorshift_6_21_7
     35#define PRNG_ARG_T uint32_t
     36#endif // XORSHIFT_6_21_7
     37
     38#ifdef __cforall                                                                                // don't include in C code (invoke.h)
     39
    2640// Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned
    2741// (copied), and then compute and store the next random value.
     
    2943#if defined(__SIZEOF_INT128__)
    3044//--------------------------------------------------
    31         #ifdef LEHMER64
    32         #define PRNG_ARG_T __uint128_t
    33         #define PRNG_NAME lehmer64
    34         #endif // LEHMER64
    35 
    3645        static inline uint64_t lehmer64( __uint128_t & state ) {
    3746                __uint128_t ret = state;
     
    6271
    6372//--------------------------------------------------
    64 
    65 #ifdef XORSHIFT_6_21_7
    66 #define PRNG_ARG_T uint32_t
    67 #define PRNG_NAME xorshift_6_21_7
    68 #endif // XORSHIFT_6_21_7
    69 
    7073static inline uint32_t xorshift_6_21_7( uint32_t & state ) {
    7174        uint32_t ret = state;
     
    7881//--------------------------------------------------
    7982typedef struct {
    80   uint32_t a, b, c, d;
    81   uint32_t counter;
     83        uint32_t a, b, c, d;
     84        uint32_t counter;
    8285} xorwow__state_t;
    8386
     
    133136#undef C
    134137#undef D
     138
     139#endif // __cforall
  • libcfa/src/concurrency/invoke.h

    r910e1d0 r9fce2572  
    1010// Created On       : Tue Jan 17 12:27:26 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Nov 18 12:20:26 2022
    13 // Update Count     : 49
     12// Last Modified On : Mon Nov 21 17:40:24 2022
     13// Update Count     : 55
    1414//
    1515
     
    1717#include "bits/defs.hfa"
    1818#include "bits/locks.hfa"
     19#include "bits/random.hfa"
    1920#include "kernel/fwd.hfa"
    2021
     
    222223                struct processor * last_proc;
    223224
    224                 __uint128_t random_state;                                               // fast random numbers
     225                PRNG_ARG_T random_state;                                                // fast random numbers
    225226
    226227                #if defined( __CFA_WITH_VERIFY__ )
Note: See TracChangeset for help on using the changeset viewer.