ComputeManager Class Reference

HiCR: HiCR::ComputeManager Class Reference
HiCR
HiCR::ComputeManager Class Referenceabstract

#include <computeManager.hpp>

Inheritance diagram for HiCR::ComputeManager:
HiCR::backend::ascend::ComputeManager HiCR::backend::boost::ComputeManager HiCR::backend::nosv::ComputeManager HiCR::backend::opencl::ComputeManager HiCR::backend::pthreads::ComputeManager

Public Member Functions

virtual ~ComputeManager ()=default
 
virtual std::unique_ptr< HiCR::ProcessingUnitcreateProcessingUnit (std::shared_ptr< HiCR::ComputeResource > resource) const =0
 
virtual std::unique_ptr< HiCR::ExecutionStatecreateExecutionState (std::shared_ptr< HiCR::ExecutionUnit > executionUnit, void *const argument=nullptr) const =0
 
__INLINE__ void initialize (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
 
__INLINE__ void start (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit, std::unique_ptr< HiCR::ExecutionState > &executionState)
 
__INLINE__ void suspend (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
 
__INLINE__ void resume (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
 
__INLINE__ void terminate (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
 
__INLINE__ void await (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
 

Protected Member Functions

virtual void initializeImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)=0
 
virtual void startImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit, std::unique_ptr< HiCR::ExecutionState > &executionState)=0
 
virtual void suspendImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)=0
 
virtual void resumeImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)=0
 
virtual void terminateImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)=0
 
virtual void awaitImpl (std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)=0
 

Detailed Description

This class represents an abstract definition of a compute manager. That is, the set of functions to be implemented by a given backend that allows the discovery of compute resources, the definition of replicable execution units (functions or kernels to run), and the instantiation of execution states, that represent the execution lifetime of an execution unit.

Constructor & Destructor Documentation

◆ ~ComputeManager()

virtual HiCR::ComputeManager::~ComputeManager ( )
virtualdefault

Member Function Documentation

◆ await()

__INLINE__ void HiCR::ComputeManager::await ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
inline

Suspends the execution of the caller until the given processing unit has finalized

Parameters
[in]processingUnitThe processing unit to wait for

◆ awaitImpl()

virtual void HiCR::ComputeManager::awaitImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
protectedpure virtual

Internal implementation of the await function

Parameters
[in]processingUnitThe processing to wait for

◆ createExecutionState()

virtual std::unique_ptr< HiCR::ExecutionState > HiCR::ComputeManager::createExecutionState ( std::shared_ptr< HiCR::ExecutionUnit executionUnit,
void *const  argument = nullptr 
) const
pure virtual

This function enables the creation of an empty execution state object.

The instantiation of its internal memory structures is delayed until explicit initialization to reduce memory usage when, for example, scheduling many tasks that do not need to execute at the same time.

Parameters
[in]executionUnitThe replicable state-less execution unit to instantiate into an execution state
[in]argumentArgument (closure) to pass to the execution unit to make this execution state unique
Returns
A unique pointer to the newly create execution state. It needs to be unique because the state cannot be simultaneously executed my multiple processing units

◆ createProcessingUnit()

virtual std::unique_ptr< HiCR::ProcessingUnit > HiCR::ComputeManager::createProcessingUnit ( std::shared_ptr< HiCR::ComputeResource resource) const
pure virtual

Creates a new processing unit from the provided compute resource

Parameters
[in]resourceThis is the identifier of the compute resource to use to instantiate into a processing unit. The identifier should be one of those provided by the backend. Providing an arbitrary identifier may lead to unexpected behavior.
Returns
A unique pointer to the newly created processing unit. It is important to preserve the uniqueness of this object, since it represents a physical resource (e.g., core) and we do not want to assign it to multiple workers.

Implemented in HiCR::backend::boost::ComputeManager, HiCR::backend::nosv::ComputeManager, and HiCR::backend::pthreads::ComputeManager.

◆ initialize()

__INLINE__ void HiCR::ComputeManager::initialize ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
inline

Initializes the a processing unit and leaves it ready to execute work

Parameters
[in]processingUnitThe procesing unit to initialize

◆ initializeImpl()

virtual void HiCR::ComputeManager::initializeImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
protectedpure virtual

Backend-specific implementation of the initialize function

Parameters
[in]processingUnitThe processing unit to initialize

◆ resume()

__INLINE__ void HiCR::ComputeManager::resume ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
inline

Resumes the execution of the processing unit.

Parameters
[in]processingUnitThe processing unit to resume

◆ resumeImpl()

virtual void HiCR::ComputeManager::resumeImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
protectedpure virtual

Internal implementation of the resume function

Parameters
[in]processingUnitThe processing unit to resume

◆ start()

__INLINE__ void HiCR::ComputeManager::start ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit,
std::unique_ptr< HiCR::ExecutionState > &  executionState 
)
inline

Starts running an executing state on a processing unit

Parameters
[in]processingUnitThe processing unit to initiate computation with
[in]executionStateThe execution state to start running with the given processing unit

◆ startImpl()

virtual void HiCR::ComputeManager::startImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit,
std::unique_ptr< HiCR::ExecutionState > &  executionState 
)
protectedpure virtual

Internal implmentation of the start function

Parameters
[in]processingUnitThe processing unit to initiate computation with
[in]executionStateThe execution state to start running with the given processing unit

◆ suspend()

__INLINE__ void HiCR::ComputeManager::suspend ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
inline

Triggers the suspension of the resource. All the elements that make the resource remain active in memory, but will not execute.

Parameters
[in]processingUnitThe processing unit to suspend

◆ suspendImpl()

virtual void HiCR::ComputeManager::suspendImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
protectedpure virtual

Internal implementation of the suspend function

Parameters
[in]processingUnitThe processing unit to suspend

◆ terminate()

__INLINE__ void HiCR::ComputeManager::terminate ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
inline

Requests the processing unit to finalize as soon as possible. This is an asynchronous operation, so returning from this function does not guarantee that the resource has terminated.

Parameters
[in]processingUnitThe processing unit to terminate

◆ terminateImpl()

virtual void HiCR::ComputeManager::terminateImpl ( std::unique_ptr< HiCR::ProcessingUnit > &  processingUnit)
protectedpure virtual

Internal implementation of the terminate function

Parameters
[in]processingUnitThe processing unit to terminate

The documentation for this class was generated from the following file: