Search in sources :

Example 21 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class TaskScheduler method increasedWorkerResources.

private <T extends WorkerResourceDescription> void increasedWorkerResources(ResourceScheduler<T> worker, ResourceUpdate<T> modification) {
    if (worker.getExecutableCores().isEmpty()) {
    // We no longer remove workers with empty executable cores since new core elements
    // can be registered on execution time
    } else {
        // Inspect blocked actions to be freed
        List<AllocatableAction> compatibleActions = this.blockedActions.removeAllCompatibleActions(worker.getResource());
        // Prioritize them
        PriorityQueue<ObjectValue<AllocatableAction>> sortedCompatibleActions = new PriorityQueue<>();
        for (AllocatableAction action : compatibleActions) {
            ObjectValue<AllocatableAction> obj = new ObjectValue<>(action, generateActionScore(action));
            sortedCompatibleActions.add(obj);
        }
        // Schedule them
        while (!sortedCompatibleActions.isEmpty()) {
            ObjectValue<AllocatableAction> obj = sortedCompatibleActions.poll();
            Score actionScore = obj.getScore();
            AllocatableAction action = obj.getObject();
            if (!action.hasDataPredecessors()) {
                addToReady(action);
            }
            try {
                scheduleAction(action, actionScore);
                tryToLaunch(action);
            } catch (BlockedActionException bae) {
                removeFromReady(action);
                addToBlocked(action);
            }
        }
        // Update worker load
        this.workerLoadUpdate(worker);
    }
}
Also used : Score(es.bsc.compss.scheduler.types.Score) ObjectValue(es.bsc.compss.scheduler.types.ObjectValue) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue)

Example 22 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class TaskScheduler method getRunningActionMonitorData.

/**
 * Returns the running actions on a given @worker pre-pending the @prefix
 *
 * @param <T>
 * @param worker
 * @param prefix
 * @return
 */
public final <T extends WorkerResourceDescription> String getRunningActionMonitorData(Worker<T> worker, String prefix) {
    LOGGER.info("[TaskScheduler] Get running actions monitoring data");
    StringBuilder runningActions = new StringBuilder();
    ResourceScheduler<T> ui = workers.get(worker);
    if (ui != null) {
        AllocatableAction[] hostedActions = ui.getHostedActions();
        for (AllocatableAction action : hostedActions) {
            runningActions.append(prefix);
            runningActions.append("<Action>").append(action.toString()).append("</Action>");
            runningActions.append("\n");
        }
    } else {
        LOGGER.info("[TaskScheduler] Worker is not in the list");
    }
    return runningActions.toString();
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction)

Example 23 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class TaskScheduler method handleDependencyFreeActions.

/**
 * Notifies to the scheduler that some actions have become free of data dependencies or resource dependencies.
 *
 * @param <T>
 * @param dataFreeActions
 *            IN, list of actions free of data dependencies
 * @param resourceFreeActions
 *            IN, list of actions free of resource dependencies
 * @param blockedCandidates
 *            OUT, list of blocked candidates
 * @param resource
 *            Resource where the previous task was executed
 */
public <T extends WorkerResourceDescription> void handleDependencyFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
    LOGGER.debug("[TaskScheduler] Treating dependency free actions");
    // All actions should have already been assigned to a resource, no need
    // to change the assignation once they become free of dependencies
    // Try to launch all the data free actions and the resource free actions
    PriorityQueue<ObjectValue<AllocatableAction>> executableActions = new PriorityQueue<>();
    for (AllocatableAction freeAction : dataFreeActions) {
        Score actionScore = generateActionScore(freeAction);
        Score fullScore = freeAction.schedulingScore(resource, actionScore);
        ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
        executableActions.add(obj);
    }
    for (AllocatableAction freeAction : resourceFreeActions) {
        Score actionScore = generateActionScore(freeAction);
        Score fullScore = freeAction.schedulingScore(resource, actionScore);
        ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
        if (!executableActions.contains(obj)) {
            executableActions.add(obj);
        }
    }
    while (!executableActions.isEmpty()) {
        ObjectValue<AllocatableAction> obj = executableActions.poll();
        AllocatableAction freeAction = obj.getObject();
        tryToLaunch(freeAction);
    }
}
Also used : Score(es.bsc.compss.scheduler.types.Score) ObjectValue(es.bsc.compss.scheduler.types.ObjectValue) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue)

