Class CudaRandHost
Wrapper for a CUrand generator handle in host mode
Inheritance
Inherited Members
Namespace: ManagedCuda.CudaRand
Assembly: CudaRand.dll
Syntax
public class CudaRandHost
Constructors
| Improve this Doc View SourceCudaRandHost(GeneratorType)
Creates a new random number generator of type Type
Declaration
public CudaRandHost(GeneratorType Type)
Parameters
| Type | Name | Description |
|---|---|---|
| GeneratorType | Type | Generator type |
Properties
| Improve this Doc View SourceGenerator
Returns the wrapped curand generator handle
Declaration
public CurandGenerator Generator { get; }
Property Value
| Type | Description |
|---|---|
| CurandGenerator |
Methods
| Improve this Doc View SourceDispose()
Dispose
Declaration
public void Dispose()
Dispose(Boolean)
For IDisposable
Declaration
protected virtual void Dispose(bool fDisposing)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Boolean | fDisposing |
Finalize()
For dispose
Declaration
protected void Finalize()
Generate(UInt32[])
Use generator to generate num 32-bit results into the device memory at output. The device memory must have been previously allocated and be large enough to hold all the results.
Results are 32-bit values with every bit random.
Declaration
public void Generate(uint[] output)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32[] | output | CudaDeviceVariable |
Generate(UInt64[])
Use generator to generate num 64-bit results into the device memory at output. The device memory must have been previously allocated and be large enough to hold all the results.
Results are 64-bit values with every bit random.
Declaration
public void Generate(ulong[] output)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64[] | output | CudaDeviceVariable |
GenerateLogNormal(Double[], Double, Double)
Use generator to generate num double results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using curandSetStream(), or the null stream if no stream has been set.
Results are 64-bit floating point values with log-normal distribution based on an associated normal distribution with mean mean and standard deviation stddev.
Normally distributed results are generated from pseudorandom generators with a Box-Muller transform, and so require num to be even. Quasirandom generators use an inverse cumulative distribution function to preserve dimensionality. The normally distributed results are transformed into log-normal distribution.
There may be slight numerical differences between results generated on the GPU with generators created with ::curandCreateGenerator() and results calculated on the CPU with generators created with ::curandCreateGeneratorHost(). These differences arise because of differences in results for transcendental functions. In addition, future versions of CURAND may use newer versions of the CUDA math library, so different versions of CURAND may give slightly different numerical values.
Declaration
public void GenerateLogNormal(double[] output, double mean, double stddev)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | output | CudaDeviceVariable |
| System.Double | mean | |
| System.Double | stddev |
GenerateLogNormal(Single[], Single, Single)
Use generator to generate num float results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using ::curandSetStream(), or the null stream if no stream has been set.
Results are 32-bit floating point values with log-normal distribution based on an associated normal distribution with mean mean and standard deviation stddev.
Normally distributed results are generated from pseudorandom generators with a Box-Muller transform, and so require num to be even. Quasirandom generators use an inverse cumulative distribution function to preserve dimensionality.
The normally distributed results are transformed into log-normal distribution.
There may be slight numerical differences between results generated on the GPU with generators created with ::curandCreateGenerator() and results calculated on the CPU with generators created with ::curandCreateGeneratorHost(). These differences arise because of differences in results for transcendental functions. In addition, future versions of CURAND may use newer versions of the CUDA math library, so different versions of CURAND may give slightly different numerical values.
Declaration
public void GenerateLogNormal(float[] output, float mean, float stddev)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single[] | output | CudaDeviceVariable |
| System.Single | mean | |
| System.Single | stddev |
GenerateNormal(Double[], Double, Double)
Use generator to generate num double results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using curandSetStream(), or the null stream if no stream has been set.
Results are 64-bit floating point values with mean mean and standard deviation stddev.
Normally distributed results are generated from pseudorandom generators with a Box-Muller transform, and so require num to be even. Quasirandom generators use an inverse cumulative distribution function to preserve dimensionality.
There may be slight numerical differences between results generated on the GPU with generators created with curandCreateGenerator() and results calculated on the CPU with generators created with curandCreateGeneratorHost(). These differences arise because of differences in results for transcendental functions. In addition, future versions of CURAND may use newer versions of the CUDA math library, so different versions of CURAND may give slightly different numerical values.
Declaration
public void GenerateNormal(double[] output, double mean, double stddev)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | output | CudaDeviceVariable |
| System.Double | mean | |
| System.Double | stddev |
GenerateNormal(Single[], Single, Single)
Use generator to generate num float results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using curandSetStream(), or the null stream if no stream has been set.
Results are 32-bit floating point values with mean mean and standard deviation stddev.
Normally distributed results are generated from pseudorandom generators with a Box-Muller transform, and so require num to be even. Quasirandom generators use an inverse cumulative distribution function to preserve dimensionality.
There may be slight numerical differences between results generated on the GPU with generators created with curandCreateGenerator() and results calculated on the CPU with generators created with curandCreateGeneratorHost(). These differences arise because of differences in results for transcendental functions. In addition, future versions of CURAND may use newer versions of the CUDA math library, so different versions of CURAND may give slightly different numerical values.
Declaration
public void GenerateNormal(float[] output, float mean, float stddev)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single[] | output | CudaDeviceVariable |
| System.Single | mean | |
| System.Single | stddev |
GenerateSeeds()
Generate the starting state of the generator. This function is automatically called by generation functions such as Generate(CudaDeviceVariable) and GenerateUniform(CudaDeviceVariable). It can be called manually for performance testing reasons to separate timings for starting state generation and random number generation.
Declaration
public void GenerateSeeds()
GenerateUniform(Double[])
Use generator to generate num double results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using curandSetStream(), or the null stream if no stream has been set.
Results are 64-bit double precision floating point values between 0.0 and 1.0, excluding 0.0 and including 1.0.
Declaration
public void GenerateUniform(double[] output)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double[] | output | CudaDeviceVariable |
GenerateUniform(Single[])
Use generator to generate num float results into the device memory at outputPtr. The device memory must have been previously allocated and be large enough to hold all the results. Launches are done with the stream set using SetStream(), or the null stream if no stream has been set.
Results are 32-bit floating point values between 0.0f and 1.0f, excluding 0.0f and including 1.0f.
Declaration
public void GenerateUniform(float[] output)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Single[] | output | CudaDeviceVariable |
GetDirectionVectors32(DirectionVectorSet)
Get an array of direction vectors that can be used for quasirandom number generation.
The array contains vectors for many dimensions. Each dimension has 32 vectors. Each individual vector is an unsigned int.
Legal values for set are: - JoeKuo6_32 (20,000 dimensions) - ScrambledJoeKuo6_32 (20,000 dimensions)
Declaration
public static DirectionVectors32[] GetDirectionVectors32(DirectionVectorSet set)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectionVectorSet | set |
Returns
| Type | Description |
|---|---|
| DirectionVectors32[] |
GetDirectionVectors64(DirectionVectorSet)
Get an array of direction vectors that can be used for quasirandom number generation.
The array contains vectors for many dimensions. Each dimension has 64 vectors. Each individual vector is an unsigned long long.
Legal values for set are: - JoeKuo6_64 (20,000 dimensions) - ScrambledJoeKuo6_64 (20,000 dimensions)
Declaration
public static DirectionVectors64[] GetDirectionVectors64(DirectionVectorSet set)
Parameters
| Type | Name | Description |
|---|---|---|
| DirectionVectorSet | set |
Returns
| Type | Description |
|---|---|
| DirectionVectors64[] |
GetScrambleConstants32()
Get scramble constants that can be used for quasirandom number generation.
The array contains constants for many dimensions. Each dimension has a single uint constant.
Declaration
public static uint[] GetScrambleConstants32()
Returns
| Type | Description |
|---|---|
| System.UInt32[] |
GetScrambleConstants64()
Get scramble constants that can be used for quasirandom number generation.
The array contains constants for many dimensions. Each dimension has a single ulong constant.
Declaration
public static ulong[] GetScrambleConstants64()
Returns
| Type | Description |
|---|---|
| System.UInt64[] |
GetVersion()
Returns the version number of the dynamically linked CURAND library.
Declaration
public static Version GetVersion()
Returns
| Type | Description |
|---|---|
| System.Version |
SetGeneratorOrdering(Ordering)
Set the ordering of results of the pseudo or quasirandom number generator.
Legal values of order for pseudorandom generators are:
Legal values of order for quasirandom generators are:
Declaration
public void SetGeneratorOrdering(Ordering order)
Parameters
| Type | Name | Description |
|---|---|---|
| Ordering | order |
SetOffset(UInt64)
Set the absolute offset of the pseudo or quasirandom number generator.
All values of offset are valid. The offset position is absolute, not relative to the current position in the sequence.
Declaration
public void SetOffset(ulong offset)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | offset | All values of offset are valid. |
SetPseudoRandomGeneratorSeed(UInt64)
Set the seed value of the pseudorandom number generator.
All values of seed are valid. Different seeds will produce different sequences. Different seeds will often not be statistically correlated with each other, but some pairs of seed values may generate sequences which are statistically correlated.
Declaration
public void SetPseudoRandomGeneratorSeed(ulong seed)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt64 | seed | All values of seed are valid. |
SetQuasiRandomGeneratorDimensions(UInt32)
Set the number of dimensions to be generated by the quasirandom number generator.
Legal values for dimensions are 1 to 20000.
Declaration
public void SetQuasiRandomGeneratorDimensions(uint dimensions)
Parameters
| Type | Name | Description |
|---|---|---|
| System.UInt32 | dimensions | Legal values for dimensions are 1 to 20000. |