Lattice Microbes 2.5
This is for whole cell modeling
Loading...
Searching...
No Matches
XORWow.h
Go to the documentation of this file.
1/*
2 * University of Illinois Open Source License
3 * Copyright 2011-2018 Luthey-Schulten Group,
4 * All rights reserved.
5 *
6 * Developed by: Luthey-Schulten Group
7 * University of Illinois at Urbana-Champaign
8 * http://www.scs.uiuc.edu/~schulten
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a copy of
11 * this software and associated documentation files (the Software), to deal with
12 * the Software without restriction, including without limitation the rights to
13 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
14 * of the Software, and to permit persons to whom the Software is furnished to
15 * do so, subject to the following conditions:
16 *
17 * - Redistributions of source code must retain the above copyright notice,
18 * this list of conditions and the following disclaimers.
19 *
20 * - Redistributions in binary form must reproduce the above copyright notice,
21 * this list of conditions and the following disclaimers in the documentation
22 * and/or other materials provided with the distribution.
23 *
24 * - Neither the names of the Luthey-Schulten Group, University of Illinois at
25 * Urbana-Champaign, nor the names of its contributors may be used to endorse or
26 * promote products derived from this Software without specific prior written
27 * permission.
28 *
29 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
32 * THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
33 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
34 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35 * OTHER DEALINGS WITH THE SOFTWARE.
36 *
37 * Author(s): Elijah Roberts
38 */
39
40#ifndef LM_RNG_XORWOW_H_
41#define LM_RNG_XORWOW_H_
42
43#include <cuda.h>
44#include <cuda_runtime.h>
45#include <curand_kernel.h>
46#include "core/Types.h"
47#include "rng/RandomGenerator.h"
48
49namespace lm {
50namespace rng {
51
53{
54public:
55 XORWow(int cudaDevice, uint32_t seedTop, uint32_t seedBottom, Distributions availableDists);
56 virtual ~XORWow();
57
58 virtual uint32_t getRandom();
59 virtual double getRandomDouble();
60 virtual double getExpRandomDouble();
61 virtual double getNormRandomDouble();
62 virtual void getRandomDoubles(double * rngs, int numberRNGs);
63 virtual void getExpRandomDoubles(double * rngs, int numberRNGs);
64 virtual void getNormRandomDoubles(double * rngs, int numberRNGs);
65
66protected:
67 virtual void generateRandomValues();
68 virtual void launchGenerateKernel();
70 curandState * state;
71 cudaStream_t stream;
72 #ifdef RNG_CUDA_DOUBLE_PRECISION
73 double * randomValues;
74 double * nextRandomValues;
75 double * randomValuesDev;
76 double * expRandomValues;
77 double * nextExpRandomValues;
78 double * expRandomValuesDev;
79 double * normRandomValues;
80 double * nextNormRandomValues;
81 double * normRandomValuesDev;
82 #else
83 float * randomValues;
92 #endif
93 const size_t numberValues;
94 size_t nextValue;
95};
96
97__global__ void xorwow_init_kernel(const unsigned long long seed, curandState *rngState);
98#ifdef RNG_CUDA_DOUBLE_PRECISION
99__global__ void xorwow_generate_kernel(curandState *state, double * randomValues, double * expRandomValues, double * normRandomValues, uint iterations);
100#else
101__global__ void xorwow_generate_kernel(curandState *state, float * randomValues, float * expRandomValues, float * normRandomValues, uint iterations);
102#endif
103
104}
105}
106
107#endif
unsigned int uint
Definition Types.h:52
Distributions availableDists
Definition RandomGenerator.h:100
Distributions
Types of random number generators that are allowed.
Definition RandomGenerator.h:56
RandomGenerator(uint32_t seedTop, uint32_t seedBottom, Distributions availableDists=(Distributions)(ALL))
Definition RandomGenerator.cpp:54
curandState * state
Definition XORWow.h:70
float * nextRandomValues
Definition XORWow.h:84
float * normRandomValuesDev
Definition XORWow.h:91
virtual ~XORWow()
float * expRandomValuesDev
Definition XORWow.h:88
size_t nextValue
Definition XORWow.h:94
float * randomValues
Definition XORWow.h:83
XORWow(int cudaDevice, uint32_t seedTop, uint32_t seedBottom, Distributions availableDists)
float * expRandomValues
Definition XORWow.h:86
virtual void generateRandomValues()
float * randomValuesDev
Definition XORWow.h:85
virtual void getExpRandomDoubles(double *rngs, int numberRNGs)
Get a number of random exponentially distiributed doubles.
virtual uint32_t getRandom()
Get a random integer.
virtual void getNormRandomDoubles(double *rngs, int numberRNGs)
Get a number of random normally distributed doubles.
virtual double getNormRandomDouble()
Get a random normally distributed double.
virtual void getRandomDoubles(double *rngs, int numberRNGs)
Get a number of random doubles.
const size_t numberValues
Definition XORWow.h:93
float * normRandomValues
Definition XORWow.h:89
virtual double getRandomDouble()
Get a random double.
virtual double getExpRandomDouble()
Get a random exponentially distributed double.
virtual void launchGenerateKernel()
float * nextExpRandomValues
Definition XORWow.h:87
int cudaDevice
Definition XORWow.h:69
cudaStream_t stream
Definition XORWow.h:71
float * nextNormRandomValues
Definition XORWow.h:90
Definition RandomGenerator.cpp:52
__global__ void xorwow_init_kernel(const unsigned long long seed, curandState *rngState)
__global__ void xorwow_generate_kernel(curandState *state, float *randomValues, float *expRandomValues, float *normRandomValues, uint iterations)
Definition Capsule.cpp:46