Games Task Scheduler (GTS)
A multi-processor scheduling framework for games engines
gts::ComputeResource Class Referenceabstract

A ComputeResource represents a entity that can execute a Workload in a Node. More...

#include <ComputeResource.h>

Inherited by gts::MicroScheduler_ComputeResource.

Public Member Functions

 ComputeResource ()
 
virtual ~ComputeResource ()=default
 
virtual ComputeResourceType::Enum type () const =0
 
virtual bool canExecute (Node *pNode) const =0
 
virtual uint32_t processorCount () const =0
 
GTS_INLINE uint32_t maxRank () const
 
GTS_INLINE double executionNormalizationFactor () const
 
GTS_INLINE ComputeResourceId id () const
 
void setExecutionNormalizationFactor (double exeWeight)
 Sets the normalization factor applied to each Nodes execution time. This factor normalizes all execution times into a single ComputeResrouce's execution space. More...
 
virtual bool process (Schedule *pSchedule, bool canBlock)=0
 
virtual void notify (Schedule *pSchedule)=0
 
virtual void registerSchedule (Schedule *)
 
virtual void unregisterSchedule (Schedule *)
 
GTS_INLINE void _setMaxRank (uint32_t maxRank)
 Sets the maximum Node rank this ComputeResouce can execute. More...
 

Protected Attributes

QueueMPSC< Node * > m_affinityQueue
 

Detailed Description

A ComputeResource represents a entity that can execute a Workload in a Node.

Constructor & Destructor Documentation

◆ ComputeResource()

gts::ComputeResource::ComputeResource ( )

Assign a resource ID.

◆ ~ComputeResource()

virtual gts::ComputeResource::~ComputeResource ( )
virtualdefault

For polymorphic destruction.

Member Function Documentation

◆ _setMaxRank()

GTS_INLINE void gts::ComputeResource::_setMaxRank ( uint32_t  maxRank)
inline

Sets the maximum Node rank this ComputeResouce can execute.

Remarks
Internal use only.
Not thread-safe.

◆ canExecute()

virtual bool gts::ComputeResource::canExecute ( Node pNode) const
pure virtual
Returns
True if this ComputeResource can execute the specified Node.

Implemented in gts::MicroScheduler_ComputeResource.

◆ executionNormalizationFactor()

GTS_INLINE double gts::ComputeResource::executionNormalizationFactor ( ) const
inline
Returns
The normalization factor applied to execution times produced by this compute resource.

◆ id()

GTS_INLINE ComputeResourceId gts::ComputeResource::id ( ) const
inline
Returns
This ComputeResource's unique id.

◆ maxRank()

GTS_INLINE uint32_t gts::ComputeResource::maxRank ( ) const
inline
Returns
The maximum Node rank this ComputeResouce can execute.

◆ notify()

virtual void gts::ComputeResource::notify ( Schedule pSchedule)
pure virtual

Notify this ComputeResrouce of work available.

Implemented in gts::MicroScheduler_ComputeResource.

◆ process()

virtual bool gts::ComputeResource::process ( Schedule pSchedule,
bool  canBlock 
)
pure virtual

Process pSchedule until it is complete. If 'canBlock' is true, this ComputeResouces can use the calling thread; if false, it must fork its own thread.

Returns
True if a node was processed.

Implemented in gts::MicroScheduler_ComputeResource.

◆ processorCount()

virtual uint32_t gts::ComputeResource::processorCount ( ) const
pure virtual
Returns
The number of independent processing elements.

Implemented in gts::MicroScheduler_ComputeResource.

◆ registerSchedule()

virtual void gts::ComputeResource::registerSchedule ( Schedule )
inlinevirtual

Register a Schedule with this ComputeResrouce.

Reimplemented in gts::MicroScheduler_ComputeResource.

◆ setExecutionNormalizationFactor()

void gts::ComputeResource::setExecutionNormalizationFactor ( double  exeWeight)
inline

Sets the normalization factor applied to each Nodes execution time. This factor normalizes all execution times into a single ComputeResrouce's execution space.

Todo:
Have the MicroScheduler set this during initialization instead of the user.

◆ type()

virtual ComputeResourceType::Enum gts::ComputeResource::type ( ) const
pure virtual
Returns
This ComputeResource's type.

Implemented in gts::MicroScheduler_ComputeResource.

◆ unregisterSchedule()

virtual void gts::ComputeResource::unregisterSchedule ( Schedule )
inlinevirtual

Unregister a Schedule from this ComputeResrouce.

Reimplemented in gts::MicroScheduler_ComputeResource.

Member Data Documentation

◆ m_affinityQueue

QueueMPSC<Node*> gts::ComputeResource::m_affinityQueue
protected

Nodes that require this ComputeResource. They are send from other ComputeResouce while processing a Schedule. These Node must be processed first when looking for work.