forked from OSchip/llvm-project
[pstl] Remove warnings in tests and headers
Mostly unused parameter, unused local typedefs and shadowed declarations. This massaging it necessary if we want to be able to run the tests under the libc++ lit configuration. llvm-svn: 363872
This commit is contained in:
parent
f46f41411b
commit
3491119f9b
|
@ -604,7 +604,6 @@ __find_subrange(_RandomAccessIterator __first, _RandomAccessIterator __last, _Ra
|
||||||
return __last; // According to the standard last shall be returned when count < 1
|
return __last; // According to the standard last shall be returned when count < 1
|
||||||
}
|
}
|
||||||
|
|
||||||
auto __n = __global_last - __first;
|
|
||||||
auto __unary_pred = __equal_value_by_pred<_Tp, _BinaryPredicate>(__value, __pred);
|
auto __unary_pred = __equal_value_by_pred<_Tp, _BinaryPredicate>(__value, __pred);
|
||||||
while (__first != __last && (static_cast<_Size>(__global_last - __first) >= __count))
|
while (__first != __last && (static_cast<_Size>(__global_last - __first) >= __count))
|
||||||
{
|
{
|
||||||
|
@ -821,7 +820,7 @@ __pattern_search_n(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _Ra
|
||||||
_Size __count, const _Tp& __value, _BinaryPredicate __pred, _IsVector __is_vector,
|
_Size __count, const _Tp& __value, _BinaryPredicate __pred, _IsVector __is_vector,
|
||||||
/*is_parallel=*/std::true_type) noexcept
|
/*is_parallel=*/std::true_type) noexcept
|
||||||
{
|
{
|
||||||
if (__last - __first == __count)
|
if (static_cast<_Size>(__last - __first) == __count)
|
||||||
{
|
{
|
||||||
const bool __result = !__internal::__pattern_any_of(
|
const bool __result = !__internal::__pattern_any_of(
|
||||||
std::forward<_ExecutionPolicy>(__exec), __first, __last,
|
std::forward<_ExecutionPolicy>(__exec), __first, __last,
|
||||||
|
|
|
@ -79,8 +79,8 @@ struct __serial_move_merge
|
||||||
}
|
}
|
||||||
else if (__n == 0)
|
else if (__n == 0)
|
||||||
{
|
{
|
||||||
const auto __i = __zs - __zs_beg;
|
const auto __j = __zs - __zs_beg;
|
||||||
if (__same_move_seq || __i < __nx)
|
if (__same_move_seq || __j < __nx)
|
||||||
__zs = __move_sequence_x(__ys, __ye, __zs);
|
__zs = __move_sequence_x(__ys, __ye, __zs);
|
||||||
else
|
else
|
||||||
__zs = __move_sequence_y(__ys, __ye, __zs);
|
__zs = __move_sequence_y(__ys, __ye, __zs);
|
||||||
|
@ -97,8 +97,8 @@ struct __serial_move_merge
|
||||||
++__zs, --__n;
|
++__zs, --__n;
|
||||||
if (++__xs == __xe)
|
if (++__xs == __xe)
|
||||||
{
|
{
|
||||||
const auto __i = __zs - __zs_beg;
|
const auto __j = __zs - __zs_beg;
|
||||||
if (__same_move_seq || __i < __nx)
|
if (__same_move_seq || __j < __nx)
|
||||||
__move_sequence_x(__ys, __ye, __zs);
|
__move_sequence_x(__ys, __ye, __zs);
|
||||||
else
|
else
|
||||||
__move_sequence_y(__ys, __ye, __zs);
|
__move_sequence_y(__ys, __ye, __zs);
|
||||||
|
@ -106,8 +106,8 @@ struct __serial_move_merge
|
||||||
}
|
}
|
||||||
else if (__n == 0)
|
else if (__n == 0)
|
||||||
{
|
{
|
||||||
const auto i = __zs - __zs_beg;
|
const auto __j = __zs - __zs_beg;
|
||||||
if (__same_move_seq || __i < __nx)
|
if (__same_move_seq || __j < __nx)
|
||||||
{
|
{
|
||||||
__zs = __move_sequence_x(__xs, __xe, __zs);
|
__zs = __move_sequence_x(__xs, __xe, __zs);
|
||||||
__move_sequence_x(__ys, __ye, __zs);
|
__move_sequence_x(__ys, __ye, __zs);
|
||||||
|
|
|
@ -42,8 +42,6 @@ struct test_one_policy
|
||||||
operator()(Policy&& exec, BiDirIt1 first1, BiDirIt1 last1, BiDirIt1 first2, BiDirIt1 last2, Size n, Size m,
|
operator()(Policy&& exec, BiDirIt1 first1, BiDirIt1 last1, BiDirIt1 first2, BiDirIt1 last2, Size n, Size m,
|
||||||
Generator1 generator1, Generator2 generator2, Compare comp)
|
Generator1 generator1, Generator2 generator2, Compare comp)
|
||||||
{
|
{
|
||||||
|
|
||||||
using T = typename std::iterator_traits<BiDirIt1>::value_type;
|
|
||||||
const BiDirIt1 mid1 = std::next(first1, m);
|
const BiDirIt1 mid1 = std::next(first1, m);
|
||||||
fill_data(first1, mid1, generator1);
|
fill_data(first1, mid1, generator1);
|
||||||
fill_data(mid1, last1, generator2);
|
fill_data(mid1, last1, generator2);
|
||||||
|
@ -60,8 +58,8 @@ struct test_one_policy
|
||||||
template <typename Policy, typename BiDirIt1, typename Size, typename Generator1, typename Generator2,
|
template <typename Policy, typename BiDirIt1, typename Size, typename Generator1, typename Generator2,
|
||||||
typename Compare>
|
typename Compare>
|
||||||
typename std::enable_if<is_same_iterator_category<BiDirIt1, std::forward_iterator_tag>::value, void>::type
|
typename std::enable_if<is_same_iterator_category<BiDirIt1, std::forward_iterator_tag>::value, void>::type
|
||||||
operator()(Policy&& exec, BiDirIt1 first1, BiDirIt1 last1, BiDirIt1 first2, BiDirIt1 last2, Size n, Size m,
|
operator()(Policy&&, BiDirIt1, BiDirIt1, BiDirIt1, BiDirIt1, Size, Size,
|
||||||
Generator1 generator1, Generator2 generator2, Compare comp)
|
Generator1, Generator2, Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ struct test_merge
|
||||||
operator()(Policy&& exec, std::reverse_iterator<InputIterator1> first1, std::reverse_iterator<InputIterator1> last1,
|
operator()(Policy&& exec, std::reverse_iterator<InputIterator1> first1, std::reverse_iterator<InputIterator1> last1,
|
||||||
std::reverse_iterator<InputIterator2> first2, std::reverse_iterator<InputIterator2> last2,
|
std::reverse_iterator<InputIterator2> first2, std::reverse_iterator<InputIterator2> last2,
|
||||||
std::reverse_iterator<OutputIterator> out_first, std::reverse_iterator<OutputIterator> out_last,
|
std::reverse_iterator<OutputIterator> out_first, std::reverse_iterator<OutputIterator> out_last,
|
||||||
Compare comp)
|
Compare)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
typedef typename std::iterator_traits<std::reverse_iterator<InputIterator1>>::value_type T;
|
typedef typename std::iterator_traits<std::reverse_iterator<InputIterator1>>::value_type T;
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct run_copy_if
|
||||||
typename Predicate, typename T>
|
typename Predicate, typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size n,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size n,
|
||||||
Predicate pred, T trash)
|
Predicate pred, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
|
@ -135,7 +135,7 @@ main()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
||||||
test<int32_t>(-666, [](const int32_t& x) { return true; }, [](size_t j) { return j; }, false);
|
test<int32_t>(-666, [](const int32_t&) { return true; }, [](size_t j) { return j; }, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test_algo_basic_double<int32_t>(run_for_rnd_fw<test_non_const>());
|
test_algo_basic_double<int32_t>(run_for_rnd_fw<test_non_const>());
|
||||||
|
|
|
@ -89,7 +89,7 @@ main()
|
||||||
test<int32_t>([](const int32_t x) { return x > 1000; });
|
test<int32_t>([](const int32_t x) { return x > 1000; });
|
||||||
test<uint16_t>([](const uint16_t x) { return x % 5 < 3; });
|
test<uint16_t>([](const uint16_t x) { return x % 5 < 3; });
|
||||||
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN && !_PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN
|
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN && !_PSTL_ICC_19_TEST_IS_PARTITIONED_RELEASE_BROKEN
|
||||||
test<LocalWrapper<float64_t>>([](const LocalWrapper<float64_t>& x) { return true; });
|
test<LocalWrapper<float64_t>>([](const LocalWrapper<float64_t>&) { return true; });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test_algo_basic_single<int32_t>(run_for_rnd_fw<test_non_const>());
|
test_algo_basic_single<int32_t>(run_for_rnd_fw<test_non_const>());
|
||||||
|
|
|
@ -55,7 +55,7 @@ is_equal(Iterator first, Iterator last, Iterator d_first)
|
||||||
|
|
||||||
template <typename Iterator>
|
template <typename Iterator>
|
||||||
typename std::enable_if<!std::is_trivial<typename std::iterator_traits<Iterator>::value_type>::value, bool>::type
|
typename std::enable_if<!std::is_trivial<typename std::iterator_traits<Iterator>::value_type>::value, bool>::type
|
||||||
is_equal(Iterator first, Iterator last, Iterator d_first)
|
is_equal(Iterator, Iterator, Iterator)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ struct test_one_policy
|
||||||
|
|
||||||
template <typename Policy, typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
|
template <typename Policy, typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
|
||||||
typename std::enable_if<!is_same_iterator_category<BiDirIt, std::forward_iterator_tag>::value, void>::type
|
typename std::enable_if<!is_same_iterator_category<BiDirIt, std::forward_iterator_tag>::value, void>::type
|
||||||
operator()(Policy&& exec, BiDirIt first, BiDirIt last, BiDirIt exp_first, BiDirIt exp_last, Size n,
|
operator()(Policy&& exec, BiDirIt first, BiDirIt last, BiDirIt exp_first, BiDirIt exp_last, Size,
|
||||||
UnaryOp unary_op, Generator generator)
|
UnaryOp unary_op, Generator generator)
|
||||||
{
|
{
|
||||||
// partition
|
// partition
|
||||||
|
@ -119,8 +119,8 @@ struct test_one_policy
|
||||||
}
|
}
|
||||||
template <typename Policy, typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
|
template <typename Policy, typename BiDirIt, typename Size, typename UnaryOp, typename Generator>
|
||||||
typename std::enable_if<is_same_iterator_category<BiDirIt, std::forward_iterator_tag>::value, void>::type
|
typename std::enable_if<is_same_iterator_category<BiDirIt, std::forward_iterator_tag>::value, void>::type
|
||||||
operator()(Policy&& exec, BiDirIt first, BiDirIt last, BiDirIt exp_first, BiDirIt exp_last, Size n,
|
operator()(Policy&&, BiDirIt, BiDirIt, BiDirIt, BiDirIt, Size,
|
||||||
UnaryOp unary_op, Generator generator)
|
UnaryOp, Generator)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct test_partition_copy
|
||||||
typename UnaryOp>
|
typename UnaryOp>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator true_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator true_first,
|
||||||
OutputIterator true_last, OutputIterator2 false_first, OutputIterator2 false_last, UnaryOp unary_op)
|
OutputIterator, OutputIterator2 false_first, OutputIterator2, UnaryOp unary_op)
|
||||||
{
|
{
|
||||||
|
|
||||||
auto actual_ret = std::partition_copy(exec, first, last, true_first, false_first, unary_op);
|
auto actual_ret = std::partition_copy(exec, first, last, true_first, false_first, unary_op);
|
||||||
|
@ -101,7 +101,7 @@ main()
|
||||||
test<int32_t>([](const int32_t value) { return value % 2; });
|
test<int32_t>([](const int32_t value) { return value % 2; });
|
||||||
|
|
||||||
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
||||||
test<int32_t>([](const int32_t value) { return true; });
|
test<int32_t>([](const int32_t) { return true; });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test<float64_t>([](const float64_t value) { return value > 2 << 6; });
|
test<float64_t>([](const float64_t value) { return value > 2 << 6; });
|
||||||
|
|
|
@ -52,7 +52,7 @@ struct test_one_policy
|
||||||
|
|
||||||
template <typename ExecutionPolicy, typename Iterator1, typename Iterator2>
|
template <typename ExecutionPolicy, typename Iterator1, typename Iterator2>
|
||||||
typename std::enable_if<is_same_iterator_category<Iterator1, std::forward_iterator_tag>::value>::type
|
typename std::enable_if<is_same_iterator_category<Iterator1, std::forward_iterator_tag>::value>::type
|
||||||
operator()(ExecutionPolicy&& exec, Iterator1 data_b, Iterator1 data_e, Iterator2 actual_b, Iterator2 actual_e)
|
operator()(ExecutionPolicy&&, Iterator1, Iterator1, Iterator2, Iterator2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -79,7 +79,6 @@ struct test_one_policy
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using T = typename iterator_traits<Iterator1>::value_type;
|
using T = typename iterator_traits<Iterator1>::value_type;
|
||||||
using DifferenceType = typename iterator_traits<Iterator1>::difference_type;
|
|
||||||
|
|
||||||
fill(actual_b, actual_e, T(-123));
|
fill(actual_b, actual_e, T(-123));
|
||||||
Iterator1 actual_return = reverse_copy(exec, data_b, data_e, actual_b);
|
Iterator1 actual_return = reverse_copy(exec, data_b, data_e, actual_b);
|
||||||
|
|
|
@ -44,7 +44,7 @@ struct run_copy
|
||||||
typename T>
|
typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size size,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size size,
|
||||||
Size n, T trash)
|
Size n, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
|
@ -96,8 +96,8 @@ struct run_move
|
||||||
template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
|
template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size size,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size size,
|
||||||
Size n, T trash)
|
Size, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
std::fill_n(expected_first, size, trash);
|
std::fill_n(expected_first, size, trash);
|
||||||
|
@ -139,8 +139,8 @@ struct run_move<Wrapper<T>>
|
||||||
template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
|
template <typename Policy, typename InputIterator, typename OutputIterator, typename OutputIterator2, typename Size>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size size,
|
OutputIterator out_last, OutputIterator2, OutputIterator2, Size size,
|
||||||
Size n, Wrapper<T> trash)
|
Size, Wrapper<T> trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
std::fill_n(out_first, size, trash);
|
std::fill_n(out_first, size, trash);
|
||||||
|
|
|
@ -73,7 +73,7 @@ template <typename T>
|
||||||
void
|
void
|
||||||
test_fill_by_type(std::size_t n)
|
test_fill_by_type(std::size_t n)
|
||||||
{
|
{
|
||||||
Sequence<T> in(n, [](std::size_t v) -> T { return T(0); }); //fill with zeros
|
Sequence<T> in(n, [](std::size_t) -> T { return T(0); }); //fill with zeros
|
||||||
T value = -1;
|
T value = -1;
|
||||||
|
|
||||||
invoke_on_all_policies(test_fill(), in.begin(), in.end(), value);
|
invoke_on_all_policies(test_fill(), in.begin(), in.end(), value);
|
||||||
|
|
|
@ -54,11 +54,11 @@ struct test_generate
|
||||||
{
|
{
|
||||||
Generator_count<T> g;
|
Generator_count<T> g;
|
||||||
const auto m = n / 2;
|
const auto m = n / 2;
|
||||||
auto last = generate_n(exec, first, m, g);
|
auto actual_last = generate_n(exec, first, m, g);
|
||||||
Size count = std::count(first, last, g.default_value());
|
Size count = std::count(first, actual_last, g.default_value());
|
||||||
EXPECT_TRUE(count == m && last == std::next(first, m),
|
EXPECT_TRUE(count == m && actual_last == std::next(first, m),
|
||||||
"generate_n wrong result for generate_n");
|
"generate_n wrong result for generate_n");
|
||||||
std::fill(first, last, T(0));
|
std::fill(first, actual_last, T(0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -69,7 +69,7 @@ test_generate_by_type()
|
||||||
{
|
{
|
||||||
for (size_t n = 0; n <= 100000; n = n < 16 ? n + 1 : size_t(3.1415 * n))
|
for (size_t n = 0; n <= 100000; n = n < 16 ? n + 1 : size_t(3.1415 * n))
|
||||||
{
|
{
|
||||||
Sequence<T> in(n, [](size_t v) -> T { return T(0); }); //fill by zero
|
Sequence<T> in(n, [](size_t) -> T { return T(0); }); //fill by zero
|
||||||
|
|
||||||
invoke_on_all_policies(test_generate(), in.begin(), in.end(), in.size());
|
invoke_on_all_policies(test_generate(), in.begin(), in.end(), in.size());
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ int32_t
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN
|
#if !_PSTL_ICC_18_TEST_EARLY_EXIT_MONOTONIC_RELEASE_BROKEN
|
||||||
test<int32_t>(666, 42, [](int32_t val) { return true; }, [](size_t j) { return j; });
|
test<int32_t>(666, 42, [](int32_t) { return true; }, [](size_t j) { return j; });
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
test<int32_t>(666, 2001, [](const int32_t& val) { return val != 2001; },
|
test<int32_t>(666, 2001, [](const int32_t& val) { return val != 2001; },
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct run_remove_copy
|
||||||
typename T>
|
typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size n,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size n,
|
||||||
const T& value, T trash)
|
const T& value, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
|
@ -30,8 +30,9 @@ struct run_remove_copy
|
||||||
std::fill_n(out_first, n, trash);
|
std::fill_n(out_first, n, trash);
|
||||||
|
|
||||||
// Run copy_if
|
// Run copy_if
|
||||||
auto i = remove_copy(first, last, expected_first, value);
|
auto i = std::remove_copy(first, last, expected_first, value);
|
||||||
auto k = remove_copy(exec, first, last, out_first, value);
|
(void)i;
|
||||||
|
auto k = std::remove_copy(exec, first, last, out_first, value);
|
||||||
EXPECT_EQ_N(expected_first, out_first, n, "wrong remove_copy effect");
|
EXPECT_EQ_N(expected_first, out_first, n, "wrong remove_copy effect");
|
||||||
for (size_t j = 0; j < GuardSize; ++j)
|
for (size_t j = 0; j < GuardSize; ++j)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,9 +21,9 @@ struct copy_int
|
||||||
{
|
{
|
||||||
int32_t value;
|
int32_t value;
|
||||||
int32_t copied_times = 0;
|
int32_t copied_times = 0;
|
||||||
explicit copy_int(int32_t val = 0) { value = val; }
|
constexpr explicit copy_int(int32_t val = 0) : value(val) { }
|
||||||
|
|
||||||
copy_int&
|
constexpr copy_int&
|
||||||
operator=(const copy_int& other)
|
operator=(const copy_int& other)
|
||||||
{
|
{
|
||||||
if (&other == this)
|
if (&other == this)
|
||||||
|
@ -36,7 +36,7 @@ struct copy_int
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
constexpr bool
|
||||||
operator==(const copy_int& other) const
|
operator==(const copy_int& other) const
|
||||||
{
|
{
|
||||||
return (value == other.value);
|
return (value == other.value);
|
||||||
|
@ -81,7 +81,7 @@ struct test_one_policy
|
||||||
|
|
||||||
template <typename T, typename Iterator1>
|
template <typename T, typename Iterator1>
|
||||||
bool
|
bool
|
||||||
check(Iterator1 b, Iterator1 e)
|
check(Iterator1, Iterator1)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -102,13 +102,13 @@ test(Pred pred)
|
||||||
|
|
||||||
const std::size_t max_len = 100000;
|
const std::size_t max_len = 100000;
|
||||||
|
|
||||||
const T1 value = T1(0);
|
static constexpr T1 value = T1(0);
|
||||||
const T1 new_value = T1(666);
|
static constexpr T1 new_value = T1(666);
|
||||||
|
|
||||||
Sequence<T2> expected(max_len);
|
Sequence<T2> expected(max_len);
|
||||||
Sequence<T2> actual(max_len);
|
Sequence<T2> actual(max_len);
|
||||||
|
|
||||||
Sequence<T2> data(max_len, [&value](std::size_t i) {
|
Sequence<T2> data(max_len, [](std::size_t i) {
|
||||||
if (i % 3 == 2)
|
if (i % 3 == 2)
|
||||||
{
|
{
|
||||||
return T1(i);
|
return T1(i);
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct test_replace_copy
|
||||||
typename Predicate, typename T>
|
typename Predicate, typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size n,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size n,
|
||||||
Predicate pred, const T& old_value, const T& new_value, T trash)
|
Predicate pred, const T& old_value, const T& new_value, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
|
|
|
@ -115,7 +115,7 @@ struct test_one_policy
|
||||||
!std::is_same<ExecutionPolicy, std::execution::sequenced_policy>::value &&
|
!std::is_same<ExecutionPolicy, std::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&&, 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;
|
||||||
|
@ -131,7 +131,7 @@ struct test_one_policy
|
||||||
!std::is_same<ExecutionPolicy, std::execution::sequenced_policy>::value &&
|
!std::is_same<ExecutionPolicy, std::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&&, Iterator, Iterator, Size)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ template <typename T>
|
||||||
struct check_swap
|
struct check_swap
|
||||||
{
|
{
|
||||||
bool
|
bool
|
||||||
operator()(T& a)
|
operator()(T&)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,10 +60,11 @@ struct test_one_policy
|
||||||
template <typename Policy, typename InputIterator1, typename InputIterator2, typename OutputIterator,
|
template <typename Policy, typename InputIterator1, typename InputIterator2, typename OutputIterator,
|
||||||
typename BinaryOp>
|
typename BinaryOp>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
|
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2,
|
||||||
OutputIterator out_first, OutputIterator out_last, BinaryOp op)
|
OutputIterator out_first, OutputIterator, BinaryOp op)
|
||||||
{
|
{
|
||||||
auto orrr = std::transform(exec, first1, last1, first2, out_first, op);
|
auto result = std::transform(exec, first1, last1, first2, out_first, op);
|
||||||
|
(void)result;
|
||||||
check_and_reset(first1, last1, first2, out_first);
|
check_and_reset(first1, last1, first2, out_first);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -77,7 +78,7 @@ test(Predicate pred)
|
||||||
Sequence<In1> in1(n, [](size_t k) { return k % 5 != 1 ? 3 * k - 7 : 0; });
|
Sequence<In1> in1(n, [](size_t k) { return k % 5 != 1 ? 3 * k - 7 : 0; });
|
||||||
Sequence<In2> in2(n, [](size_t k) { return k % 7 != 2 ? 5 * k - 5 : 0; });
|
Sequence<In2> in2(n, [](size_t k) { return k % 7 != 2 ? 5 * k - 5 : 0; });
|
||||||
|
|
||||||
Sequence<Out> out(n, [](size_t k) { return -1; });
|
Sequence<Out> out(n, [](size_t) { return -1; });
|
||||||
|
|
||||||
invoke_on_all_policies(test_one_policy(), in1.begin(), in1.end(), in2.begin(), in2.end(), out.begin(),
|
invoke_on_all_policies(test_one_policy(), in1.begin(), in1.end(), in2.begin(), in2.end(), out.begin(),
|
||||||
out.end(), pred);
|
out.end(), pred);
|
||||||
|
|
|
@ -43,7 +43,7 @@ struct run_unique_copy
|
||||||
typename Predicate, typename T>
|
typename Predicate, typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2 expected_last, Size n,
|
OutputIterator out_last, OutputIterator2 expected_first, OutputIterator2, Size n,
|
||||||
Predicate pred, T trash)
|
Predicate pred, T trash)
|
||||||
{
|
{
|
||||||
// Cleaning
|
// Cleaning
|
||||||
|
@ -114,7 +114,7 @@ struct test_non_const
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t
|
int32_t
|
||||||
main(int32_t argc, char* argv[])
|
main()
|
||||||
{
|
{
|
||||||
test<Number>(Number(42, OddTag()), std::equal_to<Number>(),
|
test<Number>(Number(42, OddTag()), std::equal_to<Number>(),
|
||||||
[](int32_t j) { return Number(3 * j / 13 ^ (j & 8), OddTag()); });
|
[](int32_t j) { return Number(3 * j / 13 ^ (j & 8), OddTag()); });
|
||||||
|
@ -122,7 +122,7 @@ main(int32_t argc, char* argv[])
|
||||||
test<float32_t>(float32_t(42), std::equal_to<float32_t>(),
|
test<float32_t>(float32_t(42), std::equal_to<float32_t>(),
|
||||||
[](int32_t j) { return float32_t(5 * j / 23 ^ (j / 7)); });
|
[](int32_t j) { return float32_t(5 * j / 23 ^ (j / 7)); });
|
||||||
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
||||||
test<float32_t>(float32_t(42), [](float32_t x, float32_t y) { return false; },
|
test<float32_t>(float32_t(42), [](float32_t, float32_t) { return false; },
|
||||||
[](int32_t j) { return float32_t(j); }, false);
|
[](int32_t j) { return float32_t(j); }, false);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ test(size_t bits)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Sequence of odd values
|
// Sequence of odd values
|
||||||
Sequence<T> in(n, [n, bits](size_t k) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
Sequence<T> in(n, [n, bits](size_t) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
||||||
|
|
||||||
// Even value, or false when T is bool.
|
// Even value, or false when T is bool.
|
||||||
T spike(2 * HashBits(n, bits - 1));
|
T spike(2 * HashBits(n, bits - 1));
|
||||||
|
|
|
@ -45,7 +45,7 @@ test(size_t bits)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Sequence of odd values
|
// Sequence of odd values
|
||||||
Sequence<T> in(n, [n, bits](size_t k) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
Sequence<T> in(n, [n, bits](size_t) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
||||||
|
|
||||||
// Even value, or false when T is bool.
|
// Even value, or false when T is bool.
|
||||||
T spike(2 * HashBits(n, bits - 1));
|
T spike(2 * HashBits(n, bits - 1));
|
||||||
|
|
|
@ -93,7 +93,7 @@ main()
|
||||||
{
|
{
|
||||||
test<int32_t>(42, IsEqual<int32_t>(50, OddTag()), [](int32_t j) { return j; });
|
test<int32_t>(42, IsEqual<int32_t>(50, OddTag()), [](int32_t j) { return j; });
|
||||||
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
#if !_PSTL_ICC_16_17_TEST_REDUCTION_RELEASE_BROKEN
|
||||||
test<int32_t>(42, [](const int32_t& x) { return true; }, [](int32_t j) { return j; });
|
test<int32_t>(42, [](const int32_t&) { return true; }, [](int32_t j) { return j; });
|
||||||
#endif
|
#endif
|
||||||
test<float64_t>(42, IsEqual<float64_t>(50, OddTag()), [](int32_t j) { return float64_t(j); });
|
test<float64_t>(42, IsEqual<float64_t>(50, OddTag()), [](int32_t j) { return float64_t(j); });
|
||||||
test<Number>(Number(42, OddTag()), IsEqual<Number>(Number(50, OddTag()), OddTag()),
|
test<Number>(Number(42, OddTag()), IsEqual<Number>(Number(50, OddTag()), OddTag()),
|
||||||
|
|
|
@ -82,7 +82,7 @@ int32_t
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
// Note that the "hit" and "miss" functions here avoid overflow issues.
|
// Note that the "hit" and "miss" functions here avoid overflow issues.
|
||||||
test<Number>(Weird(42, OddTag()), [](int32_t j) { return Number(42, OddTag()); }, // hit
|
test<Number>(Weird(42, OddTag()), [](int32_t) { return Number(42, OddTag()); }, // hit
|
||||||
[](int32_t j) { return Number(j == 42 ? 0 : j, OddTag()); }); // miss
|
[](int32_t j) { return Number(j == 42 ? 0 : j, OddTag()); }); // miss
|
||||||
|
|
||||||
// Test with value that is equal to two different bit patterns (-0.0 and 0.0)
|
// Test with value that is equal to two different bit patterns (-0.0 and 0.0)
|
||||||
|
|
|
@ -68,8 +68,8 @@ test(const std::size_t bits)
|
||||||
|
|
||||||
const std::size_t max_n1 = 1000;
|
const std::size_t max_n1 = 1000;
|
||||||
const std::size_t max_n2 = (max_n1 * 10) / 8;
|
const std::size_t max_n2 = (max_n1 * 10) / 8;
|
||||||
Sequence<T> in(max_n1, [bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1) ^ 1); });
|
Sequence<T> in(max_n1, [bits](std::size_t) { return T(2 * HashBits(max_n1, bits - 1) ^ 1); });
|
||||||
Sequence<T> sub(max_n2, [bits](std::size_t k) { return T(2 * HashBits(max_n1, bits - 1)); });
|
Sequence<T> sub(max_n2, [bits](std::size_t) { return T(2 * HashBits(max_n1, bits - 1)); });
|
||||||
for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1))
|
for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1))
|
||||||
{
|
{
|
||||||
std::size_t sub_n[] = {0, 1, 3, n1, (n1 * 10) / 8};
|
std::size_t sub_n[] = {0, 1, 3, n1, (n1 * 10) / 8};
|
||||||
|
|
|
@ -56,8 +56,8 @@ test(Predicate pred)
|
||||||
|
|
||||||
const std::size_t max_n1 = 1000;
|
const std::size_t max_n1 = 1000;
|
||||||
const std::size_t max_n2 = (max_n1 * 10) / 8;
|
const std::size_t max_n2 = (max_n1 * 10) / 8;
|
||||||
Sequence<T> in1(max_n1, [](std::size_t k) { return T(1); });
|
Sequence<T> in1(max_n1, [](std::size_t) { return T(1); });
|
||||||
Sequence<T> in2(max_n2, [](std::size_t k) { return T(0); });
|
Sequence<T> in2(max_n2, [](std::size_t) { return T(0); });
|
||||||
for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1))
|
for (std::size_t n1 = 0; n1 <= max_n1; n1 = n1 <= 16 ? n1 + 1 : size_t(3.1415 * n1))
|
||||||
{
|
{
|
||||||
std::size_t sub_n[] = {0, 1, n1 / 3, n1, (n1 * 10) / 8};
|
std::size_t sub_n[] = {0, 1, n1 / 3, n1, (n1 * 10) / 8};
|
||||||
|
|
|
@ -45,7 +45,7 @@ test(size_t bits)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Sequence of odd values
|
// Sequence of odd values
|
||||||
Sequence<T> in(n, [n, bits](size_t k) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
Sequence<T> in(n, [n, bits](size_t) { return T(2 * HashBits(n, bits - 1) ^ 1); });
|
||||||
|
|
||||||
// Even value, or false when T is bool.
|
// Even value, or false when T is bool.
|
||||||
T spike(2 * HashBits(n, bits - 1));
|
T spike(2 * HashBits(n, bits - 1));
|
||||||
|
|
|
@ -111,8 +111,8 @@ struct test_one_policy
|
||||||
template <typename Policy, typename Iterator1, typename Size, typename Generator1, typename Generator2,
|
template <typename Policy, typename Iterator1, typename Size, typename Generator1, typename Generator2,
|
||||||
typename Compare>
|
typename Compare>
|
||||||
typename std::enable_if<!is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
|
typename std::enable_if<!is_same_iterator_category<Iterator1, std::random_access_iterator_tag>::value, void>::type
|
||||||
operator()(Policy&& exec, Iterator1 first1, Iterator1 last1, Iterator1 first2, Iterator1 last2, Size n, Size m,
|
operator()(Policy&&, Iterator1, Iterator1, Iterator1, Iterator1, Size, Size,
|
||||||
Generator1 generator1, Generator2 generator2, Compare comp)
|
Generator1, Generator2, Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -67,7 +67,7 @@ test()
|
||||||
}
|
}
|
||||||
for (auto r : res)
|
for (auto r : res)
|
||||||
{
|
{
|
||||||
Sequence<T> in(n1, [](std::size_t k) { return T(0); });
|
Sequence<T> in(n1, [](std::size_t) { return T(0); });
|
||||||
std::size_t i = r, isub = 0;
|
std::size_t i = r, isub = 0;
|
||||||
for (; i < n1 & isub < n2; ++i, ++isub)
|
for (; i < n1 & isub < n2; ++i, ++isub)
|
||||||
in[i] = value;
|
in[i] = value;
|
||||||
|
|
|
@ -77,13 +77,14 @@ struct test_is_heap
|
||||||
const Iterator actual = is_heap_until(exec, first, last, pred);
|
const Iterator actual = is_heap_until(exec, first, last, pred);
|
||||||
const auto x = std::distance(first, actual);
|
const auto x = std::distance(first, actual);
|
||||||
EXPECT_TRUE(expected == actual, "wrong return value from is_heap_until with predicate");
|
EXPECT_TRUE(expected == actual, "wrong return value from is_heap_until with predicate");
|
||||||
|
EXPECT_EQ(x, y, "both iterators should be the same distance away from 'first'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// is_heap, is_heap_until works only with random access iterators
|
// is_heap, is_heap_until works only with random access iterators
|
||||||
template <typename Policy, typename Iterator, typename Predicate>
|
template <typename Policy, typename Iterator, typename Predicate>
|
||||||
typename std::enable_if<!is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value, void>::type
|
typename std::enable_if<!is_same_iterator_category<Iterator, std::random_access_iterator_tag>::value, void>::type
|
||||||
operator()(Policy&& exec, Iterator first, Iterator last, Predicate pred)
|
operator()(Policy&&, Iterator, Iterator, Predicate)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -111,7 +112,7 @@ test_is_heap_by_type(Comp comp)
|
||||||
invoke_on_all_policies(test_is_heap(), in.cbegin(), in.cend(), comp);
|
invoke_on_all_policies(test_is_heap(), in.cbegin(), in.cend(), comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
Sequence<T> in(max_size / 10, [](size_t v) -> T { return T(1); });
|
Sequence<T> in(max_size / 10, [](size_t) -> T { return T(1); });
|
||||||
invoke_on_all_policies(test_is_heap(), in.begin(), in.end(), comp);
|
invoke_on_all_policies(test_is_heap(), in.begin(), in.end(), comp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,8 +55,8 @@ struct test_one_policy
|
||||||
|
|
||||||
template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
|
template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
|
||||||
typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
|
typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
|
||||||
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
|
operator()(Policy&&, InputIterator1, InputIterator1, InputIterator2, InputIterator2,
|
||||||
Compare comp)
|
Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -95,8 +95,8 @@ struct test_one_policy
|
||||||
|
|
||||||
template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
|
template <typename Policy, typename InputIterator1, typename InputIterator2, typename Compare>
|
||||||
typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
|
typename std::enable_if<TestUtils::isReverse<InputIterator1>::value, void>::type
|
||||||
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
|
operator()(Policy&&, InputIterator1, InputIterator1, InputIterator2, InputIterator2,
|
||||||
Compare comp)
|
Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -65,7 +65,7 @@ test_is_sorted_by_type()
|
||||||
invoke_on_all_policies(test_is_sorted(), in0.cbegin(), in0.cend(), std::is_sorted(in0.begin(), in0.end()));
|
invoke_on_all_policies(test_is_sorted(), in0.cbegin(), in0.cend(), std::is_sorted(in0.begin(), in0.end()));
|
||||||
|
|
||||||
//non-descending order
|
//non-descending order
|
||||||
Sequence<T> in1(9, [](size_t v) -> T { return T(0); });
|
Sequence<T> in1(9, [](size_t) -> T { return T(0); });
|
||||||
invoke_on_all_policies(test_is_sorted(), in1.begin(), in1.end(), std::is_sorted(in1.begin(), in1.end()));
|
invoke_on_all_policies(test_is_sorted(), in1.begin(), in1.end(), std::is_sorted(in1.begin(), in1.end()));
|
||||||
invoke_on_all_policies(test_is_sorted(), in1.cbegin(), in1.cend(), std::is_sorted(in1.begin(), in1.end()));
|
invoke_on_all_policies(test_is_sorted(), in1.cbegin(), in1.cend(), std::is_sorted(in1.begin(), in1.end()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,19 +78,18 @@ struct test_brick_partial_sort
|
||||||
//checking upper bound number of comparisons; O(p*(last-first)log(middle-first)); where p - number of threads;
|
//checking upper bound number of comparisons; O(p*(last-first)log(middle-first)); where p - number of threads;
|
||||||
if (m1 - first > 1)
|
if (m1 - first > 1)
|
||||||
{
|
{
|
||||||
auto complex = std::ceil(n * std::log(float32_t(m1 - first)));
|
|
||||||
#if defined(_PSTL_PAR_BACKEND_TBB)
|
|
||||||
auto p = tbb::this_task_arena::max_concurrency();
|
|
||||||
#else
|
|
||||||
auto p = 1;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
|
# if defined(_PSTL_PAR_BACKEND_TBB)
|
||||||
|
auto p = tbb::this_task_arena::max_concurrency();
|
||||||
|
# else
|
||||||
|
auto p = 1;
|
||||||
|
# endif
|
||||||
|
auto complex = std::ceil(n * std::log(float32_t(m1 - first)));
|
||||||
if (count_comp > complex * p)
|
if (count_comp > complex * p)
|
||||||
{
|
{
|
||||||
std::cout << "complexity exceeded" << std::endl;
|
std::cout << "complexity exceeded" << std::endl;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // _DEBUG
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -98,8 +97,8 @@ struct test_brick_partial_sort
|
||||||
template <typename Policy, typename InputIterator, typename Compare>
|
template <typename Policy, typename InputIterator, typename Compare>
|
||||||
typename std::enable_if<!is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
typename std::enable_if<!is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
||||||
void>::type
|
void>::type
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, InputIterator exp_first, InputIterator exp_last,
|
operator()(Policy&&, InputIterator, InputIterator, InputIterator, InputIterator,
|
||||||
Compare compare)
|
Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,7 +160,7 @@ struct test_sort_with_compare
|
||||||
typename std::enable_if<is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
typename std::enable_if<is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
||||||
void>::type
|
void>::type
|
||||||
operator()(Policy&& exec, OutputIterator tmp_first, OutputIterator tmp_last, OutputIterator2 expected_first,
|
operator()(Policy&& exec, OutputIterator tmp_first, OutputIterator tmp_last, OutputIterator2 expected_first,
|
||||||
OutputIterator2 expected_last, InputIterator first, InputIterator last, Size n, Compare compare)
|
OutputIterator2 expected_last, InputIterator first, InputIterator, Size n, Compare compare)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
copy_n(first, n, expected_first);
|
copy_n(first, n, expected_first);
|
||||||
|
@ -187,8 +187,8 @@ struct test_sort_with_compare
|
||||||
typename Compare>
|
typename Compare>
|
||||||
typename std::enable_if<!is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
typename std::enable_if<!is_same_iterator_category<InputIterator, std::random_access_iterator_tag>::value,
|
||||||
void>::type
|
void>::type
|
||||||
operator()(Policy&& exec, OutputIterator tmp_first, OutputIterator tmp_last, OutputIterator2 expected_first,
|
operator()(Policy&&, OutputIterator, OutputIterator, OutputIterator2,
|
||||||
OutputIterator2 expected_last, InputIterator first, InputIterator last, Size n, Compare compare)
|
OutputIterator2, InputIterator, InputIterator, Size, Compare)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -21,19 +21,19 @@ template <typename T>
|
||||||
struct wrapper
|
struct wrapper
|
||||||
{
|
{
|
||||||
T t;
|
T t;
|
||||||
explicit wrapper(T t_) : t(t_) {}
|
constexpr explicit wrapper(T t_) : t(t_) {}
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
wrapper(const wrapper<T2>& a)
|
constexpr wrapper(const wrapper<T2>& a)
|
||||||
{
|
{
|
||||||
t = a.t;
|
t = a.t;
|
||||||
}
|
}
|
||||||
template <typename T2>
|
template <typename T2>
|
||||||
void
|
constexpr void
|
||||||
operator=(const wrapper<T2>& a)
|
operator=(const wrapper<T2>& a)
|
||||||
{
|
{
|
||||||
t = a.t;
|
t = a.t;
|
||||||
}
|
}
|
||||||
wrapper<T>
|
constexpr wrapper<T>
|
||||||
operator-(const wrapper<T>& a) const
|
operator-(const wrapper<T>& a) const
|
||||||
{
|
{
|
||||||
return wrapper<T>(t - a.t);
|
return wrapper<T>(t - a.t);
|
||||||
|
@ -63,9 +63,11 @@ compute_and_check(Iterator1 first, Iterator1 last, Iterator2 d_first, T, Functio
|
||||||
if (first == last)
|
if (first == last)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
T2 temp(*first);
|
{
|
||||||
if (!compare(temp, *d_first))
|
T2 temp(*first);
|
||||||
return false;
|
if (!compare(temp, *d_first))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Iterator1 second = std::next(first);
|
Iterator1 second = std::next(first);
|
||||||
|
|
||||||
++d_first;
|
++d_first;
|
||||||
|
@ -83,7 +85,7 @@ compute_and_check(Iterator1 first, Iterator1 last, Iterator2 d_first, T, Functio
|
||||||
// because we can't be sure it will be strictly equal for floating point types
|
// because we can't be sure it will be strictly equal for floating point types
|
||||||
template <typename Iterator1, typename Iterator2, typename T, typename Function>
|
template <typename Iterator1, typename Iterator2, typename T, typename Function>
|
||||||
typename std::enable_if<std::is_floating_point<T>::value, bool>::type
|
typename std::enable_if<std::is_floating_point<T>::value, bool>::type
|
||||||
compute_and_check(Iterator1 first, Iterator1 last, Iterator2 d_first, T, Function)
|
compute_and_check(Iterator1, Iterator1, Iterator2, T, Function)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -134,16 +136,14 @@ template <typename T1, typename T2, typename Pred>
|
||||||
void
|
void
|
||||||
test(Pred pred)
|
test(Pred pred)
|
||||||
{
|
{
|
||||||
typedef typename Sequence<T2>::iterator iterator_type;
|
|
||||||
|
|
||||||
const std::size_t max_len = 100000;
|
const std::size_t max_len = 100000;
|
||||||
|
|
||||||
const T2 value = T2(77);
|
static constexpr T2 value = T2(77);
|
||||||
const T1 trash = T1(31);
|
static constexpr T1 trash = T1(31);
|
||||||
|
|
||||||
Sequence<T1> actual(max_len, [](std::size_t i) { return T1(i); });
|
Sequence<T1> actual(max_len, [](std::size_t i) { return T1(i); });
|
||||||
|
|
||||||
Sequence<T2> data(max_len, [&value](std::size_t i) { return i % 3 == 2 ? T2(i * i) : value; });
|
Sequence<T2> data(max_len, [](std::size_t i) { return i % 3 == 2 ? T2(i * i) : value; });
|
||||||
|
|
||||||
for (std::size_t len = 0; len < max_len; len = len <= 16 ? len + 1 : std::size_t(3.1415 * len))
|
for (std::size_t len = 0; len < max_len; len = len <= 16 ? len + 1 : std::size_t(3.1415 * len))
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,12 +98,13 @@ struct test_scan_with_plus
|
||||||
template <typename Policy, typename Iterator1, typename Iterator2, typename Iterator3, typename Size, typename T>
|
template <typename Policy, typename Iterator1, typename Iterator2, typename Iterator3, typename Size, typename T>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, Iterator1 in_first, Iterator1 in_last, Iterator2 out_first, Iterator2 out_last,
|
operator()(Policy&& exec, Iterator1 in_first, Iterator1 in_last, Iterator2 out_first, Iterator2 out_last,
|
||||||
Iterator3 expected_first, Iterator3 expected_last, Size n, T init, T trash)
|
Iterator3 expected_first, Iterator3, Size n, T init, T trash)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
auto orr1 = inclusive ? inclusive_scan_serial(in_first, in_last, expected_first)
|
auto orr1 = inclusive ? inclusive_scan_serial(in_first, in_last, expected_first)
|
||||||
: exclusive_scan_serial(in_first, in_last, expected_first, init);
|
: exclusive_scan_serial(in_first, in_last, expected_first, init);
|
||||||
|
(void)orr1;
|
||||||
auto orr = inclusive ? inclusive_scan(exec, in_first, in_last, out_first)
|
auto orr = inclusive ? inclusive_scan(exec, in_first, in_last, out_first)
|
||||||
: exclusive_scan(exec, in_first, in_last, out_first, init);
|
: exclusive_scan(exec, in_first, in_last, out_first, init);
|
||||||
EXPECT_TRUE(out_last == orr,
|
EXPECT_TRUE(out_last == orr,
|
||||||
|
@ -136,12 +137,13 @@ struct test_scan_with_binary_op
|
||||||
typename BinaryOp>
|
typename BinaryOp>
|
||||||
typename std::enable_if<!TestUtils::isReverse<Iterator1>::value, void>::type
|
typename std::enable_if<!TestUtils::isReverse<Iterator1>::value, void>::type
|
||||||
operator()(Policy&& exec, Iterator1 in_first, Iterator1 in_last, Iterator2 out_first, Iterator2 out_last,
|
operator()(Policy&& exec, Iterator1 in_first, Iterator1 in_last, Iterator2 out_first, Iterator2 out_last,
|
||||||
Iterator3 expected_first, Iterator3 expected_last, Size n, T init, BinaryOp binary_op, T trash)
|
Iterator3 expected_first, Iterator3, Size n, T init, BinaryOp binary_op, T trash)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
auto orr1 = inclusive ? inclusive_scan_serial(in_first, in_last, expected_first, binary_op, init)
|
auto orr1 = inclusive ? inclusive_scan_serial(in_first, in_last, expected_first, binary_op, init)
|
||||||
: exclusive_scan_serial(in_first, in_last, expected_first, init, binary_op);
|
: exclusive_scan_serial(in_first, in_last, expected_first, init, binary_op);
|
||||||
|
(void)orr1;
|
||||||
auto orr = inclusive ? inclusive_scan(exec, in_first, in_last, out_first, binary_op, init)
|
auto orr = inclusive ? inclusive_scan(exec, in_first, in_last, out_first, binary_op, init)
|
||||||
: exclusive_scan(exec, in_first, in_last, out_first, init, binary_op);
|
: exclusive_scan(exec, in_first, in_last, out_first, init, binary_op);
|
||||||
|
|
||||||
|
@ -152,8 +154,8 @@ struct test_scan_with_binary_op
|
||||||
template <typename Policy, typename Iterator1, typename Iterator2, typename Iterator3, typename Size, typename T,
|
template <typename Policy, typename Iterator1, typename Iterator2, typename Iterator3, typename Size, typename T,
|
||||||
typename BinaryOp>
|
typename BinaryOp>
|
||||||
typename std::enable_if<TestUtils::isReverse<Iterator1>::value, void>::type
|
typename std::enable_if<TestUtils::isReverse<Iterator1>::value, void>::type
|
||||||
operator()(Policy&& exec, Iterator1 in_first, Iterator1 in_last, Iterator2 out_first, Iterator2 out_last,
|
operator()(Policy&&, Iterator1, Iterator1, Iterator2, Iterator2,
|
||||||
Iterator3 expected_first, Iterator3 expected_last, Size n, T init, BinaryOp binary_op, T trash)
|
Iterator3, Iterator3, Size, T, BinaryOp, T)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -73,7 +73,7 @@ CheckResults(const T& expected, const T& in)
|
||||||
// We need to check correctness only for "int" (for example) except cases
|
// We need to check correctness only for "int" (for example) except cases
|
||||||
// if we have "floating-point type"-specialization
|
// if we have "floating-point type"-specialization
|
||||||
void
|
void
|
||||||
CheckResults(const float32_t& expected, const float32_t& in)
|
CheckResults(const float32_t&, const float32_t&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ struct test_transform_reduce
|
||||||
template <typename Policy, typename InputIterator1, typename InputIterator2, typename T, typename BinaryOperation1,
|
template <typename Policy, typename InputIterator1, typename InputIterator2, typename T, typename BinaryOperation1,
|
||||||
typename BinaryOperation2, typename UnaryOp>
|
typename BinaryOperation2, typename UnaryOp>
|
||||||
void
|
void
|
||||||
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
|
operator()(Policy&& exec, InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2,
|
||||||
T init, BinaryOperation1 opB1, BinaryOperation2 opB2, UnaryOp opU)
|
T init, BinaryOperation1 opB1, BinaryOperation2 opB2, UnaryOp opU)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -118,16 +118,16 @@ int32_t
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
test_by_type<int32_t>(42, std::plus<int32_t>(), std::multiplies<int32_t>(), std::negate<int32_t>(),
|
test_by_type<int32_t>(42, std::plus<int32_t>(), std::multiplies<int32_t>(), std::negate<int32_t>(),
|
||||||
[](std::size_t a) -> int32_t { return int32_t(rand() % 1000); });
|
[](std::size_t) -> int32_t { return int32_t(rand() % 1000); });
|
||||||
test_by_type<int64_t>(0, [](const int64_t& a, const int64_t& b) -> int64_t { return a | b; }, XOR(),
|
test_by_type<int64_t>(0, [](const int64_t& a, const int64_t& b) -> int64_t { return a | b; }, XOR(),
|
||||||
[](const int64_t& x) -> int64_t { return x * 2; },
|
[](const int64_t& x) -> int64_t { return x * 2; },
|
||||||
[](std::size_t a) -> int64_t { return int64_t(rand() % 1000); });
|
[](std::size_t) -> int64_t { return int64_t(rand() % 1000); });
|
||||||
test_by_type<float32_t>(1.0f, std::multiplies<float32_t>(),
|
test_by_type<float32_t>(1.0f, std::multiplies<float32_t>(),
|
||||||
[](const float32_t& a, const float32_t& b) -> float32_t { return a + b; },
|
[](const float32_t& a, const float32_t& b) -> float32_t { return a + b; },
|
||||||
[](const float32_t& x) -> float32_t { return x + 2; },
|
[](const float32_t& x) -> float32_t { return x + 2; },
|
||||||
[](std::size_t a) -> float32_t { return rand() % 1000; });
|
[](std::size_t) -> float32_t { return rand() % 1000; });
|
||||||
test_by_type<MyClass>(MyClass(), std::plus<MyClass>(), std::multiplies<MyClass>(), std::negate<MyClass>(),
|
test_by_type<MyClass>(MyClass(), std::plus<MyClass>(), std::multiplies<MyClass>(), std::negate<MyClass>(),
|
||||||
[](std::size_t a) -> MyClass { return MyClass(rand() % 1000); });
|
[](std::size_t) -> MyClass { return MyClass(rand() % 1000); });
|
||||||
|
|
||||||
std::cout << done() << std::endl;
|
std::cout << done() << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct test_transform_scan
|
||||||
typename T, typename BinaryOp>
|
typename T, typename BinaryOp>
|
||||||
typename std::enable_if<!TestUtils::isReverse<InputIterator>::value, void>::type
|
typename std::enable_if<!TestUtils::isReverse<InputIterator>::value, void>::type
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
||||||
OutputIterator out_last, OutputIterator expected_first, OutputIterator expected_last, Size n,
|
OutputIterator out_last, OutputIterator expected_first, OutputIterator, Size n,
|
||||||
UnaryOp unary_op, T init, BinaryOp binary_op, T trash)
|
UnaryOp unary_op, T init, BinaryOp binary_op, T trash)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -64,9 +64,9 @@ struct test_transform_scan
|
||||||
template <typename Policy, typename InputIterator, typename OutputIterator, typename Size, typename UnaryOp,
|
template <typename Policy, typename InputIterator, typename OutputIterator, typename Size, typename UnaryOp,
|
||||||
typename T, typename BinaryOp>
|
typename T, typename BinaryOp>
|
||||||
typename std::enable_if<TestUtils::isReverse<InputIterator>::value, void>::type
|
typename std::enable_if<TestUtils::isReverse<InputIterator>::value, void>::type
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first,
|
operator()(Policy&&, InputIterator, InputIterator, OutputIterator,
|
||||||
OutputIterator out_last, OutputIterator expected_first, OutputIterator expected_last, Size n,
|
OutputIterator, OutputIterator, OutputIterator, Size,
|
||||||
UnaryOp unary_op, T init, BinaryOp binary_op, T trash)
|
UnaryOp, T, BinaryOp, T)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -130,6 +130,7 @@ test(UnaryOp unary_op, Out init, BinaryOp binary_op, Out trash)
|
||||||
inclusive
|
inclusive
|
||||||
? transform_inclusive_scan_serial(in.cbegin(), in.cend(), out.fbegin(), unary_op, init, binary_op)
|
? transform_inclusive_scan_serial(in.cbegin(), in.cend(), out.fbegin(), unary_op, init, binary_op)
|
||||||
: transform_exclusive_scan_serial(in.cbegin(), in.cend(), out.fbegin(), unary_op, init, binary_op);
|
: transform_exclusive_scan_serial(in.cbegin(), in.cend(), out.fbegin(), unary_op, init, binary_op);
|
||||||
|
(void)result;
|
||||||
check_and_reset(expected.begin(), out.begin(), out.size(), trash);
|
check_and_reset(expected.begin(), out.begin(), out.size(), trash);
|
||||||
|
|
||||||
invoke_on_all_policies(test_transform_scan(), in.begin(), in.end(), out.begin(), out.end(), expected.begin(),
|
invoke_on_all_policies(test_transform_scan(), in.begin(), in.end(), out.begin(), out.end(), expected.begin(),
|
||||||
|
|
|
@ -91,8 +91,6 @@ struct test_uninitialized_copy_move
|
||||||
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first, size_t n,
|
operator()(Policy&& exec, InputIterator first, InputIterator last, OutputIterator out_first, size_t n,
|
||||||
/*is_trivial<T>=*/std::true_type)
|
/*is_trivial<T>=*/std::true_type)
|
||||||
{
|
{
|
||||||
typedef typename std::iterator_traits<InputIterator>::value_type T;
|
|
||||||
|
|
||||||
std::uninitialized_copy(exec, first, last, out_first);
|
std::uninitialized_copy(exec, first, last, out_first);
|
||||||
EXPECT_TRUE(IsCheckValueCorrectness(first, out_first, n), "wrong uninitialized_copy");
|
EXPECT_TRUE(IsCheckValueCorrectness(first, out_first, n), "wrong uninitialized_copy");
|
||||||
std::destroy_n(exec, out_first, n);
|
std::destroy_n(exec, out_first, n);
|
||||||
|
|
Loading…
Reference in New Issue