Skip to content

Commit 92a7fe7

Browse files
committed
Work around missing constructor implementation
This commit works around a bug in DPC++ version 2025.1. The constructor with no parameter of class `include_files` was only declared, but never defined. Calling it when creating a SYCL source kernel bundle therefore leads to references to undefined symbols with DPC++ version 2025.1. This change works around this issue by calling an alternative constructor, which is defined in the release. Signed-off-by: Lukas Sommer <[email protected]>
1 parent 01fc7f9 commit 92a7fe7

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

libsyclinterface/source/dpctl_sycl_kernel_bundle_interface.cpp

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,37 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
873873
return nullptr;
874874
}
875875
try {
876-
syclex::include_files IncludeFiles;
877-
for (auto &Include :
878-
*reinterpret_cast<virtual_header_list_t *>(Headers))
879-
{
880-
const auto &[Name, Content] = Include;
881-
IncludeFiles.add(Name, Content);
882-
}
883-
876+
auto *IncludeFileList =
877+
reinterpret_cast<virtual_header_list_t *>(Headers);
878+
std::unique_ptr<kernel_bundle<bundle_state::ext_oneapi_source>>
879+
SrcBundle;
884880
std::string Src(Source);
885-
auto SrcBundle = syclex::create_kernel_bundle_from_source(
886-
*SyclCtx, syclex::source_language::sycl, Src,
887-
syclex::properties{IncludeFiles});
881+
// The following logic is to work around a bug in DPC++ version 2025.1.
882+
// This version declares a constructor with no parameters for the
883+
// `include_files` property, but does not implement it. Therefore, the
884+
// only way to create `include_files` is with the name and content of
885+
// the first virtual header, if any.
886+
if (!IncludeFileList->empty()) {
887+
auto IncludeFileIt = IncludeFileList->begin();
888+
syclex::include_files IncludeFiles{IncludeFileIt->first,
889+
IncludeFileIt->second};
890+
for (std::advance(IncludeFileIt, 1);
891+
IncludeFileIt != IncludeFileList->end(); ++IncludeFileIt)
892+
{
893+
IncludeFiles.add(IncludeFileIt->first, IncludeFileIt->second);
894+
}
895+
SrcBundle = std::make_unique<
896+
kernel_bundle<bundle_state::ext_oneapi_source>>(
897+
syclex::create_kernel_bundle_from_source(
898+
*SyclCtx, syclex::source_language::sycl, Src,
899+
syclex::properties{IncludeFiles}));
900+
}
901+
else {
902+
SrcBundle = std::make_unique<
903+
kernel_bundle<bundle_state::ext_oneapi_source>>(
904+
syclex::create_kernel_bundle_from_source(
905+
*SyclCtx, syclex::source_language::sycl, Src));
906+
}
888907

889908
registered_names_property_t RegisteredNames;
890909
for (const std::string &Name :
@@ -899,7 +918,7 @@ __dpctl_give DPCTLSyclKernelBundleRef DPCTLKernelBundle_CreateFromSYCLSource(
899918
std::vector<sycl::device> Devices({*SyclDev});
900919

901920
auto ExeBundle = syclex::build(
902-
SrcBundle, Devices, syclex::properties{RegisteredNames, Opts});
921+
*SrcBundle, Devices, syclex::properties{RegisteredNames, Opts});
903922
auto ResultBundle =
904923
std::make_unique<sycl::kernel_bundle<bundle_state::executable>>(
905924
ExeBundle);

0 commit comments

Comments
 (0)