Search in sources :

Example 1 with Profile

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

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

the class FullGraphResourceScheduler method manageRunningAction.

private void manageRunningAction(AllocatableAction<P, T, I> action, LocalOptimizationState<P, T, I> state) {
    I impl = action.getAssignedImplementation();
    FullGraphSchedulingInformation<P, T, I> actionDSI = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
    // Set start Time
    Long startTime = action.getStartTime();
    long start;
    if (startTime != null) {
        start = startTime - state.getId();
    } else {
        start = 0;
    }
    actionDSI.setExpectedStart(start);
    // Set End Time
    Profile p = getProfile(impl);
    long endTime = start;
    if (p != null) {
        endTime += p.getAverageExecutionTime();
    }
    if (endTime < 0) {
        endTime = 0;
    }
    actionDSI.setExpectedEnd(endTime);
    actionDSI.clearPredecessors();
    actionDSI.clearSuccessors();
    actionDSI.setToReschedule(false);
    state.reserveResources(impl.getRequirements(), 0);
}
Also used : Profile(es.bsc.es.bsc.compss.scheduler.types.Profile)

Example 3 with Profile

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

the class FullGraphResourceScheduler method generateImplementationScore.

/**
 * @param action
 * @param params
 * @param impl
 * @param resourceScore
 * @return
 */
@SuppressWarnings("unchecked")
@Override
public Score generateImplementationScore(AllocatableAction<P, T, I> action, TaskDescription params, I impl, Score resourceScore) {
    LOGGER.debug("[FullGraphScheduler] Generate implementation score for action " + action.getId());
    ResourceDescription rd = impl.getRequirements().copy();
    long resourceFreeTime = 0;
    try {
        for (Gap<P, T, I> g : gaps) {
            rd.reduceDynamic(g.getResources());
            if (rd.isDynamicUseless()) {
                resourceFreeTime = g.getInitialTime();
                break;
            }
        }
    } catch (ConcurrentModificationException cme) {
        resourceFreeTime = 0;
    }
    if (resourceFreeTime < 0) {
        resourceFreeTime = 0;
    }
    long implScore;
    Profile p = this.getProfile(impl);
    if (p != null) {
        implScore = p.getAverageExecutionTime();
    } else {
        implScore = 0;
    }
    // The data transfer penalty is already included on the datadependency time of the resourceScore
    return new FullGraphScore<P, T, I>((FullGraphScore<P, T, I>) resourceScore, 0, 0, resourceFreeTime, implScore);
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) FullGraphScore(es.bsc.es.bsc.compss.scheduler.types.FullGraphScore) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) Profile(es.bsc.es.bsc.compss.scheduler.types.Profile)

Example 4 with Profile

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

the class ScheduleOptimizer method move.

private boolean move(AllocatableAction<P, T, I> action, OptimizationWorker<P, T, I> donor, OptimizationWorker<P, T, I> receiver) {
    LinkedList<AllocatableAction<P, T, I>> dataPreds = action.getDataPredecessors();
    long dataAvailable = 0;
    try {
        for (AllocatableAction<P, T, I> dataPred : dataPreds) {
            FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) dataPred.getSchedulingInfo();
            dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
        }
    } catch (ConcurrentModificationException cme) {
        dataAvailable = 0;
        dataPreds = action.getDataPredecessors();
    }
    I bestImpl = null;
    long bestTime = Long.MAX_VALUE;
    LinkedList<I> impls = action.getCompatibleImplementations(receiver.getResource());
    for (I impl : impls) {
        Profile p = receiver.getResource().getProfile(impl);
        long avgTime = p.getAverageExecutionTime();
        if (avgTime < bestTime) {
            bestTime = avgTime;
            bestImpl = impl;
        }
    }
    FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
    long currentEnd = dsi.getExpectedEnd();
    if (bestImpl != null && currentEnd > receiver.getResource().getLastGapExpectedStart() + bestTime) {
        unschedule(action);
        schedule(action, bestImpl, receiver);
        return true;
    }
    return false;
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) AllocatableAction(es.bsc.es.bsc.compss.scheduler.types.AllocatableAction) Profile(es.bsc.es.bsc.compss.scheduler.types.Profile)

Aggregations

Profile (es.bsc.es.bsc.compss.scheduler.types.Profile)4 ResourceDescription (es.bsc.compss.types.resources.ResourceDescription)2 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)2 AllocatableAction (es.bsc.es.bsc.compss.scheduler.types.AllocatableAction)2 ConcurrentModificationException (java.util.ConcurrentModificationException)2 FullGraphScore (es.bsc.es.bsc.compss.scheduler.types.FullGraphScore)1 Gap (es.bsc.es.bsc.compss.scheduler.types.Gap)1 LinkedList (java.util.LinkedList)1