Changeset View
Changeset View
Standalone View
Standalone View
test/std/algorithms/alg.modifying.operations/rotate.pass.cpp
- This file was moved from test/test_rotate.cpp.
// -*- C++ -*- | // -*- C++ -*- | ||||
//===-- test_rotate.cpp ---------------------------------------------------===// | //===-- rotate.pass.cpp ---------------------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "pstl_test_config.h" | #include "support/pstl_test_config.h" | ||||
#include <iterator> | #include <iterator> | ||||
#ifdef PSTL_STANDALONE_TESTS | |||||
#include "pstl/execution" | #include "pstl/execution" | ||||
#include "pstl/algorithm" | #include "pstl/algorithm" | ||||
#include "utils.h" | #else | ||||
#include <execution> | |||||
#include <algorithm> | |||||
#endif // PSTL_STANDALONE_TESTS | |||||
#include "support/parallel_utils.h" | |||||
using namespace TestUtils; | using namespace Parallel_TestUtils; | ||||
template <typename T> | template <typename T> | ||||
struct wrapper | struct wrapper | ||||
{ | { | ||||
T t; | T t; | ||||
int move_count; | int move_count; | ||||
explicit wrapper(T t_) : t(t_), move_count(0) {} | explicit wrapper(T t_) : t(t_), move_count(0) {} | ||||
wrapper& | wrapper& | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
struct test_one_policy | struct test_one_policy | ||||
{ | { | ||||
#if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \ | #if __PSTL_ICC_17_VC141_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN || \ | ||||
__PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specializations to skip testing in case of broken configuration | __PSTL_ICC_16_VC14_TEST_SIMD_LAMBDA_DEBUG_32_BROKEN // dummy specializations to skip testing in case of broken configuration | ||||
template <typename Iterator, typename Size> | template <typename Iterator, typename Size> | ||||
void | void | ||||
operator()(pstl::execution::unsequenced_policy, Iterator data_b, Iterator data_e, Iterator actual_b, | operator()(__pstl::execution::unsequenced_policy, Iterator data_b, Iterator data_e, Iterator actual_b, | ||||
Iterator actual_e, Size shift) | Iterator actual_e, Size shift) | ||||
{ | { | ||||
} | } | ||||
template <typename Iterator, typename Size> | template <typename Iterator, typename Size> | ||||
void | void | ||||
operator()(pstl::execution::parallel_unsequenced_policy, Iterator data_b, Iterator data_e, Iterator actual_b, | operator()(__pstl::execution::parallel_unsequenced_policy, Iterator data_b, Iterator data_e, Iterator actual_b, | ||||
Iterator actual_e, Size shift) | Iterator actual_e, Size shift) | ||||
{ | { | ||||
} | } | ||||
#endif | #endif | ||||
template <typename ExecutionPolicy, typename Iterator, typename Size> | template <typename ExecutionPolicy, typename Iterator, typename Size> | ||||
void | void | ||||
operator()(ExecutionPolicy&& exec, Iterator data_b, Iterator data_e, Iterator actual_b, Iterator actual_e, | operator()(ExecutionPolicy&& exec, Iterator data_b, Iterator data_e, Iterator actual_b, Iterator actual_e, | ||||
Show All 13 Lines | operator()(ExecutionPolicy&& exec, Iterator data_b, Iterator data_e, Iterator actual_b, Iterator actual_e, | ||||
EXPECT_TRUE(check, "wrong effect of rotate"); | EXPECT_TRUE(check, "wrong effect of rotate"); | ||||
EXPECT_TRUE(check_move(exec, actual_b, actual_e, shift), "wrong move test of rotate"); | EXPECT_TRUE(check_move(exec, actual_b, actual_e, shift), "wrong move test of rotate"); | ||||
} | } | ||||
template <typename ExecutionPolicy, typename Iterator, typename Size> | template <typename ExecutionPolicy, typename Iterator, typename Size> | ||||
typename std::enable_if< | typename std::enable_if< | ||||
is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value && | is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value && | ||||
!std::is_same<ExecutionPolicy, pstl::execution::sequenced_policy>::value && | !std::is_same<ExecutionPolicy, __pstl::execution::sequenced_policy>::value && | ||||
std::is_same<typename std::iterator_traits<Iterator>::value_type, wrapper<float32_t>>::value, | std::is_same<typename std::iterator_traits<Iterator>::value_type, wrapper<float32_t>>::value, | ||||
bool>::type | bool>::type | ||||
check_move(ExecutionPolicy&& exec, Iterator b, Iterator e, Size shift) | check_move(ExecutionPolicy&& exec, Iterator b, Iterator e, Size shift) | ||||
{ | { | ||||
bool result = all_of(b, e, [](wrapper<float32_t>& a) { | bool result = all_of(b, e, [](wrapper<float32_t>& a) { | ||||
bool temp = a.move_count > 0; | bool temp = a.move_count > 0; | ||||
a.move_count = 0; | a.move_count = 0; | ||||
return temp; | return temp; | ||||
}); | }); | ||||
return shift == 0 || result; | return shift == 0 || result; | ||||
} | } | ||||
template <typename ExecutionPolicy, typename Iterator, typename Size> | template <typename ExecutionPolicy, typename Iterator, typename Size> | ||||
typename std::enable_if< | typename std::enable_if< | ||||
!(is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value && | !(is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value && | ||||
!std::is_same<ExecutionPolicy, pstl::execution::sequenced_policy>::value && | !std::is_same<ExecutionPolicy, __pstl::execution::sequenced_policy>::value && | ||||
std::is_same<typename std::iterator_traits<Iterator>::value_type, wrapper<float32_t>>::value), | std::is_same<typename std::iterator_traits<Iterator>::value_type, wrapper<float32_t>>::value), | ||||
bool>::type | bool>::type | ||||
check_move(ExecutionPolicy&& exec, Iterator b, Iterator e, Size shift) | check_move(ExecutionPolicy&& exec, Iterator b, Iterator e, Size shift) | ||||
{ | { | ||||
return true; | return true; | ||||
} | } | ||||
}; | }; | ||||
Show All 32 Lines |