Search in sources :

Example 6 with ResourceDescription

use of es.bsc.compss.types.resources.ResourceDescription 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)

Example 7 with ResourceDescription

use of es.bsc.compss.types.resources.ResourceDescription in project compss by bsc-wdc.

the class FullGraphResourceScheduler method scheduleUsingGaps.

private void scheduleUsingGaps(AllocatableAction<P, T, I> action, LinkedList<Gap<P, T, I>> gaps) {
    long expectedStart = 0;
    // Compute start time due to data dependencies
    for (AllocatableAction<P, T, I> predecessor : action.getDataPredecessors()) {
        FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
        if (predDSI.isScheduled()) {
            long predEnd = predDSI.getExpectedEnd();
            expectedStart = Math.max(expectedStart, predEnd);
        }
    }
    FullGraphSchedulingInformation<P, T, I> schedInfo = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
    I impl = action.getAssignedImplementation();
    Profile p = getProfile(impl);
    ResourceDescription constraints = impl.getRequirements().copy();
    LinkedList<AllocatableAction<P, T, I>> predecessors = new LinkedList<>();
    Iterator<Gap<P, T, I>> gapIt = gaps.descendingIterator();
    boolean fullyCoveredReqs = false;
    // Check gaps before data start
    while (gapIt.hasNext() && !fullyCoveredReqs) {
        Gap<P, T, I> gap = gapIt.next();
        if (gap.getInitialTime() <= expectedStart) {
            AllocatableAction<P, T, I> predecessor = (AllocatableAction<P, T, I>) gap.getOrigin();
            if (predecessor != null) {
                FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
                predDSI.lock();
                predecessors.add(predecessor);
            }
            ResourceDescription gapResource = gap.getResources();
            ResourceDescription.reduceCommonDynamics(gapResource, constraints);
            if (gapResource.isDynamicUseless()) {
                gapIt.remove();
            }
            if (constraints.isDynamicUseless()) {
                fullyCoveredReqs = true;
            }
        }
    }
    // Check gaps after data start
    gapIt = gaps.iterator();
    while (gapIt.hasNext() && !fullyCoveredReqs) {
        Gap<P, T, I> gap = gapIt.next();
        AllocatableAction<P, T, I> predecessor = (AllocatableAction<P, T, I>) gap.getOrigin();
        if (predecessor != null) {
            FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
            predDSI.lock();
            predecessors.add(predecessor);
        }
        ResourceDescription gapResource = gap.getResources();
        ResourceDescription.reduceCommonDynamics(gapResource, constraints);
        if (gapResource.isDynamicUseless()) {
            gapIt.remove();
        }
        if (constraints.isDynamicUseless()) {
            fullyCoveredReqs = true;
        }
    }
    // Lock acces to the current task
    schedInfo.lock();
    schedInfo.scheduled();
    // Unlock access to predecessor
    for (AllocatableAction<P, T, I> predecessor : predecessors) {
        FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
        if (predDSI.isScheduled()) {
            long predEnd = predDSI.getExpectedEnd();
            expectedStart = Math.max(expectedStart, predEnd);
            schedInfo.addPredecessor(predecessor);
            predDSI.addSuccessor(action);
        }
        predDSI.unlock();
    }
    // Compute end time
    schedInfo.setExpectedStart(expectedStart);
    long expectedEnd = expectedStart;
    if (p != null) {
        expectedEnd += p.getAverageExecutionTime();
    }
    schedInfo.setExpectedEnd(expectedEnd);
    // Unlock access to current task
    schedInfo.unlock();
    // Create new Gap correspondin to the resources released by the action
    addGap(new Gap<P, T, I>(expectedEnd, Long.MAX_VALUE, action, impl.getRequirements().copy(), 0));
}
Also used : AllocatableAction(es.bsc.es.bsc.compss.scheduler.types.AllocatableAction) Profile(es.bsc.es.bsc.compss.scheduler.types.Profile) LinkedList(java.util.LinkedList) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) Gap(es.bsc.es.bsc.compss.scheduler.types.Gap)

Example 8 with ResourceDescription

use of es.bsc.compss.types.resources.ResourceDescription in project compss by bsc-wdc.

the class LocalOptimizationState method reserveResources.

public LinkedList<Gap<P, T, I>> reserveResources(ResourceDescription resources, long startTime) {
    LinkedList<Gap<P, T, I>> previousGaps = new LinkedList<>();
    // Remove requirements from resource description
    ResourceDescription requirements = resources.copy();
    Iterator<Gap<P, T, I>> gapIt = gaps.iterator();
    while (gapIt.hasNext() && !requirements.isDynamicUseless()) {
        Gap<P, T, I> g = gapIt.next();
        if (checkGapForReserve(g, requirements, startTime, previousGaps)) {
            gapIt.remove();
        }
    }
    return previousGaps;
}
Also used : ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) LinkedList(java.util.LinkedList)

Example 9 with ResourceDescription

use of es.bsc.compss.types.resources.ResourceDescription in project compss by bsc-wdc.

the class MOResourceScheduler method addGap.

private void addGap(Gap g) {
    AllocatableAction gapAction = g.getOrigin();
    ResourceDescription releasedResources = g.getResources();
    boolean merged = false;
    for (Gap registeredGap : gaps) {
        if (registeredGap.getOrigin() == gapAction) {
            ResourceDescription registeredResources = registeredGap.getResources();
            registeredResources.increaseDynamic(releasedResources);
            merged = true;
            break;
        }
    }
    if (!merged) {
        Iterator<Gap> gapIt = gaps.iterator();
        int index = 0;
        Gap gap;
        while (gapIt.hasNext() && (gap = gapIt.next()) != null && gap.getInitialTime() <= g.getInitialTime()) {
            index++;
        }
        gaps.add(index, g);
    }
}
Also used : WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) Gap(es.bsc.compss.scheduler.multiobjective.types.Gap) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction)

Example 10 with ResourceDescription

use of es.bsc.compss.types.resources.ResourceDescription in project compss by bsc-wdc.

the class LocalOptimizationState method replaceAction.

public void replaceAction(AllocatableAction action) {
    this.action = action;
    if (this.action != null) {
        missingResources = this.action.getAssignedImplementation().getRequirements().copy();
        // Check if the new peek can run in the already freed resources.
        for (Gap gap : gaps) {
            ResourceDescription empty = gap.getResources().copy();
            topStartTime = gap.getInitialTime();
            ResourceDescription.reduceCommonDynamics(empty, missingResources);
            if (missingResources.isDynamicUseless()) {
                break;
            }
        }
    } else {
        missingResources = null;
        topStartTime = 0l;
    }
}
Also used : ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription)

Aggregations

ResourceDescription (es.bsc.compss.types.resources.ResourceDescription)17 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)17 Gap (es.bsc.compss.scheduler.multiobjective.types.Gap)6 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)6 LinkedList (java.util.LinkedList)5 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)3 MOSchedulingInformation (es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation)2 Implementation (es.bsc.compss.types.implementations.Implementation)2 FullGraphSchedulingInformation (es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation)2 Profile (es.bsc.es.bsc.compss.scheduler.types.Profile)2 ConcurrentModificationException (java.util.ConcurrentModificationException)2 PriorityQueue (java.util.PriorityQueue)2 ActionNotFoundException (es.bsc.compss.scheduler.exceptions.ActionNotFoundException)1 OptimizationAction (es.bsc.compss.scheduler.multiobjective.types.OptimizationAction)1 SchedulingEvent (es.bsc.compss.scheduler.multiobjective.types.SchedulingEvent)1 AllocatableAction (es.bsc.es.bsc.compss.scheduler.types.AllocatableAction)1 FullGraphScore (es.bsc.es.bsc.compss.scheduler.types.FullGraphScore)1 Gap (es.bsc.es.bsc.compss.scheduler.types.Gap)1 LocalOptimizationState (es.bsc.es.bsc.compss.scheduler.types.LocalOptimizationState)1 SchedulingEvent (es.bsc.es.bsc.compss.scheduler.types.SchedulingEvent)1