Example 24 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class TaskScheduler method actionCompleted.

/**
 * Registers an action as completed and releases all the resource and data dependencies.
 *
 * @param action
 *            action that has finished
 */
@SuppressWarnings("unchecked")
public final void actionCompleted(AllocatableAction action) {
    LOGGER.info("[TaskScheduler] Action completed " + action);
    // Mark action as finished
    removeFromReady(action);
    ResourceScheduler<WorkerResourceDescription> resource = (ResourceScheduler<WorkerResourceDescription>) action.getAssignedResource();
    List<AllocatableAction> resourceFree;
    try {
        resourceFree = resource.unscheduleAction(action);
    } catch (ActionNotFoundException ex) {
        // Once the action starts running should cannot be moved from the resource
        resourceFree = new LinkedList<>();
    }
    // Get the data free actions and mark them as ready
    List<AllocatableAction> dataFreeActions = action.completed();
    Iterator<AllocatableAction> dataFreeIter = dataFreeActions.iterator();
    while (dataFreeIter.hasNext()) {
        AllocatableAction dataFreeAction = dataFreeIter.next();
        addToReady(dataFreeAction);
    }
    // We update the worker load
    workerLoadUpdate(resource);
    // Schedule data free actions
    List<AllocatableAction> blockedCandidates = new LinkedList<>();
    // Actions can only be scheduled and those that remain blocked must be added to the blockedCandidates list
    // and those that remain unassigned must be added to the unassigned list
    handleDependencyFreeActions(dataFreeActions, resourceFree, blockedCandidates, resource);
    for (AllocatableAction aa : blockedCandidates) {
        removeFromReady(aa);
        addToBlocked(aa);
    }
}
Also used : ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList)

Example 25 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.

the class AllocatableActionTest method error.

public void error(FakeAllocatableAction action) throws BlockedActionException, UnassignedActionException, InvalidSchedulingException {
    FakeResourceScheduler resource = (FakeResourceScheduler) action.getAssignedResource();
    List<AllocatableAction> resourceFree;
    try {
        action.error();
        resourceFree = resource.unscheduleAction(action);
    } catch (FailedActionException fae) {
        resourceFree = new LinkedList<>();
        for (AllocatableAction failed : action.failed()) {
            resourceFree.addAll(resource.unscheduleAction(failed));
        }
    }
    for (AllocatableAction a : resourceFree) {
        FakeAllocatableAction fa = (FakeAllocatableAction) a;
        fa.tryToLaunch();
    }
}
Also used : FakeAllocatableAction(es.bsc.compss.types.fake.FakeAllocatableAction) FakeResourceScheduler(es.bsc.compss.types.fake.FakeResourceScheduler) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) FakeAllocatableAction(es.bsc.compss.types.fake.FakeAllocatableAction) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException) LinkedList(java.util.LinkedList)

Aggregations

AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)43 LinkedList (java.util.LinkedList)13 MOSchedulingInformation (es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation)11 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)10 PriorityQueue (java.util.PriorityQueue)10 Gap (es.bsc.compss.scheduler.multiobjective.types.Gap)9 Score (es.bsc.compss.scheduler.types.Score)7 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)6 Implementation (es.bsc.compss.types.implementations.Implementation)6 ResourceDescription (es.bsc.compss.types.resources.ResourceDescription)6 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)5 ConcurrentModificationException (java.util.ConcurrentModificationException)5 ObjectValue (es.bsc.compss.scheduler.types.ObjectValue)4 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)3 HashSet (java.util.HashSet)3 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)2 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)2 MOScore (es.bsc.compss.scheduler.multiobjective.types.MOScore)2 OptimizationAction (es.bsc.compss.scheduler.multiobjective.types.OptimizationAction)2 Profile (es.bsc.compss.scheduler.types.Profile)2