Search in sources :

Example 1 with Worker

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

the class Action method findAvailableWorkers.

@SuppressWarnings("unchecked")
public Map<Worker<?>, List<Implementation>> findAvailableWorkers() {
    Map<Worker<?>, List<Implementation>> m = new HashMap<>();
    List<ResourceScheduler<? extends WorkerResourceDescription>> compatibleWorkers = getCoreElementExecutors(coreId);
    for (ResourceScheduler<? extends WorkerResourceDescription> ui : compatibleWorkers) {
        Worker<WorkerResourceDescription> r = (Worker<WorkerResourceDescription>) ui.getResource();
        List<Implementation> compatibleImpls = r.getExecutableImpls(coreId);
        List<Implementation> runnableImpls = new LinkedList<>();
        for (Implementation impl : compatibleImpls) {
            if (r.canRunNow(impl.getRequirements())) {
                runnableImpls.add(impl);
            }
        }
        if (runnableImpls.size() > 0) {
            m.put((Worker<?>) r, runnableImpls);
        }
    }
    return m;
}
Also used : HashMap(java.util.HashMap) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) Worker(es.bsc.compss.types.resources.Worker) List(java.util.List) LinkedList(java.util.LinkedList) ResourceScheduler(es.bsc.compss.components.impl.ResourceScheduler) Implementation(es.bsc.compss.types.implementations.Implementation) LinkedList(java.util.LinkedList)

Example 2 with Worker

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

the class TestAvailable method availableResourcesTest.

/*
     * ********************************************************************************************************
     * AVAILABLE RESOURCES TEST IMPLEMENTATION
     * ********************************************************************************************************
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void availableResourcesTest() {
    // Get CoreCount
    coreCount = CoreManager.getCoreCount();
    // Loading Core names from the interface
    idToSignatures = new LinkedList[coreCount];
    for (int coreId = 0; coreId < coreCount; coreId++) {
        idToSignatures[coreId] = new LinkedList<String>();
    }
    for (Entry<String, Integer> entry : CoreManager.getSignaturesToId().entrySet()) {
        String signature = entry.getKey();
        Integer coreId = entry.getValue();
        idToSignatures[coreId].add(signature);
    }
    // Search for the specific CoreElement ids
    boolean found_ce1 = false;
    boolean found_ce2 = false;
    int ce1 = 0;
    int ce2 = 0;
    coreToName = new String[coreCount];
    for (int i = 0; i < coreCount; i++) {
        int cutValue = idToSignatures[i].getFirst().indexOf("(");
        coreToName[i] = idToSignatures[i].getFirst().substring(0, cutValue);
        if (coreToName[i].equals(NAME_CORE_ELEMENT_1)) {
            ce1 = i;
            found_ce1 = true;
        }
        if (coreToName[i].equals(NAME_CORE_ELEMENT_2)) {
            ce2 = i;
            found_ce2 = true;
        }
    }
    // Check results
    if (!found_ce1) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_1 + " not found.");
        System.exit(-1);
    }
    if (!found_ce2) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_2 + " not found.");
        System.exit(-1);
    }
    /*
         * ********************************************************************************************************
         * Reserve and free for computingUnits test
         * ********************************************************************************************************
         */
    Worker worker = ResourceManager.getWorker(NAME_WORKER);
    System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
    System.out.println("Implementation 1: " + CoreManager.getCoreImplementations(ce1).get(0));
    WorkerResourceDescription consumed1 = worker.runTask(CoreManager.getCoreImplementations(ce1).get(0).getRequirements());
    WorkerResourceDescription consumed2 = worker.runTask(CoreManager.getCoreImplementations(ce1).get(0).getRequirements());
    System.out.println("CONSUMED: " + consumed1);
    System.out.println("CONSUMED: " + consumed2);
    // System.out.println("REMAINING: " + ((MethodWorker)worker).getAvailable());
    ActionOrchestrator orchestrator = COMPSsRuntimeImpl.getOrchestrator();
    Action a = new Action(orchestrator, ce1);
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CORE reserve is not working");
        System.exit(-1);
    }
    worker.endTask(consumed1);
    if (!a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CORE free is not working");
        System.exit(-1);
    }
    worker.endTask(consumed2);
    // System.out.println("FREE");
    // System.out.println("FREE");
    // System.out.println("TOTAL: " + ((MethodWorker)worker).getAvailable());
    // System.out.println();
    /*
         * ********************************************************************************************************
         * Reserve and free for memorySize test
         * ********************************************************************************************************
         */
    a = new Action(orchestrator, ce2);
    // System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
    // System.out.println("Implementation 1: " + CoreManager.getCoreImplementations(ce2)[0]);
    consumed1 = worker.runTask(CoreManager.getCoreImplementations(ce2).get(0).getRequirements());
    consumed2 = worker.runTask(CoreManager.getCoreImplementations(ce2).get(0).getRequirements());
    // System.out.println("REMAINING: " + ((MethodWorker)worker).getAvailable());
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for MEMORY reserve is not working");
        System.exit(-1);
    }
    worker.endTask(consumed1);
    if (!a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for MEMORY free is not working");
        System.exit(-1);
    }
    worker.endTask(consumed2);
    // System.out.println("FREE");
    // System.out.println("FREE");
    // System.out.println("TOTAL: " + ((MethodWorker)worker).getAvailable());
    // System.out.println();
    System.out.println("[LOG] * Available Resources test passed");
}
Also used : ActionOrchestrator(es.bsc.compss.scheduler.types.ActionOrchestrator) Action(commons.Action) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) Worker(es.bsc.compss.types.resources.Worker)

