Iterators from C++20 ranges model the C++20 random_access_iterator concept, but do not necessarily have a random access iterator tag. They are not recognized by the PSTL as random access iterators (but forward iterators), causing the parallel algorithms to fall back to sequential execution.
This is significantly impacting the performance a couple of large HPC applications.
A quick and dirty workaround is to modify pstl/executors_impls.hpp by changing the random_access_iterator<IteratorType> to:
See https:/ /github. com/llvm/ llvm-project/ issues/ 63447
The problem is the following:
std::vector<int> x(n), y(n); :iota(( int)0, (int)x.size()); each(std: :execution: :par_unseq, ids.begin(), ids.end(), [x = x.data(), y = y.data()](int i) {
auto ids = std::views:
std::for_
x[i] = y[i];
});
Iterators from C++20 ranges model the C++20 random_ access_ iterator concept, but do not necessarily have a random access iterator tag. They are not recognized by the PSTL as random access iterators (but forward iterators), causing the parallel algorithms to fall back to sequential execution.
This is significantly impacting the performance a couple of large HPC applications.
A quick and dirty workaround is to modify pstl/executors_ impls.hpp by changing the random_ access_ iterator< IteratorType> to:
template <typename _IteratorType> access_ iterator< _IteratorType> {
(bool) std::is_ same_v< typename std::iterator_ traits< _IteratorType> ::iterator_ category, std::random_ access_ iterator_ tag> :std::random_ access_ iterator< _IteratorType> constant< bool, value> type;
struct __is_random_
static constexpr bool value = (
|| (bool):
);
typedef std::integral_
};
Since llvm-project/pstl has been forked by libc++, it does no longer make sense to try to patch pstl upstream to fix this issue.