use of es.bsc.compss.scheduler.types.Score 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.types.Score 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.types.Score in project compss by bsc-wdc.
the class FIFODataScheduler method purgeFreeActions.
/*
* *********************************************************************************************************
* *********************************************************************************************************
* ********************************* SCHEDULING OPERATIONS *************************************************
* *********************************************************************************************************
* *********************************************************************************************************
*/
@Override
public <T extends WorkerResourceDescription> void purgeFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
LOGGER.debug("[DataScheduler] Treating dependency free actions");
PriorityQueue<ObjectValue<AllocatableAction>> executableActions = new PriorityQueue<>();
for (AllocatableAction action : dataFreeActions) {
Score actionScore = this.generateActionScore(action);
Score fullScore = action.schedulingScore(resource, actionScore);
ObjectValue<AllocatableAction> obj = new ObjectValue<>(action, fullScore);
executableActions.add(obj);
}
dataFreeActions.clear();
while (!executableActions.isEmpty()) {
ObjectValue<AllocatableAction> obj = executableActions.poll();
AllocatableAction freeAction = obj.getObject();
try {
scheduleAction(freeAction, resource, obj.getScore());
tryToLaunch(freeAction);
} catch (BlockedActionException e) {
removeFromReady(freeAction);
addToBlocked(freeAction);
} catch (UnassignedActionException e) {
dataFreeActions.add(freeAction);
}
}
List<AllocatableAction> unassignedReadyActions = this.unassignedReadyActions.getAllActions();
this.unassignedReadyActions.removeAllActions();
dataFreeActions.addAll(unassignedReadyActions);
}
use of es.bsc.compss.scheduler.types.Score in project compss by bsc-wdc.
the class TaskScheduler method workerRemoved.
/**
* One worker has been removed from the pool; the Task Scheduler is notified to modify any internal structure using
* that information.
*
* @param <T>
* @param resource
* removed worker
*/
protected <T extends WorkerResourceDescription> void workerRemoved(ResourceScheduler<T> resource) {
LOGGER.info("[TaskScheduler] Remove worker " + resource.getName());
// There are no internal structures worker-related. No need to do anything.
PriorityQueue<AllocatableAction> blockedOnResource = resource.getBlockedActions();
for (AllocatableAction action : blockedOnResource) {
try {
resource.unscheduleAction(action);
} catch (ActionNotFoundException ex) {
// Task was already moved from the worker. Do nothing!
continue;
}
Score actionScore = generateActionScore(action);
try {
scheduleAction(action, actionScore);
tryToLaunch(action);
} catch (BlockedActionException bae) {
if (!action.hasDataPredecessors()) {
removeFromReady(action);
}
addToBlocked(action);
}
}
}
use of es.bsc.compss.scheduler.types.Score in project compss by bsc-wdc.
the class TaskScheduler method errorOnAction.
/**
* Registers an error on the action given as a parameter. The action itself processes the error and triggers with
* any possible solution to re-execute it. This code is executed only on re-schedule (no resubmit)
*
* @param action
* action raising the error
*/
@SuppressWarnings("unchecked")
public final void errorOnAction(AllocatableAction action) {
LOGGER.warn("[TaskScheduler] Error on action " + action);
List<AllocatableAction> resourceFree = new LinkedList<>();
ResourceScheduler<WorkerResourceDescription> resource = (ResourceScheduler<WorkerResourceDescription>) action.getAssignedResource();
boolean failed = false;
// Process the action error (removes the assigned resource)
try {
action.error();
} catch (FailedActionException fae) {
// Action has completely failed
failed = true;
LOGGER.warn("[TaskScheduler] Action completely failed " + action);
removeFromReady(action);
// Free all the dependent tasks
for (AllocatableAction failedAction : action.failed()) {
try {
resourceFree.addAll(resource.unscheduleAction(failedAction));
} catch (ActionNotFoundException anfe) {
// Once the action starts running should cannot be moved from the resource
}
}
}
// We free the current task and get the free actions from the resource
try {
resourceFree.addAll(resource.unscheduleAction(action));
} catch (ActionNotFoundException anfe) {
// Once the action starts running should cannot be moved from the resource
}
workerLoadUpdate(resource);
if (!failed) {
// Try to re-schedule the action
Score actionScore = generateActionScore(action);
try {
scheduleAction(action, actionScore);
tryToLaunch(action);
} catch (BlockedActionException bae) {
removeFromReady(action);
addToBlocked(action);
}
}
List<AllocatableAction> blockedCandidates = new LinkedList<>();
handleDependencyFreeActions(new LinkedList<>(), resourceFree, blockedCandidates, resource);
for (AllocatableAction aa : blockedCandidates) {
removeFromReady(aa);
addToBlocked(aa);
}
}
Aggregations