[all-commits] [llvm/llvm-project] 7bf32f: [libc++][pstl] Implementation of parallel std::rev...
Michael G. Kazakov via All-commits
all-commits at lists.llvm.org
Mon Aug 3 22:58:22 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 7bf32f63ee90b964a49212efd09ebd299d6718bb
https://github.com/llvm/llvm-project/commit/7bf32f63ee90b964a49212efd09ebd299d6718bb
Author: Michael G. Kazakov <mike.kazakov at gmail.com>
Date: 2026-08-04 (Tue, 04 Aug 2026)
Changed paths:
M libcxx/include/CMakeLists.txt
M libcxx/include/__algorithm/pstl.h
M libcxx/include/__pstl/backend_fwd.h
M libcxx/include/__pstl/backends/default.h
M libcxx/include/__pstl/backends/libdispatch.h
M libcxx/include/__pstl/backends/serial.h
M libcxx/include/__pstl/backends/std_thread.h
A libcxx/include/__pstl/cpu_algos/reverse.h
M libcxx/include/module.modulemap.in
M libcxx/test/libcxx/algorithms/pstl.iterator-requirements.verify.cpp
A libcxx/test/std/algorithms/alg.modifying.operations/alg.reverse/pstl.reverse.pass.cpp
M libcxx/test/std/algorithms/pstl.exception_handling.pass.cpp
Log Message:
-----------
[libc++][pstl] Implementation of parallel std::reverse() based on parallel for_each (#213487)
This PR implements a parallel version of `std::reverse()` based on the
parallel `__for_each()`.
The implementation walks the first half of the range in chunks, each
chunk is swapped with its mirrored counterpart via `std::swap_ranges()`
and `std::reverse_iterator<>`:
```c++
// Perform a chunked for_each on the first half of the range.
return __cpu_traits<_Backend>::__for_each(
first, first + (last - first) / 2, [first, last](ForwardIterator i, ForwardIterator j) {
// Derive the last position of the mirrored range.
ForwardIterator mirror_last = last - (i - first);
// Swap the elements in the range of the first half with their mirrored counterparts in the second half.
std::swap_ranges(i, j, std::reverse_iterator<ForwardIterator>(mirror_last));
});
```
Included tests check that:
- Semantics of the function is correct.
- The function correctly SFINAE out when the first argument is not an
execution policy.
- The `noexcept` policy is followed.
- `static_assert` verifies iterators' categories.
Part of #99938.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list