use of es.bsc.compss.scheduler.multiobjective.types.MOScore in project compss by bsc-wdc.
the class MOResourceOptimizer method getBestImplementation.
private Implementation getBestImplementation(List<Implementation> impls, MOProfile[] profiles) {
Implementation impl = impls.get(0);
MOScore bestScore = new MOScore(0, 0, 0, profiles[0].getAverageExecutionTime(), profiles[0].getPower(), profiles[0].getPrice());
for (int i = 1; i < impls.size(); i++) {
Implementation candidate = impls.get(i);
long length = profiles[i].getAverageExecutionTime();
double power = profiles[i].getPower();
double price = profiles[i].getPrice();
MOScore score = new MOScore(0, 0, 0, length, power * length, price);
if (Score.isBetter(score, bestScore)) {
bestScore = score;
impl = candidate;
}
}
return impl;
}
use of es.bsc.compss.scheduler.multiobjective.types.MOScore in project compss by bsc-wdc.
the class MOResourceScheduler method tryToLaunch.
private boolean tryToLaunch(AllocatableAction action) {
boolean launched = false;
try {
action.tryToLaunch();
launched = true;
} catch (InvalidSchedulingException ise) {
}
if (!launched) {
long actionScore = MOScore.getActionScore(action);
Score aScore = new MOScore(actionScore, 0, 0, 0, 0, 0);
try {
action.schedule(aScore);
try {
action.tryToLaunch();
} catch (InvalidSchedulingException ise2) {
// Impossible exception.
LOGGER.error(ise2);
}
} catch (BlockedActionException | UnassignedActionException be) {
// Can not happen since there was an original source
LOGGER.error(be);
}
}
return launched;
}
use of es.bsc.compss.scheduler.multiobjective.types.MOScore in project compss by bsc-wdc.
the class MOResourceScheduler method generateMOScore.
public MOScore generateMOScore(long resourceFreeTime, long expectedDataAvailable, long actionPriority, Implementation impl) {
long implScore = 0;
double energy = 0;
double cost = 0;
MOProfile p = (MOProfile) this.getProfile(impl);
if (p != null) {
implScore = p.getAverageExecutionTime();
long waitingTime = Math.max(resourceFreeTime, expectedDataAvailable);
if (waitingTime < Long.MAX_VALUE) {
energy = ((waitingTime + implScore) * getIdlePower()) + (p.getPower() * implScore);
cost = ((waitingTime + implScore) * getIdlePrice()) + (p.getPrice() * implScore);
} else {
energy = Double.MAX_VALUE;
cost = Double.MAX_VALUE;
}
}
// The data transfer penalty is already included on the datadependency time of the resourceScore
return new MOScore(actionPriority, expectedDataAvailable, resourceFreeTime, implScore, energy, cost);
}
use of es.bsc.compss.scheduler.multiobjective.types.MOScore in project compss by bsc-wdc.
the class MOScheduleOptimizer method move.
private boolean move(AllocatableAction action, OptimizationWorker donor, OptimizationWorker receiver) {
LOGGER.debug(LOG_PREFIX + "Trying to move " + action + " from " + donor.getName() + " to " + receiver.getName());
List<AllocatableAction> dataPreds = action.getDataPredecessors();
long dataAvailable = 0;
try {
for (AllocatableAction dataPred : dataPreds) {
MOSchedulingInformation dsi = (MOSchedulingInformation) dataPred.getSchedulingInfo();
dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
}
} catch (ConcurrentModificationException cme) {
dataAvailable = 0;
dataPreds = action.getDataPredecessors();
}
Implementation bestImpl = null;
List<Implementation> impls = action.getCompatibleImplementations(receiver.getResource());
Score bestScore = null;
for (Implementation impl : impls) {
MOScore actionScore = MOScheduler.getActionScore(action);
MOScore score = ((MOResourceScheduler<?>) (receiver.getResource())).generateMoveImplementationScore(action, null, impl, actionScore, (long) (OPTIMIZATION_THRESHOLD * 2.5));
if (Score.isBetter(score, bestScore)) {
bestImpl = impl;
bestScore = score;
}
}
Implementation currentImpl = action.getAssignedImplementation();
MOScore actionScore = MOScheduler.getActionScore(action);
LOGGER.debug(LOG_PREFIX + "Calculating score for current execution");
MOScore currentScore = ((MOResourceScheduler<?>) (action.getAssignedResource())).generateCurrentImplementationScore(action, currentImpl, actionScore);
LOGGER.debug(LOG_PREFIX + "Comparing scores: \n" + bestScore + "\n " + currentScore);
if (bestImpl != null && Score.isBetter(bestScore, currentScore)) {
try {
LOGGER.debug(LOG_PREFIX + "Moving " + action + " from " + donor.getName() + " to " + receiver.getName());
unscheduleFromWorker(action);
scheduleOnWorker(action, bestImpl, receiver);
} catch (ActionNotFoundException anfe) {
// Action was already moved from the resource. Recompute Optimizations!!!
}
return true;
} else {
LOGGER.debug(LOG_PREFIX + "Action " + action + " not moved because new position is not better than actual");
}
return false;
}
use of es.bsc.compss.scheduler.multiobjective.types.MOScore in project compss by bsc-wdc.
the class MOResourceScheduler method generateResourceScore.
/*--------------------------------------------------
---------------------------------------------------
------------------ Score Methods ------------------
---------------------------------------------------
--------------------------------------------------*/
/**
* @param action
* @param params
* @param actionScore
* @return
*/
@Override
public Score generateResourceScore(AllocatableAction action, TaskDescription params, Score actionScore) {
long resScore = Score.calculateDataLocalityScore(params, myWorker);
for (AllocatableAction pred : action.getDataPredecessors()) {
if (pred.isPending() && pred.getAssignedResource() == this) {
resScore++;
}
}
resScore = params.getParameters().length - resScore;
long lessTimeStamp = Long.MAX_VALUE;
Gap g = gaps.peekFirst();
if (g != null) {
lessTimeStamp = g.getInitialTime();
if (lessTimeStamp < 0) {
lessTimeStamp = 0;
}
}
long actionPriority = actionScore.getActionScore();
long expectedDataAvailable = ((MOScore) actionScore).getExpectedDataAvailable() + resScore * MOConfiguration.DATA_TRANSFER_DELAY;
return new MOScore(actionPriority, expectedDataAvailable, lessTimeStamp, 0, 0, 0);
}
Aggregations