rocm.bindings.hiprand

Contents

rocm.bindings.hiprand#

2026-09-24

26 min read time

Applies to Linux and Windows

Advanced Micro Devices, Inc.

Attributes#

Classes#

uint4

(No short description)

rocrand_discrete_distribution_st

Represents a discrete probability distribution

rocrand_generator_base_type

(No short description)

rocrand_status

rocRAND function call status type

rocrand_rng_type

rocRAND generator type

rocrand_ordering

rocRAND generator ordering

rocrand_direction_vector_set

rocRAND vector set

hiprandStatus

hipRAND function call status type

hiprandRngType

hipRAND generator type

hiprandOrdering

hipRAND generator ordering

hiprandDirectionVectorSet

hipRAND vector set for quasirandom generators.

Functions#

has_symbol(→ bool)

hiprandCreateGenerator(rng_type)

Creates a new random number generator.

hiprandCreateGeneratorHost(rng_type)

Creates a new random number generator on host.

hiprandDestroyGenerator(generator)

Destroys random number generator.

hiprandGenerate(generator, output_data, n)

Generates uniformly distributed 32-bit unsigned integers.

hiprandGenerateChar(generator, output_data, n)

Generates uniformly distributed 8-bit unsigned integers.

hiprandGenerateShort(generator, output_data, n)

Generates uniformly distributed 16-bit unsigned integers.

hiprandGenerateLongLong(generator, output_data, n)

Generates uniformly distributed 64-bit unsigned integers.

hiprandGenerateUniform(generator, output_data, n)

Generates uniformly distributed floats.

hiprandGenerateUniformDouble(generator, output_data, n)

Generates uniformly distributed double-precision floating-point values.

hiprandGenerateUniformHalf(generator, output_data, n)

Generates uniformly distributed half-precision floating-point values.

hiprandGenerateNormal(generator, output_data, n, mean, ...)

Generates normally distributed floats.

hiprandGenerateNormalDouble(generator, output_data, n, ...)

Generates normally distributed doubles.

hiprandGenerateNormalHalf(generator, output_data, n, ...)

Generates normally distributed halfs.

hiprandGenerateLogNormal(generator, output_data, n, ...)

Generates log-normally distributed floats.

hiprandGenerateLogNormalDouble(generator, output_data, ...)

Generates log-normally distributed doubles.

hiprandGenerateLogNormalHalf(generator, output_data, ...)

Generates log-normally distributed halfs.

hiprandGeneratePoisson(generator, output_data, n, lambda_)

Generates Poisson-distributed 32-bit unsigned integers.

hiprandGenerateSeeds(generator)

Initializes the generator's state on GPU or host.

hiprandSetStream(generator, stream)

Sets the current stream for kernel launches.

hiprandSetPseudoRandomGeneratorSeed(generator, seed)

Sets the seed of a pseudo-random number generator.

hiprandSetGeneratorOffset(generator, offset)

Sets the offset of a random number generator.

hiprandSetGeneratorOrdering(generator, order)

Sets the ordering of a random number generator.

hiprandSetQuasiRandomGeneratorDimensions(generator, ...)

Set the number of dimensions of a quasi-random number generator.

hiprandGetVersion()

Returns the version number of the cuRAND or rocRAND library.

hiprandCreatePoissonDistribution(lambda_)

Construct the histogram for a Poisson distribution.

hiprandDestroyDistribution(discrete_distribution)

Destroy the histogram array for a discrete distribution.

hiprandGetDirectionVectors32(vectors, set)

Retrieves the Sobol 32 direction vector array specified by set.

hiprandGetDirectionVectors64(vectors, set)

Retrieves the Sobol 64 direction vector array specified by set.

hiprandGetScrambleConstants32(constants)

Retrieves the scramble constants for 32-bit scrambled Sobol generation.

hiprandGetScrambleConstants64(constants)

Retrieves the scramble constants for 64-bit scrambled Sobol generation.

Module Contents#

