[SYCL][ESIMD] Fix a compilation of mix of unnamed ESIMD and non ESIMD kernels#6557
[SYCL][ESIMD] Fix a compilation of mix of unnamed ESIMD and non ESIMD kernels#6557kbobrovs merged 11 commits intointel:syclfrom
Conversation
|
Complementary test PR: intel/llvm-test-suite#1143 |
| return true; | ||
| } | ||
| for (const Function *F1 : Deps.successors(F)) { | ||
| if (isESIMDFunctionInCallChain(F1, Deps)) { |
There was a problem hiding this comment.
Is there a possibility to break out of this loop sooner?
Thanks
There was a problem hiding this comment.
The loop itself probably not, as it needs to check all the functions to decide if they belong to ESIMD or SYCL kernels. The isESIMDFunctionInCallChain can technically limit its recursion depth and return faster.
|
@fineg74, could you please describe what the actual problem is - why unnamed ESIMD kernels lead to this problem? |
The immediate cause of the issue is that ESIMD kernel is wrapped with RoundedRangeKernel and |
…or ESIMD attribute.
|
We should try to limit ESIMD specifics penetration into general-purpose tools like post-link. My suggestion would be to find the wrapper function and add 'sycl_explicit_simd' metadata to it before doing any splits in the post-link. I believe the wrapper should have If the wrapper does not have |
|
... I would suggest to implement finding the wrapper and adding the metadata as a pass defined within the llvm/lib/SYCLLowerIR directory and invoked in sycl-post-link.cpp somewhere around (and similarly to) the |
asudarsa
left a comment
There was a problem hiding this comment.
sycl-post-link change looks good. Thanks
llvm/lib/Passes/PassRegistry.def
Outdated
| }, | ||
| parseASanPassOptions, | ||
| "kernel") | ||
| MODULE_PASS_WITH_PARAMS( |
There was a problem hiding this comment.
Looks like most of the changes in this file are unintended reformatting. Please remove.
This command formats only modified lines (requires clang-format in the PATH):
git diff -U0 --no-color HEAD^ | clang/tools/clang-format/clang-format-diff.py -i -p1
| }; | ||
|
|
||
| // Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | ||
| class SYCLLowerESIMDKernelAttrPass |
There was a problem hiding this comment.
| class SYCLLowerESIMDKernelAttrPass | |
| class SYCLFixupESIMDKernelWrapperAttrPass |
|
|
||
| // Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | ||
| class SYCLLowerESIMDKernelAttrPass | ||
| : public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { |
There was a problem hiding this comment.
| : public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { | |
| : public PassInfoMixin<SYCLFixupESIMDKernelWrapperAttrPass> { |
| namespace esimd { | ||
|
|
||
| constexpr char ATTR_DOUBLE_GRF[] = "esimd-double-grf"; | ||
| constexpr char ATTR_ESIMD_KERNEL[] = "sycl_explicit_simd"; |
There was a problem hiding this comment.
This is not an attribute, actually, but metadata. I suggest to name the same way as in
llvm/lib/SYCLLowerIR/LowerInvokeSimd.cpp:constexpr char ESIMD_MARKER_MD[] = "sycl_explicit_simd";
| constexpr char ATTR_ESIMD_KERNEL[] = "sycl_explicit_simd"; | |
| constexpr char ESIMD_MARKER_MD[] = "sycl_explicit_simd"; |
llvm/lib/SYCLLowerIR/CMakeLists.txt
Outdated
| @@ -1,4 +1,4 @@ | |||
| if(${CMAKE_VERSION} VERSION_LESS 3.14) | |||
| if (${CMAKE_VERSION} VERSION_LESS 3.14) | |||
There was a problem hiding this comment.
please drop unneeded changes in this file, only one line change is expected, AFAIU
| bool Modified = false; | ||
| for (Function &F : M) { | ||
| if (llvm::esimd::isESIMD(F)) { | ||
| llvm::esimd::traverseCallgraphUp(&F, [&](Function *GraphNode) { |
There was a problem hiding this comment.
BTW, is the wrapper function a spir_kernel or spir_function? Is the user function a spir_kernel or spir_function in presence of wrapper?
There was a problem hiding this comment.
Both user function and the wrapper are marked as spir_kernel .
There was a problem hiding this comment.
For the record: as we talked, the user function is spir_func, which is called by two kernels with spir_kernel CC - the normal and the one with the rounded range.
| MODULE_PASS("inliner-ml-advisor-release", | ||
| ModuleInlinerWrapperPass(getInlineParams(), true, {}, | ||
| InliningAdvisorMode::Release, 0)) | ||
| MODULE_PASS("inliner-ml-advisor-release", ModuleInlinerWrapperPass(getInlineParams(), true, {}, InliningAdvisorMode::Release, 0)) |
There was a problem hiding this comment.
still lots of unrelated changes in the file, please verify there are only intended before pushing update
| // Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | ||
| class SYCLLowerESIMDKernelAttrPass | ||
| : public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { | ||
| class SYCLFixupESIMDKernelWrapperAttrPass |
There was a problem hiding this comment.
Not a good name either, my bad. As I noted, sycl_explicit_simd is a metadata. So please rename once again - SYCLFixupESIMDKernelWrapperMDPass. We need another iteration anyways.
| ShouldNotRunFunctionPassesAnalysis()) | ||
| FUNCTION_ANALYSIS("should-run-extra-vector-passes", | ||
| ShouldRunExtraVectorPasses()) | ||
| FUNCTION_ANALYSIS("should-not-run-function-passes", ShouldNotRunFunctionPassesAnalysis()) |
asudarsa
left a comment
There was a problem hiding this comment.
Changes look good. Thanks.
intel#6557 rolled back necessary code, return it back with this patch. Problem somehow reproduced only in internal debug Windows build - the SYCLLowerIR/ESIMD/vec_arg_call_conv.ll test crashed opt. Signed-off-by: Konstantin S Bobrovsky <konstantin.s.bobrovsky@intel.com>
The purpose of this PR is to fix an issue that leads to runtime exception when unnamed ESIMD and non ESIMD kernels are present.