From 93090de07dc87f7b5e3de42fe589956ba674be18 Mon Sep 17 00:00:00 2001 From: Sergey Kopienko <> Date: Tue, 27 Feb 2024 17:22:35 +0100 Subject: [PATCH] inline auto TestUtils::default_selector -> TestUtils::get_default_selector() --- test/general/test_policies.pass.cpp | 20 ++++++++++---------- test/support/utils_sycl.h | 19 ++++++++++++++----- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/test/general/test_policies.pass.cpp b/test/general/test_policies.pass.cpp index de3431b5c7e..eee35d2e725 100644 --- a/test/general/test_policies.pass.cpp +++ b/test/general/test_policies.pass.cpp @@ -59,7 +59,7 @@ main() static_assert(is_execution_policy_v, "wrong result for is_execution_policy_v"); #if TEST_DPCPP_BACKEND_PRESENT - auto q = sycl::queue{TestUtils::default_selector}; + auto q = sycl::queue{TestUtils::get_default_selector()}; static_assert(is_execution_policy>::value, "wrong result for is_execution_policy"); static_assert(is_execution_policy_v>, "wrong result for is_execution_policy_v"); @@ -73,10 +73,10 @@ main() // Currently, there is no implicit conversion (implicit syc::queue constructor by a device selector) // from a device selector to a queue. // The same test call with explicit queue creation we have below in line 78. - test_policy_instance(TestUtils::make_device_policy(TestUtils::default_selector)); + test_policy_instance(TestUtils::make_device_policy(TestUtils::get_default_selector())); #endif - test_policy_instance(TestUtils::make_device_policy(sycl::device{TestUtils::default_selector})); - test_policy_instance(TestUtils::make_device_policy(sycl::queue{TestUtils::default_selector, sycl::property::queue::in_order()})); + test_policy_instance(TestUtils::make_device_policy(sycl::device{TestUtils::get_default_selector()})); + test_policy_instance(TestUtils::make_device_policy(sycl::queue{TestUtils::get_default_selector(), sycl::property::queue::in_order()})); test_policy_instance(TestUtils::make_device_policy(dpcpp_default)); // Special case: required to call make_device_policy directly from oneapi::dpl::execution namespace test_policy_instance(oneapi::dpl::execution::make_device_policy()); @@ -84,7 +84,7 @@ main() // device_policy EXPECT_TRUE(device_policy(q).queue() == q, "wrong result for queue()"); test_policy_instance(device_policy(q)); - test_policy_instance(device_policy(sycl::device{TestUtils::default_selector})); + test_policy_instance(device_policy(sycl::device{TestUtils::get_default_selector()})); test_policy_instance(device_policy(dpcpp_default)); test_policy_instance(device_policy(sycl::queue(dpcpp_default))); // conversion to sycl::queue test_policy_instance(device_policy<>{}); @@ -97,16 +97,16 @@ main() test_policy_instance(dpcpp_fpga); // make_fpga_policy - test_policy_instance(TestUtils::make_fpga_policy(sycl::queue{TestUtils::default_selector})); - test_policy_instance(TestUtils::make_fpga_policy(sycl::device{TestUtils::default_selector})); + test_policy_instance(TestUtils::make_fpga_policy(sycl::queue{TestUtils::get_default_selector()})); + test_policy_instance(TestUtils::make_fpga_policy(sycl::device{TestUtils::get_default_selector()})); test_policy_instance(TestUtils::make_fpga_policy(dpcpp_fpga)); // Special case: required to call make_fpga_policy directly from oneapi::dpl::execution namespace test_policy_instance(oneapi::dpl::execution::make_fpga_policy()); - test_policy_instance(TestUtils::make_fpga_policy(sycl::queue{TestUtils::default_selector})); + test_policy_instance(TestUtils::make_fpga_policy(sycl::queue{TestUtils::get_default_selector()})); // fpga_policy - test_policy_instance(fpga_policy(sycl::queue{TestUtils::default_selector})); - test_policy_instance(fpga_policy(sycl::device{TestUtils::default_selector})); + test_policy_instance(fpga_policy(sycl::queue{TestUtils::get_default_selector()})); + test_policy_instance(fpga_policy(sycl::device{TestUtils::get_default_selector()})); test_policy_instance(fpga_policy(dpcpp_fpga)); test_policy_instance(fpga_policy{}); static_assert(std::is_same_v::kernel_name, Kernel_25>, "wrong result for kernel_name (fpga_policy)"); diff --git a/test/support/utils_sycl.h b/test/support/utils_sycl.h index d88eee142fa..0a454987931 100644 --- a/test/support/utils_sycl.h +++ b/test/support/utils_sycl.h @@ -104,31 +104,40 @@ make_new_policy(_Policy&& __policy) #endif #if ONEDPL_FPGA_DEVICE -inline auto default_selector = +auto +get_default_selector() +{ + return # if ONEDPL_FPGA_EMULATOR sycl::ext::intel::fpga_emulator_selector{}; # else sycl::ext::intel::fpga_selector{}; # endif // ONEDPL_FPGA_EMULATOR +} inline auto&& default_dpcpp_policy = # if ONEDPL_USE_PREDEFINED_POLICIES oneapi::dpl::execution::dpcpp_fpga; # else - TestUtils::make_fpga_policy(sycl::queue{default_selector}); + TestUtils::make_fpga_policy(sycl::queue{get_default_selector()}); # endif // ONEDPL_USE_PREDEFINED_POLICIES #else -inline auto default_selector = +auto +get_default_selector() +{ + return # if TEST_LIBSYCL_VERSION >= 60000 sycl::default_selector_v; # else sycl::default_selector{}; # endif +} + inline auto&& default_dpcpp_policy = # if ONEDPL_USE_PREDEFINED_POLICIES oneapi::dpl::execution::dpcpp_default; # else - oneapi::dpl::execution::make_device_policy(sycl::queue{default_selector}); + oneapi::dpl::execution::make_device_policy(sycl::queue{get_default_selector()}); # endif // ONEDPL_USE_PREDEFINED_POLICIES #endif // ONEDPL_FPGA_DEVICE @@ -136,7 +145,7 @@ inline sycl::queue get_test_queue() { // create the queue with custom asynchronous exceptions handler - static sycl::queue my_queue(default_selector, async_handler); + static sycl::queue my_queue(get_default_selector(), async_handler); return my_queue; }