Ignore:
Timestamp:
Mar 19, 2023, 1:51:35 PM (17 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
cd477ca
Parents:
0da7181
Message:

updated runscript and shared header for rand bench

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/bench.h

    r0da7181 r5f648fb3  
    4747#endif
    4848
    49 size_t threads = 1;
     49size_t threads = 1, num_locks = -1;
    5050
    5151#define BENCH_START()                           \
    52         if ( argc > 2 ) exit( EXIT_FAILURE );   \
     52        if ( argc > 3 ) exit( EXIT_FAILURE );   \
    5353        if ( argc == 2 ) {                      \
    5454                threads = atoi( argv[1] );      \
     55        } else if ( argc == 3 ) {                       \
     56                threads = atoi( argv[1] );      \
     57        num_locks = atoi( argv[2] );    \
    5558        }
    5659
     
    7780}
    7881#endif
     82
     83// splitmix64 rand num generator
     84// https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64
     85uint64_t state;                                  /* The state can be seeded with any (upto) 64 bit integer value. */
     86
     87uint64_t next_int() {
     88    state += 0x9e3779b97f4a7c15;               /* increment the state variable */
     89    uint64_t z = state;                          /* copy the state to a working variable */
     90    z = (z ^ (z >> 30)) * 0xbf58476d1ce4e5b9;  /* xor the variable with the variable right bit shifted 30 then multiply by a constant */
     91    z = (z ^ (z >> 27)) * 0x94d049bb133111eb;  /* xor the variable with the variable right bit shifted 27 then multiply by a constant */
     92    return z ^ (z >> 31);                      /* return the variable xored with itself right bit shifted 31 */
     93}
     94
Note: See TracChangeset for help on using the changeset viewer.