-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL][ESIMD] Fix a compilation of mix of unnamed ESIMD and non ESIMD kernels #6557
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
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a possibility to break out of this loop sooner?
Thanks
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 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 |
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-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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -76,6 +76,12 @@ class SYCLLowerESIMDKernelPropsPass | |||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &); | |||
}; | |||
|
|||
// Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | |||
class SYCLLowerESIMDKernelAttrPass |
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.
class SYCLLowerESIMDKernelAttrPass | |
class SYCLFixupESIMDKernelWrapperAttrPass |
@@ -76,6 +76,12 @@ class SYCLLowerESIMDKernelPropsPass | |||
PreservedAnalyses run(Module &M, ModuleAnalysisManager &); | |||
}; | |||
|
|||
// Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | |||
class SYCLLowerESIMDKernelAttrPass | |||
: public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { |
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.
: public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { | |
: public PassInfoMixin<SYCLFixupESIMDKernelWrapperAttrPass> { |
@@ -16,6 +16,7 @@ namespace llvm { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both user function and the wrapper are marked as spir_kernel .
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.
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.
llvm/lib/Passes/PassRegistry.def
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still lots of unrelated changes in the file, please verify there are only intended before pushing update
@@ -77,8 +77,8 @@ class SYCLLowerESIMDKernelPropsPass | |||
}; | |||
|
|||
// Fixes ESIMD Kernel attributes for wrapper functions for ESIMD kernels | |||
class SYCLLowerESIMDKernelAttrPass | |||
: public PassInfoMixin<SYCLLowerESIMDKernelPropsPass> { | |||
class SYCLFixupESIMDKernelWrapperAttrPass |
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.
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.
llvm/lib/Passes/PassRegistry.def
Outdated
ShouldNotRunFunctionPassesAnalysis()) | ||
FUNCTION_ANALYSIS("should-run-extra-vector-passes", | ||
ShouldRunExtraVectorPasses()) | ||
FUNCTION_ANALYSIS("should-not-run-function-passes", ShouldNotRunFunctionPassesAnalysis()) |
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.
unrelated changes
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.
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 <[email protected]>
…on. (#6908) #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 <[email protected]>
The purpose of this PR is to fix an issue that leads to runtime exception when unnamed ESIMD and non ESIMD kernels are present.