Skip to content

[SYCL] Update native_specialization_constant when no specialization constants are present #8868

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

Merged
merged 3 commits into from
Mar 31, 2023
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
3 changes: 2 additions & 1 deletion sycl/source/detail/kernel_bundle_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ class kernel_bundle_impl {
}

bool native_specialization_constant() const noexcept {
return std::all_of(MDeviceImages.begin(), MDeviceImages.end(),
return contains_specialization_constants() &&
std::all_of(MDeviceImages.begin(), MDeviceImages.end(),
[](const device_image_plain &DeviceImage) {
return getSyclObjImpl(DeviceImage)
->all_specialization_constant_native();
Expand Down
15 changes: 15 additions & 0 deletions sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TestSetAndGetOnDevice;
bool test_default_values(sycl::queue q);
bool test_set_and_get_on_host(sycl::queue q);
bool test_set_and_get_on_device(sycl::queue q);
bool test_native_specialization_constant(sycl::queue q);

int main() {
auto exception_handler = [&](sycl::exception_list exceptions) {
Expand Down Expand Up @@ -63,6 +64,12 @@ int main() {
return 1;
}

if (!test_native_specialization_constant(q)) {
std::cout << "Test for native specialization constants failed!"
<< std::endl;
return 1;
}

return 0;
};

Expand Down Expand Up @@ -257,3 +264,11 @@ bool test_set_and_get_on_device(sycl::queue q) {

return true;
}

bool test_native_specialization_constant(sycl::queue q) {
const auto always_false_selector = [](auto device_image) { return false; };
auto bundle = sycl::get_kernel_bundle<sycl::bundle_state::executable>(
q.get_context(), always_false_selector);
return check_value(bundle.native_specialization_constant(), false,
"empty bundle native specialization constant");
}