Taskflow
2.4-master-branch
|
execution interface for running a taskflow graph More...
#include <executor.hpp>
Public Member Functions | |
Executor (size_t N=std::thread::hardware_concurrency(), size_t M=cuda_num_devices()) | |
constructs the executor with N/M cpu/gpu worker threads | |
Executor (size_t N=std::thread::hardware_concurrency()) | |
constructs the executor with N worker threads | |
~Executor () | |
destructs the executor | |
std::future< void > | run (Taskflow &taskflow) |
runs the taskflow once More... | |
template<typename C > | |
std::future< void > | run (Taskflow &taskflow, C &&callable) |
runs the taskflow once and invoke a callback upon completion More... | |
std::future< void > | run_n (Taskflow &taskflow, size_t N) |
runs the taskflow for N times More... | |
template<typename C > | |
std::future< void > | run_n (Taskflow &taskflow, size_t N, C &&callable) |
runs the taskflow for N times and then invokes a callback More... | |
template<typename P > | |
std::future< void > | run_until (Taskflow &taskflow, P &&pred) |
runs the taskflow multiple times until the predicate becomes true and then invokes a callback More... | |
template<typename P , typename C > | |
std::future< void > | run_until (Taskflow &taskflow, P &&pred, C &&callable) |
runs the taskflow multiple times until the predicate becomes true and then invokes the callback More... | |
void | wait_for_all () |
wait for all pending graphs to complete | |
size_t | num_workers () const |
queries the number of worker threads (can be zero) | |
size_t | num_topologies () const |
queries the number of running topologies at the time of this call More... | |
size_t | num_domains () const |
queries the number of worker domains More... | |
int | this_worker_id () const |
queries the id of the caller thread in this executor More... | |
template<typename Observer , typename... Args> | |
std::shared_ptr< Observer > | make_observer (Args &&... args) |
constructs an observer to inspect the activities of worker threads More... | |
template<typename Observer > | |
void | remove_observer (std::shared_ptr< Observer > observer) |
removes the associated observer | |
size_t | num_observers () const |
queries the number of observers | |
execution interface for running a taskflow graph
An executor object manages a set of worker threads and implements an efficient work-stealing scheduling algorithm to run a taskflow.
std::shared_ptr< Observer > tf::Executor::make_observer | ( | Args &&... | args | ) |
constructs an observer to inspect the activities of worker threads
Each executor manage a list of observers in shared ownership with callers.
Observer | observer type derived from tf::ObserverInterface |
ArgsT... | argument parameter pack |
args | arguments to forward to the constructor of the observer |
|
inline |
queries the number of worker domains
Each domain manages a subset of worker threads to execute domain-specific tasks, for example, HOST tasks and CUDA tasks.
|
inline |
queries the number of running topologies at the time of this call
When a taskflow is submitted to an executor, a topology is created to store runtime metadata of the running taskflow.
|
inline |
runs the taskflow once
taskflow | a tf::Taskflow object |
std::future< void > tf::Executor::run | ( | Taskflow & | taskflow, |
C && | callable | ||
) |
runs the taskflow once and invoke a callback upon completion
taskflow | a tf::Taskflow object |
callable | a callable object to be invoked after this run |
|
inline |
runs the taskflow for N times
taskflow | a tf::Taskflow object |
N | number of runs |
std::future< void > tf::Executor::run_n | ( | Taskflow & | taskflow, |
size_t | N, | ||
C && | callable | ||
) |
runs the taskflow for N times and then invokes a callback
taskflow | a tf::Taskflow |
N | number of runs |
callable | a callable object to be invoked after this run |
std::future< void > tf::Executor::run_until | ( | Taskflow & | taskflow, |
P && | pred | ||
) |
runs the taskflow multiple times until the predicate becomes true and then invokes a callback
taskflow | a tf::Taskflow |
pred | a boolean predicate to return true for stop |
std::future< void > tf::Executor::run_until | ( | Taskflow & | taskflow, |
P && | pred, | ||
C && | callable | ||
) |
runs the taskflow multiple times until the predicate becomes true and then invokes the callback
taskflow | a tf::Taskflow |
pred | a boolean predicate to return true for stop |
callable | a callable object to be invoked after this run |
|
inline |
queries the id of the caller thread in this executor
Each worker has an unique id from 0 to N-1 exclusive to the associated executor. If the caller thread does not belong to the executor, -1 is returned.