rocRAND data type support#

This topic discusses the various data types supported by rocRAND and provides a comparison with the data type support in NVIDIA CUDA cuRAND.

Host API#

This section covers the data types supported for the host API.

Generator types#

Supported generators on the host#

Generator

rocRAND support

cuRAND support

XORWOW

✅

✅

MRG32K3A

✅

✅

MTGP32

✅

✅

Philox 4x32-10

✅

✅

MT19937

✅

✅

MRG31K3P

✅

❌

LFSR113

✅

❌

ThreeFry 2x32-20

✅

❌

ThreeFry 4x32-20

✅

❌

ThreeFry 2x64-20

✅

❌

ThreeFry 4x64-20

✅

❌

Sobol32

✅

✅

Scrambled Sobol32

✅

✅

Sobol64

✅

✅

Scrambled Sobol64

✅

✅

Only Sobol64, Scrambled Sobol64, ThreeFry 2x64-20, and ThreeFry 4x64-20 support the generation of 64-bit unsigned long long int integers. The other generators generate 32-bit unsigned int integers.

Seed types#

All generators can be seeded with unsigned long long. However, LFSR113 can also be seeded using a uint4.

Output types#

The generators produce pseudo-random numbers chosen from a given distribution. The following distributions and corresponding output types are supported for the host API:

Uniform distribution#

Supported types for uniform distributions on the host#

Type

Size of type

rocRAND support

cuRAND support

unsigned char

8 bit

✅

❌

unsigned short

16 bit

✅

❌

unsigned int

32 bit

✅

✅

unsigned long long

64 bit (see note)

✅

✅

half

16 bit

✅

❌

float

32 bit

✅

✅

double

64 bit

✅

✅

Uniform distributions of integral types return a number between 0 and 2^(size in bits) - 1, whereas floating-point types return a number between 0.0 and 1.0, excluding 1.0.

Note

The generation of 64-bit unsigned long long integers is only supported by 64-bit generators (Scrambled Sobol 64, Sobol64, Threefry 2x64-20, and Threefry 4x64-20).

Poisson distribution#

Supported types for the Poisson distribution on the host#

Type

Size of type

rocRAND support

cuRAND support

unsigned int

32 bit

✅

✅

Normal distribution#

Supported types for normal distributions on the host#

Type

Size of type

rocRAND support

cuRAND support

half

16 bit

✅

❌

float

32 bit

✅

✅

double

64 bit

✅

✅

Log-normal distributions#

Supported types for log-normal distributions on the host#

Type

Size of type

rocRAND support

cuRAND support

half

16 bit

✅

❌

float

32 bit

✅

✅

double

64 bit

✅

✅

Device API#

This section covers the supported data types for the device API.

Generator types#

Supported generators on the device#

Generator

rocRAND support

cuRAND support

XORWOW

✅

✅

MRG32K3A

✅

✅

MTGP32

✅

✅

Philox 4x32-10

✅

✅

MT19937

❌

❌

MRG31K3P

✅

❌

LFSR113

✅

❌

ThreeFry 2x32-20

✅

❌

ThreeFry 4x32-20

✅

❌

ThreeFry 2x64-20

✅

❌

ThreeFry 4x64-20

✅

❌

Sobol32

✅

✅

Scrambled Sobol32

✅

✅

Sobol64

✅

✅

Scrambled Sobol64

✅

✅

Seed types#

All generators can be seeded with unsigned long long, however LFSR113 can also be seeded using an uint4.

Output types#

The generators produce pseudo-random numbers chosen from a given distribution. The following distributions and corresponding output types are supported for the device API. However, not all generators support all types.

Uniform distribution#

Supported types for uniform distributions on the device#

Type

rocRAND support

Supported rocRAND generators

cuRAND support

unsigned int

✅

All native 32-bit generators

✅

unsigned long long int

✅

All native 64-bit generators

✅

float

✅

All generators

✅

float2

✅

Philox 4x32-10

❌

float4

✅

Philox 4x32-10

✅

double

✅

All generators

✅

double2

✅

Philox 4x32-10

✅

double4

✅

Philox 4x32-10

❌

Normal distribution#

Supported types for normal distributions on the device#

Type

rocRAND support

Supported rocRAND generators

cuRAND support

float

✅

All generators

✅

float2

✅

Philox 4x32-10, MRG31K3P, MRG32K3A, XORWOW, LFSR113, all ThreeFry generators

✅

float4

✅

Philox 4x32-10

✅

double

✅

All generators

✅

double2

✅

Philox 4x32-10, MRG31K3P, MRG32K3A, XORWOW, LFSR113, all ThreeFry generators

✅

double4

✅

Philox 4x32-10

❌

Log-normal distributions#

Supported types for log-normal distributions on the device#

Type

rocRAND support

Supported rocRAND generators

cuRAND support

float

✅

All generators

✅

float2

✅

Philox 4x32-10, MRG31K3P, MRG32K3A, XORWOW, LFSR113, all ThreeFry generators

✅

float4

✅

Philox 4x32-10

✅

double

✅

All generators

✅

double2

✅

Philox 4x32-10, MRG31K3P, MRG32K3A, XORWOW, LFSR113, all ThreeFry generators

✅

double4

✅

Philox 4x32-10

❌

Poisson distributions#

Supported types for Poisson distributions on the device#

Type

rocRAND support

Supported rocRAND generators

cuRAND support

unsigned int

✅

Philox 4x32-10, MRG31k3p, MRG32K3A, XORWOW, MTGP32, Sobol32, Scrambled Sobol32, LFSR113, all ThreeFry generators

✅

unsigned long long int

✅

Sobol64, Scrambled Sobol64

❌

uint4

✅

Philox 4x32-10

✅

Discrete distributions#

Supported types for discrete distributions on the device#

Type

rocRAND support

Supported rocRAND generators

cuRAND support

unsigned int

✅

All generators

✅

uint4

✅

Philox 4x32-10

✅ - only Philox - 4x32-10