-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL] Propagate attributes from transitive calls to kernel #1878
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
Conversation
f611c15
to
b28af10
Compare
Is this right that you're only changing the comment now? |
Yes. This is supposed to address the issue #1811 Unless you think I should also include changing SYCLKernel->addAttr(A); part to contain cloned attributes to kernel, like in the previous commit f611c15 |
I could add a test case to show that indirect calls to kernel will be ignored with a warning |
That is perhaps a useful test. The addKernel cloning parts SHOULD happen, but is likely better in a separate patch. |
Agreed. |
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.
@schittir, ##1811 provides a test case exposing the problem, but it is not a complete test case and can't be used as is. The essence of the problem is:
define dso_local spir_kernel void @_ZTSZ11invoke_foo2vE10KernelName() #0 !kernel_arg_addr_space !4 !kernel_arg_access_qual !4 !kernel_arg_type !4 !kernel_arg_base_type !4 !kernel_arg_type_qual !4 !no_global_work_offset !4 {
no_global_work_offset
got propagated from unrelated function w/o warning.
Did you try it and made sure it does not happen? I'd expect to see a test case which ensures there is no no_global_work_offset
on spir_kernel
in the generated IR. I think for this test case to pass code changes are actually needed. In current implementation any function called from kernel is considered a kernel body function (functor or lambda), but there can be (and are) calls to other functions in the kernel - kernel calls things like item
constructors before calling the kernel body function, and this is not distinguished.
Also I think before we fix this part, there needs to be some explanation/theoretical justification why attributes from functions that are not kernel body functions can't be propagated to kernels.
Dmitry pointed out that "the current compiler behavior is such that the left-sided (aka declaration attributes) shall be propagated to the called as well", which is consistent with spec1.2.1 #6.7 ; Therefore direct calls within kernel body will pass on the attributes to the kernel. The "unrelated function" highlighted in @kbobrovs example at #1811 is considered a direct call because it is being called within the kernel body, and therefore propagating it to the kernel would be considered correct. @erichkeane would you agree?
I will follow up on these offline.
Yes, I would like to understand this too. |
@schittir - spec1.2.1 6.7 is the "theoretical justification" I was looking for - thanks.
So I still don't see what this is based on in the spec:
So if implementation follows the above comment, it seems to be incorrect. Also note that the spec about 3 attributes: @Ruyk, @Naghasan - could you please help interpret section "6.7 Attributes" of the SYCL spec? |
According to @Naghasan clarification, this is the correct interpretation:
Also other relevant attributes like |
Thank you for the clarification. This should make no difference to the behaviour of the test described here #1811 i.e., the propagation of attribute to kernel without a warning is accepted as it is. Also, is the spec clarification from @Naghasan recorded somewhere you can share? |
Tagging @MrSidims here. Probably it's time to write proper specs for FPGA-specific attributes and define whether they should be "left-sided" with propagation enabled or "right-sided" with propagation disabled. Please note that current spelling and propagation mechanism is deprecated in SYCL 2020 Provisional spec |
@@ -16,5 +16,8 @@ void parallel_for(Type lambda) { | |||
} | |||
|
|||
void invoke_foo2() { | |||
// CHECK-LABEL: FunctionDecl {{.*}} invoke_foo2 'void ()' | |||
// CHECK: `-FunctionDecl {{.*}} _ZTSZ11invoke_foo2vE10KernelName 'void ()' |
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.
I would suggest {{.}}KernelName{{.}} Differences in name mangling on Windows will cause issues otherwise.
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.
I agree with this thought, and changed it per your suggestion. However, please note that there are other lit tests following this name mangled pattern, with which I intended to be consistent.
e0234b8
to
dd9e2d0
Compare
Accidentally pushed 6 unrelated commits to this pull request. Please ignore them. Working on fix. |
e3e52eb
to
8a9164d
Compare
Also adding a test to check that the kernel does not get attributes from functions that are not directly called by it.
- Remove the (incorrect) distinction between direct and transitive calls for the propagation of attributes to kernel - Add a test showing propagation of attributes from transitive call to kernel
8a9164d
to
1735df4
Compare
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.
New changes appear to be minor. LGTM
…rogram * upstream/sycl: (609 commits) [SYCL] Fix fail in the post commit testing (intel#2210) [SYCL] Materialize shadow local variables for byval arguments before use (intel#2200) [SYCL] Support lambda functions passed to reduction (intel#2190) [SYCL][USM] Improve USM Allocator. (intel#2026) [SYCL] Disallow mutable lambdas (intel#1785) [SYCL][ESIMD] Setup compilation pipeline for ESIMD (intel#2134) [SYCL] Fix not found kernel due to empty kernel name when using set_arg(s) (intel#2181) [SYCL] Fixed check for set_arg (intel#2203) Refactor indirect access calls to minimize invocations. (intel#2185) [SYCL][NFC] Fix potential null-pointer access (intel#2197) [SYCL] Propagate attributes from transitive calls to kernel (intel#1878) [SYCL] Fix warnings from static analysis tool (intel#2193) [SYCL][NFC] Fix ac_float test for compilation with FE optimizations (intel#2184) [GitHub Actions] Uplift clang-format version to 10 (intel#2194) [SYCL][ESIMD] Pass to replace simd* parameters with native llvm vectors. (intel#2097) [SYCL][NFC] Fixed SYCL_PI_TRACE output while selecting a device. (intel#2192) [SYCL][FPGA] New spec for controlling load-store units in FPGAs (intel#2158) [SYCL][Doc] Clarify reqd_sub_group_size (intel#2103) [SYCL] Remove noreturn function attribute (intel#2165) [SYCL] Aligned set_arg behaviour with SYCL specification (intel#2159) ...
We removed the following restrictions on intel#1878 // Allow the following kernel attributes only on lambda functions and // function objects that are called directly from a kernel (i.e. the one // passed to the parallel_for function). For all other cases, // emit a warning and ignore. 1. SYCLIntelKernelArgsRestrictAttr 2. SYCLIntelNumSimdWorkItemsAttr 3. SYCLIntelMaxWorkGroupSizeAttr 4. SYCLIntelMaxGlobalWorkDimAttr This patch updates the attribute document to reflect the changes since we do not ignore the kernel attributes anymore if it is applied to a function called from a device kernel and the attribute gets propagated to a kernel. Signed-off-by: Soumi Manna <[email protected]>
We removed the following restrictions on #1878 // Allow the following kernel attributes only on lambda functions and // function objects that are called directly from a kernel (i.e. the one // passed to the parallel_for function). For all other cases, // emit a warning and ignore. 1. SYCLIntelKernelArgsRestrictAttr 2. SYCLIntelNumSimdWorkItemsAttr 3. SYCLIntelMaxWorkGroupSizeAttr 4. SYCLIntelMaxGlobalWorkDimAttr This patch updates the attribute document to reflect the changes since we do not ignore the kernel attributes anymore if it is applied to a function called from a device kernel and the attribute gets propagated to a kernel. Signed-off-by: Soumi Manna <[email protected]>
This entity represents a module in the programming language, for example a Fortran module. Spec: KhronosGroup/SPIRV-Registry#186 The implementation is the same as for SPV_INTEL_debug_module extension. Spec for extension: https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_debug_module.asciidoc Original commit: KhronosGroup/SPIRV-LLVM-Translator@6a0368f
propagation of attributes to kernel