Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions sycl/source/detail/device_kernel_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@ void DeviceKernelInfo::init(KernelNameStrRefT KernelName) {
}

#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
void DeviceKernelInfo::initIfNeeded(KernelNameStrRefT KernelName) {
if (!MInitialized.load())
init(KernelName);
void DeviceKernelInfo::initIfEmpty(const CompileTimeKernelInfoTy &Info) {
if (MInitialized.load())
return;

CompileTimeKernelInfoTy::operator=(Info);
Name = Info.Name.data();
init(Name.data());
}
#endif

Expand Down
3 changes: 2 additions & 1 deletion sycl/source/detail/device_kernel_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ class DeviceKernelInfo : public CompileTimeKernelInfoTy {

void init(KernelNameStrRefT KernelName);
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
void initIfNeeded(KernelNameStrRefT KernelName);
// Initialize default-created entry that has no data recorded:
void initIfEmpty(const CompileTimeKernelInfoTy &Info);
#endif
void setCompileTimeInfoIfNeeded(const CompileTimeKernelInfoTy &Info);

Expand Down
23 changes: 22 additions & 1 deletion sycl/source/handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,14 @@ event handler::finalize() {
if (type == detail::CGType::Kernel) {
if (impl->MDeviceKernelInfoPtr) {
#ifndef __INTEL_PREVIEW_BREAKING_CHANGES
impl->MDeviceKernelInfoPtr->initIfNeeded(toKernelNameStrT(MKernelName));
detail::CompileTimeKernelInfoTy HandlerInfo;
HandlerInfo.Name = MKernelName;
HandlerInfo.NumParams = impl->MKernelNumArgs;
HandlerInfo.ParamDescGetter = impl->MKernelParamDescGetter;
HandlerInfo.IsESIMD = impl->MKernelIsESIMD;
HandlerInfo.HasSpecialCaptures = impl->MKernelHasSpecialCaptures;

impl->MDeviceKernelInfoPtr->initIfEmpty(HandlerInfo);
#endif
} else {
// Fetch the device kernel info pointer if it hasn't been set (e.g.
Expand All @@ -553,6 +560,20 @@ event handler::finalize() {
&detail::ProgramManager::getInstance().getOrCreateDeviceKernelInfo(
toKernelNameStrT(MKernelName));
}

detail::DeviceKernelInfo &Info = *impl->MDeviceKernelInfoPtr;
(void)Info;

// Make sure that information set by old binaries gets properly copied to
// the `DeviceKernelInfo` so that the rest of the code base could use it as
// the single source of all the data:
assert(MKernelName == static_cast<std::string_view>(Info.Name));
assert(static_cast<unsigned>(impl->MKernelNumArgs) == Info.NumParams);
assert(impl->MKernelParamDescGetter == Info.ParamDescGetter ||
impl->MKernelParamDescGetter == nullptr);
assert(impl->MKernelIsESIMD == Info.IsESIMD);
assert(impl->MKernelHasSpecialCaptures == Info.HasSpecialCaptures);

// If there were uses of set_specialization_constant build the kernel_bundle
detail::kernel_bundle_impl *KernelBundleImpPtr =
getOrInsertHandlerKernelBundlePtr(/*Insert=*/false);
Expand Down