Skip to content
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

[onedpl][ranges][test] Added std ranges to oneDPL Tested API #1571

Merged
merged 19 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
65cd631
[oneDPL][hetero][ranges][test] + xpu_test for std transform_view
MikeDvorskiy May 8, 2024
fc5ca24
[oneDPL][hetero][ranges][test] + xpu_test for std iota_view
MikeDvorskiy May 8, 2024
b85d785
[oneDPL][hetero][ranges][test] + xpu_test for std::ranges::views:: si…
MikeDvorskiy May 8, 2024
5557d26
[oneDPL][hetero][ranges][test] + empty line in the end of each file
MikeDvorskiy May 8, 2024
721482c
[oneDPL][hetero][ranges][test] + move to the other place: oneDPL\test…
MikeDvorskiy May 13, 2024
639d059
[oneDPL][hetero][ranges][test] + modified LLVM std test for std::rang…
MikeDvorskiy May 14, 2024
0a5c48b
[oneDPL][hetero][ranges][test] + modified LLVM std test for iota_view
MikeDvorskiy May 14, 2024
4b565c8
[oneDPL][hetero][ranges][test] removed duplicates files
MikeDvorskiy May 16, 2024
c2d30fb
Revert "[oneDPL][hetero][ranges][test] removed duplicates files"
MikeDvorskiy May 20, 2024
7a6d27a
Revert "[oneDPL][hetero][ranges][test] + modified LLVM std test for i…
MikeDvorskiy May 20, 2024
ea39a93
Revert "[oneDPL][hetero][ranges][test] + modified LLVM std test for s…
MikeDvorskiy May 20, 2024
92d62b0
Revert "Revert "[oneDPL][hetero][ranges][test] removed duplicates fil…
MikeDvorskiy May 20, 2024
f52cddd
[oneDPL][hetero][ranges][test] + checks begin/end for iota_view (xpu_…
MikeDvorskiy May 20, 2024
ea7ccda
[oneDPL][hetero][ranges][test] + begin/end checks
MikeDvorskiy May 22, 2024
905ca41
[oneDPL][hetero][ranges][test] + xpu test for std::ranges::subrange
MikeDvorskiy May 22, 2024
97b6cc1
[oneDPL][tests][ranges] _regexp_dpcpp_backend_required: + xpu_api\ra…
MikeDvorskiy Dec 2, 2024
1b0955f
+ #include "support/utils_sycl.h"
MikeDvorskiy Dec 2, 2024
f74c6dd
[oneDPL][dpcpp][tested API][ranges] + test coverage enhanced
MikeDvorskiy Dec 16, 2024
eba77cc
Update test/xpu_api/ranges/xpu_std_reverse_view.pass.cpp
MikeDvorskiy Dec 16, 2024
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
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ macro(onedpl_add_test test_source_file switch_off_checked_iterators)
endif()
endmacro()

set(_regexp_dpcpp_backend_required "(xpu_api/algorithms|test/xpu_api/cmath/nearbyint|test/xpu_api/containers|xpu_api/functional|test/xpu_api/iterators|test/xpu_api/language.support/support.initlist|test/xpu_api/language.support/support.types|xpu_api/numerics|test/xpu_api/random|test/xpu_api/ratio|test/xpu_api/tuple|test/xpu_api/utilities|parallel_api/dynamic_selection/sycl)")
set(_regexp_dpcpp_backend_required "(xpu_api/ranges|xpu_api/algorithms|test/xpu_api/cmath/nearbyint|test/xpu_api/containers|xpu_api/functional|test/xpu_api/iterators|test/xpu_api/language.support/support.initlist|test/xpu_api/language.support/support.types|xpu_api/numerics|test/xpu_api/random|test/xpu_api/ratio|test/xpu_api/tuple|test/xpu_api/utilities|parallel_api/dynamic_selection/sycl)")
set(_regexp_switch_off_checked_it "(test/general/header_order_ranges|test/parallel_api/algorithm/alg.sorting/alg.min.max|test/parallel_api/ranges|test/parallel_api/dynamic_selection|test/xpu_api/iterators/iterator.primitives|test/xpu_api/random/device_tests|test/xpu_api/random/interface_tests|test/xpu_api/random/statistics_tests|test/parallel_api/numeric/numeric.ops/transform_scan)")

set(_regexp_pstl_offload_only "(test/pstl_offload)")
Expand Down
39 changes: 39 additions & 0 deletions test/xpu_api/ranges/xpu_std_all_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::iota(0, 4) | std::ranges::views::all;
return res.size() == 4 && res[0] == 0 && res[1] == 1 && res[2] == 2 && res[3] == 3 &&
*(res.begin() + 2) == res[2] && res.end() - res.begin() == 4;
};
const bool res = kernel_test<class std_all_test>(test);
EXPECT_TRUE(res, "Wrong result of all_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
39 changes: 39 additions & 0 deletions test/xpu_api/ranges/xpu_std_drop_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::iota(0, 4) | std::ranges::views::drop(2);
return res.size() == 2 && res[0] == 2 && res[1] == 3 && *res.begin() == 2
&& res.end() - res.begin() == 2;
};
const bool res = kernel_test<class std_drop_test>(test);
EXPECT_TRUE(res, "Wrong result of drop_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
40 changes: 40 additions & 0 deletions test/xpu_api/ranges/xpu_std_iota_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::iota(0, 4);
return res.size() == 4 && res[0] == 0 && res[1] == 1 && res[2] == 2 && res[3] == 3 &&
*(res.begin() + 2) == 2 && (res.end() - res.begin()) == 4 && !res.empty() &&
res.front() == 0 && res.back() == 3;
};
const bool res = kernel_test<class std_iota_test>(test);
EXPECT_TRUE(res, "Wrong result of iota_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
34 changes: 34 additions & 0 deletions test/xpu_api/ranges/xpu_std_ranges_test.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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/utils_sycl.h"

template<typename KernelName, typename Test>
bool
kernel_test(Test test)
{
sycl::queue deviceQueue = TestUtils::get_test_queue();
bool ret = false;
sycl::range<1> numOfItems{1};
sycl::buffer<bool, 1> buffer1(&ret, numOfItems);
deviceQueue.submit([&](sycl::handler& cgh) {
auto ret_access = buffer1.get_access<sycl::access::mode::write>(cgh);
cgh.single_task<KernelName>([=]() {
ret_access[0] = test(); //run test
});
});

return buffer1.get_host_access(sycl::read_only)[0];
dmitriy-sobolev marked this conversation as resolved.
Show resolved Hide resolved
}
39 changes: 39 additions & 0 deletions test/xpu_api/ranges/xpu_std_reverse_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::iota(0, 4) | std::ranges::views::reverse;
return res.size() == 4 && res[0] == 3 && res[1] == 2 && res[2] == 1 && res[3] == 0 &&
(*res.begin() + 2) == 1 && res.end() - res.begin() == 4;
MikeDvorskiy marked this conversation as resolved.
Show resolved Hide resolved
};
const bool res = kernel_test<class std_reverse_test>(test);
EXPECT_TRUE(res, "Wrong result of reverse_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
38 changes: 38 additions & 0 deletions test/xpu_api/ranges/xpu_std_single_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::single(1);
return res.size() == 1 && res[0] == 1 && *res.begin() == 1 && res.end() - res.begin() == 1 && *res.data() == 1;
};
const bool res = kernel_test<class std_single_test>(test);
EXPECT_TRUE(res, "Wrong result of single_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
41 changes: 41 additions & 0 deletions test/xpu_api/ranges/xpu_std_subrange.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto v = std::ranges::views::iota(0, 4);
auto res = std::ranges::subrange(v.begin() + 1, v.end());

return res.size() == 3 && res[0] == 1 && res[1] == 2 && res[2] == 3 && (*res.begin() + 2) == 3 &&
res.end() - res.begin() == 3 && *std::ranges::next(res.begin()) == 2 && *std::ranges::prev(res.end()) == 3;
};
const bool res = kernel_test<class std_reverse_test>(test);
EXPECT_TRUE(res, "Wrong result of subrange check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
39 changes: 39 additions & 0 deletions test/xpu_api/ranges/xpu_std_take_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
auto res = std::ranges::views::iota(0, 4) | std::ranges::views::take(2);
return res.size() == 2 && res[0] == 0 && res[1] == 1 && *(res.begin() + 1) == 1 &&
(res.end() - res.begin()) == 2;
};
const bool res = kernel_test<class std_take_test>(test);
EXPECT_TRUE(res, "Wrong result of take_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
40 changes: 40 additions & 0 deletions test/xpu_api/ranges/xpu_std_transform_view.pass.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// -*- C++ -*-
//===----------------------------------------------------------------------===//
//
// 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 "support/test_macros.h"
#include "support/utils.h"

#if _ENABLE_STD_RANGES_TESTING
#include <ranges>
#include "xpu_std_ranges_test.h"
#endif //_ENABLE_STD_RANGES_TESTING

int
main()
{
#if _ENABLE_STD_RANGES_TESTING
auto test = [](){
int a[4] = {0, 0, 0, 0};
auto res = std::ranges::subrange(a, a+4) | std::ranges::views::transform([](auto v) { return v + 1;});
return res[0] == 1 && res[1] == 1 && res[2] == 1 && res[3] == 1 && *(res.begin() + 2) == 1 &&
res.end() - res.begin() == 4;
};
const bool res = kernel_test<class std_transform_test>(test);
EXPECT_TRUE(res, "Wrong result of transform_view check within a kernel");
#endif //_ENABLE_STD_RANGES_TESTING

return TestUtils::done(_ENABLE_STD_RANGES_TESTING);
}
Loading