-
Notifications
You must be signed in to change notification settings - Fork 762
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] Add new kernel-arg-runtime-aligned metadata. #5111
[SYCL] Add new kernel-arg-runtime-aligned metadata. #5111
Conversation
I have some question. Are your changes related to #5113 ? |
Not sure why |
Fyi, I ran into some issues with my dev machine that caused delay in addressing the reviews comments. I am currently working on them. |
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.
LGTM
@srividya-sundaram, please, fix "OCL x64 Test Suite" failures. |
@bader @alexbatashev I see this same error for all the failing tests in Linux / OCL x64 Test Suite.
https://github.com/intel/llvm/runs/4793458932?check_suite_focus=true#step:6:34113 Could you please comment on that? |
That is odd - Capability is 5939 is ICapRuntimeAlignedAttributeINTEL which was introduced here: KhronosGroup/SPIRV-LLVM-Translator@974d4db and is meant to work well with this change. |
I guess OpenCL CPU runtime doesn't support this extensions yet. |
It an error from SPIR-V consumer. CPU runtime and FPGA emulator added a support for SPV_INTEL_runtime_aligned long ago, whilst GPU runtime is not yet here. AFAIU GPU can have little benefits from this metadata in some corner cases, but I'll disable the extension for it in a sec, leaving only FPGA H/W to support this extension. |
From the logs: terminate called after throwing an instance of 'cl::sycl::compile_program_error' |
I see, then it just about CPU runtime version Either way it should be save to just leave the extension be supported on FPGA H/W only for now. |
I've created #5299 with this PR checkouted. Lets see if the pre-commit passes there. |
@MrSidims Hi, I now see the following error in all failing tests for SYCL / Default Linux / OCL x64 Test Suite
And the following for SYCL / Default Linux / HIP AMD GPU Test Suite :
|
I believe it can not be related with neither your patch or SPIR-V extension.
Wow, didn't know, that we have testing on AMD for a regular basis. |
3575bb3
Tagging @zahiraam for awareness. |
After SPIRV-Tools commit 2e0f4b52 ("tools: refactorize tools flags parsing. (#5111)", 2023-02-27), spirv-as needs to be told explicitly when reading from stdin. Original commit: KhronosGroup/SPIRV-LLVM-Translator@7160516
In this PR, if a kernel pointer argument comes from a global accessor, we generate a new metadata(kernel_arg_runtime_aligned) to the kernel to indicate that this pointer has runtime allocated alignment.
If this information is available to the FPGA backend and if the accessor has no offset (e.g. through the user applying the no_offset property to their accessor), improvements to area of loads and stores can be made by using aligned LSUs. Without this enhancement we will continue to experience excess area.
The SYCL spec already guarantees that accessors are aligned to some runtime-specific alignment. So the user's source doesn't need to change to provide the backend with this guarantee, we simply need to allow this information to propagate to the backend.
Current IR implementation for kernel pointer argument from accessor looks like:
define dso_local spir_kernel void @_ZTSZ4mainE8kernel_A(i32 addrspace(1)* %_arg_, %"struct.cl::sycl::range"* byval(%"struct.cl::sycl::range") align 4 %_arg_1, %"struct.cl::sycl::range"* byval(%"struct.cl::sycl::range") align 4 %_arg_2, %"struct.cl::sycl::id"* byval(%"struct.cl::sycl::id") align 4 %_arg_3) #0 !kernel_arg_buffer_location !4 {
The new implementation will look like:
define dso_local spir_kernel void @_ZTSZ4mainE8kernel_A(i32 addrspace(1)* %_arg_, %"struct.cl::sycl::range"* byval(%"struct.cl::sycl::range") align 4 %_arg_1, %"struct.cl::sycl::range"* byval(%"struct.cl::sycl::range") align 4 %_arg_2, %"struct.cl::sycl::id"* byval(%"struct.cl::sycl::id") align 4 %_arg_3) #0 !kernel_arg_buffer_location !4 !kernel_arg_runtime_aligned !5 {
!5 = !{i1 true, i1 false, i1 false, i1 false}
The metadata is applied to the kernel but really carries data about the kernel’s arguments.
The first element of the metadata maps to the first kernel argument, the second to the second and so on. For this particular metadata the request is that the value of any metadata element is 'true' for any kernel arguments that corresponds to the base pointer of an accessor and 'false' otherwise.
Accessors are handled specially by the frontend (because they are marked with sycl_special_class) and when a user captures an accessor in their SYCL kernel the FE splits up the single accessor into 4 separate kernel arguments. The first of those 4 arguments is a pointer and is the base pointer of the accessor. That pointer is known to have runtime-specific alignment and thus the element of the kernel-arg-runtime metadata that corresponds to that argument will have a value of “true”.