Search in sources :

Example 16 with AllocatableAction

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

the class ExecutionAction method tryToSchedule.

@SuppressWarnings("unchecked")
@Override
public final void tryToSchedule(Score actionScore) throws BlockedActionException, UnassignedActionException {
    // COMPUTE RESOURCE CANDIDATES
    List<ResourceScheduler<? extends WorkerResourceDescription>> candidates = new LinkedList<>();
    if (this.isTargetResourceEnforced()) {
        // The scheduling is forced to a given resource
        candidates.add((ResourceScheduler<WorkerResourceDescription>) this.getEnforcedTargetResource());
    } else if (isSchedulingConstrained()) {
        // The scheduling is constrained by dependencies
        for (AllocatableAction a : this.getConstrainingPredecessors()) {
            candidates.add((ResourceScheduler<WorkerResourceDescription>) a.getAssignedResource());
        }
    } else {
        // Free scheduling
        List<ResourceScheduler<? extends WorkerResourceDescription>> compatibleCandidates = getCompatibleWorkers();
        if (compatibleCandidates.size() == 0) {
            throw new BlockedActionException();
        }
        for (ResourceScheduler<? extends WorkerResourceDescription> currentWorker : compatibleCandidates) {
            if (currentWorker.getResource().hasAvailableSlots()) {
                candidates.add(currentWorker);
            }
        }
        if (candidates.size() == 0) {
            throw new UnassignedActionException();
        }
    }
    this.schedule(actionScore, candidates);
}
Also used : UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) List(java.util.List) LinkedList(java.util.LinkedList)

Example 17 with AllocatableAction

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

the class ResourceScheduler method tryToLaunchBlockedActions.

/**
 * Tries to launch blocked actions on resource. When an action cannot be launched, its successors are not tried
 */
@SuppressWarnings("unchecked")
public final void tryToLaunchBlockedActions() {
    LOGGER.debug("[ResourceScheduler] Try to launch blocked actions on resource " + getName());
    while (this.hasBlockedActions()) {
        AllocatableAction firstBlocked = this.getFirstBlocked();
        Implementation selectedImplementation = firstBlocked.getAssignedImplementation();
        if (!firstBlocked.isToReserveResources() || myWorker.canRunNow((T) selectedImplementation.getRequirements())) {
            try {
                firstBlocked.resumeExecution();
                this.removeFirstBlocked();
            } catch (ActionNotWaitingException anwe) {
            // Not possible. If the task is in blocked list it is waiting
            }
        } else {
            break;
        }
    }
}
Also used : ActionNotWaitingException(es.bsc.compss.scheduler.exceptions.ActionNotWaitingException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 18 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction 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);
        }
    }
}
Also used : ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction)

Example 19 with AllocatableAction

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

the class TaskScheduler method updateWorkloadState.

protected void updateWorkloadState(WorkloadState state) {
    LOGGER.info("[TaskScheduler] Get workload state");
    int coreCount = CoreManager.getCoreCount();
    Profile[] coreProfile = new Profile[coreCount];
    for (int coreId = 0; coreId < coreCount; coreId++) {
        coreProfile[coreId] = new Profile();
    }
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : workers.values()) {
        if (ui == null) {
            continue;
        }
        List<Implementation>[] impls = ui.getExecutableImpls();
        for (int coreId = 0; coreId < coreCount; coreId++) {
            for (Implementation impl : impls[coreId]) {
                coreProfile[coreId].accumulate(ui.getProfile(impl));
            }
        }
        AllocatableAction[] runningActions = ui.getHostedActions();
        long now = System.currentTimeMillis();
        for (AllocatableAction running : runningActions) {
            if (running.getImplementations().length > 0) {
                Integer coreId = running.getImplementations()[0].getCoreId();
                // CoreId can be null for Actions that are not tasks
                if (coreId != null) {
                    state.registerRunning(coreId, now - running.getStartTime());
                }
            }
        }
    }
    for (int coreId = 0; coreId < coreCount; coreId++) {
        state.registerNoResources(coreId, blockedActions.getActionCounts()[coreId]);
        state.registerReady(coreId, readyCounts[coreId]);
        state.registerTimes(coreId, coreProfile[coreId].getMinExecutionTime(), coreProfile[coreId].getAverageExecutionTime(), coreProfile[coreId].getMaxExecutionTime());
    }
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList) List(java.util.List) Profile(es.bsc.compss.scheduler.types.Profile) Implementation(es.bsc.compss.types.implementations.Implementation)

Example 20 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction 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);
    }
}
Also used : ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) Score(es.bsc.compss.scheduler.types.Score) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException)

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