[PATCH 78/79] [Backport to 15] add initial f16 type support for atomicrmw in llvm...
authorVyacheslav Levytskyy <89994100+VyacheslavLevytskyy@users.noreply.github.com>
Tue, 14 Nov 2023 15:55:37 +0000 (16:55 +0100)
committerAndreas Beckmann <anbe@debian.org>
Thu, 14 Mar 2024 19:01:08 +0000 (20:01 +0100)
commite12ebd0f2176713234b5d1d512232e278587969b
tree86c957248d467b2d5998e323ffa3de70cf26e755
parent20bb07bfa7f62ec071ee4163e7242220bc6c7ef6
[PATCH 78/79] [Backport to 15] add initial f16 type support for atomicrmw in llvm-spirv translator (#2210)

This PR aims to add f16 type support for atomicrmw in llvm-spirv translator, with the reference to the extension documented in [1].
There are two concerns related to the subject:

SPIRVAtomicFAddEXTInst::getRequiredExtension() should return a list of required extension to support the requirement to list both SPV_EXT_shader_atomic_float16_add and SPV_EXT_shader_atomic_float_add extensions in the module (see "Extension Name" section of the ref [1]). However, the return type is std::optional<ExtensionID> and returning a vector would need a bigger rework.
Including SPV_EXT_shader_atomic_float16_add into --spirv-ext argument of llvm-spirv doesn't result in producing the correspondent capability (AtomicFloat16AddEXT) and extension in a SPIRV output.
$ llvm-spirv AtomicFAddEXT.ll.tmp.bc --spirv-ext=+SPV_EXT_shader_atomic_float_add,+SPV_EXT_shader_atomic_float16_add -o AtomicFAddEXT.ll.tmp.spv
$ llvm-spirv -to-text AtomicFAddEXT.ll.tmp.spv -o /dev/stdout
...
2 Capability AtomicFloat32AddEXT
2 Capability AtomicFloat64AddEXT
9 Extension "SPV_EXT_shader_atomic_float_add"
...
This prevents extending the test case of AtomicFAddEXT.ll in EXT/SPV_EXT_shader_atomic_float.

References:
[1] https://github.com/KhronosGroup/SPIRV-Registry/blob/main/extensions/EXT/SPV_EXT_shader_atomic_float16_add.asciidoc

Gbp-Pq: Name 0078-Backport-to-15-add-initial-f16-type-support-for-atom.patch
include/LLVMSPIRVExtensions.inc
lib/SPIRV/SPIRVWriter.cpp
lib/SPIRV/libSPIRV/SPIRVInstruction.h
lib/SPIRV/libSPIRV/SPIRVModule.cpp
test/extensions/EXT/SPV_EXT_shader_atomic_float_/atomicrmw_fadd_half.ll [new file with mode: 0644]
test/extensions/EXT/SPV_EXT_shader_atomic_float_/atomicrmw_fsub_half.ll [new file with mode: 0644]