-
Notifications
You must be signed in to change notification settings - Fork 738
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
[SYCL-SPIRV] Add SPIR-V variants of TypeSampledImage as clang builtin type #1945
Conversation
…in clang. This patch adds SPIR-V sampled image types as derivative of the builtin OpenCL Image types. For each OpenCL image type, clang defines a Sampled<image type> variant and lowered as a "spirv.SampledImage.<image>" llvm opaque type. Signed-off-by: Victor Lomuller <victor@codeplay.com>
@erichkeane, @bader , could you please help with review? |
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.
The code itself seems pretty mechanical and thus non controversial to me. That said, someone more familiar with what this is doing should judge/approve based on the solution chosen for the problem (that is, does adding these types fix the issue in the best way).
A bit more background for this patch: This patch makes the SPIR-V type This allow an accurate expression of |
PR #1978 is showing the application for this new type |
@intel/llvm-reviewers-runtime, @elizabethandrews, @Fznamznon, @premanandrao, ping. |
Signed-off-by: Victor Lomuller <victor@codeplay.com>
96ab694
@@ -0,0 +1,12 @@ | |||
// RUN: %clang_cc1 %s -triple x86_64-unknown-linux-gnu -O0 -emit-llvm -o - | FileCheck %s |
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.
Is it intention to test it with x86
triple?
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.
yes-ish, it follows the same patterns as for image.cl
. This is just to make the output stable when it comes to running the tests.
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.
Runtime library headers look good to me.
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.
There are multiple places where the IMAGE_TYPE macro is redefined. This would produce a build warning.
Other than that, looks good to me.
|
If I remember correctly, the original idea of using functions with __spirv prefixes and Spirv.* opaque types was inspired by SPIR-V friendly LLVM IR ( https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/master/docs/SPIRVRepresentationInLLVM.rst ) which allows to define functions/types in source code that will be correctly mapped to SPIR-V instructions/types by SPIR-V translator tool. SPIR-V friendly LLVM IR doc also defines how to attach additional image info to SampledImage type, see https://github.com/KhronosGroup/SPIRV-LLVM-Translator/blob/master/docs/SPIRVRepresentationInLLVM.rst#optypesampledimage . I wonder what was the reason to use mix of OpenCL and SPIRV friendly types (I mean |
These types are introduced in intel#1945
These types are introduced in #1945 This PR fix following build warnings: ``` [3204/3298] Building CXX object tools/lldb/source/Plugins/TypeSystem/Clang/CMakeFiles/lldbPluginTypeSystemClang.dir/TypeSystemClang.cpp.o lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp: In member function ‘virtual lldb::Encoding lldb_private::TypeSystemClang::GetEncoding(lldb::opaque_compiler_type_t, uint64_t&)’: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage1dRO’ not handled in switch [-Wswitch] switch (llvm::cast<clang::BuiltinType>(qual_type)->getKind()) { ^ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage1dArrayRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage1dBufferRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dArrayRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dDepthRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dArrayDepthRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dMSAARO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dArrayMSAARO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dMSAADepthRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage2dArrayMSAADepthRO’ not handled in switch [-Wswitch] lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp:4829:12: warning: enumeration value ‘SampledOCLImage3dRO’ not handled in switch [-Wswitch] ```
This patch adds SPIR-V sampled image types as derivative of the builtin OpenCL Image types.
For each OpenCL image type, clang defines a Sampled variant and
lowered as a "spirv.SampledImage." llvm opaque type.
The motivation for this patch is to allow a cleaner emulation of sampled image reads for the CUDA backend as it does not support independent image and sampler definition. This change allows to properly implement the
__spirv_SampledImage
builtin function by having it return a sampled image type (which can then be properly lowered according to its target) rather thanvoid *
.Signed-off-by: Victor Lomuller victor@codeplay.com