-
Notifications
You must be signed in to change notification settings - Fork 771
[sycl-post-link] Fix a crash during spec-constant properties generation #5538
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
The sycl-post-link tool crashed during processing an IR where a specialization constant with a padding is present, for example a specialization constant of such type: struct alignas(32) coeff_str_aligned_t { std::array<float, 3> coeffs; size_t number; }; In the IR, the constant looks like the following: @_ZL8coeff_id = internal addrspace(1) constant %"class.cl::sycl::specialization_id" { %struct.coeff_str_aligned_t { %"class.std::array" zeroinitializer, i64 0, [8 x i8] undef } }, align 32 That '[8 x i8] undef' led to the crash. This patch fixes the issue. Co-authored-by: Steffen Larsen <steffen.larsen@intel.com> Signed-off-by: Pavel Samolysov <pavel.samolysov@intel.com>
Instead of generating a '__spirv_SpecConstant' invocation for every element of a composite data type with value 'undef' and then combining thir results into a call to '__spirv_SpecConstantComposite', the following optimization has been implemented. If the default value of a specialization constant or a part of such default value is undefined, the value (or its part) is passed into an invocation of the '__spirv_SpecConstantComposite' function as is.
Would it make sense to add a SYCL test (probably in llvm-test-suite) to ensure that the default values and offsets given to the runtime are correct when encountering this kind of padding? |
Good idea, @steffenlarsen I've extended the vector convolution demo test in llvm-test-suite to handle an aligned structure: intel/llvm-test-suite#830 |
/verify with intel/llvm-test-suite#830 |
/verify with intel/llvm-test-suite#830 |
Some problems with the test infrastructure. |
/verify with intel/llvm-test-suite#830 |
I tried the solution locally with this test: https://github.com/intel/llvm-test-suite/pull/830/files#diff-ec64dcd370d47e70aa3c7dcb41f18fb8780a11422e6065b9866fce62e75f1973 and the application crushes in the runtime (at |
I've pushed a new commit with changes in the spec. constant metadata generation, this works along with the changes from @steffenlarsen applied in commit 12d7c1f The idea is to skip undefined values during metadata IDs generation to let the padding processing handle such values as padding that they actually are. |
/verify with intel/llvm-test-suite#830 |
Some tests failed but they are unrelated to the changes. The |
Could you please check if failed tests have issues or create new ones for them? |
@mlychkov I've created one and there already is one for another failure. |
I would like to get a review from @steffenlarsen before merging. @steffenlarsen Could you have a look, please? |
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! It's a little confusing that ID
has an ID
member, but not enough that I worry about it.
I thought about it but didn't manage to make better naming. |
…on (intel#5538) The sycl-post-link tool crashed during processing an IR where a specialization constant with a padding is present, for example a specialization constant of such type: struct alignas(32) coeff_str_aligned_t { std::array<float, 3> coeffs; size_t number; }; In the IR, the constant looks like the following: @_ZL8coeff_id = internal addrspace(1) constant %"class.cl::sycl::specialization_id" { %struct.coeff_str_aligned_t { %"class.std::array" zeroinitializer, i64 0, [8 x i8] undef } }, align 32 That '[8 x i8] undef' led to the crash. This patch fixes the issue and adds the following optimization: if the default value of a specialization constant or a part of such default value is undefined, the value (or its part) is passed into an invocation of the '__spirv_SpecConstantComposite' function as is. Co-authored-by: Steffen Larsen <steffen.larsen@intel.com> Signed-off-by: Pavel Samolysov <pavel.samolysov@intel.com>
The test is extended with a specialization constant built upon an aligned structure. The CFE generates a padding represented as '[size x i8] undef' for such structures and the sycl-post-link tool crashed during property set generation for the specialization constant. The bug has been fixed in intel/llvm#5538, this extension is the E2E test for the fix to ensure that the default values and offsets given to the runtime are correct. Signed-off-by: Pavel Samolysov <pavel.samolysov@intel.com>
* upstream/sycl: (2757 commits) [SYCL][Doc] Fixing incorrect merge of community Readme.md with our version (intel#5636) [SYCL] Change USM pooling parameters. (intel#5457) [CI] Fix cache location on Windows (intel#5603) [SYCL][NFC] Fix a warning about uninitialized struct members (intel#5610) [Buildbot] Update Windows GPU version to 101.1340 (intel#5620) Fix SPIRV -> OCL barrier call argument attributes Move SPV_INTEL_memory_access_aliasing tokens from spirv_internal [SYCL][ESIMD] Add support for named barrier APIs (intel#5583) [SYCL][L0] Remove ZeModule when program build failed (intel#5541) [SYCL] Silence "unknown attribute" warning for `device_indirectly_callable` (intel#5591) [SYCL][DOC] Introductory material for extensions (intel#5605) [SYCL][DOC] Change extension names to lower case (intel#5607) [SYCL] Improve get_kernel_bundle performance (intel#5496) [SYCL] Do not build device code for sub-devices (intel#5240) [sycl-post-link] Fix a crash during spec-constant properties generation (intel#5538) [SYCL][DOC] Move SPIR-V and OpenCL extensions (intel#5578) [SYCL][ESIMD][EMU] Update memory intrinsics for ESIMD_EMU plugin (intel#4748) [CI] Allow stale issue bot to analyze more issues (intel#5602) [SYCL][L0] Honor property::queue::enable_profiling (intel#5543) [OpenMP] Properly save strings when doing LTO ...
…el/llvm-test-suite#830) The test is extended with a specialization constant built upon an aligned structure. The CFE generates a padding represented as '[size x i8] undef' for such structures and the sycl-post-link tool crashed during property set generation for the specialization constant. The bug has been fixed in intel#5538, this extension is the E2E test for the fix to ensure that the default values and offsets given to the runtime are correct. Signed-off-by: Pavel Samolysov <pavel.samolysov@intel.com>
The sycl-post-link tool crashed during processing an IR where a
specialization constant with a padding is present, for example a
specialization constant of such type:
struct alignas(32) coeff_str_aligned_t {
std::array<float, 3> coeffs;
size_t number;
};
In the IR, the constant looks like the following:
@_ZL8coeff_id = internal addrspace(1) constant %"class.cl::sycl::specialization_id" { %struct.coeff_str_aligned_t { %"class.std::array" zeroinitializer, i64 0, [8 x i8] undef } }, align 32
That '[8 x i8] undef' led to the crash.
This patch fixes the issue and adds the following optimization: if the
default value of a specialization constant or a part of such default value
is undefined, the value (or its part) is passed into an invocation of the
'__spirv_SpecConstantComposite' function as is.
Co-authored-by: Steffen Larsen steffen.larsen@intel.com
Signed-off-by: Pavel Samolysov pavel.samolysov@intel.com