rocm.bindings.hiprand.has_symbol(name: str | bytes | bytearray) → bool#
rocm.bindings.hiprand.HIPRAND_VERSION: Any#
rocm.bindings.hiprand.HIPRAND_DEFAULT_MAX_BLOCK_SIZE: Any#
rocm.bindings.hiprand.HIPRAND_DEFAULT_MIN_WARPS_PER_EU: Any#
class rocm.bindings.hiprand.uint4(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

x: Any#
y: Any#
z: Any#
w: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
class rocm.bindings.hiprand.rocrand_discrete_distribution_st(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

Represents a discrete probability distribution

size: Any#
offset: Any#
alias: Any#
probability: Any#
cdf: Any#
static PROPERTIES() → list[str]#
static fromObj(pyobj) → Any#
static allocate(count: int = 1) → Any#
c_sizeof() → int#
as_c_void_p() → Any#
rocm.bindings.hiprand.rocrand_discrete_distribution#
class rocm.bindings.hiprand.rocrand_generator_base_type(*args, **kwargs)#

Bases: rocm.bindings.util.types.Pointer

(No short description)

rocm.bindings.hiprand.rocrand_generator#
class rocm.bindings.hiprand.rocrand_status#

Bases: enum.IntEnum

rocRAND function call status type

ROCRAND_STATUS_SUCCESS: int#
ROCRAND_STATUS_VERSION_MISMATCH: int#
ROCRAND_STATUS_NOT_CREATED: int#
ROCRAND_STATUS_ALLOCATION_FAILED: int#
ROCRAND_STATUS_TYPE_ERROR: int#
ROCRAND_STATUS_OUT_OF_RANGE: int#
ROCRAND_STATUS_LENGTH_NOT_MULTIPLE: int#
ROCRAND_STATUS_DOUBLE_PRECISION_REQUIRED: int#
ROCRAND_STATUS_LAUNCH_FAILURE: int#
ROCRAND_STATUS_INTERNAL_ERROR: int#
class rocm.bindings.hiprand.rocrand_rng_type#

Bases: enum.IntEnum

rocRAND generator type

ROCRAND_RNG_PSEUDO_DEFAULT: int#
ROCRAND_RNG_PSEUDO_XORWOW: int#
ROCRAND_RNG_PSEUDO_MRG32K3A: int#
ROCRAND_RNG_PSEUDO_MTGP32: int#
ROCRAND_RNG_PSEUDO_PHILOX4_32_10: int#
ROCRAND_RNG_PSEUDO_MRG31K3P: int#
ROCRAND_RNG_PSEUDO_LFSR113: int#
ROCRAND_RNG_PSEUDO_MT19937: int#
ROCRAND_RNG_PSEUDO_THREEFRY2_32_20: int#
ROCRAND_RNG_PSEUDO_THREEFRY2_64_20: int#
ROCRAND_RNG_PSEUDO_THREEFRY4_32_20: int#
ROCRAND_RNG_PSEUDO_THREEFRY4_64_20: int#
ROCRAND_RNG_QUASI_DEFAULT: int#
ROCRAND_RNG_QUASI_SOBOL32: int#
ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL32: int#
ROCRAND_RNG_QUASI_SOBOL64: int#
ROCRAND_RNG_QUASI_SCRAMBLED_SOBOL64: int#
class rocm.bindings.hiprand.rocrand_ordering#

Bases: enum.IntEnum

rocRAND generator ordering

ROCRAND_ORDERING_PSEUDO_BEST: int#
ROCRAND_ORDERING_PSEUDO_DEFAULT: int#
ROCRAND_ORDERING_PSEUDO_SEEDED: int#
ROCRAND_ORDERING_PSEUDO_LEGACY: int#
ROCRAND_ORDERING_PSEUDO_DYNAMIC: int#
ROCRAND_ORDERING_QUASI_DEFAULT: int#
class rocm.bindings.hiprand.rocrand_direction_vector_set#

Bases: enum.IntEnum

rocRAND vector set

ROCRAND_DIRECTION_VECTORS_32_JOEKUO6: int#
ROCRAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6: int#
ROCRAND_DIRECTION_VECTORS_64_JOEKUO6: int#
ROCRAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6: int#
rocm.bindings.hiprand.hiprandGenerator_st#
rocm.bindings.hiprand.hiprandDiscreteDistribution_st#
rocm.bindings.hiprand.hiprandGenerator_t#
rocm.bindings.hiprand.hiprandDiscreteDistribution_t#
class rocm.bindings.hiprand.hiprandStatus#

Bases: enum.IntEnum

hipRAND function call status type

HIPRAND_STATUS_SUCCESS: int#
HIPRAND_STATUS_VERSION_MISMATCH: int#
HIPRAND_STATUS_NOT_INITIALIZED: int#
HIPRAND_STATUS_ALLOCATION_FAILED: int#
HIPRAND_STATUS_TYPE_ERROR: int#
HIPRAND_STATUS_OUT_OF_RANGE: int#
HIPRAND_STATUS_LENGTH_NOT_MULTIPLE: int#
HIPRAND_STATUS_DOUBLE_PRECISION_REQUIRED: int#
HIPRAND_STATUS_LAUNCH_FAILURE: int#
HIPRAND_STATUS_PREEXISTING_FAILURE: int#
HIPRAND_STATUS_INITIALIZATION_FAILED: int#
HIPRAND_STATUS_ARCH_MISMATCH: int#
HIPRAND_STATUS_INTERNAL_ERROR: int#
HIPRAND_STATUS_NOT_IMPLEMENTED: int#
rocm.bindings.hiprand.hiprandStatus_t#
class rocm.bindings.hiprand.hiprandRngType#

Bases: enum.IntEnum

hipRAND generator type

HIPRAND_RNG_TEST: int#
HIPRAND_RNG_PSEUDO_DEFAULT: int#
HIPRAND_RNG_PSEUDO_XORWOW: int#
HIPRAND_RNG_PSEUDO_MRG32K3A: int#
HIPRAND_RNG_PSEUDO_MTGP32: int#
HIPRAND_RNG_PSEUDO_MT19937: int#
HIPRAND_RNG_PSEUDO_PHILOX4_32_10: int#
HIPRAND_RNG_QUASI_DEFAULT: int#
HIPRAND_RNG_QUASI_SOBOL32: int#
HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32: int#
HIPRAND_RNG_QUASI_SOBOL64: int#
HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64: int#
rocm.bindings.hiprand.hiprandRngType_t#
class rocm.bindings.hiprand.hiprandOrdering#

Bases: enum.IntEnum

hipRAND generator ordering

HIPRAND_ORDERING_PSEUDO_BEST: int#
HIPRAND_ORDERING_PSEUDO_DEFAULT: int#
HIPRAND_ORDERING_PSEUDO_SEEDED: int#
HIPRAND_ORDERING_PSEUDO_LEGACY: int#
HIPRAND_ORDERING_PSEUDO_DYNAMIC: int#
HIPRAND_ORDERING_QUASI_DEFAULT: int#
rocm.bindings.hiprand.hiprandOrdering_t#
class rocm.bindings.hiprand.hiprandDirectionVectorSet#

Bases: enum.IntEnum

hipRAND vector set for quasirandom generators.

HIPRAND_DIRECTION_VECTORS_32_JOEKUO6: int#
HIPRAND_SCRAMBLED_DIRECTION_VECTORS_32_JOEKUO6: int#
HIPRAND_DIRECTION_VECTORS_64_JOEKUO6: int#
HIPRAND_SCRAMBLED_DIRECTION_VECTORS_64_JOEKUO6: int#
rocm.bindings.hiprand.hiprandDirectionVectorSet_t#
rocm.bindings.hiprand.hiprandCreateGenerator(rng_type)#

Creates a new random number generator.

Creates a new random number generator of type rng_type, and returns it in generator. That generator will use GPU to create random numbers.

Values for rng_type are: - HIPRAND_RNG_PSEUDO_DEFAULT - HIPRAND_RNG_PSEUDO_XORWOW - HIPRAND_RNG_PSEUDO_MRG32K3A - HIPRAND_RNG_PSEUDO_MTGP32 - HIPRAND_RNG_PSEUDO_MT19937 - HIPRAND_RNG_PSEUDO_PHILOX4_32_10 - HIPRAND_RNG_QUASI_DEFAULT - HIPRAND_RNG_QUASI_SOBOL32 - HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 - HIPRAND_RNG_QUASI_SOBOL64 - HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64

Args:
rng_type (hiprandRngType):

Type of random number generator to create

Returns:

A tuple of size 2 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_ALLOCATION_FAILED, if memory allocation failed

    • HIPRAND_STATUS_INITIALIZATION_FAILED if there was a problem setting up the GPU

    • HIPRAND_STATUS_VERSION_MISMATCH if the header file version does not match the dynamically linked library version

    • HIPRAND_STATUS_TYPE_ERROR if the value for rng_type is invalid

    • HIPRAND_STATUS_NOT_IMPLEMENTED if generator of type rng_type is not implemented yet

    • HIPRAND_STATUS_SUCCESS if generator was created successfully

  • rocrand_generator_base_type:

    Pointer to generator

C signature

hiprandStatus_t hiprandCreateGenerator(hiprandGenerator_t * generator, hiprandRngType_t rng_type)
rocm.bindings.hiprand.hiprandCreateGeneratorHost(rng_type)#

Creates a new random number generator on host.

Creates a new host random number generator of type rng_type and returns it in generator. Created generator will use host CPU to generate random numbers.

Values for rng_type are: - HIPRAND_RNG_PSEUDO_DEFAULT - HIPRAND_RNG_PSEUDO_XORWOW - HIPRAND_RNG_PSEUDO_MRG32K3A - HIPRAND_RNG_PSEUDO_MTGP32 - HIPRAND_RNG_PSEUDO_MT19937 - HIPRAND_RNG_PSEUDO_PHILOX4_32_10 - HIPRAND_RNG_QUASI_DEFAULT - HIPRAND_RNG_QUASI_SOBOL32 - HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 - HIPRAND_RNG_QUASI_SOBOL64 - HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64

Args:
rng_type (hiprandRngType):

Type of random number generator to create

Returns:

A tuple of size 2 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_ALLOCATION_FAILED, if memory allocation failed

    • HIPRAND_STATUS_VERSION_MISMATCH if the header file version does not match the dynamically linked library version

    • HIPRAND_STATUS_TYPE_ERROR if the value for rng_type is invalid

    • HIPRAND_STATUS_NOT_IMPLEMENTED if host generator of type rng_type is not implemented yet

    • HIPRAND_STATUS_SUCCESS if generator was created successfully

  • rocrand_generator_base_type:

    Pointer to generator

C signature

hiprandStatus_t hiprandCreateGeneratorHost(hiprandGenerator_t * generator, hiprandRngType_t rng_type)
rocm.bindings.hiprand.hiprandDestroyGenerator(generator)#

Destroys random number generator.

Destroys random number generator and frees related memory.

Args:
generator (rocrand_generator_base_type/object):

Generator to be destroyed

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_SUCCESS if generator was destroyed successfully

C signature

hiprandStatus_t hiprandDestroyGenerator(hiprandGenerator_t generator)
rocm.bindings.hiprand.hiprandGenerate(generator, output_data, n)#

Generates uniformly distributed 32-bit unsigned integers.

Generates n uniformly distributed 32-bit unsigned integers and saves them to output_data.

Generated numbers are between 0 and 2^32, including 0 and excluding 2^32.

Note: generator must be not be of type HIPRAND_RNG_QUASI_SOBOL64 or HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (PointerToUnsigned/object):

Pointer to memory to store generated numbers

n (int):

Number of 32-bit unsigned integers to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerate(hiprandGenerator_t generator, unsigned int * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateChar(generator, output_data, n)#

Generates uniformly distributed 8-bit unsigned integers.

Generates n uniformly distributed 8-bit unsigned integers and saves them to output_data.

Generated numbers are between 0 and 2^8, including 0 and excluding 2^8.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of 8-bit unsigned integers to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateChar(hiprandGenerator_t generator, unsigned char * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateShort(generator, output_data, n)#

Generates uniformly distributed 16-bit unsigned integers.

Generates n uniformly distributed 16-bit unsigned integers and saves them to output_data.

Generated numbers are between 0 and 2^16, including 0 and excluding 2^16.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of 16-bit unsigned integers to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateShort(hiprandGenerator_t generator, unsigned short * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateLongLong(generator, output_data, n)#

Generates uniformly distributed 64-bit unsigned integers.

Generates n uniformly distributed 64-bit unsigned integers and saves them to output_data.

Generated numbers are between 0 and 2^64, including 0 and excluding 2^64.

Note: generator must be of type HIPRAND_RNG_QUASI_SOBOL64 or HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL64.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of 64-bit unsigned integers to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateLongLong(hiprandGenerator_t generator, unsigned long long * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateUniform(generator, output_data, n)#

Generates uniformly distributed floats.

Generates n uniformly distributed 32-bit floating-point values and saves them to output_data.

Generated numbers are between 0.0f and 1.0f, excluding 0.0f and including 1.0f.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of floats to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not a multiple of the dimension

    of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateUniform(hiprandGenerator_t generator, float * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateUniformDouble(generator, output_data, n)#

Generates uniformly distributed double-precision floating-point values.

Generates n uniformly distributed 64-bit double-precision floating-point values and saves them to output_data.

Generated numbers are between 0.0 and 1.0, excluding 0.0 and including 1.0.

Note: When generator is of type: HIPRAND_RNG_PSEUDO_MRG32K3A, HIPRAND_RNG_PSEUDO_MTGP32, HIPRAND_RNG_QUASI_SOBOL32, or HIPRAND_RNG_QUASI_SCRAMBLED_SOBOL32 then the returned double values are generated from only 32 random bits each (one unsigned int value per one generated double).

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of floats to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not a multiple of the dimension

    of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateUniformDouble(hiprandGenerator_t generator, double * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateUniformHalf(generator, output_data, n)#

Generates uniformly distributed half-precision floating-point values.

Generates n uniformly distributed 16-bit half-precision floating-point values and saves them to output_data.

Generated numbers are between 0.0 and 1.0, excluding 0.0 and including 1.0.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of halfs to generate

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not a multiple of the dimension

    of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateUniformHalf(hiprandGenerator_t generator, half * output_data, size_t n)
rocm.bindings.hiprand.hiprandGenerateNormal(generator, output_data, n, mean, stddev)#

Generates normally distributed floats.

Generates n normally distributed 32-bit floating-point values and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of floats to generate

mean (float/int):

Mean value of normal distribution

stddev (float/int):

Standard deviation value of normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(float2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateNormal(hiprandGenerator_t generator, float * output_data, size_t n, float mean, float stddev)
rocm.bindings.hiprand.hiprandGenerateNormalDouble(generator, output_data, n, mean, stddev)#

Generates normally distributed doubles.

Generates n normally distributed 64-bit double-precision floating-point numbers and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of doubles to generate

mean (float/int):

Mean value of normal distribution

stddev (float/int):

Standard deviation value of normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(double2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateNormalDouble(hiprandGenerator_t generator, double * output_data, size_t n, double mean, double stddev)
rocm.bindings.hiprand.hiprandGenerateNormalHalf(generator, output_data, n, mean, stddev)#

Generates normally distributed halfs.

Generates n normally distributed 16-bit half-precision floating-point numbers and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of halfs to generate

mean (int):

Mean value of normal distribution

stddev (int):

Standard deviation value of normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(half2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateNormalHalf(hiprandGenerator_t generator, half * output_data, size_t n, half mean, half stddev)
rocm.bindings.hiprand.hiprandGenerateLogNormal(generator, output_data, n, mean, stddev)#

Generates log-normally distributed floats.

Generates n log-normally distributed 32-bit floating-point values and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of floats to generate

mean (float/int):

Mean value of log normal distribution

stddev (float/int):

Standard deviation value of log normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(float2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateLogNormal(hiprandGenerator_t generator, float * output_data, size_t n, float mean, float stddev)
rocm.bindings.hiprand.hiprandGenerateLogNormalDouble(generator, output_data, n, mean, stddev)#

Generates log-normally distributed doubles.

Generates n log-normally distributed 64-bit double-precision floating-point values and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of doubles to generate

mean (float/int):

Mean value of log normal distribution

stddev (float/int):

Standard deviation value of log normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(double2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateLogNormalDouble(hiprandGenerator_t generator, double * output_data, size_t n, double mean, double stddev)
rocm.bindings.hiprand.hiprandGenerateLogNormalHalf(generator, output_data, n, mean, stddev)#

Generates log-normally distributed halfs.

Generates n log-normally distributed 16-bit half-precision floating-point values and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (Pointer/object):

Pointer to memory to store generated numbers

n (int):

Number of halfs to generate

mean (int):

Mean value of log normal distribution

stddev (int):

Standard deviation value of log normal distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not even, output_data is not

    aligned to sizeof(half2) bytes, or n is not a multiple of the dimension of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGenerateLogNormalHalf(hiprandGenerator_t generator, half * output_data, size_t n, half mean, half stddev)
rocm.bindings.hiprand.hiprandGeneratePoisson(generator, output_data, n, lambda_)#

Generates Poisson-distributed 32-bit unsigned integers.

Generates n Poisson-distributed 32-bit unsigned integers and saves them to output_data.

Args:
generator (rocrand_generator_base_type/object):

Generator to use

output_data (PointerToUnsigned/object):

Pointer to memory to store generated numbers

n (int):

Number of 32-bit unsigned integers to generate

lambda (float/int):

lambda for the Poisson distribution

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_LAUNCH_FAILURE if generator failed to launch kernel

    • HIPRAND_STATUS_OUT_OF_RANGE if lambda is non-positive

    • HIPRAND_STATUS_LENGTH_NOT_MULTIPLE if n is not a multiple of the dimension

    of used quasi-random generator

    • HIPRAND_STATUS_SUCCESS if random numbers were successfully generated

C signature

hiprandStatus_t hiprandGeneratePoisson(hiprandGenerator_t generator, unsigned int * output_data, size_t n, double lambda)
rocm.bindings.hiprand.hiprandGenerateSeeds(generator)#

Initializes the generator’s state on GPU or host.

Initializes the generator’s state on GPU or host.

If hiprandGenerateSeeds() was not called for a generator, it will be automatically called by functions which generates random numbers like hiprandGenerate(), hiprandGenerateUniform(), hiprandGenerateNormal() etc.

Args:
generator (rocrand_generator_base_type/object):

Generator to initialize

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was never created

    • HIPRAND_STATUS_PREEXISTING_FAILURE if there was an existing error from a previous kernel launch

    • HIPRAND_STATUS_LAUNCH_FAILURE if the kernel launch failed for any reason

    • HIPRAND_STATUS_SUCCESS if the seeds were generated successfully

C signature

hiprandStatus_t hiprandGenerateSeeds(hiprandGenerator_t generator)
rocm.bindings.hiprand.hiprandSetStream(generator, stream)#

Sets the current stream for kernel launches.

Sets the current stream for all kernel launches of the generator. All functions will use this stream.

Args:
generator (rocrand_generator_base_type/object):

Generator to modify

stream (Pointer/object):

Stream to use or NULL for default stream

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_SUCCESS if stream was set successfully

C signature

hiprandStatus_t hiprandSetStream(hiprandGenerator_t generator, hipStream_t stream)
rocm.bindings.hiprand.hiprandSetPseudoRandomGeneratorSeed(generator, seed)#

Sets the seed of a pseudo-random number generator.

Sets the seed of the pseudo-random number generator.

  • This operation resets the generator’s internal state.

  • This operation does not change the generator’s offset.

Args:
generator (rocrand_generator_base_type/object):

Pseudo-random number generator

seed (int):

New seed value

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_TYPE_ERROR if the generator is a quasi random number generator

    • HIPRAND_STATUS_SUCCESS if seed was set successfully

C signature

hiprandStatus_t hiprandSetPseudoRandomGeneratorSeed(hiprandGenerator_t generator, unsigned long long seed)
rocm.bindings.hiprand.hiprandSetGeneratorOffset(generator, offset)#

Sets the offset of a random number generator.

Sets the absolute offset of the random number generator.

  • This operation resets the generator’s internal state.

  • This operation does not change the generator’s seed.

Absolute offset cannot be set if generator’s type is HIPRAND_RNG_PSEUDO_MTGP32 or HIPRAND_RNG_PSEUDO_MT19937.

Args:
generator (rocrand_generator_base_type/object):

Random number generator

offset (int):

New absolute offset

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_SUCCESS if offset was successfully set

    • HIPRAND_STATUS_TYPE_ERROR if generator’s type is HIPRAND_RNG_PSEUDO_MTGP32

    or HIPRAND_RNG_PSEUDO_MT19937

C signature

hiprandStatus_t hiprandSetGeneratorOffset(hiprandGenerator_t generator, unsigned long long offset)
rocm.bindings.hiprand.hiprandSetGeneratorOrdering(generator, order)#

Sets the ordering of a random number generator.

Sets the ordering of the results of a random number generator.

  • This operation resets the generator’s internal state.

  • This operation does not change the generator’s seed.

The ordering choices for pseudorandom sequences are HIPRAND_ORDERING_PSEUDO_DEFAULT and HIPRAND_ORDERING_PSEUDO_LEGACY. The default ordering is HIPRAND_ORDERING_PSEUDO_DEFAULT, which is equal to HIPRAND_ORDERING_PSEUDO_LEGACY for now.

For quasirandom sequences there is only one ordering, HIPRAND_ORDERING_QUASI_DEFAULT.

Args:
generator (rocrand_generator_base_type/object):

Random number generator

order (hiprandOrdering):

New ordering of results

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_INITIALIZED if the generator was not initialized

    • HIPRAND_STATUS_OUT_OF_RANGE if the ordering is not valid

    • HIPRAND_STATUS_SUCCESS if the ordering was successfully set

    • HIPRAND_STATUS_TYPE_ERROR if generator’s type is not valid

C signature

hiprandStatus_t hiprandSetGeneratorOrdering(hiprandGenerator_t generator, hiprandOrdering_t order)
rocm.bindings.hiprand.hiprandSetQuasiRandomGeneratorDimensions(generator, dimensions)#

Set the number of dimensions of a quasi-random number generator.

Set the number of dimensions of a quasi-random number generator. Supported values of dimensions are 1 to 20000.

  • This operation resets the generator’s internal state.

  • This operation does not change the generator’s offset.

Args:
generator (rocrand_generator_base_type/object):

Quasi-random number generator

dimensions (int):

Number of dimensions

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_NOT_CREATED if the generator wasn’t created

    • HIPRAND_STATUS_TYPE_ERROR if the generator is not a quasi-random number generator

    • HIPRAND_STATUS_OUT_OF_RANGE if dimensions is out of range

    • HIPRAND_STATUS_SUCCESS if the number of dimensions was set successfully

C signature

hiprandStatus_t hiprandSetQuasiRandomGeneratorDimensions(hiprandGenerator_t generator, unsigned int dimensions)
rocm.bindings.hiprand.hiprandGetVersion()#

Returns the version number of the cuRAND or rocRAND library.

Returns in version the version number of the underlying cuRAND or rocRAND library.

Returns:

A tuple of size 2 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_OUT_OF_RANGE if version is NULL

    • HIPRAND_STATUS_SUCCESS if the version number was successfully returned

  • int:

    Version of the library

C signature

hiprandStatus_t hiprandGetVersion(int * version)
rocm.bindings.hiprand.hiprandCreatePoissonDistribution(lambda_)#

Construct the histogram for a Poisson distribution.

Construct the histogram for the Poisson distribution with lambda lambda.

Args:
lambda (float/int):

lambda for the Poisson distribution

Returns:

A tuple of size 2 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_ALLOCATION_FAILED if memory could not be allocated

    • HIPRAND_STATUS_OUT_OF_RANGE if discrete_distribution pointer was null

    • HIPRAND_STATUS_OUT_OF_RANGE if lambda is non-positive

    • HIPRAND_STATUS_SUCCESS if the histogram was constructed successfully

  • rocrand_discrete_distribution_st:

    pointer to the histogram in device memory

C signature

hiprandStatus_t hiprandCreatePoissonDistribution(double lambda, hiprandDiscreteDistribution_t * discrete_distribution)
rocm.bindings.hiprand.hiprandDestroyDistribution(discrete_distribution)#

Destroy the histogram array for a discrete distribution.

Destroy the histogram array for a discrete distribution created by hiprandCreatePoissonDistribution.

Args:
discrete_distribution (rocrand_discrete_distribution_st/object):

pointer to the histogram in device memory

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_OUT_OF_RANGE if discrete_distribution was null

    • HIPRAND_STATUS_SUCCESS if the histogram was destroyed successfully

C signature

hiprandStatus_t hiprandDestroyDistribution(hiprandDiscreteDistribution_t discrete_distribution)
rocm.bindings.hiprand.hiprandGetDirectionVectors32(vectors, set)#

Retrieves the Sobol 32 direction vector array specified by set.

Args:
vectors (Pointer/object):

Pointer to the Sobol 32 direction vector array.

set (hiprandDirectionVectorSet):

Specifies which hipRAND vector set for quasirandom generators to retrieve.

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_OUT_OF_RANGE if set is invalid

    • HIPRAND_STATUS_SUCCESS if vectors was set successfully

C signature

hiprandStatus_t hiprandGetDirectionVectors32(hiprandDirectionVectors32_t ** vectors, hiprandDirectionVectorSet_t set)
rocm.bindings.hiprand.hiprandGetDirectionVectors64(vectors, set)#

Retrieves the Sobol 64 direction vector array specified by set.

Args:
vectors (Pointer/object):

Pointer to the Sobol 64 direction vector array.

set (hiprandDirectionVectorSet):

Specifies which hipRAND vector set for quasirandom generators to retrieve.

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_OUT_OF_RANGE if set is invalid

    • HIPRAND_STATUS_SUCCESS if vectors was set successfully

C signature

hiprandStatus_t hiprandGetDirectionVectors64(hiprandDirectionVectors64_t ** vectors, hiprandDirectionVectorSet_t set)
rocm.bindings.hiprand.hiprandGetScrambleConstants32(constants)#

Retrieves the scramble constants for 32-bit scrambled Sobol generation.

Args:
constants (Pointer/object):

Pointer to the constants pointer.

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_SUCCESS if the pointer was set successfully

C signature

hiprandStatus_t hiprandGetScrambleConstants32(const unsigned int ** constants)
rocm.bindings.hiprand.hiprandGetScrambleConstants64(constants)#

Retrieves the scramble constants for 64-bit scrambled Sobol generation.

Args:
constants (Pointer/object):

Pointer to the constants pointer.

Returns:

A tuple of size 1 that contains (in that order):

  • hiprandStatus: HIPRAND_STATUS_SUCCESS if the pointer was set successfully

C signature

hiprandStatus_t hiprandGetScrambleConstants64(const unsigned long long ** constants)