-
Notifications
You must be signed in to change notification settings - Fork 769
[SYCL][ESIMD] Setup compilation pipeline for ESIMD #2134
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
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.
LLVM changes looks good to me, but I would expect LLVM LIT test updates covering them.
llvm/lib/SYCLLowerIR/LowerESIMD.cpp
Outdated
Value *TranslatedV = | ||
TranslateFunc(*CI, SpirvIntrName.substr(1, 1)); |
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.
Could you add a regression test for this change, 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.
It is added - sycl/test/esimd/spirv_intrins_trans.cpp
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 mean LLVM LIT test, not SYCL LIT test.
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.
Oh, I guess you mean IR->IR test. OK, will add. Even though functionality is covered by sycl/test/esimd/spirv_intrins_trans.cpp.
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.
Contents of sycl/
LGTM.
@bader, added a new test case into llvm/test/SYCLLowerIR/esimd_lower_intrins.ll - see |
had to rebase to fix 2 failing tests and force-push. |
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.
SYCL part still LGTM
%call = call spir_func i64 @_Z27__spirv_LocalInvocationId_xv() | ||
; CHECK-NEXT: %call.esimd = call <3 x i32> @llvm.genx.local.id.v3i32() | ||
; CHECK-NEXT: %local_id.x = extractelement <3 x i32> %call.esimd, i32 0 | ||
; CHECK-NEXT: %local_id.x.cast.ty = zext i32 %local_id.x to i64 |
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.
Please, consider following existing design for lowering functions like SPIR-V built-ins to device specific intrinsics by linking corresponding device library with SPIR-V functions implementation (see NVPTX implementation for details).
This will allow you to remove most of LowerESIMD
pass (including the buggy part).
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 problem with NVPTX approach as well as with using existing clang built-in infra is that it is hard to support the "C++" intrinsics mechanism with those. Once C++ intrinsics is supported in clang built-in infra - yes, this pass will simplify.
What buggy part do you refer to?
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 problem with NVPTX approach as well as with using existing clang built-in infra is that it is hard to support the "C++" intrinsics mechanism with those.
I'm not sure why this mechanism is needed. translateSpirvIntrinsic
doesn't require it.
BTW, why do we need this in the first place? According to my understanding these SPIR-V built-ins are lowered to valid SPIR-V, which should be supported by the back-end.
Once C++ intrinsics is supported in clang built-in infra - yes, this pass will simplify.
What buggy part do you refer to?
The one fixed by this patch.
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 see. You refer to SPIRV translation part. Agree - this could be done similar to NVPTX.
According to my understanding these SPIR-V built-ins are lowered to valid SPIR-V, which should be supported by the back-end.
Not quite. The vector BE does not support SPIRV intrinsics, as it is not a SIMT BE. But with subgroup size = 1 restriction it is doable really. I thought about this as a future step.
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.
According to my understanding these SPIR-V built-ins are lowered to valid SPIR-V, which should be supported by the back-end.
Not quite. The vector BE does not support SPIRV intrinsics, as it is not a SIMT BE. But with subgroup size = 1 restriction it is doable really. I thought about this as a future step.
To be precise, this functions are represented in SPIR-V as a variable with decoration and I think it must be supported by any back-end. AFAIK, there are a lot of ESIMD specific patches landed to SPIR-V translator and it seems to the right place to lower this functionality.
SPIR-V consumer by design is supposed to lower standard SPIR-V instructions to HW specific intructions/intrinsics.
If I understand it correctly ESIMD extension implementation includes these two parts:
- LLVM pass replaces SPIR-V built-in functions to GEN specific intrinsics in FE/ME.
- SPIR-V translator is enhanced to preserve undefined GEN specific intrinsics in SPIR-V format.
According to my understanding these are not required if we move lowering of SPIR-V standard instructions to SPIR-V consumer.
NOTE: I'm talking about standard SPIR-V functionality only.
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.
SPIR-V consumer by design is supposed to lower standard SPIR-V instructions to HW specific intructions/intrinsics.
That is true. But ESIMD back-end by design wasn't a "SPIRV consumer" and glue passes are still required to feed it LLVM IR resulting from SPIRV translation. Also ESIMD BE can't consume arbitrary SPIRV with Kernel capability - there are a number of restrictions. E.g. ESIMD BE does not have a concept of workitem, a central one in SIMT world. My point is that there are still design options which need to be discussed with the ESIMD BE devs.
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.
But ESIMD back-end by design wasn't a "SPIRV consumer" and glue passes are still required to feed it LLVM IR resulting from SPIRV translation. Also ESIMD BE can't consume arbitrary SPIRV with Kernel capability - there are a number of restrictions. E.g. ESIMD BE does not have a concept of workitem, a central one in SIMT world. My point is that there are still design options which need to be discussed with the ESIMD BE devs.
If SPIR-V consumption is not designed, what is the point in using SPIR-V then?
It looks like using LLVM IR as exchange format in ESIMD mode would be much easier and doesn't require so much hacks.
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.
If SPIR-V consumption is not designed, what is the point in using SPIR-V then?
IR stability.
doesn't require so much hacks.
There can be parts which can be improved, but I don't see how this justifies calling it hacks.
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.
de14866 - looks good me, assuming that other changes to llvm/*
sources will be reviewed and merged separately (i.e. before this PR).
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 only commit I see here with FE change not covered by other PRs is 2689ac1. This commit LGTM. Prior commits with FE changes have been reviewed, with changes requested, in their corresponding PRs.
2e70056
2e70056
to
14dce98
Compare
Had to resolve conflicts, rebase, fix test and force-push. The only changes are @bader, please take a look at the two new above changes and re-approve. Also new base commit covered by separate PR #2161 added. |
clang/lib/CodeGen/BackendUtil.cpp
Outdated
if (LangOpts.SYCLIsDevice && LangOpts.SYCLExplicitSIMD) { | ||
PerModulePasses.add(createSYCLLowerESIMDPass()); | ||
} | ||
|
||
CreatePasses(PerModulePasses, PerFunctionPasses); | ||
|
||
if (LangOpts.SYCLIsDevice && LangOpts.SYCLExplicitSIMD && |
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 can't find review for this part, so I'll ask here.
Origianal code uses CreatePasses
to populate PerModulePasses
pass manager. It seems reasonable to move new code adding ESIMD passes to this function. Right?
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.
Good point, will do.
ece45f5
to
2b0ee47
Compare
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Authors: Konstantin S Bobrovsky <[email protected]> Denis Bakhvalov <[email protected]> Gang Chen <[email protected]> Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Authors: Wei Pan, Konstantin S Bobrovsky, Denis Bakhvalov, Shahab Layeghi. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Co-authored-by: Alexander Batashev <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Co-authored-by: Mariya Podchishchaeva <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Signed-off-by: Konstantin S Bobrovsky <[email protected]>
…e.ll. Signed-off-by: Konstantin S Bobrovsky <[email protected]>
Had to force-push after resolving conflicts, rebasing. |
@bader, please take another look (essential change - fixed test for the vecarg pass) |
@romanovvlad, could you take a look at clang-format-check. It looks like this sort of formatting suggestions should be suppressed. Right? |
…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) ...
This completes the initial bulk conversion of tests using the migration script. There are more tests to be converted; however they will need manual fixups, so leave them out of this bulk conversion. Original commit: KhronosGroup/SPIRV-LLVM-Translator@2c9f60f
Please review commits starting from
7f525d5 [SYCL][ESIMD] Enable LLVM passes for ESIMD.
Earlier commits are parts of other PRs.