Improved HEFT scheduler and fixed some bugs.

This commit is contained in:
Matthias
2017-07-25 17:13:22 +02:00
parent 3d4bb80dae
commit b93d8565a0
5 changed files with 222 additions and 211 deletions
@@ -21,9 +21,9 @@ namespace wfr {
namespace wfs {
class AtomicActivityInstance;
}
namespace wep {
class AtomicWepNode;
class ActivityWepNode;
class AbstractWepNode;
}
namespace resource {
@@ -39,63 +39,40 @@ namespace wfr {
namespace scheduling {
class HEFTScheduler: public scheduling::SchedulerBase {
protected:
struct InstanceUserData {
bool isComplete = false;
bool isScheduled = false;
NumericalMeasurement rank;
NumericalMeasurement averageComputingCost;
// resourceName => (fastest implementation, prediction);
std::map<resource::ComputingResourceType*, std::tuple<wfs::AtomicActivityImplementation*, prediction::ExecutionTimeResult>> predictions;
};
struct SchedulingQueueEntry {
InstanceUserData* instanceData = nullptr;
wfs::AtomicActivityInstance* instance = nullptr;
wep::AbstractWepNode* node = nullptr;
};
struct _SchedulingQueueEntryComparison {
bool operator()(const SchedulingQueueEntry& e1, const SchedulingQueueEntry& e2) {
if (e1.instanceData && !e2.instanceData) {
return false;
} else if (!e1.instanceData && e2.instanceData) {
return true;
} else if (e1.instanceData && e2.instanceData) {
return e1.instanceData->rank.getValue() < e2.instanceData->rank.getValue();
} else {
return false;
}
}
};
std::priority_queue<SchedulingQueueEntry, std::vector<SchedulingQueueEntry>, _SchedulingQueueEntryComparison> schedulingPriorityQueue;
resource::ResourceManager& resourceManager;
prediction::PredictionManager& predictionManager;
std::vector<std::string> debugLines;
wfr_size_t debugIteration = 0;
struct TaskRankEntry {
double rank = 0;
bool finalized = false;
wfs::AtomicActivityImplementation** fastestImplementations;
prediction::ExecutionTimeResult* fastestExecutionTimes;
double averageExecutionTime = 0.0;
TaskRankEntry(wfr_size_t resourceCount) : fastestImplementations(new wfs::AtomicActivityImplementation*[resourceCount]),
fastestExecutionTimes(new prediction::ExecutionTimeResult[resourceCount]) {}
};
NumericalMeasurement getRank(wfs::AtomicActivityInstance& ai, InstanceUserData* instanceData, const std::vector<resource::ComputingResourceType*>& resourceTypes, const std::vector<resource::ComputingResource*>& resources);
NumericalMeasurement getAverageExecutionCost(wfs::AtomicActivityInstance& ai, InstanceUserData* instanceData, const std::vector<resource::ComputingResourceType*>& resources);
NumericalMeasurement getMaxSuccValue(wfs::AtomicActivityInstance& ai, InstanceUserData* instanceData, const std::vector<resource::ComputingResourceType*>& resourceTypes, const std::vector<resource::ComputingResource*>& resources);
//std::map<wep::ActivityWepNode*, std::shared_ptr<OptimisticCostTableEntry>> optimisticCostTable;
std::set<wep::AtomicWepNode*> readySet;
void calcTaskRanks(wep::ActivityWepNode& node, std::vector<resource::ComputingResource*>& resources);
void scheduleReadySet(WepMapEntry& wepe, std::vector<resource::ComputingResource*>& resources, std::unique_lock<std::mutex>& schedulerLock);
public:
HEFTScheduler(resource::ResourceManager& resourceManager, prediction::PredictionManager& predictionManager)
: resourceManager(resourceManager), predictionManager(predictionManager) {}
~HEFTScheduler() {
/*for (auto s : debugLines) {
std::cout << s << std::endl;
}*/
}
~HEFTScheduler() {}
virtual void _notifyWEPUpdate(SchedulerBase::WepMapEntry& wepe, std::set<wep::AtomicWepNode*> readyToExecute, std::unique_lock<std::mutex>& schedulerLock);
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;
virtual void _unregisterWEP(WepMapEntry& wepe, std::unique_lock<std::mutex>& schedulerLock) override;
};
} /* namespace scheduling */
+1
View File
@@ -3,6 +3,7 @@
#include <functional>
#include <set>
namespace wfr {
namespace wep {