|
dispenso 1.5.1
A library for task parallelism
|
#include <limits>#include <dispenso/detail/pipeline_impl.h>Go to the source code of this file.
Functions | |
| template<typename F > | |
| auto | dispenso::stage (F &&f, ssize_t limit) |
| template<typename... Stages> | |
| void | dispenso::pipeline (ThreadPool &pool, Stages &&... sIn) |
| template<typename... Stages> | |
| void | dispenso::pipeline (Stages &&... sIn) |
Variables | |
| constexpr ssize_t | dispenso::kStageNoLimit = std::numeric_limits<ssize_t>::max() |
A file providing utilities for parallel pipelining of work.
Definition in file pipeline.h.
| void dispenso::pipeline | ( | Stages &&... | sIn | ) |
Pipeline work in stages. Pipelines allow stages to specify parallelism limits by using the stage function, or a function-like object can simply be passed directly, indicating a serial stage. Even if stages are serial, there can be parallelism between stages, so in a 3 stage serial pipeline, the expected runtime is the max of the 3 stages runtimes (note that this is in the absence of pipeline overheads and with an infinitely long workstream. In practice speedup is somewhat less). Work will be run on dispenso's global thread pool. This function will block until the entire pipeline has completed.
| sIn | The stages to run. The first stage must be a Generator stage, the last must be a Sink stage, and intermediate stages are Transform stages.
|
pipeline() for exception behavior details. Definition at line 122 of file pipeline.h.
| void dispenso::pipeline | ( | ThreadPool & | pool, |
| Stages &&... | sIn ) |
Pipeline work in stages. Pipelines allow stages to specify parallelism limits by using the stage function, or a function-like object can simply be passed directly, indicating a serial stage. Even if stages are serial, there can be parallelism between stages, so in a 3 stage serial pipeline, the expected runtime is the max of the 3 stages runtimes (note that this is in the absence of pipeline overheads and with an infinitely long workstream. In practice speedup is somewhat less). This function will block until the entire pipeline has completed.
| pool | The ThreadPool to run the work in. This inherently determines the upper bound for parallelism of the pipeline. |
| sIn | The stages to run. The first stage must be a Generator stage, the last must be a Sink stage, and intermediate stages are Transform stages.
|
pipeline() when the pipeline winds down. Subsequent exceptions from concurrently in-flight stages are silently discarded. All internal state (concurrency counters, resource slots, completion events) is cleaned up via RAII, so the thread pool remains in a valid state after an exception and may be reused for subsequent pipelines. When exceptions are disabled at compile time (__cpp_exceptions not defined), all exception-related checks are eliminated with zero overhead. Definition at line 89 of file pipeline.h.
| auto dispenso::stage | ( | F && | f, |
| ssize_t | limit ) |
Create a stage for use in the pipeline function.
| f | A function-like object that can accept the result of the previous stage (if any), and which produces the output for the next stage (if any). |
| limit | How many threads may concurrently run work for this stage. Values larger than the number of threads in the associated thread pool of the used ConcurrentTaskSet will be capped to the size of the pool. |
Definition at line 49 of file pipeline.h.
|
constexpr |
A simple constant representing maximum parallelism for a stage. This number has no particular significance, and is simply here for convenience.
Definition at line 36 of file pipeline.h.