-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Check the swappable requirement for the parallel_sort algorithm #656
Conversation
… test with custom swap Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
…ng tests Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
50c4fdd
to
594a6ad
Compare
include/oneapi/tbb/parallel_sort.h
Outdated
void parallel_sort( RandomAccessIterator begin, RandomAccessIterator end ) { | ||
parallel_sort(begin, end, std::less<typename std::iterator_traits<RandomAccessIterator>::value_type>()); | ||
} | ||
|
||
template<typename Range> | ||
using range_value_type = typename std::iterator_traits<range_iterator_type<Range>>::value_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be we can move this helper to _range_common.h
and simplify tbb::parallel_for_each
constraints? The same for iter_value_type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so, As I know the parallel_for_each
algorithm checks the requirements on reference types instead of value types.
test/common/concepts_common.h
Outdated
|
||
template <bool EnableBegin, bool EnableEnd> | ||
using NonSwappableValue = ParallelSortValue</*MovableV = */true, /*MoveAssignableV = */true, /*ComparableV = */true>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like ParallelSortValue<true, true, true>
is swappable...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I understand it and don't use this value in testing. So I just forgot to remove it from here. Thanks!
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
include/oneapi/tbb/parallel_sort.h
Outdated
@@ -240,7 +250,9 @@ void parallel_sort( RandomAccessIterator begin, RandomAccessIterator end, const | |||
/** @ingroup algorithms **/ | |||
template<typename RandomAccessIterator> | |||
__TBB_requires(std::random_access_iterator<RandomAccessIterator> && | |||
less_than_comparable<typename std::iterator_traits<RandomAccessIterator>::value_type>) | |||
less_than_comparable<iter_value_type<RandomAccessIterator>> && | |||
std::swappable<iter_value_type<RandomAccessIterator>> && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary, same as above
include/oneapi/tbb/parallel_sort.h
Outdated
@@ -258,7 +272,9 @@ void parallel_sort( Range&& rng, const Compare& comp ) { | |||
/** @ingroup algorithms **/ | |||
template<typename Range> | |||
__TBB_requires(container_based_sequence<Range, std::random_access_iterator_tag> && | |||
less_than_comparable<typename std::iterator_traits<range_iterator_type<Range>>::value_type>) | |||
less_than_comparable<range_value_type<Range>> && | |||
std::swappable<range_value_type<Range>> && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unnecessary, same as above
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Kochin Ivan <kochin.ivan@intel.com>
Description
The oneTBB spec contains the swappable requirement for the iterators, but this requirement isn't handled by the C++ constraints in the implementation. This patch enables these constraints for all the overloads to improve the diagnostic and also extends the testing.
Type of change
Tests
Documentation
uxlfoundation/oneAPI-spec#391
Breaks backward compatibility
Notify the following users
@kboyarinov
Signed-off-by: Kochin Ivan kochin.ivan@intel.com