Search in sources :

Example 26 with AllocatableAction

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

the class FakeResourceScheduler method unscheduleAction.

@Override
public LinkedList<AllocatableAction> unscheduleAction(AllocatableAction action) {
    LinkedList<AllocatableAction> freeTasks = new LinkedList<>();
    FakeSI actionDSI = (FakeSI) action.getSchedulingInfo();
    // Remove action from predecessors
    for (AllocatableAction pred : actionDSI.getPredecessors()) {
        FakeSI predDSI = (FakeSI) pred.getSchedulingInfo();
        predDSI.removeSuccessor(action);
    }
    for (AllocatableAction successor : actionDSI.getSuccessors()) {
        FakeSI successorDSI = (FakeSI) successor.getSchedulingInfo();
        // Remove predecessor
        successorDSI.removePredecessor(action);
        // Link with action predecessors
        for (AllocatableAction predecessor : actionDSI.getPredecessors()) {
            FakeSI predecessorDSI = (FakeSI) predecessor.getSchedulingInfo();
            if (predecessor.isPending()) {
                successorDSI.addPredecessor(predecessor);
                predecessorDSI.addSuccessor(successor);
            }
        }
        // Check executability
        if (successorDSI.isExecutable()) {
            freeTasks.add(successor);
        }
    }
    actionDSI.clearPredecessors();
    actionDSI.clearSuccessors();
    return freeTasks;
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList)

Example 27 with AllocatableAction

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

the class MOResourceScheduler method classifyPendingUnschedulings.

public void classifyPendingUnschedulings(LocalOptimizationState state) {
    for (AllocatableAction unscheduledAction : pendingUnschedulings) {
        MOSchedulingInformation actionDSI = (MOSchedulingInformation) unscheduledAction.getSchedulingInfo();
        List<AllocatableAction> successors = actionDSI.getOptimizingSuccessors();
        for (AllocatableAction successor : successors) {
            // Data Dependencies analysis
            boolean hasInternal = false;
            boolean hasExternal = false;
            long startTime = 0;
            try {
                List<AllocatableAction> dPreds = successor.getDataPredecessors();
                for (AllocatableAction dPred : dPreds) {
                    MOSchedulingInformation dPredDSI = (MOSchedulingInformation) dPred.getSchedulingInfo();
                    if (dPred.getAssignedResource() == this) {
                        if (dPredDSI.tryToLock()) {
                            if (dPredDSI.isScheduled()) {
                                hasInternal = true;
                                dPredDSI.addOptimizingSuccessor(successor);
                            }
                            dPredDSI.unlock();
                        }
                    // else
                    // The predecessor is trying to be unscheduled but it is
                    // blocked by another successor reschedule.
                    } else {
                        hasExternal = true;
                        startTime = Math.max(startTime, dPredDSI.getExpectedEnd());
                    }
                }
            } catch (ConcurrentModificationException cme) {
                hasInternal = false;
                hasExternal = false;
                startTime = 0;
            }
            actionDSI.setExpectedStart(startTime);
            state.classifyAction(successor, hasInternal, hasExternal, true, startTime);
        }
    }
    pendingUnschedulings.clear();
}
Also used : ConcurrentModificationException(java.util.ConcurrentModificationException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction)

Example 28 with AllocatableAction

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

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

the class MOResourceScheduler method localOptimization.

/*--------------------------------------------------
     ---------------------------------------------------
     -------------- Optimization Methods ---------------
     ---------------------------------------------------
     --------------------------------------------------*/
