/home/runner/work/HiCR/HiCR/include/hicr/frontends/tasking/worker.hpp Source File
HiCR
|
worker.hpp
Go to the documentation of this file.
148 };
182 __INLINE__ void setCallbackMap(workerCallbackMap_t *callbackMap) { _callbackMap = callbackMap; }
207 if (_processingUnits.empty()) HICR_THROW_LOGIC("Attempting to initialize worker without any assigned resources");
210 if (prevState != state_t::uninitialized && prevState != state_t::terminated) HICR_THROW_RUNTIME("Attempting to initialize already initialized worker");
228 if (prevState != state_t::ready) HICR_THROW_RUNTIME("Attempting to start worker that is not in the 'initialized' state");
233 // Creating new execution unit (the processing unit must support an execution unit of 'host' type)
234 auto executionUnit = HiCR::backend::pthreads::ComputeManager::createExecutionUnit([](void *worker) { static_cast<HiCR::tasking::Worker *>(worker)->mainLoop(); });
283 if (prevState != state_t::running && prevState != state_t::suspending) HICR_THROW_RUNTIME("Attempting to stop worker that is not in a terminate-able state");
294 if (prevState != state_t::terminating && prevState != state_t::running && prevState != state_t::suspended && prevState != state_t::suspending && prevState != state_t::resuming)
295 HICR_THROW_RUNTIME("Attempting to wait for a worker that has not yet started or has already terminated");
309 __INLINE__ void addProcessingUnit(std::unique_ptr<HiCR::ProcessingUnit> pu) { _processingUnits.push_back(std::move(pu)); }
316 __INLINE__ std::vector<std::unique_ptr<HiCR::ProcessingUnit>> &getProcessingUnits() { return _processingUnits; }
323 __INLINE__ void setSuspendInterval(size_t suspendIntervalMs) { _suspendIntervalMs = suspendIntervalMs; }
400 auto executionState = _executionStateComputeManager->createExecutionState(_currentTask->getExecutionUnit(), _currentTask);
420 for (size_t i = 1; i < _processingUnits.size(); i++) _processingUnitComputeManager->suspend(_processingUnits[i]);
429 for (size_t i = 1; i < _processingUnits.size(); i++) _processingUnitComputeManager->resume(_processingUnits[i]);
442 for (size_t i = 1; i < _processingUnits.size(); i++) _processingUnitComputeManager->terminate(_processingUnits[i]);
This file implements the compute manager for Pthreads backend.
Definition computeManager.hpp:48
__INLINE__ void initialize(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
Definition computeManager.hpp:81
__INLINE__ void suspend(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
Definition computeManager.hpp:123
__INLINE__ void start(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit, std::unique_ptr< HiCR::ExecutionState > &executionState)
Definition computeManager.hpp:103
virtual std::unique_ptr< HiCR::ExecutionState > createExecutionState(std::shared_ptr< HiCR::ExecutionUnit > executionUnit, void *const argument=nullptr) const =0
__INLINE__ void terminate(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
Definition computeManager.hpp:163
__INLINE__ void await(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
Definition computeManager.hpp:177
__INLINE__ void resume(std::unique_ptr< HiCR::ProcessingUnit > &processingUnit)
Definition computeManager.hpp:143
static __INLINE__ std::shared_ptr< HiCR::ExecutionUnit > createExecutionUnit(const pthreadFc_t &threadFunction)
Definition computeManager.hpp:67
Definition callbackMap.hpp:40
Definition task.hpp:57
__INLINE__ std::shared_ptr< HiCR::ExecutionUnit > getExecutionUnit() const
Definition task.hpp:152
__INLINE__ void initialize(std::unique_ptr< HiCR::ExecutionState > executionState)
Definition task.hpp:159
__INLINE__ const HiCR::ExecutionState::state_t getState()
Definition task.hpp:131
Definition worker.hpp:65
HiCR::tasking::CallbackMap< Worker *, callback_t > workerCallbackMap_t
Definition worker.hpp:102
__INLINE__ void setSuspendInterval(size_t suspendIntervalMs)
Definition worker.hpp:323
__INLINE__ std::vector< std::unique_ptr< HiCR::ProcessingUnit > > & getProcessingUnits()
Definition worker.hpp:316
Worker(HiCR::ComputeManager *executionStateComputeManager, HiCR::ComputeManager *processingUnitComputeManager, pullFunction_t pullFunction, workerCallbackMap_t *callbackMap=nullptr)
Definition worker.hpp:158
__INLINE__ HiCR::tasking::Task * getCurrentTask()
Definition worker.hpp:196
__INLINE__ workerCallbackMap_t * getCallbackMap()
Definition worker.hpp:189
__INLINE__ void addProcessingUnit(std::unique_ptr< HiCR::ProcessingUnit > pu)
Definition worker.hpp:309
virtual __INLINE__ bool checkResumeConditions()
Definition worker.hpp:332
__INLINE__ void setCallbackMap(workerCallbackMap_t *callbackMap)
Definition worker.hpp:182
Provides a definition for the abstract compute manager class.
Provides a definition for a HiCR ProcessingUnit class.
Provides a failure model and corresponding exception classes.
This file implements the HiCR task class.
constexpr size_t _MILISECONDS_PER_SECOND
Definition worker.hpp:50
std::function< HiCR::tasking::Task *()> pullFunction_t
Definition worker.hpp:55
constexpr size_t _DEFAULT_SUSPEND_INTERVAL_MS
Definition worker.hpp:45
Generated by