Skip to content

Extend test coverage for different policy qualifiers #2102

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

Draft
wants to merge 55 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3fa56f4
test/support - test staff + new implementation details test for TestU…
SergeyKopienko Jun 13, 2025
fa3f1f8
test/general - test refactoring and compilation check
SergeyKopienko Jun 12, 2025
6d01d84
test/general/sycl_iterator - apply CREATE_NEW_POLICY
SergeyKopienko Jun 12, 2025
3c88e45
test/parallel_api/algorithm/alg.modifying.operations - apply CREATE_N…
SergeyKopienko Jun 12, 2025
6537cc4
test/parallel_api/algorithm/alg.sorting/alg.binary.search/binary.sear…
SergeyKopienko Jun 12, 2025
92fd4e0
test/parallel_api/algorithm/alg.sorting/alg.set.operations - apply CR…
SergeyKopienko Jun 12, 2025
2cf4272
test/parallel_api/iterator - apply CREATE_NEW_POLICY + CLONE_NEW_POLICY
SergeyKopienko Jun 13, 2025
14b0ad9
test/parallel_api/numeric/numeric.ops - apply CREATE_NEW_POLICY
SergeyKopienko Jun 12, 2025
575b7bc
test/parallel_api/ranges - refactoring + check compilation + apply CR…
SergeyKopienko Jun 12, 2025
f35e1eb
test/parallel_api/algorithm/alg.modifying.operations/shift_left_right…
SergeyKopienko Jun 13, 2025
2dd998e
test/parallel_api/algorithm/alg.sorting/sort_by_key_common.h - apply …
SergeyKopienko Jun 13, 2025
052cfcc
test/parallel_api/experimental/asynch-scan.pass.cpp - apply CREATE_NE…
SergeyKopienko Jun 13, 2025
49132d4
test/parallel_api/experimental/asynch.pass.cpp - apply CREATE_NEW_POL…
SergeyKopienko Jun 13, 2025
359166a
test/parallel_api/numeric/numeric.ops/exclusive_scan.pass.cpp - apply…
SergeyKopienko Jun 13, 2025
2b620e5
test/parallel_api/numeric/numeric.ops/exclusive_scan_by_segment_perm_…
SergeyKopienko Jun 13, 2025
7152825
test/parallel_api/numeric/numeric.ops/exclusive_scan_by_segment_zip.p…
SergeyKopienko Jun 13, 2025
9de090c
test/parallel_api/numeric/numeric.ops/inclusive_scan_by_segment_zip.p…
SergeyKopienko Jun 13, 2025
070e0d5
test/parallel_api/numeric/numeric.ops/reduce_by_segment.pass.cpp - ap…
SergeyKopienko Jun 13, 2025
52200df
test/parallel_api/numeric/numeric.ops/reduce_by_segment_zip.pass.cpp …
SergeyKopienko Jun 13, 2025
74b46f7
test/support/utils_invoke.h - fix comment
SergeyKopienko Jun 16, 2025
ed57be1
Remove extra :: before std namespace
SergeyKopienko Jun 13, 2025
804554f
test/parallel_api/iterator/indirectly_device_accessible.pass.cpp - ge…
SergeyKopienko Jun 16, 2025
68cd99d
test/parallel_api/iterator/transform_iterator.pass.cpp - get sycl::qu…
SergeyKopienko Jun 16, 2025
af586f8
test/support/test_complex.h - get sycl::queue through TestUtils::get_…
SergeyKopienko Jun 16, 2025
94414bf
test/support/utils.h - get sycl::queue through TestUtils::get_dpcpp_t…
SergeyKopienko Jun 16, 2025
a4651e4
test/support/utils_sycl.h - get sycl::queue through TestUtils::get_dp…
SergeyKopienko Jun 16, 2025
73d359c
test/parallel_api/numeric/numeric.ops/reduce_by_segment.pass.cpp - re…
SergeyKopienko Jun 16, 2025
1ec7518
test/support/utils_invoke.h - fix compile error
SergeyKopienko Jun 17, 2025
4173561
test/support/utils_invoke.h - make CLONE_NEW_POLICY macro available f…
SergeyKopienko Jun 17, 2025
c4a0681
test/support/utils_invoke.h - fix comments
SergeyKopienko Jun 17, 2025
39da074
Apply CREATE_NEW_POLICY for host policies too
SergeyKopienko Jun 17, 2025
72cc9cf
test/parallel_api/ranges/std_ranges_mismatch_unsized.pass.cpp - fix f…
SergeyKopienko Jun 17, 2025
76d13d6
test/support/utils_invoke.h - fix implementation of CLONE_NEW_POLICY …
SergeyKopienko Jun 17, 2025
1a78fe7
Fix TestUtils::check_compile functional object calls
SergeyKopienko Jun 17, 2025
4d40683
test/general/lambda_naming.pass.cpp - apply CREATE_NEW_POLICY_WITH_NA…
SergeyKopienko Jun 17, 2025
27c30dc
test/general/lambda_naming.pass.cpp - apply CREATE_NEW_POLICY_WITH_NA…
SergeyKopienko Jun 17, 2025
c102071
test/general/lambda_naming.pass.cpp - fix compile error: avoid forwar…
SergeyKopienko Jun 17, 2025
4bc0fa0
Move class/struct definitions outside of CREATE_NEW_POLICY_WITH_NAME
SergeyKopienko Jun 17, 2025
e4f6dec
test/support/utils_invoke.h - rename struct check_compile to struct c…
SergeyKopienko Jun 17, 2025
9b4295b
test/support/utils_invoke.h - rename struct check_compile to struct c…
SergeyKopienko Jun 17, 2025
caabccf
Fix compile error: get_test_dpcpp_policy -> get_dpcpp_test_policy
SergeyKopienko Jun 17, 2025
19d9f28
Fix compile errors: we should pass policy type in the first template …
SergeyKopienko Jun 17, 2025
66d14cb
test/parallel_api/numeric/numeric.ops/inclusive_scan_by_segment_zip.p…
SergeyKopienko Jun 17, 2025
187eb37
test/parallel_api/numeric/numeric.ops/reduce_by_segment.pass.cpp - fi…
SergeyKopienko Jun 17, 2025
7fff3dd
test/support/utils_invoke.h - fix compile error: avoid forward declar…
SergeyKopienko Jun 17, 2025
fcfde04
test/parallel_api/numeric/numeric.ops/reduce_by_segment.pass.cpp - fi…
SergeyKopienko Jun 17, 2025
7806c52
test/support - Replace class keyword to typename in template paramete…
SergeyKopienko Jun 17, 2025
5b415ba
test/parallel_api/ranges/find_ranges_sycl.pass.cpp - fix compile erro…
SergeyKopienko Jun 17, 2025
fc9d3a7
Refactoring of compile checks
SergeyKopienko Jun 17, 2025
7c6e4f4
test/parallel_api/algorithm/alg.sorting/sort_by_key_common.h - fix co…
SergeyKopienko Jun 17, 2025
fc06297
test/parallel_api/experimental/asynch.pass.cpp - fix compile error: a…
SergeyKopienko Jun 17, 2025
c4135be
test/parallel_api/numeric/numeric.ops/exclusive_scan.pass.cpp - fix c…
SergeyKopienko Jun 17, 2025
1d471a6
test/general/dpl_namespace.pass.cpp - fix check result in test
SergeyKopienko Jun 17, 2025
df76105
test/parallel_api/numeric/numeric.ops/exclusive_scan.pass.cpp - apply…
SergeyKopienko Jun 17, 2025
763c97e
Refactoring to avoid decltype(CLONE_NEW_POLICY(policy)) in template s…
SergeyKopienko Jun 18, 2025
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
7 changes: 1 addition & 6 deletions test/general/dpl_namespace.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ int main()
TestUtils::make_device_policy<class Scan>(dpl::execution::dpcpp_default),
key_first, key_first + n, val_first, res_first);

if (result - res_first != k){
std::cout << "size of keys output is not valid: expected = "<< k <<", got: "<< result - res_first << std::endl;
}
else{
std::cout << "done" << std::endl;
}
EXPECT_EQ(k, result - res_first, "size of keys output is not valid");

#endif

Expand Down
24 changes: 17 additions & 7 deletions test/general/header_inclusion_order_async_0.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

#include "support/utils.h"

int
main()
{
#if TEST_DPCPP_BACKEND_PRESENT

auto policy = TestUtils::get_dpcpp_test_policy();
sycl::queue q = policy.queue();
template <typename Policy>
void test(Policy&& exec)
{
sycl::queue q = exec.queue();

constexpr std::size_t n = 100;

Expand All @@ -34,8 +32,20 @@ main()
allocator alloc(q);
std::vector<T, allocator> data(n, 1, alloc);

auto f = oneapi::dpl::experimental::reduce_async(policy, data.begin(), data.end());
auto f = oneapi::dpl::experimental::reduce_async(std::forward<Policy>(exec), data.begin(), data.end());
f.wait();
}
#endif // TEST_DPCPP_BACKEND_PRESENT

int
main()
{
#if TEST_DPCPP_BACKEND_PRESENT

auto policy = TestUtils::get_dpcpp_test_policy();
test(policy);

TestUtils::check_compilation(policy, [](auto&& policy) { test(std::forward<decltype(policy)>(policy)); });

#endif // TEST_DPCPP_BACKEND_PRESENT

Expand Down
24 changes: 17 additions & 7 deletions test/general/header_inclusion_order_async_1.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,11 @@

#include "support/utils.h"

int
main()
{
#if TEST_DPCPP_BACKEND_PRESENT

auto policy = TestUtils::get_dpcpp_test_policy();
sycl::queue q = policy.queue();
template <typename Policy>
void test(Policy&& exec)
{
sycl::queue q = exec.queue();

constexpr std::size_t n = 100;

Expand All @@ -34,8 +32,20 @@ main()
allocator alloc(q);
std::vector<T, allocator> data(n, 1, alloc);

auto f = oneapi::dpl::experimental::reduce_async(policy, data.begin(), data.end());
auto f = oneapi::dpl::experimental::reduce_async(std::forward<Policy>(exec), data.begin(), data.end());
f.wait();
}
#endif // TEST_DPCPP_BACKEND_PRESENT

int
main()
{
#if TEST_DPCPP_BACKEND_PRESENT

auto policy = TestUtils::get_dpcpp_test_policy();
test(policy);

TestUtils::check_compilation(policy, [](auto&& policy) { test(std::forward<decltype(policy)>(policy)); });

#endif // TEST_DPCPP_BACKEND_PRESENT

Expand Down
17 changes: 15 additions & 2 deletions test/general/header_order_ranges_0.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,25 @@

#include "support/utils.h"

#if _ENABLE_RANGES_TESTING
template <typename Policy>
void test(Policy&& exec)
{
using namespace oneapi::dpl::experimental::ranges;
all_of(std::forward<Policy>(exec), views::fill(-1, 10), [](auto i) { return i == -1;});
}
#endif // _ENABLE_RANGES_TESTING

int
main()
{
#if _ENABLE_RANGES_TESTING
using namespace oneapi::dpl::experimental::ranges;
all_of(TestUtils::get_dpcpp_test_policy(), views::fill(-1, 10), [](auto i) { return i == -1;});

auto policy = TestUtils::get_dpcpp_test_policy();
test(policy);

TestUtils::check_compilation(policy, [](auto&& policy) { test(std::forward<decltype(policy)>(policy)); });

#endif

return TestUtils::done(_ENABLE_RANGES_TESTING);
Expand Down
17 changes: 15 additions & 2 deletions test/general/header_order_ranges_1.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,25 @@

#include "support/utils.h"

#if _ENABLE_RANGES_TESTING
template <typename Policy>
void test(Policy&& exec)
{
using namespace oneapi::dpl::experimental::ranges;
all_of(std::forward<Policy>(exec), views::fill(-1, 10), [](auto i) { return i == -1;});
}
#endif // _ENABLE_RANGES_TESTING

int
main()
{
#if _ENABLE_RANGES_TESTING
using namespace oneapi::dpl::experimental::ranges;
all_of(TestUtils::get_dpcpp_test_policy(), views::fill(-1, 10), [](auto i) { return i == -1;});

auto policy = TestUtils::get_dpcpp_test_policy();
test(policy);

TestUtils::check_compilation(policy, [](auto&& policy) { test(std::forward<decltype(policy)>(policy)); });

#endif

return TestUtils::done(_ENABLE_RANGES_TESTING);
Expand Down
116 changes: 116 additions & 0 deletions test/general/implementation_details/test_policy_container.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// -*- C++ -*-
//===-- policy container.pass.cpp ------------------------------------------===//
//
// Copyright (C) Intel Corporation
//
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// This file incorporates work covered by the following copyright and permission
// notice:
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
//
//===----------------------------------------------------------------------===//

#include "support/test_config.h"

#include <type_traits>
#include <utility>

#include "support/utils.h"

#if TEST_DPCPP_BACKEND_PRESENT
#include "support/utils_invoke.h"
#include "oneapi/dpl/pstl/hetero/dpcpp/execution_sycl_defs.h"
#endif

#if TEST_DPCPP_BACKEND_PRESENT

struct PassByValue{};
struct PassByConstReference{};
struct PassByMove{};

template <typename SourcePolicyKernelName, typename Policy, typename PassTag>
void test_policy_container(Policy&& exec, PassTag)
{
#if TEST_EXPLICIT_KERNEL_NAMES
using ThisPolicyKernelName = oneapi::dpl::__internal::__policy_kernel_name<Policy>;
static_assert(!std::is_same_v<SourcePolicyKernelName, ThisPolicyKernelName>, "Temporary test policy should have unique Kernel name");
#endif

using DecayedPolicy = std::decay_t<decltype(exec)>;

if constexpr (std::is_same_v<PassTag, PassByValue>)
{
using DecayedPolicyRefRef = DecayedPolicy&&;

static_assert(std::is_same_v<decltype(exec), DecayedPolicyRefRef>, "Invalid test policy value category #0");
}

if constexpr (std::is_same_v<PassTag, PassByConstReference>)
{
using DecayedPolicyConstRef = const DecayedPolicy&;

static_assert(std::is_same_v<decltype(exec), DecayedPolicyConstRef>, "Invalid test policy value category #1");
}

if constexpr (std::is_same_v<PassTag, PassByMove>)
{
using DecayedPolicyConstRef = DecayedPolicy&&;

static_assert(std::is_same_v<decltype(exec), DecayedPolicyConstRef>, "Invalid test policy value category #2");
}
}

template <typename Policy>
void test_pass_by_value(Policy policy)
{
using SourcePolicyKernelName = oneapi::dpl::__internal::__policy_kernel_name<Policy>;

test_policy_container<SourcePolicyKernelName>(CREATE_NEW_POLICY(policy, 0), PassByValue{});
}

template <typename Policy>
void test_pass_by_const_ref(const Policy& policy)
{
using SourcePolicyKernelName = oneapi::dpl::__internal::__policy_kernel_name<Policy>;

test_policy_container<SourcePolicyKernelName>(CREATE_NEW_POLICY(policy, 0), PassByConstReference{});
}

template <typename Policy>
void test_pass_by_rval(Policy&& policy)
{
using SourcePolicyKernelName = oneapi::dpl::__internal::__policy_kernel_name<Policy>;

test_policy_container<SourcePolicyKernelName>(CREATE_NEW_POLICY(policy, 0), PassByMove{});
}

#endif // TEST_DPCPP_BACKEND_PRESENT

int
main()
{
#if TEST_DPCPP_BACKEND_PRESENT

{
const auto policy = TestUtils::get_dpcpp_test_policy();
test_pass_by_value(policy);
}

{
// Save the policy in a const reference
const auto& policy = TestUtils::get_dpcpp_test_policy();
test_pass_by_const_ref(policy);
}

{
auto policy = TestUtils::get_dpcpp_test_policy();
test_pass_by_rval(std::move(policy));
}

#endif // TEST_DPCPP_BACKEND_PRESENT

return TestUtils::done(TEST_DPCPP_BACKEND_PRESENT);
}
93 changes: 66 additions & 27 deletions test/general/lambda_naming.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,87 @@

#include "support/utils.h"

using namespace TestUtils;

// This is the simple test for compilation only, to check if lambda naming works correctly
int main() {
#if TEST_DPCPP_BACKEND_PRESENT

template <typename T>
struct PostIncrementOp
{
void operator()(T& x) const
{
x++;
}
};

template <typename T>
struct Add41Op
{
void operator()(T& x) const
{
x += 41;
}
};

struct ForEach;

template <typename Policy>
void
test_impl(Policy&& policy)
{
const int n = 1000;
sycl::buffer<int> buf{ sycl::range<1>(n) };
sycl::buffer<int> out_buf{ sycl::range<1>(n) };
sycl::buffer<int> buf{sycl::range<1>(n)};
sycl::buffer<int> out_buf{sycl::range<1>(n)};
auto buf_begin = oneapi::dpl::begin(buf);
auto buf_end = buf_begin + n;

const auto policy = TestUtils::get_dpcpp_test_policy();
auto buf_begin_discard_write = oneapi::dpl::begin(buf, sycl::write_only, sycl::property::no_init{});

::std::fill(policy, buf_begin_discard_write, buf_begin_discard_write + n, 1);
#if __SYCL_UNNAMED_LAMBDA__
::std::sort(policy, buf_begin, buf_end);
::std::for_each(policy, buf_begin, buf_end, [](int& x) { x += 41; });
std::fill(CLONE_NEW_POLICY(policy), buf_begin_discard_write, buf_begin_discard_write + n, 1);

# if __SYCL_UNNAMED_LAMBDA__

std::sort(CLONE_NEW_POLICY(policy), buf_begin, buf_end);
std::for_each(CLONE_NEW_POLICY(policy), buf_begin, buf_end, Add41Op<int>());

#if !ONEDPL_FPGA_DEVICE
sycl::buffer<float> out_buf_2{ sycl::range<1>(n) };
# if !ONEDPL_FPGA_DEVICE
sycl::buffer<float> out_buf_2{sycl::range<1>(n)};
auto buf_out_begin_2 = oneapi::dpl::begin(out_buf_2);
::std::copy(policy, buf_begin, buf_end, buf_out_begin_2);
::std::copy(policy, buf_out_begin_2, buf_out_begin_2 + n, buf_begin);
::std::inplace_merge(policy, buf_begin, buf_begin + n / 2, buf_end);
auto red_val = ::std::reduce(policy, buf_begin, buf_end, 1);
std::copy(CLONE_NEW_POLICY(policy), buf_begin, buf_end, buf_out_begin_2);
std::copy(CLONE_NEW_POLICY(policy), buf_out_begin_2, buf_out_begin_2 + n, buf_begin);
std::inplace_merge(CLONE_NEW_POLICY(policy), buf_begin, buf_begin + n / 2, buf_end);
auto red_val = std::reduce(CLONE_NEW_POLICY(policy), buf_begin, buf_end, 1);
EXPECT_TRUE(red_val == 42001, "wrong return value from reduce");

auto buf_out_begin = oneapi::dpl::begin(out_buf);
::std::inclusive_scan(policy, buf_begin, buf_end, buf_out_begin);
bool is_equal = ::std::equal(policy, buf_begin, buf_end, buf_out_begin);
std::inclusive_scan(CLONE_NEW_POLICY(policy), buf_begin, buf_end, buf_out_begin);
bool is_equal = std::equal(CLONE_NEW_POLICY(policy), buf_begin, buf_end, buf_out_begin);
EXPECT_TRUE(!is_equal, "wrong return value from equal");
auto does_1_exist = ::std::find(policy, buf_begin, buf_end, 1);

auto does_1_exist = std::find(CLONE_NEW_POLICY(policy), buf_begin, buf_end, 1);
EXPECT_TRUE(does_1_exist - buf_begin == 1000, "wrong return value from find");
#endif // !ONEDPL_FPGA_DEVICE
# endif // !ONEDPL_FPGA_DEVICE

#else
// ::std::for_each(policy, buf_begin, buf_end, [](int& x) { x++; }); // It's not allowed. Policy with different name is needed
::std::for_each(TestUtils::make_device_policy<class ForEach>(policy), buf_begin, buf_end, [](int& x) { x++; });
auto red_val = ::std::reduce(policy, buf_begin, buf_end, 1);
# else

// std::for_each(policy, buf_begin, buf_end, [](int& x) { x++; }); // It's not allowed. Policy with different name is needed
std::for_each(CREATE_NEW_POLICY_WITH_NAME(policy, ForEach), buf_begin, buf_end, PostIncrementOp<int>());
auto red_val = std::reduce(CLONE_NEW_POLICY(policy), buf_begin, buf_end, 1);
EXPECT_TRUE(red_val == 2001, "wrong return value from reduce");
#endif // __SYCL_UNNAMED_LAMBDA__

# endif // __SYCL_UNNAMED_LAMBDA__
}
#endif // TEST_DPCPP_BACKEND_PRESENT

// This is the simple test for compilation only, to check if lambda naming works correctly
int main()
{
#if TEST_DPCPP_BACKEND_PRESENT

auto policy = TestUtils::get_dpcpp_test_policy();
test_impl(policy);

TestUtils::check_compilation(policy, [](auto&& policy) { test_impl(std::forward<decltype(policy)>(policy)); });

#endif // TEST_DPCPP_BACKEND_PRESENT

return done(TEST_DPCPP_BACKEND_PRESENT);
return TestUtils::done(TEST_DPCPP_BACKEND_PRESENT);
}
Loading
Loading