google / clspv

Clspv is a compiler for OpenCL C to Vulkan compute shaders
Apache License 2.0
597 stars 86 forks source link

Support double-precision floating point #321

Open kpet opened 5 years ago

kpet commented 5 years ago

clspv generally doesn't have support for double-precision floating point. The following at least are missing:

Trass3r commented 3 years ago

add support for double to the built-in functions

Do they need to be emulated? Currently some are mapped to ExtInsts (like here) which are not specified for fp64: https://www.khronos.org/registry/spir-v/specs/unified1/GLSL.std.450.html#_extended_instructions

Cazadorro commented 2 months ago

add support for double to the built-in functions

Do they need to be emulated? Currently some are mapped to ExtInsts (like here) which are not specified for fp64: https://www.khronos.org/registry/spir-v/specs/unified1/GLSL.std.450.html#_extended_instructions

I know this is years late, but my understanding is that none of the current desktop GPU makers have hardware accelerated double precision trigonometry (ie they don't have special function units for). Nvidia appears to only have single precision SFU, even on their server GPUs.

This means "emulated" double precision functions are literally how special functions are handled on Nvidia cards (aside from basic arithmetic operations). Note not all double precision functions need to be "emulated" https://registry.khronos.org/SPIR-V/specs/unified1/GLSL.std.450.html#_introduction

For GLSL functions, this means Trig, Log, Pow, and Exp functions all required to be "emulated", for OpenCL, additional functions would need to be emulated (like gamma etc...).