Example 3 with Worker

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

the class TestCompatible method checkCoreResources.

private static void checkCoreResources(int coreId, Map<Worker<?>, List<Implementation>> hm) {
    // Revert Map
    Map<Implementation, List<Worker<?>>> hm_reverted = new HashMap<>();
    for (Entry<Worker<?>, List<Implementation>> entry_hm : hm.entrySet()) {
        for (Implementation impl : entry_hm.getValue()) {
            List<Worker<?>> aux = hm_reverted.get(impl);
            if (aux == null) {
                aux = new LinkedList<Worker<?>>();
            }
            aux.add(entry_hm.getKey());
            hm_reverted.put(impl, aux);
        }
    }
    // Check Resources assigned to each implementation
    for (Entry<Implementation, List<Worker<?>>> entry : hm_reverted.entrySet()) {
        System.out.println("[LOG] ** Checking Implementation " + entry.getKey());
        System.out.println("[LOG] **** Number of resources = " + entry.getValue().size());
        for (Worker<?> resource : entry.getValue()) {
            System.out.println("[LOG] **** Checking Resource " + resource.getName());
            String res = checkResourcesAssignedToImpl(entry.getKey(), resource);
            if (res != null) {
                String error = "Implementation: Core " + coreId + " Impl " + entry.getKey().getImplementationId() + " and Resource " + resource.getName() + ". ";
                error = error.concat("Implementation and resource not matching on: " + res);
                System.out.println(error);
                System.exit(-1);
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) Worker(es.bsc.compss.types.resources.Worker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) List(java.util.List) LinkedList(java.util.LinkedList) Implementation(es.bsc.compss.types.implementations.Implementation) ServiceImplementation(es.bsc.compss.types.implementations.ServiceImplementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation)

Example 4 with Worker

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

the class StopWorkerAction method doAction.

@Override
protected void doAction() {
    (new Thread() {

        @SuppressWarnings("unchecked")
        @Override
        public void run() {
            Worker<WorkerResourceDescription> wResource = (Worker<WorkerResourceDescription>) worker.getResource();
            Thread.currentThread().setName(wResource.getName() + " stopper");
            wResource.retrieveData(true);
            Semaphore sem = new Semaphore(0);
            ShutdownListener sl = new ShutdownListener(sem);
            wResource.stop(sl);
            sl.enable();
            try {
                sem.acquire();
            } catch (Exception e) {
                LOGGER.error("ERROR: Exception raised on worker shutdown", e);
                ErrorManager.warn("Exception stopping worker. Check runtime.log for more details", e);
                notifyError();
            }
            notifyCompleted();
        }
    }).start();
}
Also used : ShutdownListener(es.bsc.compss.types.resources.ShutdownListener) WorkerResourceDescription(es.bsc.compss.types.resources.WorkerResourceDescription) CloudMethodWorker(es.bsc.compss.types.resources.CloudMethodWorker) Worker(es.bsc.compss.types.resources.Worker) Semaphore(java.util.concurrent.Semaphore) BlockedActionException(es.bsc.compss.scheduler.exceptions.BlockedActionException) UnassignedActionException(es.bsc.compss.scheduler.exceptions.UnassignedActionException) FailedActionException(es.bsc.compss.scheduler.exceptions.FailedActionException)

Example 5 with Worker

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

the class TestAvailable method availableResourcesTest.

/*
     * *************************************** AVAILABLE RESOURCES TEST IMPLEMENTATION
     * 
     * Resource 4 CPU CUs (internalMemory=1), 3GPUs CUS (internalMemory=2), 3 FPGA CUs, 3 OTHER CUs CE1 -> 2 CPU CUs, 2
     * GPU CUs (internalMemory=1), 1 FPGA CU) CE2 -> 1 CPU CUs, 1 FPGA , 2 OTHER CUs , nodeMemSize= 2.0) CE3 -> 1 CPU
     * CUs, 2 GPU CU (internalMemory=3) CE4 -> 1 CPU CUs (internalMemory=3); ***************************************
     */
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void availableResourcesTest() {
    // Get CoreCount
    coreCount = CoreManager.getCoreCount();
    // Loading Core names from the interface
    idToSignatures = new LinkedList[coreCount];
    for (int coreId = 0; coreId < coreCount; coreId++) {
        idToSignatures[coreId] = new LinkedList<String>();
    }
    for (Entry<String, Integer> entry : CoreManager.getSignaturesToId().entrySet()) {
        String signature = entry.getKey();
        Integer coreId = entry.getValue();
        idToSignatures[coreId].add(signature);
    }
    // Search for the specific CoreElement ids
    boolean found_ce1 = false;
    boolean found_ce2 = false;
    boolean found_ce3 = false;
    boolean found_ce4 = false;
    int ce1 = 0;
    int ce2 = 0;
    int ce3 = 0;
    int ce4 = 0;
    coreToName = new String[coreCount];
    for (int i = 0; i < coreCount; i++) {
        int cutValue = idToSignatures[i].getFirst().indexOf("(");
        coreToName[i] = idToSignatures[i].getFirst().substring(0, cutValue);
        if (coreToName[i].equals(NAME_CORE_ELEMENT_1)) {
            ce1 = i;
            found_ce1 = true;
        }
        if (coreToName[i].equals(NAME_CORE_ELEMENT_2)) {
            ce2 = i;
            found_ce2 = true;
        }
        if (coreToName[i].equals(NAME_CORE_ELEMENT_3)) {
            ce3 = i;
            found_ce3 = true;
        }
        if (coreToName[i].equals(NAME_CORE_ELEMENT_4)) {
            ce4 = i;
            found_ce4 = true;
        }
    }
    // Check results
    if (!found_ce1) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_1 + " not found.");
        System.exit(-1);
    }
    if (!found_ce2) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_2 + " not found.");
        System.exit(-1);
    }
    if (!found_ce3) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_3 + " not found.");
        System.exit(-1);
    }
    if (!found_ce4) {
        System.out.println("[ERROR] " + NAME_CORE_ELEMENT_4 + " not found.");
        System.exit(-1);
    }
    Worker worker = ResourceManager.getWorker(NAME_WORKER);
    System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
    /*
         * ************************************************* Check internal memory
         * ***********************************************
         */
    ActionOrchestrator orchestrator = COMPSsRuntimeImpl.getOrchestrator();
    Action a = new Action(orchestrator, ce3);
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources internalMemorySize filter inside Processor annotation is not working");
        System.exit(-1);
    }
    a = new Action(orchestrator, ce4);
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources processorInternalMemorySize filter is not working");
        System.exit(-1);
    }
    /*
         * ************************************************* Reserve and free for GPU and FPGA computingUnits test
         * ***********************************************
         */
    System.out.println("Worker " + NAME_WORKER + ": " + worker.getDescription());
    System.out.println("Implementation 1: " + CoreManager.getCoreImplementations(ce1).get(0));
    MethodResourceDescription consumed1 = (MethodResourceDescription) worker.runTask(CoreManager.getCoreImplementations(ce1).get(0).getRequirements());
    System.out.println("CONSUMED: " + consumed1);
    // Check Consumed: 2 CPUs 2 GPUs 1 FPGA
    if (!checkDescription(consumed1, 2, 2, 1, 0)) {
        System.out.println("[ERROR] consumed resources for CPU + GPU + FPGA is not working");
        System.exit(-1);
    }
    ;
    MethodResourceDescription remaining = ((MethodWorker) worker).getAvailable();
    System.out.println("REMAINING: " + remaining);
    // Check Remaining: 2CPUs 1GPU , 2FPGA 3 OTHER
    if (!checkDescription(remaining, 2, 1, 2, 3)) {
        System.out.println("[ERROR] remaining resources for CPU + GPU + FPGA is not working");
        System.exit(-1);
    }
    MethodResourceDescription consumed2 = (MethodResourceDescription) worker.runTask(CoreManager.getCoreImplementations(ce2).get(0).getRequirements());
    System.out.println("CONSUMED: " + consumed2);
    // Check consumed 1 CPU 2 OTHER 1 FPGA
    if (!checkDescription(consumed2, 1, 0, 1, 2)) {
        System.out.println("[ERROR] consumed resources for CPU + OTHER + FPGA is not working");
        System.exit(-1);
    }
    remaining = ((MethodWorker) worker).getAvailable();
    System.out.println("REMAINING: " + remaining);
    // Check remaining 1CPU 1 GPU, 1 OTHER, 1 FPGA.
    if (!checkDescription(remaining, 1, 1, 1, 1)) {
        System.out.println("[ERROR] remaining resources for CPU + OTHER + FPGA is not working");
        System.exit(-1);
    }
    a = new Action(orchestrator, ce1);
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CPU + GPU + FPGA reserve is not working");
        System.exit(-1);
    }
    a = new Action(orchestrator, ce2);
    if (a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CPU + OTHER + FPGA reserve is not working");
        System.exit(-1);
    }
    worker.endTask(consumed1);
    a = new Action(orchestrator, ce1);
    if (!a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CPU + GPU + FPGA free is not working");
        System.exit(-1);
    }
    worker.endTask(consumed2);
    a = new Action(orchestrator, ce2);
    if (!a.findAvailableWorkers().containsKey(worker)) {
        System.out.println("[ERROR] Available resources for CPU + OTHER + FPGA free is not working");
        System.exit(-1);
    }
    // System.out.println("FREE");
    // System.out.println("FREE");
    // System.out.println("TOTAL: " + ((MethodWorker)worker).getAvailable());
    // System.out.println();
    System.out.println("[LOG] * Multi-processors test passed");
}
Also used : ActionOrchestrator(es.bsc.compss.scheduler.types.ActionOrchestrator) Action(commons.Action) Worker(es.bsc.compss.types.resources.Worker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription)

Aggregations

Worker (es.bsc.compss.types.resources.Worker)6 Action (commons.Action)3 ActionOrchestrator (es.bsc.compss.scheduler.types.ActionOrchestrator)3 Implementation (es.bsc.compss.types.implementations.Implementation)3 MethodWorker (es.bsc.compss.types.resources.MethodWorker)3 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)3 LinkedList (java.util.LinkedList)3 List (java.util.List)3 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)2 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)2 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)2 HashMap (java.util.HashMap)2 ResourceScheduler (es.bsc.compss.components.impl.ResourceScheduler)1 BlockedActionException (es.bsc.compss.scheduler.exceptions.BlockedActionException)1 FailedActionException (es.bsc.compss.scheduler.exceptions.FailedActionException)1 UnassignedActionException (es.bsc.compss.scheduler.exceptions.UnassignedActionException)1 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)1 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)1 ShutdownListener (es.bsc.compss.types.resources.ShutdownListener)1 Semaphore (java.util.concurrent.Semaphore)1