rand_tile
-
void ckernel::rand_tile_init(uint32_t seed = 0, uint32_t stream_id = 0)
-
Initializes the random generator with seed + stream_id * 0x9E3779B9 modulo 2^32. Distinct stream IDs domain-separate related deterministic work ranges; stream_id=0 leaves the seed unchanged.
-
void ckernel::rand_tile(uint32_t idst, uint32_t from, uint32_t scale)
-
Performs element-wise rand on each element of a of a tile in DST register at index tile_index. That is each element is overwritten with a randomly generated float. The DST register buffer must be in acquired state via acquire_dst call. This call is blocking and is only available on the compute engine. This operation records replay slots 0-15 when scale is finite and at least 2^-95, and slots 0-16 otherwise. Callers sharing the replay buffer with other SFPU operations must reinitialize it as needed. On Wormhole, this operation also programs LREG12 and LREG13. Callers must restore those programmable constants before another SFPU operation relies on them. This operation overwrites ADDR_MOD_6 (dest incr 2) on every call; that is the only state it re-establishes, so a rand_tile with no rand_tile_init in the same kernel (keeping the PRNG stream seeded by an earlier rand_tile_init or a host-set seed) is valid only while the SFPU control register still holds the state the generic SFPU init leaves (control register cleared). An init that changes SFPU control state (e.g. topk_tile_init, which enables index tracking) must be followed by a clear before rand_tile, and the caller has to issue it: any generic SFPU *_tile_init clears it, or _init_sfpu_config_reg() directly; the topk ops themselves leave index tracking on at exit. rand_tile_init also clears it, but reseeds the PRNG stream, so it is not the tool for the seedless case above. Ops relying on ADDR_MOD_6 from their own init (e.g. topk_tile_init, square, sfpu reduce, matmul with THROTTLE_LEVEL) must re-run that init after rand_tile.
Return value: None
Argument Description
tile_index The index of the tile in the DST register buffer
from FP32 bit pattern for the inclusive lower bound
scale FP32 bit pattern producing [from, from + scale], inclusively