Skip to content

Commit 3ab0bdf

Browse files
committed
Rework logic to not add another argument to computeModuleProperties
1 parent 6d29c30 commit 3ab0bdf

File tree

4 files changed

+25
-15
lines changed

4 files changed

+25
-15
lines changed

llvm/include/llvm/SYCLLowerIR/ComputeModuleRuntimeInfo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ using EntryPointSet = SetVector<Function *>;
3434

3535
PropSetRegTy computeModuleProperties(const Module &M,
3636
const EntryPointSet &EntryPoints,
37-
const GlobalBinImageProps &GlobProps,
38-
module_split::IRSplitMode SplitMode);
37+
const GlobalBinImageProps &GlobProps);
3938

4039
std::string computeModuleSymbolTable(const Module &M,
4140
const EntryPointSet &EntryPoints);

llvm/include/llvm/Support/PropertySetIO.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,17 @@ class PropertySetRegistry {
230230
PropSet.insert({PropName, PropertyValue(PropVal)});
231231
}
232232

233+
void remove(StringRef Category, StringRef PropName) {
234+
auto PropertySetIt = PropSetMap.find(Category);
235+
if (PropertySetIt == PropSetMap.end())
236+
return;
237+
auto &PropertySet = PropertySetIt->second;
238+
auto PropIt = PropertySet.find(PropName);
239+
if (PropIt == PropertySet.end())
240+
return;
241+
PropertySet.erase(PropIt);
242+
}
243+
233244
/// Parses from the given \p Buf a property set registry.
234245
static Expected<std::unique_ptr<PropertySetRegistry>>
235246
read(const MemoryBuffer *Buf);

llvm/lib/SYCLLowerIR/ComputeModuleRuntimeInfo.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@ std::optional<T> getKernelSingleEltMetadata(const Function &Func,
152152

153153
PropSetRegTy computeModuleProperties(const Module &M,
154154
const EntryPointSet &EntryPoints,
155-
const GlobalBinImageProps &GlobProps,
156-
module_split::IRSplitMode SplitMode) {
155+
const GlobalBinImageProps &GlobProps) {
157156

158157
PropSetRegTy PropSet;
159158
{
@@ -162,16 +161,8 @@ PropSetRegTy computeModuleProperties(const Module &M,
162161
PropSet.add(PropSetRegTy::SYCL_DEVICELIB_REQ_MASK, RMEntry);
163162
}
164163
{
165-
// Usually, we would only expect one ReqdWGSize, as the module passed to
166-
// this function would be split according to that. However, when splitting
167-
// is disabled, this cannot be guaranteed. In this case, we reset the value,
168-
// which makes so that no value is reqd_work_group_size data is attached in
169-
// in the device image.
170-
SYCLDeviceRequirements DeviceReqs = computeDeviceRequirements(M, EntryPoints);
171-
if (SplitMode == module_split::SPLIT_NONE)
172-
DeviceReqs.ReqdWorkGroupSize.reset();
173164
PropSet.add(PropSetRegTy::SYCL_DEVICE_REQUIREMENTS,
174-
DeviceReqs.asMap());
165+
computeDeviceRequirements(M, EntryPoints).asMap());
175166
}
176167

177168
// extract spec constant maps per each module

llvm/tools/sycl-post-link/sycl-post-link.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,15 +308,24 @@ std::string saveModuleProperties(module_split::ModuleDesc &MD,
308308
const GlobalBinImageProps &GlobProps, int I,
309309
StringRef Suff, StringRef Target = "") {
310310
auto PropSet =
311-
computeModuleProperties(MD.getModule(), MD.entries(), GlobProps, SplitMode);
311+
computeModuleProperties(MD.getModule(), MD.entries(), GlobProps);
312+
313+
// When the split mode is none, the required work group size will be added
314+
// to the whole module, which will make the runtime unable to
315+
// launch the other kernels in the module that have different
316+
// required work group sizes or no requried work group sizes. So we need to
317+
// remove the required work group size metadata in this case.
318+
if (SplitMode == module_split::SPLIT_NONE)
319+
PropSet.remove(PropSetRegTy::SYCL_DEVICE_REQUIREMENTS,
320+
"reqd_work_group_size_uint64_t");
312321

313322
std::string NewSuff = Suff.str();
314323
if (!Target.empty()) {
315324
PropSet.add(PropSetRegTy::SYCL_DEVICE_REQUIREMENTS, "compile_target",
316325
Target);
317326
NewSuff += "_";
318-
NewSuff += Target;
319327
}
328+
NewSuff += Target;
320329

321330
std::error_code EC;
322331
std::string SCFile = makeResultFileName(".prop", I, NewSuff);

0 commit comments

Comments
 (0)