72 lines
2.4 KiB
C++
Executable File
72 lines
2.4 KiB
C++
Executable File
|
|
#include <boost/program_options.hpp>
|
|
#include <boost/format.hpp>
|
|
#include <wfr/prediction/services/oracle/OraclePredictionService.h>
|
|
#include <wfr/prediction/PredictionManager.h>
|
|
#include <wfr/prediction/PredictionService.h>
|
|
#include <iostream>
|
|
|
|
|
|
|
|
namespace wfr {
|
|
namespace prediction {
|
|
|
|
|
|
PredictionManager PredictionManager::singleton;
|
|
|
|
void PredictionManager::init(int argc, char** argv) {
|
|
std::string predictionConfig;
|
|
boost::program_options::options_description opts("Prediction Options");
|
|
opts.add_options()
|
|
("predictionconfig", boost::program_options::value<std::string>(), "Set prediction service config.")
|
|
("help", "Print help message.");
|
|
boost::program_options::variables_map vm;
|
|
auto parsed = boost::program_options::command_line_parser(argc, argv).options(opts).allow_unregistered().run();
|
|
boost::program_options::store(parsed, vm);
|
|
boost::program_options::notify(vm);
|
|
if (vm.count("help")) {
|
|
std::cerr << opts << std::endl;
|
|
return;
|
|
}
|
|
if (vm.count("predictionconfig")) {
|
|
predictionConfig = vm["predictionconfig"].as<std::string>();
|
|
std::cerr << "Prediction Service Config is set to \""<< predictionConfig << "\"." << std::endl;
|
|
}
|
|
singleton.service = new OraclePredictionService(predictionConfig);
|
|
}
|
|
|
|
|
|
void PredictionManager::finish() noexcept {
|
|
}
|
|
|
|
|
|
PredictionManager::~PredictionManager() noexcept {
|
|
if (service) {
|
|
delete service;
|
|
service = nullptr;
|
|
}
|
|
}
|
|
|
|
|
|
ExecutionTimeResult PredictionManager::predictExecutionTime(wfs::ActivityInstance& instance, wfs::AtomicActivityImplementation& implementation, resource::ComputingResourceType& resourceType, const wfr_size_t& slots) noexcept {
|
|
if (service) {
|
|
return service->predictExecutionTime(instance, implementation, resourceType, slots);
|
|
} else {
|
|
std::cerr << "No Prediction Service configured." << std::endl;
|
|
return ExecutionTimeResult();
|
|
}
|
|
}
|
|
|
|
CommunicationTimeResult PredictionManager::predictCommunicationTime(wfs::ActivityInstance& srcInstance, resource::ComputingResource& srcResource,
|
|
wfs::ActivityInstance& destInstance, resource::ComputingResource& destResource) noexcept {
|
|
if (service) {
|
|
return service->predictCommunicationTime(srcInstance, srcResource, destInstance, destResource);
|
|
} else {
|
|
std::cerr << "No Prediction Service configured." << std::endl;
|
|
return CommunicationTimeResult();
|
|
}
|
|
}
|
|
|
|
} /* namespace prediction */
|
|
} /* namespace wfr */
|