.
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 {
|
||||
|
||||
@@ -39,6 +39,7 @@ private:
|
||||
std::condition_variable updateCondition;
|
||||
|
||||
bool enableWepDotFileWriter;
|
||||
bool enableWepProgressionWriter;
|
||||
bool enableEarlyEvaluation;
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
|
||||
@@ -60,11 +60,11 @@ private:
|
||||
private:
|
||||
wepNodeMap_t::mapped_type createWEPnode(wfs::Activity& a, wfs::ActivityInstance& ai, wepNodeMap_t& wepNodeMap);
|
||||
|
||||
void visitActivity(wfs::Activity& element, activityInstanceMap_t& instanceMap, wepNodeMap_t& wepNodeMap);
|
||||
void createActivityInstance(wfs::Activity& element, activityInstanceMap_t& instanceMap, wepNodeMap_t& wepNodeMap);
|
||||
|
||||
wepNodeMap_t::mapped_type createIterationWepNodes(wfr::wfs::ActivityInstance& ai, wepNodeMap_t::mapped_type& parent, wfr_id_t iterationID);
|
||||
|
||||
void handleChildren(wfs::CompositeActivityInstance& composite, wepNodeMap_t::mapped_type& parent, wepNodeMap_t::mapped_type* prevIter = nullptr);
|
||||
void createChildInstances(wfs::CompositeActivityInstance& composite, wepNodeMap_t::mapped_type& parent, wepNodeMap_t::mapped_type* prevIter = nullptr);
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
|
||||
@@ -64,15 +64,15 @@ protected:
|
||||
int statProcessedEvents;
|
||||
int statWrittenEvents;
|
||||
|
||||
/*typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::Workflow>> workflowMap_t;
|
||||
typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::Workflow>> workflowMap_t;
|
||||
typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::Activity>> activityMap_t;
|
||||
typedef std::map<wfr_id_t, std::shared_ptr<odbmodel::ActivityInstance>> activityInstanceMap_t;
|
||||
|
||||
workflowMap_t workflowMap;
|
||||
activityMap_t activityMap;
|
||||
activityInstanceMap_t activityInstanceMap;*/
|
||||
activityInstanceMap_t activityInstanceMap;
|
||||
|
||||
/*void handleWorkflowStatusEvent(WorkflowStatusEvent &event);
|
||||
void handleWorkflowStatusEvent(WorkflowStatusEvent &event);
|
||||
void handleActicityStatusEvent(ActivityStatusEvent &event);
|
||||
void handleActicityInstanceStatusEvent(ActivityInstanceStatusEvent &event);
|
||||
void handleComputingResourceStatusEvent(ComputingResourceStatusEvent &event);
|
||||
@@ -80,7 +80,7 @@ protected:
|
||||
|
||||
std::shared_ptr<odbmodel::Workflow> getWorkflowFromWfsMap(wfs::Workflow& wf);
|
||||
void persistWorkflow(std::shared_ptr<odbmodel::Workflow>& wfp, wfs::Workflow& wf);
|
||||
std::shared_ptr<odbmodel::Activity> getActivityFromWfsMap(wfs::Activity& act);
|
||||
std::shared_ptr<odbmodel::Activity> getActivityFromWfsMap(const wfs::Activity& act);
|
||||
void persistActivity(std::shared_ptr<odbmodel::Activity>& ap, wfs::Activity& a);
|
||||
std::shared_ptr<odbmodel::ActivityInstance> getActivityInstanceFromWfsMap(wfs::ActivityInstance& act);
|
||||
void persistActivityInstance(std::shared_ptr<odbmodel::ActivityInstance>& ap, wfs::ActivityInstance& a);
|
||||
@@ -89,7 +89,7 @@ protected:
|
||||
void writeActivityStatus(std::shared_ptr<odbmodel::Activity>& pA, ActivityStatusEvent &event);
|
||||
void writeActivityInstanceStatus(std::shared_ptr<odbmodel::ActivityInstance>& pA, ActivityInstanceStatusEvent &event);
|
||||
void writeComputingResourceStatus(std::shared_ptr<odbmodel::Workflow>& pwf, std::shared_ptr<odbmodel::ActivityInstance>& pai, ComputingResourceStatusEvent &event);
|
||||
void writeComponentStatus(std::shared_ptr<odbmodel::Workflow>& pwf, ComponentStatusEvent &event);*/
|
||||
void writeComponentStatus(std::shared_ptr<odbmodel::Workflow>& pwf, ComponentStatusEvent &event);
|
||||
|
||||
public:
|
||||
SQLiteLogger(std::string filename);
|
||||
|
||||
@@ -477,6 +477,8 @@ class DeviceInstanceStatusEvent {
|
||||
|
||||
wfr_id_t deviceID;
|
||||
|
||||
wfr_id_t deviceSubID;
|
||||
|
||||
std::string newStatus;
|
||||
|
||||
std::string oldStatus;
|
||||
@@ -490,7 +492,7 @@ class DeviceInstanceStatusEvent {
|
||||
wfr_size_t deviceSlotCount;
|
||||
|
||||
public:
|
||||
DeviceInstanceStatusEvent() : oid(0), deviceID(0), timestamp(0), executedImplID(0), deviceSlotCount(0) {}
|
||||
DeviceInstanceStatusEvent() : oid(0), deviceID(0), deviceSubID(0), timestamp(0), executedImplID(0), deviceSlotCount(0) {}
|
||||
|
||||
const std::string& getNewStatus() {
|
||||
return newStatus;
|
||||
@@ -532,10 +534,18 @@ class DeviceInstanceStatusEvent {
|
||||
return deviceID;
|
||||
}
|
||||
|
||||
wfr_id_t getDeviceSubId() {
|
||||
return deviceSubID;
|
||||
}
|
||||
|
||||
void setDeviceId(wfr_id_t deviceId) {
|
||||
deviceID = deviceId;
|
||||
}
|
||||
|
||||
void setDeviceSubId(wfr_id_t deviceSubId) {
|
||||
deviceSubID = deviceSubId;
|
||||
}
|
||||
|
||||
wfr_size_t getDeviceSlotCount() {
|
||||
return deviceSlotCount;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <set>
|
||||
#include <queue>
|
||||
#include <mutex>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace wfr {
|
||||
@@ -18,16 +20,18 @@ namespace execution {
|
||||
|
||||
class ExecutionManager;
|
||||
class ExecutionHandle;
|
||||
class PThreadBackend;
|
||||
class PThreadWorker;
|
||||
|
||||
class PThreadBackend {
|
||||
|
||||
class PThreadDevice {
|
||||
private:
|
||||
std::mutex objMutex;
|
||||
std::condition_variable workerCondVar;
|
||||
ExecutionManager& manager;
|
||||
PThreadBackend& backend;
|
||||
std::set<PThreadWorker*> workers;
|
||||
std::set<PThreadWorker*> idleWorkers;
|
||||
std::set<resource::ComputingResource*> resources;
|
||||
resource::ComputingResource* resource;
|
||||
std::queue<ExecutionHandle*> taskQueue;
|
||||
wfr_size_t maxWorkerCount;
|
||||
wfr_size_t currentTotalWorkerCount = 0;
|
||||
@@ -37,19 +41,47 @@ private:
|
||||
bool isShutdown = false;
|
||||
|
||||
public:
|
||||
PThreadBackend(ExecutionManager& manager, const std::set<resource::ComputingResource*>& resources);
|
||||
virtual ~PThreadBackend();
|
||||
PThreadDevice(PThreadBackend& backend, resource::ComputingResource* resource);
|
||||
virtual ~PThreadDevice();
|
||||
|
||||
void notifyExecutionHandleUpdate(ExecutionHandle& handle, PThreadWorker& worker);
|
||||
|
||||
bool queueTaskExecution(ExecutionHandle& handle);
|
||||
|
||||
wfr_id_t getDeviceId();
|
||||
|
||||
ExecutionHandle* popTaskExecution(PThreadWorker& worker);
|
||||
|
||||
wfr_size_t getBusyWorkerCount() { return currentBusyWorkerCount; }
|
||||
|
||||
wfr_size_t getTotalSlotCount() { return maxWorkerCount; }
|
||||
|
||||
wfr_size_t getFreeSlotCount() { return maxWorkerCount - currentBusyWorkerCount; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class PThreadBackend {
|
||||
private:
|
||||
std::mutex objMutex;
|
||||
ExecutionManager& manager;
|
||||
std::map<resource::ComputingResource*, std::shared_ptr<PThreadDevice>> devices;
|
||||
|
||||
public:
|
||||
PThreadBackend(ExecutionManager& manager, const std::set<resource::ComputingResource*>& resources);
|
||||
virtual ~PThreadBackend();
|
||||
|
||||
void notifyExecutionHandleUpdate(ExecutionHandle& handle, PThreadWorker& worker);
|
||||
|
||||
bool queueTaskExecution(ExecutionHandle& handle);
|
||||
|
||||
wfr_size_t getDeviceCount();
|
||||
|
||||
wfr_size_t getBusyWorkerCount();
|
||||
|
||||
wfr_size_t getTotalSlotCount();
|
||||
|
||||
wfr_size_t getFreeSlotCount();
|
||||
};
|
||||
|
||||
} /* namespace execution */
|
||||
|
||||
@@ -21,6 +21,7 @@ class SchedulingDecision;
|
||||
namespace execution {
|
||||
|
||||
class PThreadBackend;
|
||||
class PThreadDevice;
|
||||
class ExecutionHandle;
|
||||
|
||||
class PThreadWorker {
|
||||
@@ -44,13 +45,13 @@ private:
|
||||
bool stopThread;
|
||||
bool threadRunning;
|
||||
bool threadBusy;
|
||||
PThreadBackend& backend;
|
||||
PThreadDevice& device;
|
||||
std::mutex threadMutex;
|
||||
std::thread* thread;
|
||||
wfr_size_t usedSlotCount;
|
||||
wfs::ComputingResourceStatus status;
|
||||
|
||||
PThreadWorker(PThreadBackend& backend);
|
||||
PThreadWorker(PThreadDevice& device);
|
||||
|
||||
public:
|
||||
virtual ~PThreadWorker();
|
||||
@@ -73,7 +74,7 @@ public:
|
||||
|
||||
void setStatus(wfs::ComputingResourceStatus status, std::shared_ptr<wfr::scheduling::SchedulingDecision> sd = nullptr);
|
||||
|
||||
static PThreadWorker* createNewThread(PThreadBackend& backend);
|
||||
static PThreadWorker* createNewThread(PThreadDevice& device);
|
||||
};
|
||||
|
||||
} /* namespace execution */
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/scheduling/AbstractScheduler.h>
|
||||
#include <wfr/prediction/PredictionManager.h>
|
||||
#include <wfr/scheduling/scheduler/minmin/MinMinScheduler.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wep {
|
||||
class AtomicWepNode;
|
||||
class WEPnode;
|
||||
}
|
||||
namespace wfs {
|
||||
class AtomicActivityType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace scheduling {
|
||||
|
||||
class MaxMinScheduler: public MinMinScheduler {
|
||||
protected:
|
||||
virtual std::pair<wep::AtomicWepNode*, ECTEntry> _getNextTaskToSchedule(std::map<wep::AtomicWepNode*, ECTEntry>& estimatedTaskCompletionTimes) override;
|
||||
|
||||
|
||||
public:
|
||||
MaxMinScheduler(resource::ResourceManager& resourceManager, prediction::PredictionManager& predictionManager)
|
||||
: MinMinScheduler(resourceManager, predictionManager) {}
|
||||
|
||||
~MaxMinScheduler() {}
|
||||
};
|
||||
|
||||
} /* namespace scheduling */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/scheduling/AbstractScheduler.h>
|
||||
#include <wfr/prediction/PredictionManager.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wep {
|
||||
class AtomicWepNode;
|
||||
class WEPnode;
|
||||
}
|
||||
namespace wfs {
|
||||
class AtomicActivityType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace scheduling {
|
||||
|
||||
class MinMinScheduler: public wfr::scheduling::SchedulerBase {
|
||||
protected:
|
||||
resource::ResourceManager& resourceManager;
|
||||
prediction::PredictionManager& predictionManager;
|
||||
|
||||
std::map<resource::ComputingResource*, std::vector<std::shared_ptr<SchedulingDecision>>> scheduledTasks;
|
||||
|
||||
typedef std::map<resource::ComputingResourceType*, std::pair<wfs::AtomicActivityImplementation*, prediction::ExecutionTimeResult>> ImplementationCacheInnerMap;
|
||||
std::map<wfs::AtomicActivityType*, ImplementationCacheInnerMap> implementationCache;
|
||||
|
||||
double _getResourceEstimatedAvailableTime(resource::ComputingResource* resource);
|
||||
|
||||
typedef std::tuple<resource::ComputingResource*, wfs::AtomicActivityImplementation*, double, prediction::ExecutionTimeResult> ECTEntry;
|
||||
virtual std::pair<wep::AtomicWepNode*, ECTEntry> _getNextTaskToSchedule(std::map<wep::AtomicWepNode*, ECTEntry>& estimatedTaskCompletionTimes);
|
||||
|
||||
|
||||
public:
|
||||
MinMinScheduler(resource::ResourceManager& resourceManager, prediction::PredictionManager& predictionManager)
|
||||
: resourceManager(resourceManager), predictionManager(predictionManager) {}
|
||||
|
||||
~MinMinScheduler() {}
|
||||
|
||||
virtual void _notifyWEPUpdate(SchedulerBase::WepMapEntry& wepe, std::set<wep::AtomicWepNode*> readyToExecute, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
virtual void _notifySchedulingDecisionStatusUpdate(WepMapEntry& wepe, std::shared_ptr<SchedulingDecision> sd, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
};
|
||||
|
||||
} /* namespace scheduling */
|
||||
} /* namespace wfr */
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/scheduling/AbstractScheduler.h>
|
||||
#include <wfr/prediction/PredictionManager.h>
|
||||
#include <wfr/common/resource/Resource.h>
|
||||
#include <wfr/common/resource/ResourceManager.h>
|
||||
#include <wfr/common/types/WfrTypes.h>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
namespace wfs {
|
||||
class AtomicActivityInstance;
|
||||
}
|
||||
namespace wep {
|
||||
class AtomicWepNode;
|
||||
class ActivityWepNode;
|
||||
class AbstractWepNode;
|
||||
}
|
||||
namespace resource {
|
||||
class ResourceManager;
|
||||
}
|
||||
namespace prediction {
|
||||
class PredictionManager;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace scheduling {
|
||||
|
||||
|
||||
class PEFTScheduler: public scheduling::SchedulerBase {
|
||||
protected:
|
||||
resource::ResourceManager& resourceManager;
|
||||
prediction::PredictionManager& predictionManager;
|
||||
|
||||
struct OptimisticCostTableEntry {
|
||||
wfr_size_t resourceCount;
|
||||
double* values;
|
||||
double rank = 0;
|
||||
bool finalized = false;
|
||||
|
||||
wfs::AtomicActivityImplementation** fastestImplementations;
|
||||
prediction::ExecutionTimeResult* fastestExecutionTimes;
|
||||
|
||||
OptimisticCostTableEntry(wfr_size_t resourceCount) : resourceCount(resourceCount),
|
||||
values(new double[resourceCount]), fastestImplementations(new wfs::AtomicActivityImplementation*[resourceCount]),
|
||||
fastestExecutionTimes(new prediction::ExecutionTimeResult[resourceCount]) {}
|
||||
~OptimisticCostTableEntry() {
|
||||
delete[] values;
|
||||
}
|
||||
};
|
||||
|
||||
//std::map<wep::ActivityWepNode*, std::shared_ptr<OptimisticCostTableEntry>> optimisticCostTable;
|
||||
|
||||
std::set<wep::AtomicWepNode*> readySet;
|
||||
|
||||
void calcOptimisticCosts(wep::ActivityWepNode& node, std::vector<resource::ComputingResource*>& resources);
|
||||
|
||||
void scheduleReadySet(WepMapEntry& wepe, std::vector<resource::ComputingResource*>& resources, std::unique_lock<std::mutex>& schedulerLock);
|
||||
|
||||
public:
|
||||
PEFTScheduler(resource::ResourceManager& resourceManager, prediction::PredictionManager& predictionManager)
|
||||
: resourceManager(resourceManager), predictionManager(predictionManager) {}
|
||||
|
||||
~PEFTScheduler() {}
|
||||
|
||||
virtual void _notifyWEPUpdate(SchedulerBase::WepMapEntry& wepe, std::set<wep::AtomicWepNode*> readyToExecute, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
virtual void _notifySchedulingDecisionStatusUpdate(WepMapEntry& wepe, std::shared_ptr<SchedulingDecision> sd, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
};
|
||||
|
||||
} /* namespace scheduling */
|
||||
} /* namespace wfr */
|
||||
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <wfr/scheduling/AbstractScheduler.h>
|
||||
#include <wfr/prediction/PredictionManager.h>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wep {
|
||||
class AtomicWepNode;
|
||||
class WEPnode;
|
||||
}
|
||||
namespace wfs {
|
||||
class AtomicActivityType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace scheduling {
|
||||
|
||||
class SufferageScheduler: public wfr::scheduling::SchedulerBase {
|
||||
protected:
|
||||
resource::ResourceManager& resourceManager;
|
||||
prediction::PredictionManager& predictionManager;
|
||||
|
||||
std::map<resource::ComputingResource*, std::vector<std::shared_ptr<SchedulingDecision>>> scheduledTasks;
|
||||
|
||||
typedef std::map<resource::ComputingResourceType*, std::pair<wfs::AtomicActivityImplementation*, prediction::ExecutionTimeResult>> ImplementationCacheInnerMap;
|
||||
std::map<wfs::AtomicActivityType*, ImplementationCacheInnerMap> implementationCache;
|
||||
|
||||
double _getResourceEstimatedAvailableTime(resource::ComputingResource* resource);
|
||||
|
||||
typedef std::tuple<resource::ComputingResource*, wfs::AtomicActivityImplementation*, double, prediction::ExecutionTimeResult> ECTEntry;
|
||||
std::pair<wep::AtomicWepNode*, ECTEntry> _getNextTaskToSchedule(std::map<wep::AtomicWepNode*, ECTEntry>& estimatedTaskCompletionTimes);
|
||||
|
||||
|
||||
public:
|
||||
SufferageScheduler(resource::ResourceManager& resourceManager, prediction::PredictionManager& predictionManager)
|
||||
: resourceManager(resourceManager), predictionManager(predictionManager) {}
|
||||
|
||||
~SufferageScheduler() {}
|
||||
|
||||
virtual void _notifyWEPUpdate(SchedulerBase::WepMapEntry& wepe, std::set<wep::AtomicWepNode*> readyToExecute, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
virtual void _notifySchedulingDecisionStatusUpdate(WepMapEntry& wepe, std::shared_ptr<SchedulingDecision> sd, std::unique_lock<std::mutex>& schedulerLock) override;
|
||||
};
|
||||
|
||||
} /* namespace scheduling */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace wfr {
|
||||
namespace wep {
|
||||
|
||||
// Forward declarations
|
||||
class WorkflowExecutionPlan;
|
||||
class AbstractWepNode;
|
||||
|
||||
// main namespace
|
||||
namespace utils {
|
||||
|
||||
|
||||
class WepProgressionWriter {
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
const std::shared_ptr<WorkflowExecutionPlan> wep;
|
||||
const std::string workflowName;
|
||||
|
||||
private:
|
||||
std::ofstream outfile;
|
||||
int64_t epoch = 0;
|
||||
|
||||
public:
|
||||
WepProgressionWriter(const std::shared_ptr<WorkflowExecutionPlan>& wep) noexcept;
|
||||
|
||||
void openFile(const std::string filename = std::string());
|
||||
void writeProgressToFile();
|
||||
void closeFile();
|
||||
|
||||
};
|
||||
|
||||
|
||||
} /* namespace utils */
|
||||
} /* namespace wep */
|
||||
} /* namespace wfr */
|
||||
Reference in New Issue
Block a user