Search in sources :

Example 1 with Task

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

the class TaskAnalyser method deleteFile.

/**
 * Deletes the specified file and its renamings
 *
 * @param fileInfo
 */
public void deleteFile(FileInfo fileInfo) {
    int dataId = fileInfo.getDataId();
    LOGGER.debug("Deleting file with id " + dataId + " and location " + fileInfo.getOriginalLocation());
    Task task = writers.get(dataId);
    if (task != null) {
        return;
    }
    LOGGER.debug("Removing " + fileInfo.getDataId() + " from written files");
    for (TreeSet<Integer> files : appIdToWrittenFiles.values()) {
        files.remove(fileInfo.getDataId());
    }
}
Also used : Task(es.bsc.compss.types.Task)

Example 2 with Task

use of es.bsc.compss.types.Task 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 3 with Task

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

the class TaskAnalyser method addNewBarrier.

/**
 * We have explicitly called the barrier API. STEPS: Add a new synchronization node. Add an edge from last
 * synchronization point to barrier. Add edges from writer tasks to barrier
 */
private void addNewBarrier() {
    // Add barrier node
    synchronizationId++;
    taskDetectedAfterSync = false;
    this.GM.addBarrierToGraph(synchronizationId);
    // Add edge from last sync
    if (synchronizationId > 1) {
        this.GM.addEdgeToGraph("Synchro" + (synchronizationId - 1), "Synchro" + synchronizationId, "");
    }
    // Add edges from writers to barrier
    HashSet<Task> uniqueWriters = new HashSet<>(writers.values());
    for (Task writer : uniqueWriters) {
        if (writer.getSynchronizationId() == (synchronizationId - 1)) {
            this.GM.addEdgeToGraph(String.valueOf(writer.getId()), "Synchro" + synchronizationId, "");
        }
    }
}
Also used : Task(es.bsc.compss.types.Task) HashSet(java.util.HashSet)

Example 4 with Task

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

the class TaskAnalyser method findWaitedTask.

/**
 * Returns the tasks dependent to the requested task
 *
 * @param request
 */
public void findWaitedTask(WaitForTaskRequest request) {
    int dataId = request.getDataId();
    AccessMode am = request.getAccessMode();
    Semaphore sem = request.getSemaphore();
    Task lastWriter = writers.get(dataId);
    if (lastWriter != null) {
        // Add to writers if needed
        if (am == AccessMode.RW) {
            writers.put(dataId, null);
        }
        // Add graph description
        if (drawGraph) {
            addEdgeFromTaskToMain(lastWriter, dataId);
        }
    }
    // Release task if possible. Otherwise add to waiting
    if (lastWriter == null || lastWriter.getStatus() == TaskState.FINISHED) {
        sem.release();
    } else {
        List<Semaphore> list = waitedTasks.get(lastWriter);
        if (list == null) {
            list = new LinkedList<>();
            waitedTasks.put(lastWriter, list);
        }
        list.add(sem);
    }
}
Also used : Task(es.bsc.compss.types.Task) Semaphore(java.util.concurrent.Semaphore)

Example 5 with Task

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

the class TaskAnalyser method checkDependencyForRead.

/*
     **************************************************************************************************************
     * DATA DEPENDENCY MANAGEMENT PRIVATE METHODS
     **************************************************************************************************************/
/**
 * Checks the dependencies of a task @currentTask considering the parameter @dp
 *
 * @param currentTask
 * @param dp
 */
private void checkDependencyForRead(Task currentTask, DependencyParameter dp) {
    int dataId = dp.getDataAccessId().getDataId();
    Task lastWriter = writers.get(dataId);
    if (lastWriter != null && lastWriter != currentTask) {
        if (DEBUG) {
            LOGGER.debug("Last writer for datum " + dp.getDataAccessId().getDataId() + " is task " + lastWriter.getId());
            LOGGER.debug("Adding dependency between task " + lastWriter.getId() + " and task " + currentTask.getId());
        }
        // Add dependency
        currentTask.addDataDependency(lastWriter);
        // Draw dependency to graph
        if (drawGraph) {
            addEdgeFromTaskToTask(lastWriter, currentTask, dataId);
        }
    } else {
        // Last writer is the main
        if (drawGraph) {
            addEdgeFromMainToTask(currentTask, dataId);
        }
    }
}
Also used : Task(es.bsc.compss.types.Task)

Aggregations

Task (es.bsc.compss.types.Task)5 HashSet (java.util.HashSet)2 AllocatableAction (es.bsc.compss.scheduler.types.AllocatableAction)1 ExecutionAction (es.bsc.compss.types.allocatableactions.ExecutionAction)1 IOException (java.io.IOException)1 PriorityQueue (java.util.PriorityQueue)1 Semaphore (java.util.concurrent.Semaphore)1