Taskflow
2.7.0
|
building methods of a task dependency graph More...
#include <flow_builder.hpp>
Public Member Functions | |
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... | |
Task | placeholder () |
creates an empty task 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... | |
template<typename B , typename E , typename C > | |
Task | for_each (B &&first, E &&last, C &&callable) |
constructs a STL-styled parallel-for task More... | |
template<typename B , typename E , typename C , typename H = size_t> | |
Task | for_each_guided (B &&beg, E &&end, C &&callable, H &&chunk_size=1) |
constructs a STL-styled parallel-for task using the guided partition algorithm More... | |
template<typename B , typename E , typename C , typename H = size_t> | |
Task | for_each_dynamic (B &&beg, E &&end, C &&callable, H &&chunk_size=1) |
constructs a STL-styled parallel-for task using the dynamic partition algorithm More... | |
template<typename B , typename E , typename C , typename H = size_t> | |
Task | for_each_static (B &&beg, E &&end, C &&callable, H &&chunk_size=0) |
constructs a STL-styled parallel-for task using the dynamic partition algorithm More... | |
template<typename B , typename E , typename S , typename C > | |
Task | for_each_index (B &&first, E &&last, S &&step, C &&callable) |
constructs an index-based parallel-for task More... | |
template<typename B , typename E , typename S , typename C , typename H = size_t> | |
Task | for_each_index_guided (B &&beg, E &&end, S &&step, C &&callable, H &&chunk_size=1) |
constructs an index-based parallel-for task using the guided partition algorithm. More... | |
template<typename B , typename E , typename S , typename C , typename H = size_t> | |
Task | for_each_index_dynamic (B &&beg, E &&end, S &&step, C &&callable, H &&chunk_size=1) |
constructs an index-based parallel-for task using the dynamic partition algorithm. More... | |
template<typename B , typename E , typename S , typename C , typename H = size_t> | |
Task | for_each_index_static (B &&beg, E &&end, S &&step, C &&callable, H &&chunk_size=0) |
constructs an index-based parallel-for task using the static partition algorithm. More... | |
template<typename B , typename E , typename T , typename O > | |
Task | reduce (B &&first, E &&last, T &init, O &&bop) |
constructs a STL-styled parallel-reduce task More... | |
template<typename B , typename E , typename T , typename O , typename H = size_t> | |
Task | reduce_guided (B &&first, E &&last, T &init, O &&bop, H &&chunk_size=1) |
constructs a STL-styled parallel-reduce task using the guided partition algorithm More... | |
template<typename B , typename E , typename T , typename O , typename H = size_t> | |
Task | reduce_dynamic (B &&first, E &&last, T &init, O &&bop, H &&chunk_size=1) |
constructs a STL-styled parallel-reduce task using the dynamic partition algorithm More... | |
template<typename B , typename E , typename T , typename O , typename H = size_t> | |
Task | reduce_static (B &&first, E &&last, T &init, O &&bop, H &&chunk_size=0) |
constructs a STL-styled parallel-reduce task using the static partition algorithm More... | |
template<typename B , typename E , typename T , typename BOP , typename UOP > | |
Task | transform_reduce (B &&first, E &&last, T &init, BOP &&bop, UOP &&uop) |
constructs a STL-styled parallel transform-reduce task More... | |
template<typename B , typename E , typename T , typename BOP , typename UOP , typename H = size_t> | |
Task | transform_reduce_guided (B &&first, E &&last, T &init, BOP &&bop, UOP &&uop, H &&chunk_size=1) |
constructs a STL-styled parallel transform-reduce task using the guided partition algorithm More... | |
template<typename B , typename E , typename T , typename BOP , typename UOP , typename H = size_t> | |
Task | transform_reduce_static (B &&first, E &&last, T &init, BOP &&bop, UOP &&uop, H &&chunk_size=0) |
constructs a STL-styled parallel transform-reduce task using the static partition algorithm More... | |
template<typename B , typename E , typename T , typename BOP , typename UOP , typename H = size_t> | |
Task | transform_reduce_dynamic (B &&first, E &&last, T &init, BOP &&bop, UOP &&uop, H &&chunk_size=1) |
constructs a STL-styled parallel transform-reduce task using the dynamic partition algorithm More... | |
Protected Member Functions | |
FlowBuilder (Graph &graph) | |
constructs a flow builder with a graph | |
Protected Attributes | |
Graph & | _graph |
associated graph object | |
Friends | |
class | Executor |
building methods of a task dependency graph
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 |
Task tf::FlowBuilder::for_each | ( | B && | first, |
E && | last, | ||
C && | callable | ||
) |
constructs a STL-styled parallel-for task
B | beginning iterator type |
E | ending iterator type |
C | callable type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
callable | a callable object to apply to the dereferenced iterator |
The task spawns a subflow that applies the callable object to each object obtained by dereferencing every iterator in the range [first, last)
. By default, we employ the guided partition algorithm with chunk size equal to one.
This method is equivalent to the parallel execution of the following loop:
Arguments templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the dereferenced type.
Task tf::FlowBuilder::for_each_dynamic | ( | B && | beg, |
E && | end, | ||
C && | callable, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel-for task using the dynamic partition algorithm
B | beginning iterator type |
E | ending iterator type |
C | callable type |
H | chunk size type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
callable | a callable object to apply to the dereferenced iterator |
chunk_size | chunk size |
The task spawns a subflow that applies the callable object to each object obtained by dereferencing every iterator in the range [beg, end)
. The runtime partitions the range into chunks of the given chunk size, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the dereferenced type.
Task tf::FlowBuilder::for_each_guided | ( | B && | beg, |
E && | end, | ||
C && | callable, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel-for task using the guided partition algorithm
B | beginning iterator type |
E | ending iterator type |
C | callable type |
H | chunk size type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
callable | a callable object to apply to the dereferenced iterator |
chunk_size | chunk size |
The task spawns a subflow that applies the callable object to each object obtained by dereferencing every iterator in the range [beg, end)
. The runtime partitions the range into chunks of the given chunk size, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the dereferenced type.
Task tf::FlowBuilder::for_each_index | ( | B && | first, |
E && | last, | ||
S && | step, | ||
C && | callable | ||
) |
constructs an index-based parallel-for task
B | beginning index type (must be integral) |
E | ending index type (must be integral) |
S | step type (must be integral) |
C | callable type |
first | index of the beginning (inclusive) |
last | index of the end (exclusive) |
step | step size |
callable | a callable object to apply to each valid index |
The task spawns a subflow that applies the callable object to each index in the range [first, last)
with the step size. By default, we employ the guided partition algorithm with chunk size equal to one.
This method is equivalent to the parallel execution of the following loop:
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the index type.
Task tf::FlowBuilder::for_each_index_dynamic | ( | B && | beg, |
E && | end, | ||
S && | step, | ||
C && | callable, | ||
H && | chunk_size = 1 |
||
) |
constructs an index-based parallel-for task using the dynamic partition algorithm.
B | beginning index type (must be integral) |
E | ending index type (must be integral) |
S | step type (must be integral) |
C | callable type |
H | chunk size type |
beg | index of the beginning (inclusive) |
end | index of the end (exclusive) |
step | step size |
callable | a callable object to apply to each valid index |
chunk_size | chunk size (default 1) |
The task spawns a subflow that applies the callable object to each index in the range [beg, end)
with the step size. The runtime partitions the range into chunks of the given size, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the index type.
Task tf::FlowBuilder::for_each_index_guided | ( | B && | beg, |
E && | end, | ||
S && | step, | ||
C && | callable, | ||
H && | chunk_size = 1 |
||
) |
constructs an index-based parallel-for task using the guided partition algorithm.
B | beginning index type (must be integral) |
E | ending index type (must be integral) |
S | step type (must be integral) |
C | callable type |
H | chunk size type |
beg | index of the beginning (inclusive) |
end | index of the end (exclusive) |
step | step size |
callable | a callable object to apply to each valid index |
chunk_size | chunk size (default 1) |
The task spawns a subflow that applies the callable object to each index in the range [beg, end)
with the step size. The runtime partitions the range into chunks of the given size, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the index type.
Task tf::FlowBuilder::for_each_index_static | ( | B && | beg, |
E && | end, | ||
S && | step, | ||
C && | callable, | ||
H && | chunk_size = 0 |
||
) |
constructs an index-based parallel-for task using the static partition algorithm.
B | beginning index type (must be integral) |
E | ending index type (must be integral) |
S | step type (must be integral) |
C | callable type |
H | chunk size type |
beg | index of the beginning (inclusive) |
end | index of the end (exclusive) |
step | step size |
callable | a callable object to apply to each valid index |
chunk_size | chunk size (default 0) |
The task spawns a subflow that applies the callable object to each index in the range [beg, end)
with the step size. The runtime partitions the range into chunks of the given size, where each chunk is processed by a worker. When the given chunk size is zero, the runtime distributes the work evenly across workers.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the index type.
Task tf::FlowBuilder::for_each_static | ( | B && | beg, |
E && | end, | ||
C && | callable, | ||
H && | chunk_size = 0 |
||
) |
constructs a STL-styled parallel-for task using the dynamic partition algorithm
B | beginning iterator type |
E | ending iterator type |
C | callable type |
H | chunk size type |
beg | iterator to the beginning (inclusive) |
end | iterator to the end (exclusive) |
callable | a callable object to apply to the dereferenced iterator |
chunk_size | chunk size |
The task spawns a subflow that applies the callable object to each object obtained by dereferencing every iterator in the range [beg, end)
. The runtime partitions the range into chunks of the given chunk size, where each chunk is processed by a worker. When the given chunk size is zero, the runtime distributes the work evenly across workers.
Arguments are templated to enable stateful passing using std::reference_wrapper.
The callable needs to take a single argument of the dereferenced type.
|
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 |
Task tf::FlowBuilder::reduce | ( | B && | first, |
E && | last, | ||
T & | init, | ||
O && | bop | ||
) |
constructs a STL-styled parallel-reduce task
B | beginning iterator type |
E | ending iterator type |
T | result type |
O | binary reducer type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied |
The task spawns a subflow to perform parallel reduction over init
and the elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of the given chunk size, where each chunk is processed by a worker. By default, we employ the guided partition algorithm.
This method is equivalent to the parallel execution of the following loop:
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::reduce_dynamic | ( | B && | first, |
E && | last, | ||
T & | init, | ||
O && | bop, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel-reduce task using the dynamic partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
O | binary reducer type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::reduce_guided | ( | B && | first, |
E && | last, | ||
T & | init, | ||
O && | bop, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel-reduce task using the guided partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
O | binary reducer type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::reduce_static | ( | B && | first, |
E && | last, | ||
T & | init, | ||
O && | bop, | ||
H && | chunk_size = 0 |
||
) |
constructs a STL-styled parallel-reduce task using the static partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
O | binary reducer type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::transform_reduce | ( | B && | first, |
E && | last, | ||
T & | init, | ||
BOP && | bop, | ||
UOP && | uop | ||
) |
constructs a STL-styled parallel transform-reduce task
B | beginning iterator type |
E | ending iterator type |
T | result type |
BOP | binary reducer type |
UOP | unary transformion type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied in unspecified order to the results of uop |
uop | unary operator that will be applied to transform each element in the range to the result type |
The task spawns a subflow to perform parallel reduction over init
and the transformed elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of the given chunk size, where each chunk is processed by a worker. By default, we employ the guided partition algorithm.
This method is equivalent to the parallel execution of the following loop:
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::transform_reduce_dynamic | ( | B && | first, |
E && | last, | ||
T & | init, | ||
BOP && | bop, | ||
UOP && | uop, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel transform-reduce task using the dynamic partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
BOP | binary reducer type |
UOP | unary transformion type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied in unspecified order to the results of uop |
uop | unary operator that will be applied to transform each element in the range to the result type |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the transformed elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::transform_reduce_guided | ( | B && | first, |
E && | last, | ||
T & | init, | ||
BOP && | bop, | ||
UOP && | uop, | ||
H && | chunk_size = 1 |
||
) |
constructs a STL-styled parallel transform-reduce task using the guided partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
BOP | binary reducer type |
UOP | unary transformion type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied in unspecified order to the results of uop |
uop | unary operator that will be applied to transform each element in the range to the result type |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the transformed elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.
Task tf::FlowBuilder::transform_reduce_static | ( | B && | first, |
E && | last, | ||
T & | init, | ||
BOP && | bop, | ||
UOP && | uop, | ||
H && | chunk_size = 0 |
||
) |
constructs a STL-styled parallel transform-reduce task using the static partition algorithm
B | beginning iterator type |
E | ending iterator type |
T | result type |
BOP | binary reducer type |
UOP | unary transformion type |
H | chunk size type |
first | iterator to the beginning (inclusive) |
last | iterator to the end (exclusive) |
init | initial value of the reduction and the storage for the reduced result |
bop | binary operator that will be applied in unspecified order to the results of uop |
uop | unary operator that will be applied to transform each element in the range to the result type |
chunk_size | chunk size |
The task spawns a subflow to perform parallel reduction over init
and the transformed elements in the range [first, last)
. The reduced result is store in init
. The runtime partitions the range into chunks of size chunk_size
, where each chunk is processed by a worker.
Arguments are templated to enable stateful passing using std::reference_wrapper.