[all-commits] [llvm/llvm-project] 954095: [libc++] Overhaul the PSTL dispatching mechanism (...
Louis Dionne via All-commits
all-commits at lists.llvm.org
Wed Jun 12 09:24:56 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 9540950a45eee79a3ae4e9e0fa92d72b703d14dd
https://github.com/llvm/llvm-project/commit/9540950a45eee79a3ae4e9e0fa92d72b703d14dd
Author: Louis Dionne <ldionne.2 at gmail.com>
Date: 2024-06-12 (Wed, 12 Jun 2024)
Changed paths:
M libcxx/benchmarks/algorithms/pstl.stable_sort.bench.cpp
M libcxx/include/CMakeLists.txt
M libcxx/include/__algorithm/pstl.h
R libcxx/include/__algorithm/pstl_frontend_dispatch.h
M libcxx/include/__numeric/pstl.h
A libcxx/include/__pstl/backend.h
A libcxx/include/__pstl/backend_fwd.h
A 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
R libcxx/include/__pstl/configuration.h
R libcxx/include/__pstl/configuration_fwd.h
M libcxx/include/__pstl/cpu_algos/any_of.h
M libcxx/include/__pstl/cpu_algos/fill.h
M libcxx/include/__pstl/cpu_algos/find_if.h
M libcxx/include/__pstl/cpu_algos/for_each.h
M libcxx/include/__pstl/cpu_algos/merge.h
M libcxx/include/__pstl/cpu_algos/stable_sort.h
M libcxx/include/__pstl/cpu_algos/transform.h
M libcxx/include/__pstl/cpu_algos/transform_reduce.h
A libcxx/include/__pstl/dispatch.h
A libcxx/include/__pstl/handle_exception.h
M libcxx/include/module.modulemap
M libcxx/test/libcxx/algorithms/pstl.iterator-requirements.verify.cpp
R libcxx/test/libcxx/algorithms/pstl.robust_against_customization_points_not_working.pass.cpp
M libcxx/test/libcxx/transitive_includes/cxx17.csv
M libcxx/test/libcxx/transitive_includes/cxx20.csv
M libcxx/test/libcxx/transitive_includes/cxx23.csv
M libcxx/test/libcxx/transitive_includes/cxx26.csv
Log Message:
-----------
[libc++] Overhaul the PSTL dispatching mechanism (#88131)
The experimental PSTL's current dispatching mechanism was designed with
flexibility in mind. However, while reviewing the in-progress OpenMP
backend, I realized that the dispatching mechanism based on ADL and
default definitions in the frontend had several downsides. To name a
few:
1. The dispatching of an algorithm to the back-end and its default
implementation is bundled together via `_LIBCPP_PSTL_CUSTOMIZATION_POINT`.
This makes the dispatching really confusing and leads to annoyances
such as variable shadowing and weird lambda captures in the front-end.
2. The distinction between back-end functions and front-end algorithms
is not as clear as it could be, which led us to call one where we meant
the other in a few cases. This is bad due to the exception requirements
of the PSTL: calling a front-end algorithm inside the implementation of
a back-end is incorrect for exception-safety.
3. There are two levels of back-end dispatching in the PSTL, which treat
CPU backends as a special case. This was confusing and not as flexible
as we'd like. For example, there was no straightforward way to dispatch
all uses of `unseq` to a specific back-end from the OpenMP backend,
or for CPU backends to fall back on each other.
This patch rewrites the backend dispatching mechanism to solve these
problems, but doesn't touch any of the actual implementation of
algorithms. Specifically, this rewrite has the following
characteristics:
- There is a single level of backend dispatching, however partial backends can
be stacked to provide a full implementation of the PSTL. The two-level dispatching
that was used for CPU-based backends is handled by providing CPU-based basis
operations as simple helpers that can easily be reused when defining any PSTL
backend.
- The default definitions for algorithms are separated from their dispatching logic.
- The front-end is thus simplified a whole lot and made very consistent
for all algorithms, which makes it easier to audit the front-end for
things like exception-correctness, appropriate forwarding, etc.
Fixes #70718
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