Search in sources :

Example 1 with SchedulingEvent

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

the class MOResourceScheduler method rescheduleTasks.

@SuppressWarnings("unchecked")
public List<Gap> rescheduleTasks(LocalOptimizationState state, PriorityQueue<AllocatableAction> rescheduledActions) {
    this.runActionsCost = 0;
    this.runActionsEnergy = 0;
    for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
        for (int implId = 0; implId < CoreManager.getNumberCoreImplementations(coreId); implId++) {
            MOProfile profile = (MOProfile) this.getProfile(coreId, implId);
            runActionsEnergy += profile.getPower() * profile.getExecutionCount() * profile.getAverageExecutionTime();
            runActionsCost += profile.getPrice() * profile.getExecutionCount() * profile.getAverageExecutionTime();
        }
    }
    /*
         * 
         * 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.
         */
    Gap gap = state.peekFirstGap();
    ResourceDescription gapResource = gap.getResources();
    PriorityQueue<SchedulingEvent> schedulingQueue = new PriorityQueue<>();
    // For every running action we create a start event on their real start timeStamp
    for (AllocatableAction action : state.getRunningActions()) {
        manageRunningAction(action, state);
        MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
        schedulingQueue.offer(new SchedulingEvent.End(actionDSI.getExpectedEnd(), action));
    }
    while (state.areRunnableActions() && !gapResource.isDynamicUseless()) {
        AllocatableAction top = state.getMostPrioritaryRunnableAction();
        state.replaceAction(top);
        if (state.canActionRun()) {
            state.removeMostPrioritaryRunnableAction();
            // Start the current action
            MOSchedulingInformation topDSI = (MOSchedulingInformation) top.getSchedulingInfo();
            topDSI.lock();
            topDSI.clearPredecessors();
            manageRunningAction(top, state);
            if (tryToLaunch(top)) {
                schedulingQueue.offer(new SchedulingEvent.End(topDSI.getExpectedEnd(), top));
            }
        } else {
            break;
        }
    }
    while (!schedulingQueue.isEmpty() || state.areActionsToBeRescheduled()) {
        while (!schedulingQueue.isEmpty()) {
            SchedulingEvent 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:
                 * 
                 */
            List<SchedulingEvent> result = e.process(state, (MOResourceScheduler<WorkerResourceDescription>) this, rescheduledActions);
            for (SchedulingEvent r : result) {
                schedulingQueue.offer(r);
            }
        }
        if (state.areActionsToBeRescheduled()) {
            AllocatableAction topAction = state.getEarliestActionToBeRescheduled();
            MOSchedulingInformation topActionDSI = (MOSchedulingInformation) topAction.getSchedulingInfo();
            topActionDSI.lock();
            topActionDSI.setToReschedule(false);
            schedulingQueue.offer(new SchedulingEvent.Start(topActionDSI.getExpectedStart(), topAction));
        }
    }
    for (Gap g : state.getGaps()) {
        state.removeTmpGap(g);
    }
    this.pendingActionsCost = state.getTotalCost();
    this.pendingActionsEnergy = state.getTotalEnergy();
    this.implementationsCount = state.getImplementationsCount();
    this.expectedEndTimeRunning = state.getEndRunningTime();
    this.runningImplementationsCount = state.getRunningImplementations();
    this.runningActionsEnergy = state.getRunningEnergy();
    this.runningActionsCost = state.getRunningCost();
    this.resourceBlockingAction = state.getResourceBlockingAction();
    this.dataBlockingAction = state.getDataBlockingAction();
    return state.getGaps();
}
Also used : SchedulingEvent(es.bsc.compss.scheduler.multiobjective.types.SchedulingEvent) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) ResourceDescription(es.bsc.compss.types.resources.ResourceDescription) Gap(es.bsc.compss.scheduler.multiobjective.types.Gap) MOProfile(es.bsc.compss.scheduler.multiobjective.types.MOProfile)

Aggregations

Gap (es.bsc.compss.scheduler.multiobjective.types.Gap)1 MOProfile (es.bsc.compss.scheduler.multiobjective.types.MOProfile)1 SchedulingEvent (es.bsc.compss.scheduler.multiobjective.types.SchedulingEvent)1 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)1 ResourceDescription (es.bsc.compss.types.resources.ResourceDescription)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1 PriorityQueue (java.util.PriorityQueue)1