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;
}
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();
}
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);
}
}
}
Aggregations