Search in sources :

Example 6 with AllocatableAction

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

the class AllocatableActionTest method completed.

/*---------------------------------------------------------
     ----------------------------------------------------------
     --------------------- SCHEDULER ACTIONS ------------------
     ----------------------------------------------------------
     --------------------------------------------------------*/
public void completed(FakeAllocatableAction action) throws BlockedActionException, UnassignedActionException, InvalidSchedulingException {
    FakeResourceScheduler resource = (FakeResourceScheduler) action.getAssignedResource();
    List<AllocatableAction> dataFree = action.completed();
    List<AllocatableAction> resourceFree = resource.unscheduleAction(action);
    Set<AllocatableAction> freeTasks = new HashSet<>();
    freeTasks.addAll(dataFree);
    freeTasks.addAll(resourceFree);
    for (AllocatableAction a : freeTasks) {
        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) HashSet(java.util.HashSet)

Example 7 with AllocatableAction

use of es.bsc.compss.scheduler.types.AllocatableAction 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;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore) Score(es.bsc.compss.scheduler.types.Score) ActionNotFoundException(es.bsc.compss.scheduler.exceptions.ActionNotFoundException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) Implementation(es.bsc.compss.types.implementations.Implementation) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

Example 8 with AllocatableAction

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

the class MOScheduleOptimizer method globalOptimization.

/*--------------------------------------------------
     ---------------------------------------------------
     --------------- Local  optimization ---------------
     ---------------------------------------------------
     --------------------------------------------------*/
@SuppressWarnings("unchecked")
public void globalOptimization(long optimizationTS, Collection<ResourceScheduler<? extends WorkerResourceDescription>> workers) {
    LOGGER.debug(LOG_PREFIX + " --- Start Global Optimization ---");
    int workersCount = workers.size();
    if (workersCount == 0) {
        return;
    }
    OptimizationWorker[] optimizedWorkers = new OptimizationWorker[workersCount];
    LinkedList<OptimizationWorker> receivers = new LinkedList<>();
    int i = 0;
    for (ResourceScheduler<? extends WorkerResourceDescription> worker : workers) {
        optimizedWorkers[i] = new OptimizationWorker((MOResourceScheduler<WorkerResourceDescription>) worker);
        i++;
    }
    boolean hasDonated = true;
    while (hasDonated) {
        optimizationTS = System.currentTimeMillis();
        hasDonated = false;
        LOGGER.debug(LOG_PREFIX + " --- Iteration of global Optimization ---");
        // Perform local optimizations
        for (OptimizationWorker ow : optimizedWorkers) {
            LOGGER.debug(LOG_PREFIX + "Optimizing localy resource " + ow.getName());
            ow.localOptimization(optimizationTS);
            LOGGER.debug(LOG_PREFIX + "Resource " + ow.getName() + " will end at " + ow.getDonationIndicator());
        }
        LinkedList<OptimizationWorker> donors = determineDonorAndReceivers(optimizedWorkers, receivers);
        while (!hasDonated && !donors.isEmpty()) {
            OptimizationWorker donor = donors.remove();
            AllocatableAction candidate;
            while (!hasDonated && (candidate = donor.pollDonorAction()) != null) {
                /*
                     * if (candidate == null) { break; }
                     */
                Iterator<OptimizationWorker> recIt = receivers.iterator();
                while (recIt.hasNext()) {
                    OptimizationWorker receiver = recIt.next();
                    if (move(candidate, donor, receiver)) {
                        hasDonated = true;
                        break;
                    }
                }
            }
        }
        LOGGER.debug(LOG_PREFIX + "--- Optimization Iteration finished ---");
    }
    LOGGER.debug(LOG_PREFIX + "--- Global Optimization finished ---");
}
Also used : OptimizationWorker(es.bsc.compss.scheduler.multiobjective.types.OptimizationWorker) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList)

Example 9 with AllocatableAction

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

the class MOScheduler 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
 */
@Override
public <T extends WorkerResourceDescription> void handleDependencyFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
    Set<AllocatableAction> freeTasks = new HashSet<>();
    freeTasks.addAll(dataFreeActions);
    freeTasks.addAll(resourceFreeActions);
    for (AllocatableAction freeAction : freeTasks) {
        tryToLaunch(freeAction);
    }
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) HashSet(java.util.HashSet)

Example 10 with AllocatableAction

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

the class LocalOptimizationState method checkGapForReserve.

private boolean checkGapForReserve(Gap g, ResourceDescription requirements, long reserveStart, List<Gap> previousGaps) {
    boolean remove = false;
    AllocatableAction gapAction = g.getOrigin();
    ResourceDescription rd = g.getResources();
    ResourceDescription reduction = ResourceDescription.reduceCommonDynamics(rd, requirements);
    if (!reduction.isDynamicUseless()) {
        Gap tmpGap = new Gap(g.getInitialTime(), reserveStart, g.getOrigin(), reduction, 0);
        previousGaps.add(tmpGap);
        if (gapAction != null) {
            MOSchedulingInformation gapDSI = (MOSchedulingInformation) gapAction.getSchedulingInfo();
            // Remove resources from the first gap
            gapDSI.addGap();
        }
        // If the gap has been fully used
        if (rd.isDynamicUseless()) {
            // Remove the gap
            remove = true;
            if (gapAction != null) {
                MOSchedulingInformation gapDSI = (MOSchedulingInformation) gapAction.getSchedulingInfo();
                gapDSI.removeGap();
            }
        }
    }
    return remove;
}
Also used : MOSchedulingInformation(es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction)

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