-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL] Fix ESIMD split detection in module properties computation #15527
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| #include "llvm/SYCLLowerIR/DeviceGlobals.h" | ||
| #include "llvm/SYCLLowerIR/LowerInvokeSimd.h" | ||
| #include "llvm/SYCLLowerIR/SYCLUtils.h" | ||
| #include "llvm/SYCLLowerIR/SpecConstants.h" | ||
| #include "llvm/Support/CommandLine.h" | ||
| #include "llvm/Support/Error.h" | ||
| #include "llvm/Support/FileSystem.h" | ||
|
|
@@ -798,6 +799,23 @@ void ModuleDesc::dump() const { | |
| } | ||
| #endif // NDEBUG | ||
|
|
||
| void ModuleDesc::saveSplitInformationAsMetadata() { | ||
| // Add metadata to the module so we can identify what kind of SYCL/ESIMD split | ||
| // later. | ||
| auto *SplitMD = M->getOrInsertNamedMetadata(SYCL_ESIMD_SPLIT_MD_NAME); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A nit: Thanks
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't expect it to grow that much, the things we check in module properties is limited and doesn't grow that often. If it does blow up we can just move each MD to a function, sure, thanks. |
||
| auto *SplitMDOp = MDNode::get( | ||
| M->getContext(), ConstantAsMetadata::get(ConstantInt::get( | ||
| Type::getInt8Ty(M->getContext()), | ||
| static_cast<uint8_t>(EntryPoints.Props.HasESIMD)))); | ||
| SplitMD->addOperand(SplitMDOp); | ||
|
|
||
| // Add metadata to the module so we can identify it as the default value spec | ||
| // constants split later. | ||
| if (isSpecConstantDefault()) | ||
| M->getOrInsertNamedMetadata( | ||
| SpecConstantsPass::SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING); | ||
| } | ||
|
|
||
| void EntryPointGroup::saveNames(std::vector<std::string> &Dest) const { | ||
| Dest.reserve(Dest.size() + Functions.size()); | ||
| std::transform(Functions.begin(), Functions.end(), | ||
|
|
@@ -1291,6 +1309,7 @@ static Expected<SplitModule> saveModuleDesc(ModuleDesc &MD, std::string Prefix, | |
| bool OutputAssembly) { | ||
| SplitModule SM; | ||
| Prefix += OutputAssembly ? ".ll" : ".bc"; | ||
| MD.saveSplitInformationAsMetadata(); | ||
| Error E = saveModuleIRInFile(MD.getModule(), Prefix, OutputAssembly); | ||
| if (E) | ||
| return E; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| ; RUN: sycl-post-link -properties -split-esimd -S < %s -o %t.table | ||
| ; RUN: FileCheck %s -input-file=%t_esimd_0.prop | ||
|
|
||
| ; Verify we mark a image with an ESIMD kernel with the isEsimdImage property | ||
|
|
||
| ; CHECK: isEsimdImage=1|1 | ||
|
|
||
| target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64-G1" | ||
| target triple = "spir64-unknown-unknown" | ||
|
|
||
| %"struct.sycl::_V1::detail::AssertHappened" = type { i32, [257 x i8], [257 x i8], [129 x i8], i32, i64, i64, i64, i64, i64, i64 } | ||
| %"class.sycl::_V1::id" = type { %"class.sycl::_V1::detail::array" } | ||
| %"class.sycl::_V1::detail::array" = type { [1 x i64] } | ||
|
|
||
| @.str = private unnamed_addr addrspace(1) constant [10 x i8] c"Id != 400\00", align 1 | ||
| @.str.1 = private unnamed_addr addrspace(1) constant [8 x i8] c"foo.cpp\00", align 1 | ||
| @__PRETTY_FUNCTION__ = private unnamed_addr addrspace(1) constant [56 x i8] c"auto main()::(anonymous class)::operator()(id<1>) const\00", align 1 | ||
| @SPIR_AssertHappenedMem = linkonce_odr dso_local addrspace(1) global %"struct.sycl::_V1::detail::AssertHappened" zeroinitializer, align 8 | ||
|
|
||
| declare void @llvm.assume(i1 noundef) #2 | ||
|
|
||
| define weak_odr dso_local spir_kernel void @esimd_kernel() local_unnamed_addr #0 !sycl_explicit_simd !0 { | ||
| entry: | ||
| tail call spir_func void @__assert_fail(ptr addrspace(4) noundef addrspacecast (ptr addrspace(1) @.str to ptr addrspace(4)), ptr addrspace(4) noundef addrspacecast (ptr addrspace(1) @.str.1 to ptr addrspace(4)), i32 noundef 13, ptr addrspace(4) noundef addrspacecast (ptr addrspace(1) @__PRETTY_FUNCTION__ to ptr addrspace(4))) #12 | ||
| ret void | ||
| } | ||
|
|
||
| define weak dso_local spir_func void @__assert_fail(ptr addrspace(4) noundef %expr, ptr addrspace(4) noundef %file, i32 noundef %line, ptr addrspace(4) noundef %func) #1 { | ||
| entry: | ||
| tail call spir_func void @__devicelib_assert_fail(ptr addrspace(4) noundef %expr, ptr addrspace(4) noundef %file, i32 noundef %line, ptr addrspace(4) noundef %func) #1 | ||
| ret void | ||
| } | ||
|
|
||
| define weak dso_local spir_func void @__devicelib_assert_fail(ptr addrspace(4) noundef %expr, ptr addrspace(4) noundef %file, i32 noundef %line, ptr addrspace(4) noundef %func) #2 { | ||
| entry: | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { convergent mustprogress norecurse nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="foo.cpp" "sycl-optlevel"="2" "uniform-work-group-size"="true" } | ||
| attributes #1 = { convergent mustprogress norecurse nounwind "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "sycl-module-id"="/localdisk2/nsarnie/llvm_assert2/libdevice/fallback-cassert.cpp" "sycl-optlevel"="2" } | ||
| attributes #2 = { convergent nounwind } | ||
|
|
||
| !0 = !{} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -419,6 +419,7 @@ void saveModule(std::vector<std::unique_ptr<util::SimpleTable>> &OutTables, | |
| module_split::ModuleDesc &MD, int I, StringRef IRFilename) { | ||
| IrPropSymFilenameTriple BaseTriple; | ||
| StringRef Suffix = getModuleSuffix(MD); | ||
| MD.saveSplitInformationAsMetadata(); | ||
| if (!IRFilename.empty()) { | ||
| // don't save IR, just record the filename | ||
| BaseTriple.Ir = IRFilename.str(); | ||
|
|
@@ -509,10 +510,6 @@ processSpecConstantsWithDefaultValues(const module_split::ModuleDesc &MD) { | |
| assert(NewModuleDesc->Props.SpecConstsMet && | ||
| "This property should be true since the presence of SpecConsts " | ||
| "has been checked before the run of the pass"); | ||
| // Add metadata to the module so we can identify it as the default value split | ||
| // later. | ||
| NewModuleDesc->getModule().getOrInsertNamedMetadata( | ||
| SpecConstantsPass::SPEC_CONST_DEFAULT_VAL_MODULE_MD_STRING); | ||
| NewModuleDesc->rebuildEntryPoints(); | ||
| return NewModuleDesc; | ||
| } | ||
|
|
@@ -791,7 +788,7 @@ processInputModule(std::unique_ptr<Module> M) { | |
| // to keep the optimizer from wrongfully removing them. llvm.compiler.used | ||
| // symbols are usually removed at backend lowering, but this is handled here | ||
| // for SPIR-V since SYCL compilation uses llvm-spirv, not the SPIR-V backend. | ||
| if (auto Triple = M->getTargetTriple().find("spir") != std::string::npos) | ||
| if (M->getTargetTriple().find("spir") != std::string::npos) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not related to this change but fixes an unused variable warning. |
||
| Modified |= removeDeviceGlobalFromCompilerUsed(*M.get()); | ||
|
|
||
| // Instrument each image scope device globals if the module has been | ||
|
|
||
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.
May be sycl-esimd-split-status?
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.
sure, will rename, thanks.