Search in sources :

Example 11 with ResourceDescription

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

the class LocalOptimizationState method reserveResources.

public List<Gap> reserveResources(ResourceDescription resources, long startTime) {
    List<Gap> previousGaps = new LinkedList<>();
    // Remove requirements from resource description
    ResourceDescription requirements = resources.copy();
    Iterator<Gap> gapIt = gaps.iterator();
    while (gapIt.hasNext() && !requirements.isDynamicUseless()) {
        Gap 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 12 with ResourceDescription

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

the class LocalOptimizationState method releaseResources.

public void releaseResources(long expectedStart, AllocatableAction action) {
    if (action.getAssignedImplementation() != null) {
        Gap gap;
        gap = new Gap(expectedStart, Long.MAX_VALUE, action, action.getAssignedImplementation().getRequirements().copy(), 0);
        MOSchedulingInformation dsi = (MOSchedulingInformation) action.getSchedulingInfo();
        dsi.addGap();
        gaps.add(gap);
        if (missingResources != null) {
            ResourceDescription empty = gap.getResources().copy();
            topStartTime = gap.getInitialTime();
            ResourceDescription.reduceCommonDynamics(empty, missingResources);
        }
    } else {
        LOGGER.debug(LOG_PREFIX + "Action has null implementation. Nothing done at release resources *** ");
    }
}
Also used : MOSchedulingInformation(es.bsc.compss.scheduler.multiobjective.MOSchedulingInformation) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription)

Example 13 with ResourceDescription

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

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

the class FullGraphResourceScheduler method rescheduleTasks.

public LinkedList<Gap<P, T, I>> rescheduleTasks(long updateId, PriorityQueue<AllocatableAction<P, T, I>> readyActions, PriorityActionSet<P, T, I> selectableActions, LinkedList<AllocatableAction<P, T, I>> runningActions, PriorityQueue<AllocatableAction<P, T, I>> rescheduledActions) {
    /*
         * 
         * ReadyActions contains those actions that have no dependencies with other actions scheduled on the node, but
         * they have data dependencies with tasks on other resources. They are sorted by the expected time when these
         * dependencies will be solved.
         * 
         * SelectableActions contains those actions that have no data dependencies with other actions but they wait for
         * resources to be released.
         * 
         * Running actions contains a list of Actions that are executing or potentially executing at the moment.
         * 
         * All Actions that need to be rescheduled have the onOptimization and scheduled flags on.
         * 
         * Those actions that are running or could potentially be started ( no dependencies with other actions in the
         * resource) are already locked to avoid their start without being on the runningActions set.
         */
    LocalOptimizationState<P, T, I> state = new LocalOptimizationState<>(updateId, myWorker.getDescription());
    Gap<P, T, I> gap = state.peekFirstGap();
    ResourceDescription gapResource = gap.getResources();
    PriorityQueue<SchedulingEvent<P, T, I>> schedulingQueue = new PriorityQueue<SchedulingEvent<P, T, I>>();
    // For every running action we create a start event on their real start timeStamp
    for (AllocatableAction<P, T, I> action : runningActions) {
        manageRunningAction(action, state);
        FullGraphSchedulingInformation<P, T, I> actionDSI = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
        schedulingQueue.offer(new SchedulingEvent.End<P, T, I>(actionDSI.getExpectedEnd(), action));
    }
    while (!selectableActions.isEmpty() && !gapResource.isDynamicUseless()) {
        AllocatableAction<P, T, I> top = selectableActions.peek();
        state.replaceAction(top);
        if (state.canActionRun()) {
            selectableActions.poll();
            // Start the current action
            FullGraphSchedulingInformation<P, T, I> topDSI = (FullGraphSchedulingInformation<P, T, I>) top.getSchedulingInfo();
            topDSI.lock();
            topDSI.clearPredecessors();
            manageRunningAction(top, state);
            if (tryToLaunch(top)) {
                schedulingQueue.offer(new SchedulingEvent.End<P, T, I>(topDSI.getExpectedEnd(), top));
            }
        } else {
            break;
        }
    }
    while (!schedulingQueue.isEmpty() || !readyActions.isEmpty()) {
        while (!schedulingQueue.isEmpty()) {
            SchedulingEvent<P, T, I> e = schedulingQueue.poll();
            /*
                 * Start Event: - sets the expected start and end times - adds resource dependencies with the previous
                 * actions - if there's a gap before the dependency -tries to fill it with other tasks - if all the
                 * resources released by the predecessor are used later - the action is unlocked
                 * 
                 * End Event:
                 */
            LinkedList<SchedulingEvent<P, T, I>> result = e.process(state, this, readyActions, selectableActions, rescheduledActions);
            for (SchedulingEvent<P, T, I> r : result) {
                schedulingQueue.offer(r);
            }
        }
        if (!readyActions.isEmpty()) {
            AllocatableAction<P, T, I> topAction = readyActions.poll();
            FullGraphSchedulingInformation<P, T, I> topActionDSI = (FullGraphSchedulingInformation<P, T, I>) topAction.getSchedulingInfo();
            topActionDSI.lock();
            topActionDSI.setToReschedule(false);
            schedulingQueue.offer(new SchedulingEvent.Start<P, T, I>(topActionDSI.getExpectedStart(), topAction));
        }
    }
    for (Gap<P, T, I> g : state.getGaps()) {
        state.removeTmpGap(g);
    }
    return state.getGaps();
}
Also used : LocalOptimizationState(es.bsc.es.bsc.compss.scheduler.types.LocalOptimizationState) SchedulingEvent(es.bsc.es.bsc.compss.scheduler.types.SchedulingEvent) PriorityQueue(java.util.PriorityQueue) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription)

Example 15 with ResourceDescription

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

the class LocalOptimizationState method releaseResources.

public void releaseResources(long expectedStart, AllocatableAction<P, T, I> action) {
    Gap<P, T, I> gap = new Gap<>(expectedStart, Long.MAX_VALUE, action, action.getAssignedImplementation().getRequirements(), 0);
    FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
    dsi.addGap();
    gaps.add(gap);
    if (missingResources != null) {
        ResourceDescription empty = gap.getResources().copy();
        topStartTime = gap.getInitialTime();
        ResourceDescription.reduceCommonDynamics(empty, missingResources);
    }
}
Also used : FullGraphSchedulingInformation(es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation) 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