Search in sources :

Example 1 with ActionOrchestrator

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

use of es.bsc.compss.scheduler.types.ActionOrchestrator 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)

Example 3 with ActionOrchestrator

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

the class TestCompatible method resourceManagerTest.

/*
     * **********************************************************************************************************
     * RESOURCE MANAGER TEST IMPLEMENTATION
     * **********************************************************************************************************
     */
private static void resourceManagerTest() {
    coreCount = CoreManager.getCoreCount();
    ActionOrchestrator orchestrator = COMPSsRuntimeImpl.getOrchestrator();
    // Check for each implementation the correctness of its resources
    System.out.println("[LOG] Number of cores = " + coreCount);
    for (int coreId = 0; coreId < coreCount; coreId++) {
        System.out.println("[LOG] Checking Core" + coreId);
        Action a = new Action(orchestrator, coreId);
        Map<Worker<?>, List<Implementation>> m = a.findAvailableWorkers();
        // For the test construction, all implementations can be run. Check it
        if (m.size() == 0) {
            System.err.println("[ERROR] CoreId " + coreId + " cannot be run");
            List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
            for (Implementation impl : impls) {
                System.out.println("-- Impl: " + impl.getRequirements().toString());
            }
            System.exit(-1);
        }
        // Check that all assigned resources are really valid
        checkCoreResources(coreId, m);
    }
}
Also used : ActionOrchestrator(es.bsc.compss.scheduler.types.ActionOrchestrator) Action(commons.Action) 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)

Aggregations

Action (commons.Action)3 ActionOrchestrator (es.bsc.compss.scheduler.types.ActionOrchestrator)3 Worker (es.bsc.compss.types.resources.Worker)3 MethodWorker (es.bsc.compss.types.resources.MethodWorker)2 Implementation (es.bsc.compss.types.implementations.Implementation)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)1 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)1 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)1 WorkerResourceDescription (es.bsc.compss.types.resources.WorkerResourceDescription)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1