DirectXShaderCompiler
DirectXShaderCompiler copied to clipboard
Support IMul/UMul/UDiv with two outputs from HLSL
IMul/UMul/UDiv ops with two outputs have been part of the shader models since 4.0, but HLSL has never explicitly exposed these to HLSL so they could be fully used.
This is the suggestion that we should add new intrinsic functions to HLSL that map to these DXIL ops, which could open up scenarios without requiring the optional 64-bit support to be used.
The UMul instruction, in particular, is useful for implementing the Philox-4x32 pseudorandom number generator. This is one of the fastest PRNGs available for GPUs, since it is non-sequential, and mulhi/mullo (the two outputs of UMul) are at at the core of the Philox algorithm. Philox is commonly used for hardware-accelerated machine learning frameworks to initialize random weights in a model.
This instruction is exposed as umulExtended in GLSL.
@tex3d Needing this even more now, after having implemented several int64 operators in DirectML. The equivalent emulation is very verbose.
+1