Search in sources :

Example 41 with AllocatableAction

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

the class ActionSet method removeAllCompatibleActions.

public <T extends WorkerResourceDescription> List<AllocatableAction> removeAllCompatibleActions(Worker<T> r) {
    List<AllocatableAction> runnable = new LinkedList<>();
    Iterator<AllocatableAction> actions = this.noCore.iterator();
    while (actions.hasNext()) {
        AllocatableAction action = actions.next();
        if (action.isCompatible(r)) {
            actions.remove();
            totalActions--;
            runnable.add(action);
        }
    }
    List<Integer> executableCores = r.getExecutableCores();
    for (int core : executableCores) {
        runnable.addAll(coreIndexed[core]);
        totalActions = totalActions - this.counts[core];
        this.coreIndexed[core] = new LinkedList<>();
        this.counts[core] = 0;
    }
    return runnable;
}
Also used : AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) LinkedList(java.util.LinkedList)

Example 42 with AllocatableAction

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

the class PrintCurrentGraphRequest method process.

@Override
public void process(TaskScheduler ts) throws ShutdownException {
    try {
        PriorityQueue<Task> pending = new PriorityQueue<>();
        Set<Task> tasks = new HashSet<>();
        String prefix = "  ";
        // Header options
        graph.write(prefix + "outputorder=\"edgesfirst\";");
        graph.newLine();
        graph.write(prefix + "compound=true;");
        graph.newLine();
        /* Subgraph for blocked and scheduled tasks ******************** */
        graph.write(prefix + "subgraph cluster1 {");
        graph.newLine();
        graph.write(prefix + prefix + "color=white");
        graph.newLine();
        // Room for Blocked tasks
        int roomIndex = 1;
        graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
        ++roomIndex;
        graph.newLine();
        graph.write(prefix + prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "label = \"Blocked\"");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "color=red");
        graph.newLine();
        List<AllocatableAction> blockedActions = ts.getBlockedActions();
        for (AllocatableAction action : blockedActions) {
            if (action instanceof ExecutionAction) {
                ExecutionAction se = (ExecutionAction) action;
                Task t = se.getTask();
                graph.write(prefix + prefix + prefix + t.getDotDescription());
                graph.newLine();
                pending.addAll(t.getSuccessors());
                tasks.add(t);
            }
        }
        graph.write(prefix + prefix + "}");
        graph.newLine();
        // Room for unassigned tasks
        graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
        ++roomIndex;
        graph.newLine();
        graph.write(prefix + prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "label = \"No Assigned\"");
        graph.newLine();
        graph.write(prefix + prefix + prefix + "color=orange");
        graph.newLine();
        List<AllocatableAction> unassignedActions = ts.getUnassignedActions();
        for (AllocatableAction action : unassignedActions) {
            if (action instanceof ExecutionAction) {
                ExecutionAction se = (ExecutionAction) action;
                Task t = se.getTask();
                graph.write(prefix + prefix + prefix + t.getDotDescription());
                graph.newLine();
                pending.addAll(t.getSuccessors());
                tasks.add(t);
            }
        }
        graph.write(prefix + prefix + "}");
        graph.newLine();
        // Add another room for each worker
        for (Worker<? extends WorkerResourceDescription> worker : ResourceManager.getAllWorkers()) {
            graph.write(prefix + prefix + "subgraph cluster_room" + roomIndex + " {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "label = \"" + worker.getName() + "\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "color=black");
            graph.newLine();
            // Create a box for running tasks
            graph.write(prefix + prefix + prefix + "subgraph cluster_box" + roomIndex + "1 {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "label = \"Running\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "ranksep=0.20;");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "node[height=0.75];");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "color=green");
            graph.newLine();
            AllocatableAction[] hostedActions = ts.getHostedActions(worker);
            for (AllocatableAction action : hostedActions) {
                if (action instanceof ExecutionAction) {
                    ExecutionAction se = (ExecutionAction) action;
                    Task t = se.getTask();
                    graph.write(prefix + prefix + prefix + prefix + t.getDotDescription());
                    graph.newLine();
                    pending.addAll(t.getSuccessors());
                    tasks.add(t);
                }
            }
            graph.write(prefix + prefix + prefix + "}");
            graph.newLine();
            graph.write(prefix + prefix + prefix + "subgraph cluster_box" + roomIndex + "2 {");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "label = \"Resource Blocked\"");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "ranksep=0.20;");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "node[height=0.75];");
            graph.newLine();
            graph.write(prefix + prefix + prefix + prefix + "color=red");
            graph.newLine();
            PriorityQueue<AllocatableAction> blockedActionsOnResource = ts.getBlockedActionsOnResource(worker);
            for (AllocatableAction action : blockedActionsOnResource) {
                if (action instanceof ExecutionAction) {
                    ExecutionAction se = (ExecutionAction) action;
                    Task t = se.getTask();
                    graph.write(prefix + prefix + prefix + prefix + t.getDotDescription());
                    graph.newLine();
                    pending.addAll(t.getSuccessors());
                    tasks.add(t);
                }
            }
            // Close box
            graph.write(prefix + prefix + prefix + "}");
            graph.newLine();
            // Close room
            graph.write(prefix + prefix + "}");
            graph.newLine();
            ++roomIndex;
        }
        // Close cluster
        graph.write(prefix + "}");
        graph.newLine();
        /* Subgraph for pending tasks ********************************** */
        graph.write(prefix + "subgraph cluster2 {");
        graph.newLine();
        graph.write(prefix + prefix + "label = \"Pending\"");
        graph.newLine();
        graph.write(prefix + prefix + "ranksep=0.20;");
        graph.newLine();
        graph.write(prefix + prefix + "node[height=0.75];");
        graph.newLine();
        graph.write(prefix + prefix + "color=blue");
        graph.newLine();
        while (!pending.isEmpty()) {
            Task t = pending.poll();
            if (!tasks.contains(t)) {
                graph.write(prefix + prefix + t.getDotDescription());
                graph.newLine();
                tasks.add(t);
                pending.addAll(t.getSuccessors());
            }
        }
        // Close cluster
        graph.write(prefix + "}");
        graph.newLine();
        /* Write edges *************************************************** */
        for (Task t : tasks) {
            Set<Task> successors = new HashSet<>();
            successors.addAll(t.getSuccessors());
            for (Task t2 : successors) {
                graph.write(prefix + t.getId() + " -> " + t2.getId() + ";");
                graph.newLine();
            }
        }
        /* Force flush before end ***************************************** */
        graph.flush();
    } catch (IOException e) {
        LOGGER.error(ERROR_PRINT_CURRENT_GRAPH);
    }
    sem.release();
}
Also used : Task(es.bsc.compss.types.Task) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) IOException(java.io.IOException) PriorityQueue(java.util.PriorityQueue) ExecutionAction(es.bsc.compss.types.allocatableactions.ExecutionAction) HashSet(java.util.HashSet)

