Repository navigation
Support read-write images - #21
Merged
Merged
Conversation
OpImageRead and OpImageWrite map to read_image*/write_image*, picking the builtin from the texel's component type, with integer coordinates (a 3D coordinate padded to int4). Other image operands than the Nontemporal hint and the signedness of integer texels are refused rather than dropped. SPIR-V integers are signless, and clang's SPIR-V backend emits neither SignExtend nor ZeroExtend. Without them, the SPIR-V environment has the image's channel type decide the extension, while OpenCL C has a builtin for either and leaves mismatches undefined. Dispatch on get_image_channel_data_type then, and honour the operands when present.
… 2.0 Writing 3D images is an extension before OpenCL C 2.0, where it became core. Now that image writes are translated, a module writing one at 1.2 otherwise produces source compilers without the extension pragma reject.
Producers declare it for read_write images, which are core in OpenCL C 2.0 and optional in 3.0. Below 2.0 OpenCL C has no read_write qualifier, so refuse the capability there, and the ReadWrite image type too, since it only requires the Kernel capability. Fixes #13.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Kernels taking a
read_writeimage couldn't be translated (#13). Accepting theImageReadWritecapability wasn't enough on its own:OpImageReadandOpImageWrite, the only way to use such an image, weren't implemented either, so the issue's kernel then failed on those.OpImageRead/OpImageWritemap toread_image*/write_image*, with the builtin picked from the texel's component type and integer coordinates. SPIR-V integers are signless, and clang's SPIR-V backend emits neitherSignExtendnorZeroExtend; without them the SPIR-V environment lets the image's channel type decide, whereas OpenCL C has separate_i/_uibuiltins and leaves mismatches undefined. So integer texels dispatch onget_image_channel_data_type, unless an operand states the signedness. Other image operands than theNontemporalhint are refused rather than dropped.cl_khr_3d_image_writesbelow OpenCL C 2.0, whose pragma is now emitted with the write-only 3D image type.ImageReadWriteis accepted from OpenCL C 2.0 on and refused below, as is theReadWriteimage type itself, which only requiresKerneland would otherwise produce aread_writequalifier that 1.2 compilers reject.The issue's kernel, and an integer read-modify-write kernel on signed and unsigned 8-bit images, produce correct results on PoCL and Intel's CPU runtime (NVIDIA doesn't support read-write images). On those and on NVIDIA, the
_iand_uibuiltins in fact behave identically, following the channel type, so the dispatch is about conforming to OpenCL C rather than fixing an observed miscompile.Fixes #13. Related problems found along the way: #19, #20.