Skip to content

Commit

Permalink
inline auto TestUtils::default_selector -> TestUtils::get_default_sel…
Browse files Browse the repository at this point in the history
…ector()
  • Loading branch information
Sergey Kopienko committed Mar 21, 2024
1 parent 2977863 commit 93090de
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
20 changes: 10 additions & 10 deletions test/general/test_policies.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ main()
static_assert(is_execution_policy_v<parallel_unsequenced_policy>, "wrong result for is_execution_policy_v<parallel_unsequenced_policy>");

#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<device_policy<class Kernel_0>>::value, "wrong result for is_execution_policy<device_policy>");
static_assert(is_execution_policy_v<device_policy<class Kernel_0>>, "wrong result for is_execution_policy_v<device_policy>");
Expand All @@ -73,18 +73,18 @@ 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<class Kernel_12>(TestUtils::default_selector));
test_policy_instance(TestUtils::make_device_policy<class Kernel_12>(TestUtils::get_default_selector()));
#endif
test_policy_instance(TestUtils::make_device_policy<class Kernel_13>(sycl::device{TestUtils::default_selector}));
test_policy_instance(TestUtils::make_device_policy<class Kernel_14>(sycl::queue{TestUtils::default_selector, sycl::property::queue::in_order()}));
test_policy_instance(TestUtils::make_device_policy<class Kernel_13>(sycl::device{TestUtils::get_default_selector()}));
test_policy_instance(TestUtils::make_device_policy<class Kernel_14>(sycl::queue{TestUtils::get_default_selector(), sycl::property::queue::in_order()}));
test_policy_instance(TestUtils::make_device_policy<class Kernel_15>(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<class Kernel_16>());

// device_policy
EXPECT_TRUE(device_policy<class Kernel_1>(q).queue() == q, "wrong result for queue()");
test_policy_instance(device_policy<class Kernel_21>(q));
test_policy_instance(device_policy<class Kernel_22>(sycl::device{TestUtils::default_selector}));
test_policy_instance(device_policy<class Kernel_22>(sycl::device{TestUtils::get_default_selector()}));
test_policy_instance(device_policy<class Kernel_23>(dpcpp_default));
test_policy_instance(device_policy<class Kernel_24>(sycl::queue(dpcpp_default))); // conversion to sycl::queue
test_policy_instance(device_policy<>{});
Expand All @@ -97,16 +97,16 @@ main()
test_policy_instance(dpcpp_fpga);

// make_fpga_policy
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 1, class Kernel_31>(sycl::queue{TestUtils::default_selector}));
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 2, class Kernel_32>(sycl::device{TestUtils::default_selector}));
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 1, class Kernel_31>(sycl::queue{TestUtils::get_default_selector()}));
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 2, class Kernel_32>(sycl::device{TestUtils::get_default_selector()}));
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 4, class Kernel_33>(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</*unroll_factor =*/ 8, class Kernel_34>());
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 16, class Kernel_35>(sycl::queue{TestUtils::default_selector}));
test_policy_instance(TestUtils::make_fpga_policy</*unroll_factor =*/ 16, class Kernel_35>(sycl::queue{TestUtils::get_default_selector()}));

// fpga_policy
test_policy_instance(fpga_policy</*unroll_factor =*/ 1, class Kernel_41>(sycl::queue{TestUtils::default_selector}));
test_policy_instance(fpga_policy</*unroll_factor =*/ 2, class Kernel_42>(sycl::device{TestUtils::default_selector}));
test_policy_instance(fpga_policy</*unroll_factor =*/ 1, class Kernel_41>(sycl::queue{TestUtils::get_default_selector()}));
test_policy_instance(fpga_policy</*unroll_factor =*/ 2, class Kernel_42>(sycl::device{TestUtils::get_default_selector()}));
test_policy_instance(fpga_policy</*unroll_factor =*/ 4, class Kernel_43>(dpcpp_fpga));
test_policy_instance(fpga_policy</*unroll_factor =*/ 8, class Kernel_44>{});
static_assert(std::is_same_v<fpga_policy</*unroll_factor =*/ 8, Kernel_25>::kernel_name, Kernel_25>, "wrong result for kernel_name (fpga_policy)");
Expand Down
19 changes: 14 additions & 5 deletions test/support/utils_sycl.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,39 +104,48 @@ 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

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;
}

Expand Down

0 comments on commit 93090de

Please sign in to comment.