imate
C++/CUDA Reference
Loading...
Searching...
No Matches
random_number_generator.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3 * SPDX-License-Identifier: BSD-3-Clause
4 * SPDX-FileType: SOURCE
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the license found in the LICENSE.txt file in the root
8 * directory of this source tree.
9 */
10
11
12#ifndef _RANDOM_GENERATOR_RANDOM_NUMBER_GENERATOR_H_
13#define _RANDOM_GENERATOR_RANDOM_NUMBER_GENERATOR_H_
14
15
16// =======
17// Headers
18// =======
19
20#include <stdint.h> // int64_t, uint64_t
22
23
24// =======================
25// Random Number Generator
26// =======================
27
102
104{
105 public:
106 // Member methods
108 explicit RandomNumberGenerator(const int num_threads_);
109 explicit RandomNumberGenerator(
110 const int num_threads_,
111 const int64_t seed);
113 uint64_t next(const int thread_id);
114
115 protected:
116 // Member methods
117 void initialize(int64_t seed);
118
119 // Member data
120 const int num_threads;
122};
123
124
125#endif // _RANDOM_GENERATOR_RANDOM_NUMBER_GENERATOR_H_
Generates 64-bit integers on multiple parallel threads.
void initialize(int64_t seed)
Initializes an array of xoshiro_256_star_star objects.
Xoshiro256StarStar ** xoshiro_256_star_star
RandomNumberGenerator()
Initializes with one parallel thread and default seed.
uint64_t next(const int thread_id)
Generates the next random number in the sequence, depending on the thread id.
~RandomNumberGenerator()
Deallocates the array of xoshiro_256_star_star.
Pseudo-random integer generator. This class generates 64-bit integer using Xoshiro256** algorithm.