From d1495cbc991fd70685738589a0873d14498887f9 Mon Sep 17 00:00:00 2001 From: "Cai, Justin" Date: Wed, 29 Mar 2023 16:13:42 -0700 Subject: [PATCH 1/2] [SYCL] Update native_specialization_constant when no specialization constants are present Signed-off-by: Cai, Justin --- sycl/source/detail/kernel_bundle_impl.hpp | 3 ++- .../SpecConstants/2020/kernel-bundle-api.cpp | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/sycl/source/detail/kernel_bundle_impl.hpp b/sycl/source/detail/kernel_bundle_impl.hpp index 4bfade66778a3..4dab1076c3033 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 5222fdecc8719..9e274ca6b9024 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,13 @@ 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); + if (!check_value(bundle.native_specialization_constant(), false, + "empty bundle native specialization constant")) + return false; + return true; +} From d5ac140a3279ccf5ce862ac3cd0d5596cbf0eba0 Mon Sep 17 00:00:00 2001 From: "Cai, Justin" Date: Thu, 30 Mar 2023 08:38:36 -0700 Subject: [PATCH 2/2] Address review comments Signed-off-by: Cai, Justin --- sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp b/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp index 9e274ca6b9024..91055cf840511 100644 --- a/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp +++ b/sycl/test-e2e/SpecConstants/2020/kernel-bundle-api.cpp @@ -269,8 +269,6 @@ 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); - if (!check_value(bundle.native_specialization_constant(), false, - "empty bundle native specialization constant")) - return false; - return true; + return check_value(bundle.native_specialization_constant(), false, + "empty bundle native specialization constant"); }