katgpucbf.curand_helpers module

Helpers to initialise random state with curand.

See Dithering for an explanation of why we introduce a separate randState_t structure. Code using this module should not generate Gaussian distributions without understanding the implications.

katgpucbf.curand_helpers.RAND_STATE_ALIGNMENT = 8

alignof(randState_t)

katgpucbf.curand_helpers.RAND_STATE_DTYPE = dtype({'names': ['_align'], 'formats': ['<u8'], 'offsets': [0], 'itemsize': 24}, align=True)

opaque dtype corresponding to randState_t (only size and alignment matter)

katgpucbf.curand_helpers.RAND_STATE_SIZE = 24

sizeof(randState_t)

class katgpucbf.curand_helpers.RandomStateBuilder(context: AbstractContext)[source]

Bases: object

Build array of initialised random states for curand.

make_states(command_queue: AbstractCommandQueue, shape: tuple[int, ...], seed: int, sequence_first: int, sequence_step: int = 1, offset: int = 0) DeviceArray[source]

Create a multi-dimensional array of random states.

This method is not particularly efficient. It’s intended to be used just during startup, after which the random states will be persisted in global memory and reused.

The initialisation process is enqueued to command_queue.