Taskflow
2.4-master-branch
|
building methods of a task dependency graph More...
#include <flow_builder.hpp>
Public Member Functions | |
FlowBuilder (Graph &graph) | |
constructs a flow builder object More... | |
template<typename C > | |
std::enable_if_t< is_static_task_v< C >, Task > | emplace (C &&callable) |
creates a static task from a given callable object More... | |
template<typename C > | |
std::enable_if_t< is_dynamic_task_v< C >, Task > | emplace (C &&callable) |
creates a dynamic task from a given callable object More... | |
template<typename C > | |
std::enable_if_t< is_condition_task_v< C >, Task > | emplace (C &&callable) |
creates a condition task from a given callable object More... | |
template<typename C > | |
std::enable_if_t< is_cudaflow_task_v< C >, Task > | emplace (C &&callable) |
creates a cudaflow task from a given callable object More... | |
template<typename... C, std::enable_if_t<(sizeof...(C)> 1> | |
auto | emplace (C &&... callables) |
creates multiple tasks from a list of callable objects More... | |
Task | composed_of (Taskflow &taskflow) |
creates a module task from a taskflow More... | |
template<typename I , typename C > | |
std::pair< Task, Task > | parallel_for (I beg, I end, C &&callable, size_t chunk=1) |
constructs a task dependency graph of range-based parallel_for More... | |
template<typename I , typename C , std::enable_if_t< std::is_integral< std::decay_t< I >>::value, void > * = nullptr> | |
std::pair< Task, Task > | parallel_for (I beg, I end, I step, C &&callable, size_t chunk=1) |
constructs a task dependency graph of integer index-based parallel_for More... | |
template<typename I , typename C , std::enable_if_t< std::is_floating_point< std::decay_t< I >>::value, void > * = nullptr> | |
std::pair< Task, Task > | parallel_for (I beg, I end, I step, C &&callable, size_t chunk=1) |
constructs a task dependency graph of floating index-based parallel_for More... | |
template<typename I , typename T , typename B > | |
std::pair< Task, Task > | reduce (I beg, I end, T &result, B &&bop) |
construct a task dependency graph of parallel reduction More... | |
template<typename I , typename T > | |
std::pair< Task, Task > | reduce_min (I beg, I end, T &result) |
constructs a task dependency graph of parallel reduction through std::min More... | |
template<typename I , typename T > | |
std::pair< Task, Task > | reduce_max (I beg, I end, T &result) |
constructs a task dependency graph of parallel reduction through std::max More... | |
template<typename I , typename T , typename B , typename U > | |
std::pair< Task, Task > | transform_reduce (I beg, I end, T &result, B &&bop, U &&uop) |
constructs a task dependency graph of parallel transformation and reduction More... | |
template<typename I , typename T , typename B , typename P , typename U > | |
std::pair< Task, Task > | transform_reduce (I beg, I end, T &result, B &&bop1, P &&bop2, U &&uop) |
constructs a task dependency graph of parallel transformation and reduction More... | |
Task | placeholder () |
creates an empty task More... | |
void | precede (Task A, Task B) |
adds a dependency link from task A to task B More... | |
void | linearize (std::vector< Task > &tasks) |
adds adjacent dependency links to a linear list of tasks More... | |
void | linearize (std::initializer_list< Task > tasks) |
adds adjacent dependency links to a linear list of tasks More... | |
void | broadcast (Task A, std::vector< Task > &others) |
adds dependency links from one task A to many tasks More... | |
void | broadcast (Task A, std::initializer_list< Task > others) |
adds dependency links from one task A to many tasks More... | |
void | succeed (std::vector< Task > &others, Task A) |
adds dependency links from many tasks to one task A More... | |
void | succeed (std::initializer_list< Task > others, Task A) |
adds dependency links from many tasks to one task A More... | |
Friends | |
class | Task |
building methods of a task dependency graph
|
inline |
constructs a flow builder object
graph | a task dependency graph to manipulate |
|
inline |
adds dependency links from one task A to many tasks
A | task A |
others | a task set which A precedes |
|
inline |
adds dependency links from one task A to many tasks
A | task A |
others | a task set which A precedes |
creates a module task from a taskflow
taskflow | a taskflow object for the module |
std::enable_if_t< is_static_task_v< C >, Task > tf::FlowBuilder::emplace | ( | C && | callable | ) |
creates a static task from a given callable object
C | callable type |
callable | a callable object constructible from std::function<void()> |
std::enable_if_t< is_dynamic_task_v< C >, Task > tf::FlowBuilder::emplace | ( | C && | callable | ) |
creates a dynamic task from a given callable object
C | callable type |
callable | a callable object constructible from std::function<void(Subflow&)> |
std::enable_if_t< is_condition_task_v< C >, Task > tf::FlowBuilder::emplace | ( | C && | callable | ) |
creates a condition task from a given callable object
C | callable type |
callable | a callable object constructible from std::function<int()> |
std::enable_if_t< is_cudaflow_task_v< C >, Task > tf::FlowBuilder::emplace | ( | C && | callable | ) |
creates a cudaflow task from a given callable object
C | callable type |
callable | a callable object constructible from std::function<void(cudaFlow&)> |
auto tf::FlowBuilder::emplace | ( | C &&... | callables | ) |
creates multiple tasks from a list of callable objects
C... | callable types |
callables | one or multiple callable objects constructible from each task category |
|
inline |
adds adjacent dependency links to a linear list of tasks
tasks | a vector of tasks |
|
inline |
adds adjacent dependency links to a linear list of tasks
tasks | an initializer list of tasks |
std::pair< Task, Task > tf::FlowBuilder::parallel_for | ( | I | beg, |
I | end, | ||
C && | callable, | ||
size_t | chunk = 1 |
||
) |
constructs a task dependency graph of range-based parallel_for
The task dependency graph applies the callable object callable
to each object obtained by dereferencing every iterator in the range [beg, end). The range is split into chunks of size chunk
, where each of them is processed by one Task.
The callable needs to accept a single argument, the object in the range.
I | input iterator type |
C | callable type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
callable | a callable object to be applied to |
chunk | size (default 1) |
std::pair< Task, Task > tf::FlowBuilder::parallel_for | ( | I | beg, |
I | end, | ||
I | step, | ||
C && | callable, | ||
size_t | chunk = 1 |
||
) |
constructs a task dependency graph of integer index-based parallel_for
The task dependency graph applies a callable object to every index in the range [beg, end) with a step size chunk by chunk.
I | integer (arithmetic) index type |
C | callable type |
beg | index of the beginning (inclusive) |
end | index of the end (exclusive) |
step | step size |
callable | a callable object to be applied to |
chunk | items per task |
std::pair<Task, Task> tf::FlowBuilder::parallel_for | ( | I | beg, |
I | end, | ||
I | step, | ||
C && | callable, | ||
size_t | chunk = 1 |
||
) |
constructs a task dependency graph of floating index-based parallel_for
The task dependency graph applies a callable object to every index in the range [beg, end) with a step size chunk by chunk.
I | floating (arithmetic) index type |
C | callable type |
beg | index of the beginning (inclusive) |
end | index of the end (exclusive) |
step | step size |
callable | a callable object to be applied to |
chunk | items per task |
adds a dependency link from task A to task B
A | task A |
B | task B |
std::pair< Task, Task > tf::FlowBuilder::reduce | ( | I | beg, |
I | end, | ||
T & | result, | ||
B && | bop | ||
) |
construct a task dependency graph of parallel reduction
The task dependency graph reduces items in the range [beg, end) to a single result.
I | input iterator type |
T | data type |
B | binary operator type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
result | reference variable to store the final result |
bop | binary operator that will be applied in unspecified order to the result of dereferencing the input iterator |
std::pair< Task, Task > tf::FlowBuilder::reduce_max | ( | I | beg, |
I | end, | ||
T & | result | ||
) |
constructs a task dependency graph of parallel reduction through std::max
The task dependency graph applies a parallel reduction to find the maximum item in the range [beg, end) through std::max reduction.
I | input iterator type |
T | data type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
result | reference variable to store the final result |
std::pair< Task, Task > tf::FlowBuilder::reduce_min | ( | I | beg, |
I | end, | ||
T & | result | ||
) |
constructs a task dependency graph of parallel reduction through std::min
The task dependency graph applies a parallel reduction to find the minimum item in the range [beg, end) through std::min reduction.
I | input iterator type |
T | data type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
result | reference variable to store the final result |
|
inline |
adds dependency links from many tasks to one task A
others | a task set to precede A |
A | task A |
|
inline |
adds dependency links from many tasks to one task A
others | a task set to precede A |
A | task A |
std::pair< Task, Task > tf::FlowBuilder::transform_reduce | ( | I | beg, |
I | end, | ||
T & | result, | ||
B && | bop, | ||
U && | uop | ||
) |
constructs a task dependency graph of parallel transformation and reduction
The task dependency graph transforms each item in the range [beg, end) into a new data type and then reduce the results.
I | input iterator type |
T | data type |
B | binary operator |
U | unary operator type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
result | reference variable to store the final result |
bop | binary function object that will be applied in unspecified order to the results of uop ; the return type must be T |
uop | unary function object that transforms each element in the input range; the return type must be acceptable as input to bop |
std::pair< Task, Task > tf::FlowBuilder::transform_reduce | ( | I | beg, |
I | end, | ||
T & | result, | ||
B && | bop1, | ||
P && | bop2, | ||
U && | uop | ||
) |
constructs a task dependency graph of parallel transformation and reduction
The task dependency graph transforms each item in the range [beg, end) into a new data type and then apply two-layer reductions to derive the result.
I | input iterator type |
T | data type |
B | binary operator type |
P | binary operator type |
U | unary operator type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
result | reference variable to store the final result |
bop1 | binary function object that will be applied in the second-layer reduction to the results of bop2 |
bop2 | binary function object that will be applied in the first-layer reduction to the results of uop and the dereferencing of input iterators |
uop | unary function object that will be applied to transform an item to a new data type that is acceptable as input to bop2 |