Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check the swappable requirement for the parallel_sort algorithm #656

Merged
merged 11 commits into from
Dec 6, 2021
Prev Previous commit
Next Next commit
Use custom constant iterator to get rid of forbidden constant allocator
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
  • Loading branch information
Kochin Ivan committed Nov 16, 2021
commit 594a6ad279d27c85ede7b7c752b4ae85d20e67c0
14 changes: 8 additions & 6 deletions test/common/concepts_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ namespace parallel_sort_value {
using NonMoveAssignableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */false, /*ComparableV = */true>;
using NonComparableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */true, /*ComparableV = */false>;
} // namespace parallel_sort_value
template <typename T>
class ConstantIT {
T data{};
const T& operator* () const { return data; }
};
namespace container_based_sequence {

template <bool EnableBegin, bool EnableEnd, typename T = int>
Expand All @@ -272,12 +277,9 @@ using NoEnd = ContainerBasedSequence</*Begin = */true, /*End = */false>;
template <typename T>
using CustomValueCBS = ContainerBasedSequence</*Begin = */true, /*End = */true, T>;


template <typename T>
struct ConstantAccessCBS {
using iterator = utils::RandomIterator<const T>;
iterator begin() { return nullptr; }
iterator end() { return nullptr; }
struct ConstantCBS {
ConstantIT<int> begin() const { return ConstantIT<int>{}; }
ConstantIT<int> end() const { return ConstantIT<int>{}; }
};

struct ForwardIteratorCBS {
Expand Down
8 changes: 4 additions & 4 deletions test/tbb/test_parallel_sort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,18 @@ void test_psort_iterator_constraints() {
static_assert(can_call_parallel_sort_with_iterator<typename std::vector<int>::iterator>);
static_assert(!can_call_parallel_sort_with_iterator<utils::ForwardIterator<int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::InputIterator<int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<const int>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonMovableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonMoveAssignableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<utils::RandomIterator<NonComparableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<ConstantIT<int>>);

static_assert(can_call_parallel_sort_with_iterator_and_compare<utils::RandomIterator<int>, CorrectCompare<int>>);
static_assert(can_call_parallel_sort_with_iterator_and_compare<typename std::vector<int>::iterator, CorrectCompare<int>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<utils::ForwardIterator<int>, CorrectCompare<int>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<utils::InputIterator<int>, CorrectCompare<int>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<utils::RandomIterator<const int>, CorrectCompare<const int>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<utils::RandomIterator<NonMovableValue>, CorrectCompare<NonMovableValue>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<utils::RandomIterator<NonMoveAssignableValue>, CorrectCompare<NonMoveAssignableValue>>);
static_assert(!can_call_parallel_sort_with_iterator_and_compare<ConstantIT<int>, CorrectCompare<const int>>);
}

void test_psort_compare_constraints() {
Expand Down Expand Up @@ -279,7 +279,7 @@ void test_psort_cbs_constraints() {
static_assert(!can_call_parallel_sort_with_cbs<NoBegin>);
static_assert(!can_call_parallel_sort_with_cbs<NoEnd>);
static_assert(!can_call_parallel_sort_with_cbs<ForwardIteratorCBS>);
static_assert(!can_call_parallel_sort_with_cbs<ConstantAccessCBS<int>>);
static_assert(!can_call_parallel_sort_with_cbs<ConstantCBS>);
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonMovableValue>>);
ivankochin marked this conversation as resolved.
Show resolved Hide resolved
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonMoveAssignableValue>>);
static_assert(!can_call_parallel_sort_with_iterator<CustomValueCBS<NonComparableValue>>);
Expand All @@ -292,7 +292,7 @@ void test_psort_cbs_constraints() {
static_assert(!can_call_parallel_sort_with_cbs_and_compare<NoBegin, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<NoEnd, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ForwardIteratorCBS, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ConstantAccessCBS<int>, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<ConstantCBS, CorrectCompare>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<CustomValueCBS<NonMovableValue>, CompareMovable>);
static_assert(!can_call_parallel_sort_with_cbs_and_compare<CustomValueCBS<NonMoveAssignableValue>, CompareMoveAssignable>);
}
Expand Down