-
Notifications
You must be signed in to change notification settings - Fork 572
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spirv-val: Some Float16 fixes #6009
base: main
Are you sure you want to change the base?
Conversation
According to the OpenCL environment capability, the environments which allow the cl_khr_fp16 extension must allow the Float16 capability. Currently, however, the validator only allowed the Float16Buffer capability to be declared by the module. This commit adds the Float16 capability to the list of allowed optional capabilities.
Small type uses are the same for Shader modules as Kernel modules. Currently, the validation rules are disabled for any module which does not advertise the Shader capability. This commit removes this check, enabling the validator to also check these rules for OpenCL kernel modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code-wise this seems ok, but I'd like Ben to comment on the actual OpenCL rules. The description of Float16Buffer is:
Allows a 16-bit OpTypeFloat instruction using the IEEE 754 encoding for creating an OpTypePointer to a 16-bit float. Pointers to a 16-bit float must not be dereferenced, unless specifically allowed by a specific instruction. All other uses of 16-bit OpTypeFloat are disallowed.
I'm not sure what is meant by "specifically allowed by a specific instruction" since I don't see any other mentions of Float16Buffer.
I believe that part refers to the ability of some extensions to allow operation on fp16 types like https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/AMD/SPV_AMD_gpu_shader_half_float.asciidoc, though i guess this would technically already require Float16. |
I'm not super familiar with this code, but looking at the tests it seems to be doing the right thing. The Float16Buffer capability allows creating a pointer to a 16-bit float (half), and then use of those pointers with the In other words, this should validate even though it doesn't declare Float16, because it declares Float16Buffer:
|
If that is true I'm not certain this is the right validation. This family of code checks the validation rules about 8- or 16-bit storage access capabilities. So for example, this would allow scalar loads of 16-bit floats. Based on @bashbaug comment this is not allowed. |
There is already such a test for the Shader capability (val_data_test.cpp,
Ah, I guess that is indeed missed right now. I'm slightly confused by this comment in
I don't see why There should probably also be a test using |
Those rules come from the following validation (and similar for 8-bit):
In particular the conversions bullet. |
ValidateSmallTypeUses
for non-Shader modulesOn a side note, it looks like clang does not generate the right capabilities here.