oneDPL icon indicating copy to clipboard operation
oneDPL copied to clipboard

Fix serial execution of parallel algorithms with C++20 iterators

Open kboyarinov opened this issue 2 years ago • 2 comments

I propose this PR as a fix for #1253.

Our internal random access iterator checks relied on std::iterator_traits::iterator_category type. But for C++20 iterators, like std::ranges::iota_view::iterator, iterator_category is equivalent to std::input_iterator_tag even if the iterator is random access. For these modern iterators, the real iterator category should be observed using std::iterator_traits::iterator_concept. This PR modifies dpl::__internal::__is_random_access_iterator traits to use std::random_access_iterator concept since C++20. This concept respects both iterator_concept (for modern iterators) and iterator_category (for "legacy" iterators).

This PR also removes dpl::__internal::__iterator_traits helper since std::iterator_traits is SFINAE friendly since C++17 and hence internal structure is redundant now.

kboyarinov avatar Nov 09 '23 12:11 kboyarinov

@kboyarinov you may take a look to https://github.com/oneapi-src/oneDPL/pull/1239 There is some similar approach from @rarutyun

  • this file: https://github.com/oneapi-src/oneDPL/pull/1239/files#diff-deed20001ff532923c71880283f45817ed065a09752a00c0da1192ee65655fef

SergeyKopienko avatar Nov 09 '23 13:11 SergeyKopienko

@kboyarinov you may take a look to #1239 There is some similar approach from @rarutyun

  • this file: https://github.com/oneapi-src/oneDPL/pull/1239/files#diff-deed20001ff532923c71880283f45817ed065a09752a00c0da1192ee65655fef

For me these PRs and approaches are orthogonal. The approach in the PR you mentioned is better than the existing one, but does not fix the problem described. It is required to complete it with the fix similar to this one. But I guess these PRs and their goals should be considered separately.

kboyarinov avatar Nov 15 '23 12:11 kboyarinov