|
ADS
Algorithms and Data Structures
|
The executor [see Executor.h] on a scheduler of the senders and the receivers (the std::execution of C++26, P2300), beyond the book, on the implementation of reference, stdexec: SenderExecutor< Sch > runs bulk( n , f ) as the sender schedule( s ) | bulk( par , n , f ) of the scheduler \( s \), waited by sync_wait(), so that the parallel algorithms of ADS run on whatever scheduler the program has: the static_thread_pool of stdexec, its system scheduler, the pools of oneTBB and of Taskflow that stdexec wraps, a scheduler of HPX, or one of the program itself. More...
#include "ADS/Contract.h"#include "ADS/parallel/Executor.h"#include <stdexec/execution.hpp>#include <cstddef>#include <utility>Go to the source code of this file.
Classes | |
| class | ADS::SenderExecutor< Sch > |
| the executor on a scheduler of the senders More... | |
Namespaces | |
| namespace | ADS |
The executor [see Executor.h] on a scheduler of the senders and the receivers (the std::execution of C++26, P2300), beyond the book, on the implementation of reference, stdexec: SenderExecutor< Sch > runs bulk( n , f ) as the sender schedule( s ) | bulk( par , n , f ) of the scheduler \( s \), waited by sync_wait(), so that the parallel algorithms of ADS run on whatever scheduler the program has: the static_thread_pool of stdexec, its system scheduler, the pools of oneTBB and of Taskflow that stdexec wraps, a scheduler of HPX, or one of the program itself.
The standard has no query of the threads of a scheduler, so that concurrency() is the number given to the constructor.
A sync_wait() holds the thread that waits. On a thread of the pool of the scheduler, the fork and join of ADS (the recursion of parallelInvoke(), the trees by join, the sorts) would hold all of them and wait for ever; a call of bulk() made inside a call of the executor therefore runs its calls in order on that thread [see detail::InsideCall], which the contract of the executors allows (a thread may run several calls one after the other). The cost is the parallelism of the nested calls, which is lost, while the algorithms whose parallelism is in one level (the loops, the reductions, the prefix sums, the sorts at their top level, the visits of the graphs) keep all of theirs; on the executors that nest (ThreadPool, TBBExecutor, OpenMPExecutor) nothing is lost. There is no run(), since a scheduler does not promise that the calls of a bulk run at the same time.
The header is compiled where the headers of stdexec are found (<stdexec/execution.hpp>, or ADS_WITH_STDEXEC, which the CMake target ADS::stdexec defines). The interface of stdexec still changes, and the header follows the wording of C++26 (the policy as the first argument of bulk), which stdexec has since 2025.
The contracts [see Contract.h]: \( p \ge 1 \); an exception thrown by \( f \) stops the claims and is thrown again by bulk().