Example 43 with AllocatableAction

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

the class ReadyScheduler method tryToLaunchFreeActions.

private <T extends WorkerResourceDescription> void tryToLaunchFreeActions(List<AllocatableAction> dataFreeActions, List<AllocatableAction> resourceFreeActions, List<AllocatableAction> blockedCandidates, ResourceScheduler<T> resource) {
    // Try to launch all the data free actions and the resource free actions
    PriorityQueue<ObjectValue<AllocatableAction>> executableActions = new PriorityQueue<>();
    for (AllocatableAction freeAction : dataFreeActions) {
        Score actionScore = generateActionScore(freeAction);
        Score fullScore = freeAction.schedulingScore(resource, actionScore);
        ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
        executableActions.add(obj);
    }
    for (AllocatableAction freeAction : resourceFreeActions) {
        Score actionScore = generateActionScore(freeAction);
        Score fullScore = freeAction.schedulingScore(resource, actionScore);
        ObjectValue<AllocatableAction> obj = new ObjectValue<>(freeAction, fullScore);
        if (!executableActions.contains(obj)) {
            executableActions.add(obj);
        }
    }
    while (!executableActions.isEmpty()) {
        ObjectValue<AllocatableAction> obj = executableActions.poll();
        AllocatableAction freeAction = obj.getObject();
        // LOGGER.debug("Trying to launch action " + freeAction);
        try {
            scheduleAction(freeAction, obj.getScore());
            tryToLaunch(freeAction);
        } catch (BlockedActionException e) {
            removeFromReady(freeAction);
            addToBlocked(freeAction);
        }
    }
}
Also used : Score(es.bsc.compss.scheduler.types.Score) ObjectValue(es.bsc.compss.scheduler.types.ObjectValue) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) AllocatableAction(es.bsc.compss.scheduler.types.AllocatableAction) PriorityQueue(java.util.PriorityQueue)

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