-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[onedpl][ranges][test] Added std ranges to oneDPL Tested API (#1571)
- Loading branch information
1 parent
caa1c27
commit eb2471a
Showing
10 changed files
with
350 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; | ||
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |