diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 4bfade66778a..4dab1076c303 100644 --- a/sycl/source/detail/kernel_bundle_impl.hpp +++ b/sycl/source/detail/kernel_bundle_impl.hpp @@ -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(); diff --git a/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp b/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp index 5222fdecc871..91055cf84051 100644 --- a/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp +++ b/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp @@ -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) { @@ -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; }; @@ -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( + q.get_context(), always_false_selector); + return check_value(bundle.native_specialization_constant(), false, + "empty bundle native specialization constant"); +}