.
This commit is contained in:
@@ -224,6 +224,7 @@ protected:
|
||||
wfr::wfs::Workflow* workflow;
|
||||
wfr::wfs::ActivityImplementationType deviceType;
|
||||
wfr_id_t deviceID;
|
||||
wfr_id_t subDeviceId;
|
||||
wfr::wfs::ComputingResourceStatus oldStatus;
|
||||
wfr::wfs::ComputingResourceStatus newStatus;
|
||||
wfr::wfs::ActivityInstance* executedTask;
|
||||
@@ -231,13 +232,13 @@ protected:
|
||||
wfr_size_t deviceSlotCount;
|
||||
|
||||
public:
|
||||
ComputingResourceStatusEvent(wfr::wfs::Workflow* wf, wfr::wfs::ActivityImplementationType deviceType, wfr_id_t deviceID,
|
||||
ComputingResourceStatusEvent(wfr::wfs::Workflow* wf, wfr::wfs::ActivityImplementationType deviceType, wfr_id_t deviceID, wfr_id_t subDeviceId,
|
||||
wfr::wfs::ComputingResourceStatus oldStatus, wfr::wfs::ComputingResourceStatus newStatus,
|
||||
wfr::wfs::ActivityInstance* executedTask = nullptr, wfr::wfs::AtomicActivityImplementation* executedImpl = nullptr,
|
||||
wfr_size_t deviceSlotCount = 0,
|
||||
wfr_timestamp_sc_t timestamp = std::chrono::system_clock::now()) noexcept
|
||||
: Event(EventType::ComputingResourceStatusEvent, timestamp), workflow(wf), deviceType(deviceType),
|
||||
deviceID(deviceID), oldStatus(oldStatus), newStatus(newStatus), executedTask(executedTask),
|
||||
deviceID(deviceID), subDeviceId(subDeviceId), oldStatus(oldStatus), newStatus(newStatus), executedTask(executedTask),
|
||||
executedImpl(executedImpl), deviceSlotCount(deviceSlotCount) {}
|
||||
|
||||
wfr::wfs::ActivityImplementationType getDeviceType() const noexcept { return deviceType; }
|
||||
@@ -246,6 +247,8 @@ public:
|
||||
|
||||
wfr_id_t getDeviceID() const noexcept { return deviceID; }
|
||||
|
||||
wfr_id_t getDeviceSubID() const noexcept { return subDeviceId; }
|
||||
|
||||
wfr::wfs::ComputingResourceStatus getNewStatus() const noexcept { return newStatus; }
|
||||
|
||||
wfr::wfs::ComputingResourceStatus getOldStatus() const noexcept { return oldStatus; }
|
||||
@@ -261,6 +264,7 @@ public:
|
||||
static std::shared_ptr<ComputingResourceStatusEvent> fireEvent( wfr::wfs::Workflow* wf,
|
||||
wfr::wfs::ActivityImplementationType deviceType,
|
||||
wfr_id_t deviceID,
|
||||
wfr_id_t subDeviceId,
|
||||
wfr::wfs::ComputingResourceStatus oldStatus,
|
||||
wfr::wfs::ComputingResourceStatus newStatus,
|
||||
wfr::wfs::ActivityInstance* executedTask = nullptr,
|
||||
|
||||
@@ -25,11 +25,12 @@ class AbstractResource {
|
||||
public:
|
||||
const ResourceClass resourceClass;
|
||||
const std::string resourceIdentifier;
|
||||
const wfr_id_t resourceId;
|
||||
|
||||
// Public Functions
|
||||
public:
|
||||
AbstractResource( ResourceClass resourceClass, const std::string& resourceIdentifier ) noexcept
|
||||
: resourceClass(resourceClass), resourceIdentifier(resourceIdentifier) {}
|
||||
AbstractResource( ResourceClass resourceClass, const std::string& resourceIdentifier, const wfr_id_t resourceId ) noexcept
|
||||
: resourceClass(resourceClass), resourceIdentifier(resourceIdentifier), resourceId(resourceId) {}
|
||||
virtual ~AbstractResource() {}
|
||||
|
||||
virtual bool hasCapability(const RequiredResourceCapability& type) const noexcept = 0;
|
||||
@@ -100,8 +101,8 @@ public:
|
||||
|
||||
// Public Functions
|
||||
public:
|
||||
ResourceBase(ResourceClass resourceClass, const std::string& resourceIdentifier, RType& resourceType ) noexcept
|
||||
: AbstractResource(resourceClass, resourceIdentifier), resourceType(resourceType) {}
|
||||
ResourceBase(ResourceClass resourceClass, const std::string& resourceIdentifier, const wfr_id_t resourceId, RType& resourceType ) noexcept
|
||||
: AbstractResource(resourceClass, resourceIdentifier, resourceId), resourceType(resourceType) {}
|
||||
|
||||
virtual bool hasCapability(const RequiredResourceCapability& type) const noexcept { return resourceType.hasCapability(type); }
|
||||
virtual bool hasCapability(wfr::resource::ResourceCapabilityType type) const noexcept { return resourceType.hasCapability(type); }
|
||||
@@ -138,17 +139,20 @@ protected:
|
||||
|
||||
// Public Functions
|
||||
public:
|
||||
ComputingResource( const std::string& resourceIdentifier, ComputingResourceType& resourceType ) noexcept
|
||||
: ResourceBase(ResourceClass::ComputingResource, resourceIdentifier, resourceType) {
|
||||
ComputingResource( const std::string& resourceIdentifier, const wfr_id_t resourceId, ComputingResourceType& resourceType ) noexcept
|
||||
: ResourceBase(ResourceClass::ComputingResource, resourceIdentifier, resourceId, resourceType) {
|
||||
resourceType.addResource(this);
|
||||
}
|
||||
|
||||
wfr_size_t getMaxSlotCount() const noexcept { return resourceType.maxSlots; }
|
||||
wfr_size_t getReservedSlotCount() const noexcept { return reservedSlots; }
|
||||
wfr_size_t getBusySlotCount() const noexcept { return busySlots; }
|
||||
wfr_size_t getFreeSlotCount() const noexcept { return resourceType.maxSlots - (busySlots + reservedSlots); }
|
||||
wfr_size_t getFreeSlotCount() const noexcept {
|
||||
auto nonFreeSlots = busySlots + reservedSlots;
|
||||
return nonFreeSlots >= resourceType.maxSlots ? 0 : resourceType.maxSlots - nonFreeSlots;
|
||||
}
|
||||
|
||||
bool reserveSlots(const wfr_size_t& slots) noexcept;
|
||||
bool reserveSlots(const wfr_size_t& slots, bool requireFreeSlots = false) noexcept;
|
||||
bool markReservedSlotsBusy(const wfr_size_t& slots) noexcept;
|
||||
bool markFreeSlotsBusy(const wfr_size_t& slots) noexcept;
|
||||
bool releaseBusySlots(const wfr_size_t& slots) noexcept;
|
||||
|
||||
@@ -13,7 +13,13 @@
|
||||
#include <wfr/common/types/ResourceTypes.h>
|
||||
|
||||
|
||||
|
||||
namespace wfr {
|
||||
|
||||
namespace wfs {
|
||||
class AtomicActivityInstance;
|
||||
}
|
||||
|
||||
namespace resource {
|
||||
|
||||
class AbstractResource;
|
||||
@@ -32,6 +38,13 @@ private:
|
||||
std::map<std::string, ComputingResourceType*> computingResourceTypes;
|
||||
std::map<std::string, ComputingResource*> computingResources;
|
||||
|
||||
private:
|
||||
static std::atomic<wfr_id_t> _nextResourceId;
|
||||
|
||||
static wfr_id_t getNextResourceId() {
|
||||
return _nextResourceId.fetch_add(1);
|
||||
}
|
||||
|
||||
// Non-public functions
|
||||
private:
|
||||
ResourceManager(std::string resourceConfigFile, bool cpuAutoConfig, bool printResourceTable);
|
||||
@@ -53,11 +66,12 @@ public:
|
||||
ComputingResource* getComputingResource(std::string identifier) const noexcept;
|
||||
std::vector<ComputingResource*> filterComputingResources(std::vector<RequiredResourceCapability> filter) const noexcept;
|
||||
|
||||
ComputingResourceReservation reserveComputingResource(ComputingResource* device, const wfr_size_t& slots = 1) noexcept;
|
||||
std::shared_ptr<ComputingResourceReservation> reserveComputingResource(ComputingResource* device, const wfr_size_t& slots, bool requireFreeSlots = false) noexcept;
|
||||
bool releaseComputingResources(ComputingResourceReservation* handle) noexcept;
|
||||
|
||||
wfr_size_t getComputingResourceTypeCount() const noexcept { return computingResourceTypes.size(); }
|
||||
std::vector<ComputingResourceType*> getComputingResourceTypes() const noexcept;
|
||||
std::vector<ComputingResourceType*> getCompatibleComputingResourceTypes(wfs::AtomicActivityInstance* activity) const noexcept;
|
||||
ComputingResourceType* getComputingResourceType(std::string name) const noexcept;
|
||||
|
||||
void printResourceTable(std::ostream& out) const noexcept;
|
||||
|
||||
@@ -25,20 +25,20 @@ public:
|
||||
wfs::AtomicActivityImplementation* const activityImplementation = nullptr;
|
||||
wep::WorkflowExecutionPlan* const wep = nullptr;
|
||||
resource::ComputingResource* const resource = nullptr;
|
||||
resource::ComputingResourceReservation reservationHandle;
|
||||
wfr_size_t slotCount = 0;
|
||||
|
||||
// Mutable properties that need to be accessed via getter-/setter-functions.
|
||||
// Some of them are invariant, but this class needs to be copyable, so no const properties :(
|
||||
private:
|
||||
prediction::ExecutionTimeResult prediction;
|
||||
std::shared_ptr<resource::ComputingResourceReservation> reservationHandle;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
SchedulingDecision(wfs::ActivityInstance* activityInstance, wfs::AtomicActivityImplementation* activityImplementation,
|
||||
wep::WorkflowExecutionPlan* wep, resource::ComputingResourceReservation reservationHandle) noexcept
|
||||
wep::WorkflowExecutionPlan* wep, std::shared_ptr<resource::ComputingResourceReservation> reservationHandle) noexcept
|
||||
: activityInstance(activityInstance), activityImplementation(activityImplementation), wep(wep),
|
||||
resource(reservationHandle.resource), reservationHandle(reservationHandle), slotCount(reservationHandle.slotCount) {}
|
||||
resource(reservationHandle->resource), slotCount(reservationHandle->slotCount), reservationHandle(reservationHandle) {}
|
||||
SchedulingDecision(wfs::ActivityInstance* activityInstance, wfs::AtomicActivityImplementation* activityImplementation,
|
||||
wep::WorkflowExecutionPlan* wep, resource::ComputingResource* resource = nullptr, const wfr_size_t& slotCount = 1) noexcept
|
||||
: activityInstance(activityInstance), activityImplementation(activityImplementation), wep(wep),
|
||||
@@ -47,6 +47,7 @@ public:
|
||||
|
||||
const prediction::ExecutionTimeResult& getPrediction() const noexcept { return prediction; }
|
||||
void setPrediction(const prediction::ExecutionTimeResult& prediction) noexcept { this->prediction = prediction; }
|
||||
std::shared_ptr<resource::ComputingResourceReservation> getComputingResourceReservation() noexcept { return reservationHandle; }
|
||||
};
|
||||
|
||||
} /* namespace scheduling */
|
||||
|
||||
@@ -216,7 +216,10 @@ public:
|
||||
|
||||
bool areAllInputsAvailable() const noexcept { return allInputsAvailable; }
|
||||
|
||||
void setAllInputsAvailable(const bool& areAvailable = true) noexcept { allInputsAvailable = areAvailable; }
|
||||
void setAllInputsAvailable(const bool& areAvailable = true) noexcept {
|
||||
allInputsAvailable = areAvailable;
|
||||
dirtyStateFlag = false;
|
||||
}
|
||||
|
||||
bool areAllOutputsAvailable() const noexcept { return allOutputsAvailable; }
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ public:
|
||||
virtual bool executePreExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual bool executePostExecutionHooks(bool earlyEvaluation) override;
|
||||
|
||||
virtual void notifyChildHasFinished(ActivityInstance& ai) noexcept override;
|
||||
};
|
||||
|
||||
} /* namespace wfs */
|
||||
|
||||
@@ -51,10 +51,12 @@ public:
|
||||
void setFinalised(bool v) noexcept { finalisedFlag = v; }
|
||||
|
||||
bool hasIterationFinished(wfr_id_t iterationID) const noexcept {
|
||||
if (iterationID < finishedIterations.size())
|
||||
return finishedIterations[iterationID];
|
||||
else
|
||||
if (iterationID < finishedIterations.size()) {
|
||||
bool retval = finishedIterations[iterationID];
|
||||
return retval;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool isIterationRunning(wfr_id_t iterationID)const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user