Initial commit
This commit is contained in:
Executable
+108
@@ -0,0 +1,108 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <cstdint>
|
||||
#include <wfr/common/types/WfrTypes.h>
|
||||
#include <string>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
namespace wfs {
|
||||
class AtomicActivityImplementation;
|
||||
class ActivityInstance;
|
||||
}
|
||||
|
||||
namespace resource {
|
||||
class Resource;
|
||||
class ComputingResourceType;
|
||||
class ComputingResource;
|
||||
class ResourceManager;
|
||||
}
|
||||
|
||||
namespace prediction {
|
||||
|
||||
class PredictionService;
|
||||
|
||||
|
||||
|
||||
class ExecutionTimeResult {
|
||||
|
||||
// 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 :(
|
||||
public:
|
||||
wfs::ActivityInstance* instance = nullptr;
|
||||
wfs::AtomicActivityImplementation* implementation = nullptr;
|
||||
resource::ComputingResourceType* resourceType = nullptr;
|
||||
wfr::NumericalMeasurement executionTime;
|
||||
wfr_size_t slots = 0;
|
||||
bool validFlag = false;
|
||||
|
||||
// Public functions
|
||||
public:
|
||||
ExecutionTimeResult() noexcept {}
|
||||
ExecutionTimeResult(wfs::ActivityInstance* instance, wfs::AtomicActivityImplementation* implementation,
|
||||
resource::ComputingResourceType* resourceType, wfr::NumericalMeasurement executionTime, wfr_size_t slots = 1, bool validFlag = true) noexcept
|
||||
: instance(instance), implementation(implementation), resourceType(resourceType), executionTime(executionTime),
|
||||
slots(slots), validFlag(validFlag) {}
|
||||
|
||||
wfs::ActivityInstance* getActivityInstance() const noexcept { return instance; }
|
||||
wfs::AtomicActivityImplementation* getActivityImplementation() const noexcept { return implementation; }
|
||||
resource::ComputingResourceType* getResourceType() const noexcept { return resourceType; }
|
||||
const wfr::NumericalMeasurement& getExecutionTime() const noexcept { return executionTime; }
|
||||
wfr_size_t getSlots() const noexcept { return slots; }
|
||||
bool isValid() const noexcept { return validFlag; }
|
||||
operator bool() const noexcept { return validFlag; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
class CommunicationTimeResult {
|
||||
|
||||
// Invariant properties that can be accessed directly.
|
||||
public:
|
||||
wfs::ActivityInstance* const srcInstance = nullptr;
|
||||
resource::ComputingResource* const srcResource = nullptr;
|
||||
wfs::ActivityInstance* const destInstance = nullptr;
|
||||
resource::ComputingResource* const destResource = nullptr;
|
||||
const wfr::NumericalMeasurement communicationTime;
|
||||
const bool isValid = false;
|
||||
public:
|
||||
CommunicationTimeResult() noexcept {}
|
||||
CommunicationTimeResult(wfs::ActivityInstance* srcInstance, resource::ComputingResource* srcResource,
|
||||
wfs::ActivityInstance* destInstance, resource::ComputingResource* destResource,
|
||||
wfr::NumericalMeasurement communicationTime, bool validFlag = true) noexcept
|
||||
: srcInstance(srcInstance), srcResource(srcResource), destInstance(destInstance), destResource(destResource),
|
||||
communicationTime(communicationTime), isValid(validFlag) {}
|
||||
|
||||
operator bool() const {
|
||||
return isValid;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
class PredictionManager {
|
||||
private:
|
||||
static PredictionManager singleton;
|
||||
PredictionService* service = nullptr;
|
||||
public:
|
||||
static void init(int argc, char** argv);
|
||||
|
||||
static void finish() noexcept;
|
||||
|
||||
static PredictionManager& getInstance() noexcept { return singleton; }
|
||||
|
||||
public:
|
||||
~PredictionManager() noexcept;
|
||||
|
||||
ExecutionTimeResult predictExecutionTime(wfs::ActivityInstance& instance, wfs::AtomicActivityImplementation& implementation,
|
||||
resource::ComputingResourceType& resourceType, const wfr_size_t& slots = 1) noexcept;
|
||||
|
||||
CommunicationTimeResult predictCommunicationTime(wfs::ActivityInstance& srcInstance, resource::ComputingResource& srcResource,
|
||||
wfs::ActivityInstance& destInstance, resource::ComputingResource& destResource) noexcept;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace prediction */
|
||||
} /* namespace wfr */
|
||||
|
||||
Executable
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/prediction/PredictionManager.h>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
namespace resource {
|
||||
class Resource;
|
||||
class ComputingResourceType;
|
||||
class ComputingResource;
|
||||
class ResourceManager;
|
||||
}
|
||||
|
||||
namespace prediction {
|
||||
|
||||
class PredictionService {
|
||||
public:
|
||||
virtual ~PredictionService() {}
|
||||
|
||||
virtual ExecutionTimeResult predictExecutionTime(wfs::ActivityInstance& instance, wfs::AtomicActivityImplementation& implementation,
|
||||
resource::ComputingResourceType& resourceType, const wfr_size_t& slots = 1) = 0;
|
||||
|
||||
virtual CommunicationTimeResult predictCommunicationTime(wfs::ActivityInstance& srcInstance, resource::ComputingResource& srcResource,
|
||||
wfs::ActivityInstance& destInstance, resource::ComputingResource& destResource) = 0;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace prediction */
|
||||
} /* namespace wfr */
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wfr/prediction/PredictionService.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
namespace wfr {
|
||||
|
||||
namespace prediction {
|
||||
|
||||
|
||||
class OraclePredictionService : public PredictionService {
|
||||
private:
|
||||
struct PredictionTableEntry {
|
||||
NumericalMeasurement prediction;
|
||||
};
|
||||
|
||||
// Primary Key: (ActivityType, ActivityImplementation, Device)
|
||||
std::map<std::string, std::map<std::string, std::map<std::string, PredictionTableEntry>>> predictionTable;
|
||||
public:
|
||||
OraclePredictionService(const std::string& config = std::string());
|
||||
|
||||
virtual ExecutionTimeResult predictExecutionTime(wfs::ActivityInstance& instance, wfs::AtomicActivityImplementation& implementation,
|
||||
resource::ComputingResourceType& resourceType, const wfr_size_t& slots = 1) override;
|
||||
|
||||
virtual CommunicationTimeResult predictCommunicationTime(wfs::ActivityInstance& srcInstance, resource::ComputingResource& srcResource,
|
||||
wfs::ActivityInstance& destInstance, resource::ComputingResource& destResource) override;
|
||||
};
|
||||
|
||||
|
||||
} /* namespace prediction */
|
||||
} /* namespace wfr */
|
||||
Reference in New Issue
Block a user