|
GREM 3.12.0
Game/Rendering Engine Modules for C++
|
Statically scheduled task graph builder. More...
#include <GREM/execution/Scheduler.hpp>
Public Member Functions | |
| void | clear () noexcept |
| Erase all tasks from the task list and reset the scheduler to an empty state. | |
| template<auto TaskFunction> | |
| Scheduler & | addTask (String name={}) |
| Append a basic task to the task list. | |
| template<auto TaskFunction> | |
| Scheduler & | addOptionalTask (String name={}) |
| Append an optional basic task to the task list. | |
| template<auto TaskFunction> | |
| Scheduler & | addParallelTask (Task::ParallelCount parallelism, String name={}) |
| Append a data-parallel task to the task list that performs a chunked operation over a specific resource. | |
| template<auto TaskFunction> | |
| Scheduler & | addOptionalParallelTask (Task::ParallelCount parallelism, String name={}) |
| Append an optional data-parallel task to the task list that performs a chunked operation over a specific resource. | |
| template<auto TaskFunction> | |
| Scheduler & | addUnsafeParallelTask (Task::ParallelCount parallelism, String name={}) |
| Append a data-parallel task to the task list that performs a chunked operation over a specific resource, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data. | |
| template<auto TaskFunction> | |
| Scheduler & | addOptionalUnsafeParallelTask (Task::ParallelCount parallelism, String name={}) |
| Append an optional data-parallel task to the task list that performs a chunked operation over a specific resource, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data. | |
| template<auto TaskFunction> | |
| Scheduler & | addParallelTransformationTask (Task::ParallelCount parallelism, String name={}) |
| Append a data-parallel task to the task list that performs a chunked transformation over a specific entity range. | |
| template<auto TaskFunction> | |
| Scheduler & | addOptionalParallelTransformationTask (Task::ParallelCount parallelism, String name={}) |
| Append an optional data-parallel task to the task list that performs a chunked transformation over a specific entity range. | |
| template<auto TaskFunction> | |
| Scheduler & | addUnsafeParallelTransformationTask (Task::ParallelCount parallelism, String name={}) |
| Append a data-parallel task to the task list that performs a chunked transformation over a specific entity range, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data. | |
| template<auto TaskFunction> | |
| Scheduler & | addOptionalUnsafeParallelTransformationTask (Task::ParallelCount parallelism, String name={}) |
| Append an optional data-parallel task to the task list that performs a chunked transformation over a specific entity range, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data. | |
| template<auto TaskFunction, auto ReductionFunction> | |
| Scheduler & | addParallelReductionTask (Task::ParallelCount parallelism, String name={}) |
| Append a data-parallel task to the task list that performs a chunked reduction operation over a specific entity range and outputs the result to a specific resource. | |
| template<auto TaskFunction, auto ReductionFunction> | |
| Scheduler & | addOptionalParallelReductionTask (Task::ParallelCount parallelism, String name={}) |
| Append an optional data-parallel task to the task list that performs a chunked reduction operation over a specific entity range and outputs the result to a specific resource. | |
| Scheduler & | addBarrier () |
| Append a full synchronization barrier to the task list. | |
| Schedule< EntReg, ResReg > | buildSchedule (String name={}) |
| Consume the current task list, calculate the dependencies between the tasks and schedule the final execution graph. | |
Statically scheduled task graph builder.
This class is intended to be used at application startup to automatically determine the data dependencies between a dynamic list of ordered tasks (which can e.g. be loaded by dynamically linked plugins) and generate a static execution graph in the form of a Schedule that specifies which tasks are able to be run independently in parallel, such that they can be efficiently executed by a multithreaded Executor any number of times.
There are four kinds of tasks that can be scheduled, using the following categories of functions:
The parallel task types also have "unsafe" variants, e.g. addUnsafeParallelTask(), that don't enforce read-only access to the non-chunked data. These can be useful when doing manual synchronization/separation of the shared data, separate from the scheduling system.
Each task type also has a corresponding "optional" variant, e.g. addOptionalTask(), that does not throw an exception when there are missing task arguments, and simply skips the task instead in that case.
| EntReg | concrete entity registry type used by the scheduled tasks, e.g. some specialization of EntityRegistry or EntityTable. |
| ResReg | concrete resource registry type used by the scheduled tasks, e.g. some specialization of ResourceRegistry or ResourceTable. |
|
inlinenoexcept |
Erase all tasks from the task list and reset the scheduler to an empty state.
|
inline |
Append a basic task to the task list.
| TaskFunction | contextless function object that executes the task. The task function should return void and may accept the following kinds of parameters:
|
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional basic task to the task list.
| TaskFunction | contextless function object that executes the task. The task function should return void and may accept the following kinds of parameters:
|
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a data-parallel task to the task list that performs a chunked operation over a specific resource.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional data-parallel task to the task list that performs a chunked operation over a specific resource.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a data-parallel task to the task list that performs a chunked operation over a specific resource, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional data-parallel task to the task list that performs a chunked operation over a specific resource, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a data-parallel task to the task list that performs a chunked transformation over a specific entity range.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional data-parallel task to the task list that performs a chunked transformation over a specific entity range.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a data-parallel task to the task list that performs a chunked transformation over a specific entity range, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional data-parallel task to the task list that performs a chunked transformation over a specific entity range, without any of the compile-time safety checks that prevent sub-tasks from accidentally mutating shared data.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a data-parallel task to the task list that performs a chunked reduction operation over a specific entity range and outputs the result to a specific resource.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| ReductionFunction | contextless function object that takes two instances of the resource type output by TaskFunction and reduces them into one, returning the result. This reduction function is used to combine the intermediate results produced by the main task function for each chunk. It may also, in addition to the two resource instances, accept the same kinds of read-only parameters as the main task function at the end of the parameter list. |
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append an optional data-parallel task to the task list that performs a chunked reduction operation over a specific entity range and outputs the result to a specific resource.
| TaskFunction | contextless function object that executes one chunk of the task. The task function should return void and may accept the following kinds of parameters:
|
| ReductionFunction | contextless function object that takes two instances of the resource type output by TaskFunction and reduces them into one, returning the result. This reduction function is used to combine the intermediate results produced by the main task function for each chunk. It may also, in addition to the two resource instances, accept the same kinds of read-only parameters as the main task function at the end of the parameter list. |
| parallelism | number of parallel chunks to split the task into. Should typically be less than or equal to the executor.getMaxParallelism() value of the executor that the schedule will be executed on. |
| name | optional UTF-8-encoded human-readable name of the task. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |
|
inline |
Append a full synchronization barrier to the task list.
This causes all subsequent tasks added to the task list to unconditionally synchronize with all tasks that were added before the barrier, preventing them from running in parallel with those tasks.
This may be useful for synchronizing tasks that have global data dependencies, unknown to the scheduling system.
|
inlinenodiscard |
Consume the current task list, calculate the dependencies between the tasks and schedule the final execution graph.
| name | optional UTF-8-encoded human-readable name of the schedule. |
| std::length_error | if an internal size limit was exceeded. |
| std::bad_array_new_length | if an internal size limit was exceeded. |
| std::bad_alloc | on allocation failure. |