Search in sources :

Example 6 with Score

use of es.bsc.compss.scheduler.types.Score 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 7 with Score

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

the class TaskScheduler method newAllocatableAction.

/*
     * *********************************************************************************************************
     * *********************************************************************************************************
     * ********************************* SCHEDULING OPERATIONS *************************************************
     * *********************************************************************************************************
     * *********************************************************************************************************
     */
/**
 * Introduces a new action in the Scheduler system. The method should place the action in a resource hurriedly
 *
 * @param action
 *            Action to be scheduled.
 */
public final void newAllocatableAction(AllocatableAction action) {
    LOGGER.info("[TaskScheduler] Registering new AllocatableAction " + action);
    if (!action.hasDataPredecessors()) {
        addToReady(action);
    }
    Score actionScore = generateActionScore(action);
    try {
        scheduleAction(action, actionScore);
        tryToLaunch(action);
    } catch (BlockedActionException bae) {
        removeFromReady(action);
        addToBlocked(action);
    }
}
Also used : Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException)

Example 8 with Score

use of es.bsc.compss.scheduler.types.Score 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 9 with Score

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

the class MOScheduleOptimizer method scheduleOnWorker.

public void scheduleOnWorker(AllocatableAction action, Implementation impl, OptimizationWorker ow) {
    boolean failedSpecificScheduling = false;
    try {
        action.schedule(ow.getResource(), impl);
        try {
            action.tryToLaunch();
        } catch (InvalidSchedulingException ise) {
            failedSpecificScheduling = true;
        }
    } catch (BlockedActionException bae) {
    // Can not happen since there was an original source
    } catch (UnassignedActionException be) {
        failedSpecificScheduling = true;
    }
    if (failedSpecificScheduling) {
        try {
            long actionScore = MOScore.getActionScore(action);
            long dataTime = MOScore.getDataPredecessorTime(action.getDataPredecessors());
            Score aScore = new MOScore(actionScore, dataTime, 0, 0, 0, 0);
            action.schedule(aScore);
            try {
                action.tryToLaunch();
            } catch (InvalidSchedulingException ise2) {
            // Impossible exception if schedule method on action is ok.
            }
        } catch (BlockedActionException | UnassignedActionException be) {
        // Can not happen since there was an original source
        }
    }
}
Also used : MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore) Score(es.bsc.compss.scheduler.types.Score) UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) InvalidSchedulingException(es.bsc.compss.scheduler.exceptions.InvalidSchedulingException) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 10 with Score

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

the class ExecutionAction method schedule.

private final <T extends WorkerResourceDescription> void schedule(Score actionScore, List<ResourceScheduler<? extends WorkerResourceDescription>> candidates) throws BlockedActionException, UnassignedActionException {
    // COMPUTE BEST WORKER AND IMPLEMENTATION
    StringBuilder debugString = new StringBuilder("Scheduling " + this + " execution:\n");
    ResourceScheduler<? extends WorkerResourceDescription> bestWorker = null;
    Implementation bestImpl = null;
    Score bestScore = null;
    int usefulResources = 0;
    for (ResourceScheduler<? extends WorkerResourceDescription> worker : candidates) {
        if (this.getExecutingResources().contains(worker)) {
            if (DEBUG) {
                LOGGER.debug("Task already ran on worker " + worker.getName());
            }
            continue;
        }
        Score resourceScore = worker.generateResourceScore(this, task.getTaskDescription(), actionScore);
        ++usefulResources;
        for (Implementation impl : getCompatibleImplementations(worker)) {
            Score implScore = worker.generateImplementationScore(this, task.getTaskDescription(), impl, resourceScore);
            if (DEBUG) {
                debugString.append(" Resource ").append(worker.getName()).append(" ").append(" Implementation ").append(impl.getImplementationId()).append(" ").append(" Score ").append(implScore).append("\n");
            }
            if (Score.isBetter(implScore, bestScore)) {
                bestWorker = worker;
                bestImpl = impl;
                bestScore = implScore;
            }
        }
    }
    // CHECK SCHEDULING RESULT
    if (DEBUG) {
        LOGGER.debug(debugString.toString());
    }
    if (bestWorker == null && usefulResources == 0) {
        LOGGER.warn("No worker can run " + this);
        throw new BlockedActionException();
    }
    schedule(bestWorker, bestImpl);
}
Also used : Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) Implementation(es.bsc.compss.types.implementations.Implementation)

Aggregations

Score (es.bsc.compss.scheduler.types.Score)12 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)9 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)7 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)4 ObjectValue (es.bsc.compss.scheduler.types.ObjectValue)4 PriorityQueue (java.util.PriorityQueue)4 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)3 MOScore (es.bsc.compss.scheduler.multiobjective.types.MOScore)3 Implementation (es.bsc.compss.types.implementations.Implementation)3 InvalidSchedulingException (es.bsc.compss.scheduler.exceptions.InvalidSchedulingException)2 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1 ConcurrentModificationException (java.util.ConcurrentModificationException)1 LinkedList (java.util.LinkedList)1