Skip to content
Merged
Changes from 1 commit
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
13 changes: 7 additions & 6 deletions sycl/include/sycl/kernel_bundle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,19 @@ class kernel_bundle : public detail::kernel_bundle_plain,
template <auto &SpecName>
typename std::remove_reference_t<decltype(SpecName)>::value_type
get_specialization_constant() const {
const char *SpecSymName = detail::get_spec_constant_symbolic_ID<SpecName>();
if (!is_specialization_constant_set(SpecSymName))
return SpecName.getDefaultValue();

using SCType =
typename std::remove_reference_t<decltype(SpecName)>::value_type;

std::array<char *, sizeof(SCType)> RetValue;
const char *SpecSymName = detail::get_spec_constant_symbolic_ID<SpecName>();
SCType Res{SpecName.getDefaultValue()};
if (!is_specialization_constant_set(SpecSymName))
return Res;

std::array<char, sizeof(SCType)> RetValue;
get_specialization_constant_impl(SpecSymName, RetValue.data());
std::memcpy(&Res, RetValue.data(), sizeof(SCType));

return *reinterpret_cast<SCType *>(RetValue.data());
return Res;
}

/// \returns an iterator to the first device image kernel_bundle contains
Expand Down