HTGS
v2.0
The Hybrid Task Graph Scheduler
|
Provides an interface to send data along RuleManager edges for processing state and dependencies. More...
#include <htgs/api/IRule.hpp>
Public Member Functions | |
IRule () | |
Creates an IRule. | |
IRule (bool useLocks) | |
Creates an IRule with locks specified. More... | |
virtual | ~IRule () override |
Destructor. | |
virtual bool | canTerminateRule (size_t pipelineId) override |
Virtual function to determine if a rule is ready to be terminated. More... | |
virtual void | shutdownRule (size_t pipelineId) override |
Virtual function that handles when a rule is being shutdown for a particular pipelineId. More... | |
virtual std::string | getName () override |
Virtual function to get the name of the IRule. More... | |
virtual void | applyRule (std::shared_ptr< T > data, size_t pipelineId)=0 |
Pure virtual function to process input data. More... | |
std::list< std::shared_ptr< U > > * | applyRuleFunction (std::shared_ptr< T > data, size_t pipelineId) |
Applies the virtual rule function and processes output. More... | |
void | addResult (std::shared_ptr< U > result) |
Adds a result value to the output. More... | |
void | addResult (U *result) |
Adds a result value to the output. More... | |
StateContainer< std::shared_ptr< T > > * | allocStateContainer (size_t height, size_t width) |
Allocates a two dimensional state container using the input type of the IRule. More... | |
template<class V > | |
StateContainer< V > * | allocStateContainer (size_t height, size_t width, V defaultValue) |
Allocates a two dimensional state container using the template argument. More... | |
StateContainer< std::shared_ptr< T > > * | allocStateContainer (size_t size) |
Allocates a one dimensional state container using the input type of the IRule. More... | |
template<class V > | |
StateContainer< V > * | allocStateContainer (size_t size, V defaultValue) |
Allocates a one dimensional state container using the input type of the IRule. More... | |
Public Member Functions inherited from htgs::AnyIRule | |
AnyIRule () | |
Creates an AnyIRule with locks enabled. | |
AnyIRule (bool useLocks) | |
Creates an AnyIRule with locks specified. More... | |
virtual | ~AnyIRule () |
Destructor. | |
std::mutex & | getMutex () |
Gets the mutex associated with this IRule. More... | |
bool | canUseLocks () const |
Gets whether the rule should use locks or not. More... | |
Private Attributes | |
std::list< std::shared_ptr< U > > * | output |
The output data that is sent as soon as the applyRule has finished processing. | |
Provides an interface to send data along RuleManager edges for processing state and dependencies.
The IRule is added to a Bookkeeper and is responsible for producing data for the Bookkeeper.
IRule behavior is defined based on the needs of an algorithm. In many cases, the IRule is used to manage the global state of the computation and issue new work when dependencies are satisfied.
The Bookkeeper accesses each IRule synchronously, so every IRule should not require a significant amount of computation to finish processing an IRule.
When a Bookkeeper is duplicated for an ExecutionPipeline, the IRule's within that Bookkeeper are shared, thus ensuring that no race conditions occur when updating the state when multiple Bookkeepers are attempting to process the same IRule.
It is possible to share the same IRule among multiple bookkeepers by wrapping the IRule into a std::shared_ptr and calling TaskGraphConf::addRuleEdge. The rule will be synchronously accessed among the bookkeepers.
Example Implementation
Example Usage:
|
inline |
Creates an IRule with locks specified.
useLocks | whether to use locks on the rule or not to ensure one thread accesses the rule at a time |
|
inline |
Adds a result value to the output.
result | the result value that is added |
|
inline |
Adds a result value to the output.
This will convert the pointer into a shared pointer.
result | the result value that is added |
|
inline |
Allocates a two dimensional state container using the input type of the IRule.
height | the height of the state container |
width | the width of the state container |
|
inline |
Allocates a two dimensional state container using the template argument.
height | the height of the state container |
width | the width of the state container |
defaultValue | the value that represents no data or default value |
V | the state container type |
|
inline |
Allocates a one dimensional state container using the input type of the IRule.
size | the size of the state container |
|
inline |
Allocates a one dimensional state container using the input type of the IRule.
size | the size of the state container |
defaultValue | the value that represents no data or default value |
V | the state container type |
|
pure virtual |
Pure virtual function to process input data.
Use the addResult function to add values to the output edge.
data | the input data |
pipelineId | the pipelineId |
Implemented in htgs::ExecutionPipelineBroadcastRule< T >.
|
inline |
Applies the virtual rule function and processes output.
data | the input data |
pipelineId | the pipelineId |
|
inlineoverridevirtual |
Virtual function to determine if a rule is ready to be terminated.
If there is no more data entering the RuleManager that is managing this IRule, then the rule will be automatically terminated.
pipelineId | the pipelineId associated with this rule |
TRUE | if the rule should be terminated |
FALSE | if the rule should not be terminated |
Implements htgs::AnyIRule.
Reimplemented in htgs::ExecutionPipelineBroadcastRule< T >.
|
inlineoverridevirtual |
Virtual function to get the name of the IRule.
Implements htgs::AnyIRule.
Reimplemented in htgs::ExecutionPipelineBroadcastRule< T >.
|
inlineoverridevirtual |
Virtual function that handles when a rule is being shutdown for a particular pipelineId.
pipelineId | the pipelineId to shutdown |
Implements htgs::AnyIRule.
Reimplemented in htgs::ExecutionPipelineBroadcastRule< T >.