diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 45bf4680e5..1862f2e439 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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)") diff --git a/test/xpu_api/ranges/xpu_std_all_view.pass.cpp b/test/xpu_api/ranges/xpu_std_all_view.pass.cpp new file mode 100644 index 0000000000..cb4f08a73b --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_all_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_drop_view.pass.cpp b/test/xpu_api/ranges/xpu_std_drop_view.pass.cpp new file mode 100644 index 0000000000..060ca7999d --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_drop_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_iota_view.pass.cpp b/test/xpu_api/ranges/xpu_std_iota_view.pass.cpp new file mode 100644 index 0000000000..50ab60f860 --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_iota_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_ranges_test.h b/test/xpu_api/ranges/xpu_std_ranges_test.h new file mode 100644 index 0000000000..19f1a793bf --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_ranges_test.h @@ -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 +bool +kernel_test(Test test) +{ + sycl::queue deviceQueue = TestUtils::get_test_queue(); + bool ret = false; + sycl::range<1> numOfItems{1}; + sycl::buffer buffer1(&ret, numOfItems); + deviceQueue.submit([&](sycl::handler& cgh) { + auto ret_access = buffer1.get_access(cgh); + cgh.single_task([=]() { + ret_access[0] = test(); //run test + }); + }); + + return buffer1.get_host_access(sycl::read_only)[0]; +} diff --git a/test/xpu_api/ranges/xpu_std_reverse_view.pass.cpp b/test/xpu_api/ranges/xpu_std_reverse_view.pass.cpp new file mode 100644 index 0000000000..a117451f04 --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_reverse_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_single_view.pass.cpp b/test/xpu_api/ranges/xpu_std_single_view.pass.cpp new file mode 100644 index 0000000000..5824635b7b --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_single_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_subrange.pass.cpp b/test/xpu_api/ranges/xpu_std_subrange.pass.cpp new file mode 100644 index 0000000000..bc6df95f8d --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_subrange.pass.cpp @@ -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 +#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(test); + EXPECT_TRUE(res, "Wrong result of subrange check within a kernel"); +#endif //_ENABLE_STD_RANGES_TESTING + + return TestUtils::done(_ENABLE_STD_RANGES_TESTING); +} diff --git a/test/xpu_api/ranges/xpu_std_take_view.pass.cpp b/test/xpu_api/ranges/xpu_std_take_view.pass.cpp new file mode 100644 index 0000000000..570a037a93 --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_take_view.pass.cpp @@ -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 +#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(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); +} diff --git a/test/xpu_api/ranges/xpu_std_transform_view.pass.cpp b/test/xpu_api/ranges/xpu_std_transform_view.pass.cpp new file mode 100644 index 0000000000..0b0ad4f78d --- /dev/null +++ b/test/xpu_api/ranges/xpu_std_transform_view.pass.cpp @@ -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 +#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(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); +}