Show / Hide Table of Contents

    Class CudaRandDevice

    Wrapper for a CUrand generator handle in device mode

    Inheritance
    System.Object
    CudaRandDevice
    Implements
    System.IDisposable
    Inherited Members
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: ManagedCuda.CudaRand
    Assembly: CudaRand.dll
    Syntax
    public class CudaRandDevice : IDisposable

    Constructors

    | Improve this Doc View Source

    CudaRandDevice(GeneratorType)

    Creates a new random number generator of type Type

    Declaration
    public CudaRandDevice(GeneratorType Type)
    Parameters
    Type Name Description
    GeneratorType Type

    Generator type

    Properties

    | Improve this Doc View Source

    Generator

    Returns the wrapped curand generator handle

    Declaration
    public CurandGenerator Generator { get; }
    Property Value
    Type Description
    CurandGenerator

    Methods

    | Improve this Doc View Source

    Dispose()

    Dispose

    Declaration
    public void Dispose()
    | Improve this Doc View Source

    Dispose(Boolean)

    For IDisposable

    Declaration
    protected virtual void Dispose(bool fDisposing)
    Parameters
    Type Name Description
    System.Boolean fDisposing
    | Improve this Doc View Source

    Finalize()

    For dispose

    Declaration
    protected void Finalize()
    | Improve this Doc View Source

    Generate(CudaDeviceVariable<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. Launches are done with the stream set using SetStream(CUstream), or the null stream if no stream has been set.

    Results are 32-bit values with every bit random.

    Declaration
    public void Generate(CudaDeviceVariable<uint> output)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.UInt32> output

    CudaDeviceVariable

    | Improve this Doc View Source

    Generate(CudaDeviceVariable<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. Launches are done with the stream set using SetStream(CUstream), or the null stream if no stream has been set.

    Results are 64-bit values with every bit random.

    Declaration
    public void Generate(CudaDeviceVariable<ulong> output)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.UInt64> output

    CudaDeviceVariable

    | Improve this Doc View Source

    Generate32(CUdeviceptr, SizeT)

    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. Launches are done with the stream set using SetStream(CUstream), or the null stream if no stream has been set.

    Results are 32-bit values with every bit random.

    Declaration
    public void Generate32(CUdeviceptr output, SizeT size)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type uint*

    SizeT size

    Number of random elements to create

    | Improve this Doc View Source

    Generate64(CUdeviceptr, SizeT)

    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. Launches are done with the stream set using SetStream(CUstream), or the null stream if no stream has been set.

    Results are 64-bit values with every bit random.

    Declaration
    public void Generate64(CUdeviceptr output, SizeT size)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type ulong*

    SizeT size

    Number of random elements to create

    | Improve this Doc View Source

    GenerateLogNormal(CudaDeviceVariable<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(CudaDeviceVariable<double> output, double mean, double stddev)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Double> output

    CudaDeviceVariable

    System.Double mean
    System.Double stddev
    | Improve this Doc View Source

    GenerateLogNormal(CudaDeviceVariable<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(CudaDeviceVariable<float> output, float mean, float stddev)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Single> output

    CudaDeviceVariable

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    GenerateLogNormal32(CUdeviceptr, SizeT, 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 GenerateLogNormal32(CUdeviceptr output, SizeT size, float mean, float stddev)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type float*

    SizeT size

    Number of random elements to create

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    GenerateLogNormal64(CUdeviceptr, SizeT, Single, Single)

    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 GenerateLogNormal64(CUdeviceptr output, SizeT size, float mean, float stddev)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type double*

    SizeT size

    Number of random elements to create

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    GenerateNormal(CudaDeviceVariable<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(CudaDeviceVariable<double> output, double mean, double stddev)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Double> output

    CudaDeviceVariable

    System.Double mean
    System.Double stddev
    | Improve this Doc View Source

    GenerateNormal(CudaDeviceVariable<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(CudaDeviceVariable<float> output, float mean, float stddev)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Single> output

    CudaDeviceVariable

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    GenerateNormal32(CUdeviceptr, SizeT, 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 GenerateNormal32(CUdeviceptr output, SizeT size, float mean, float stddev)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type float*

    SizeT size

    Number of random elements to create

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    GenerateNormal64(CUdeviceptr, SizeT, Single, Single)

    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 GenerateNormal64(CUdeviceptr output, SizeT size, float mean, float stddev)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type double*

    SizeT size

    Number of random elements to create

    System.Single mean
    System.Single stddev
    | Improve this Doc View Source

    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()
    | Improve this Doc View Source

    GenerateUniform(CudaDeviceVariable<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(CudaDeviceVariable<double> output)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Double> output

    CudaDeviceVariable

    | Improve this Doc View Source

    GenerateUniform(CudaDeviceVariable<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(CudaDeviceVariable<float> output)
    Parameters
    Type Name Description
    CudaDeviceVariable<System.Single> output

    CudaDeviceVariable

    | Improve this Doc View Source

    GenerateUniform32(CUdeviceptr, SizeT)

    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 GenerateUniform32(CUdeviceptr output, SizeT size)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type float*

    SizeT size

    Number of random elements to create

    | Improve this Doc View Source

    GenerateUniform64(CUdeviceptr, SizeT)

    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 GenerateUniform64(CUdeviceptr output, SizeT size)
    Parameters
    Type Name Description
    CUdeviceptr output

    DevicePtr of type double*

    SizeT size

    Number of random elements to create

    | Improve this Doc View Source

    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[]
    | Improve this Doc View Source

    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[]
    | Improve this Doc View Source

    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[]
    | Improve this Doc View Source

    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[]
    | Improve this Doc View Source

    GetVersion()

    Returns the version number of the dynamically linked CURAND library.

    Declaration
    public static Version GetVersion()
    Returns
    Type Description
    System.Version
    | Improve this Doc View Source

    SetGeneratorOrdering(Ordering)

    Set the ordering of results of the pseudo or quasirandom number generator.

    Legal values of order for pseudorandom generators are:

    - PseudoDefault

    - PseudoBest

    - PseudoSeeded

    Legal values of order for quasirandom generators are:

    - QuasiDefault

    Declaration
    public void SetGeneratorOrdering(Ordering order)
    Parameters
    Type Name Description
    Ordering order
    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    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.

    | Improve this Doc View Source

    SetStream(CUstream)

    Set the current stream for CURAND kernel launches. All library functions will use this stream until set again.

    Declaration
    public void SetStream(CUstream stream)
    Parameters
    Type Name Description
    CUstream stream

    Implements

    System.IDisposable
    • Improve this Doc
    • View Source
    Back to top Generated by DocFX