@SuppressWarnings("unchecked")
public PriorityQueue<AllocatableAction> localOptimization(long updateId, Comparator<AllocatableAction> selectionComparator, Comparator<AllocatableAction> donorComparator) {
    // System.out.println("Local Optimization for " + this.getName() + " starts");
    LocalOptimizationState state = new LocalOptimizationState(updateId, (MOResourceScheduler<WorkerResourceDescription>) this, getReadyComparator(), selectionComparator);
    PriorityQueue<AllocatableAction> actions = new PriorityQueue<AllocatableAction>(1, donorComparator);
    synchronized (gaps) {
        opAction = new OptimizationAction();
    }
    // No changes in the Gap structure
    // Scan actions: Filters ready and selectable actions
    LOGGER.debug(LOG_PREFIX + "Scanning current actions");
    List<AllocatableAction> lockedActions = scanActions(state);
    // Gets all the pending schedulings
    List<AllocatableAction> newPendingSchedulings = new LinkedList<>();
    List<AllocatableAction> pendingSchedulings;
    synchronized (gaps) {
        MOSchedulingInformation opDSI = (MOSchedulingInformation) opAction.getSchedulingInfo();
        pendingSchedulings = opDSI.replaceSuccessors(newPendingSchedulings);
    }
    // Classify pending actions: Filters ready and selectable actions
    LOGGER.debug(LOG_PREFIX + "Classify Pending Scheduling/Unscheduling actions");
    classifyPendingSchedulings(pendingSchedulings, state);
    classifyPendingUnschedulings(state);
    // ClassifyActions
    LOGGER.debug(LOG_PREFIX + "Reschedule pending actions");
    List<Gap> newGaps = rescheduleTasks(state, actions);
    // Ensuring there are no locked actions after rescheduling
    for (AllocatableAction action : lockedActions) {
        MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
        try {
            actionDSI.unlock();
        } catch (IllegalMonitorStateException e) {
            LOGGER.debug(LOG_PREFIX + "Illegal Monitor Exception when releasing locked actions. Ignoring...");
        }
    }
    /*
         * System.out.println("\t is running: "); for (AllocatableAction aa : state.getRunningActions()) {
         * System.out.println("\t\t" + aa + " with implementation " + ((aa.getAssignedImplementation() == null) ? "null"
         * : aa .getAssignedImplementation().getImplementationId()) + " started " + ((aa.getStartTime() == null) ? "-" :
         * (System .currentTimeMillis() - aa.getStartTime())));
         * 
         * }
         * 
         * System.out.println(this.getName() + " has no resources for: "); for (AllocatableAction aa :
         * this.resourceBlockingAction .getDataSuccessors()) { System.out .println("\t" + aa + " with" +
         * " implementation " + ((aa.getAssignedImplementation() == null) ? "null" : aa.getAssignedImplementation()
         * .getImplementationId())); } System.out .println(this.getName() +
         * " will wait for data producers to be rescheduled for actions:"); for (AllocatableAction aa :
         * this.dataBlockingAction.getDataSuccessors()) { System.out .println("\t" + aa + " with" + " implementation " +
         * ((aa.getAssignedImplementation() == null) ? "null" : aa.getAssignedImplementation() .getImplementationId()));
         * }
         */
    // Schedules all the pending scheduligns and unblocks the scheduling of new actions
    LOGGER.debug(LOG_PREFIX + "Manage new gaps");
    synchronized (gaps) {
        gaps.clear();
        gaps.addAll(newGaps);
        MOSchedulingInformation opDSI = (MOSchedulingInformation) opAction.getSchedulingInfo();
        List<AllocatableAction> successors = opDSI.getSuccessors();
        for (AllocatableAction action : successors) {
            actions.add(action);
            MOSchedulingInformation actionDSI = (MOSchedulingInformation) action.getSchedulingInfo();
            actionDSI.lock();
            actionDSI.removePredecessor(opAction);
            this.scheduleUsingGaps(action, gaps);
            actionDSI.unlock();
        }
        opDSI.clearSuccessors();
        opAction = null;
    }
    // System.out.println("Local Optimization for " + this.getName() + " ends");
    return actions;
}
Also used : OptimizationAction(es.bsc.compss.scheduler.multiobjective.types.OptimizationAction) LocalOptimizationState(es.bsc.compss.scheduler.multiobjective.types.LocalOptimizationState) Gap(es.bsc.compss.scheduler.multiobjective.types.Gap) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue) LinkedList(java.util.LinkedList)

Example 30 with AllocatableAction

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

the class MOResourceScheduler method generateResourceScore.

/*--------------------------------------------------
     ---------------------------------------------------
     ------------------ Score Methods ------------------
     ---------------------------------------------------
     --------------------------------------------------*/
/**
 * @param action
 * @param params
 * @param actionScore
 * @return
 */
@Override
public Score generateResourceScore(AllocatableAction action, TaskDescription params, Score actionScore) {
    long resScore = Score.calculateDataLocalityScore(params, myWorker);
    for (AllocatableAction pred : action.getDataPredecessors()) {
        if (pred.isPending() && pred.getAssignedResource() == this) {
            resScore++;
        }
    }
    resScore = params.getParameters().length - resScore;
    long lessTimeStamp = Long.MAX_VALUE;
    Gap g = gaps.peekFirst();
    if (g != null) {
        lessTimeStamp = g.getInitialTime();
        if (lessTimeStamp < 0) {
            lessTimeStamp = 0;
        }
    }
    long actionPriority = actionScore.getActionScore();
    long expectedDataAvailable = ((MOScore) actionScore).getExpectedDataAvailable() + resScore * MOConfiguration.DATA_TRANSFER_DELAY;
    return new MOScore(actionPriority, expectedDataAvailable, lessTimeStamp, 0, 0, 0);
}
Also used : Gap(es.bsc.compss.scheduler.multiobjective.types.Gap) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) MOScore(es.bsc.compss.scheduler.multiobjective.types.MOScore)

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