Search in sources :

Example 6 with MethodWorker

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

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

the class TestCompatible method checkResourcesAssignedToImpl.

private static String checkResourcesAssignedToImpl(Implementation impl, Worker<?> resource) {
    if ((impl.getTaskType().equals(TaskType.METHOD) && resource.getType().equals(Resource.Type.SERVICE)) || (impl.getTaskType().equals(TaskType.SERVICE) && resource.getType().equals(Resource.Type.WORKER))) {
        return "types";
    }
    if (resource.getType() == Worker.Type.WORKER) {
        MethodImplementation mImpl = (MethodImplementation) impl;
        MethodResourceDescription iDescription = mImpl.getRequirements();
        MethodWorker worker = (MethodWorker) resource;
        MethodResourceDescription wDescription = (MethodResourceDescription) worker.getDescription();
        /*
             * *********************************************************************************************************
             * COMPUTING UNITS
             **********************************************************************************************************/
        if ((iDescription.getTotalCPUComputingUnits() >= MethodResourceDescription.ONE_INT) && (wDescription.getTotalCPUComputingUnits() >= MethodResourceDescription.ONE_INT) && (wDescription.getTotalCPUComputingUnits() < iDescription.getTotalCPUComputingUnits())) {
            return "computingUnits";
        }
        /*
             * *********************************************************************************************************
             * PROCESSOR
             ***********************************************************************************************************/
        for (Processor ip : iDescription.getProcessors()) {
            // Check if processor can be executed in worker
            boolean canBeHosted = false;
            for (Processor wp : wDescription.getProcessors()) {
                // Static checks
                if (!ip.getName().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getName().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getName().equals(ip.getName())) {
                    // System.out.println("DUE TO: " + ip.getName() + " != " + wp.getName());
                    continue;
                }
                if (ip.getSpeed() != MethodResourceDescription.UNASSIGNED_FLOAT && wp.getSpeed() != MethodResourceDescription.UNASSIGNED_FLOAT && wp.getSpeed() < ip.getSpeed()) {
                    // System.out.println("DUE TO: " + ip.getSpeed() + " != " + wp.getSpeed());
                    continue;
                }
                if (!ip.getArchitecture().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getArchitecture().equals(MethodResourceDescription.UNASSIGNED_STR) && !wp.getArchitecture().equals(ip.getArchitecture())) {
                    // System.out.println("DUE TO: " + ip.getArchitecture() + " != " + wp.getArchitecture());
                    continue;
                }
                if ((!ip.getPropName().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wp.getPropName().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!ip.getPropName().equals(wp.getPropName()))) {
                    // System.out.println("DUE TO: " + ip.getPropName() + " != " + wp.getPropName());
                    continue;
                }
                if ((!ip.getPropValue().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wp.getPropValue().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!ip.getPropValue().equals(wp.getPropValue()))) {
                    // System.out.println("DUE TO: " + ip.getPropValue() + " != " + wp.getPropValue());
                    continue;
                }
                // Dynamic checks
                if (wp.getComputingUnits() >= ip.getComputingUnits()) {
                    canBeHosted = true;
                    break;
                } else {
                // System.out.println("DUE TO: " + ip.getComputingUnits() + " != " + wp.getComputingUnits());
                }
            }
            if (!canBeHosted) {
                return "processor";
            }
        }
        /*
             * *********************************************************************************************************
             * MEMORY
             ***********************************************************************************************************/
        if ((iDescription.getMemorySize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getMemorySize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getMemorySize() < iDescription.getMemorySize())) {
            return "memorySize";
        }
        if ((!iDescription.getMemoryType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getMemoryType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getMemoryType().equals(iDescription.getMemoryType()))) {
            return "memoryType";
        }
        /*
             * *********************************************************************************************************
             * STORAGE
             ***********************************************************************************************************/
        if ((iDescription.getStorageSize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getStorageSize() != MethodResourceDescription.UNASSIGNED_FLOAT) && (wDescription.getStorageSize() < iDescription.getStorageSize())) {
            return "storageSize";
        }
        if ((!iDescription.getStorageType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getStorageType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getStorageType().equals(iDescription.getStorageType()))) {
            return "storageType";
        }
        /*
             * *********************************************************************************************************
             * OPERATING SYSTEM
             ***********************************************************************************************************/
        if ((!iDescription.getOperatingSystemType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemType().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemType().equals(iDescription.getOperatingSystemType()))) {
            return "operatingSystemType";
        }
        if ((!iDescription.getOperatingSystemDistribution().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemDistribution().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemDistribution().equals(iDescription.getOperatingSystemDistribution()))) {
            return "operatingSystemDistribution";
        }
        if ((!iDescription.getOperatingSystemVersion().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!iDescription.getOperatingSystemVersion().equals(MethodResourceDescription.UNASSIGNED_STR)) && (!wDescription.getOperatingSystemVersion().equals(iDescription.getOperatingSystemVersion()))) {
            return "operatingSystemVersion";
        }
        /*
             * *********************************************************************************************************
             * APPLICATION SOFTWARE
             ***********************************************************************************************************/
        if (!(iDescription.getAppSoftware().isEmpty()) && !(wDescription.getAppSoftware().containsAll(iDescription.getAppSoftware()))) {
            return "appSoftware";
        }
        /*
             * *********************************************************************************************************
             * HOST QUEUE
             ***********************************************************************************************************/
        if (!(iDescription.getHostQueues().isEmpty()) && !(wDescription.getHostQueues().containsAll(iDescription.getHostQueues()))) {
            return "hostQueues";
        }
    } else if (resource.getType() == Worker.Type.SERVICE) {
        ServiceImplementation sImpl = (ServiceImplementation) impl;
        ServiceResourceDescription iDescription = sImpl.getRequirements();
        ServiceWorker worker = (ServiceWorker) resource;
        ServiceResourceDescription wDescription = (ServiceResourceDescription) worker.getDescription();
        if (!wDescription.getServiceName().equals(iDescription.getServiceName())) {
            return "ServiceName";
        }
        if (!wDescription.getNamespace().equals(iDescription.getNamespace())) {
            return "Namespace";
        }
        if (!wDescription.getPort().equals(iDescription.getPort())) {
            return "Port";
        }
    } else {
        return "Unknown resource type";
    }
    /*
         * ************************************************************************************************************
         * ALL CONSTAINT VALUES OK
         *************************************************************************************************************/
    return null;
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) ServiceResourceDescription(es.bsc.compss.types.resources.ServiceResourceDescription) Processor(es.bsc.compss.types.resources.components.Processor) ServiceImplementation(es.bsc.compss.types.implementations.ServiceImplementation) ServiceWorker(es.bsc.compss.types.resources.ServiceWorker) MethodWorker(es.bsc.compss.types.resources.MethodWorker) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription)

Aggregations

MethodWorker (es.bsc.compss.types.resources.MethodWorker)7 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)4 ExtendedCloudMethodWorker (es.bsc.compss.types.ExtendedCloudMethodWorker)2 ServiceResourceDescription (es.bsc.compss.types.resources.ServiceResourceDescription)2 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)2 MethodConfiguration (es.bsc.compss.types.resources.configuration.MethodConfiguration)2 Action (commons.Action)1 FakeMethodAdaptor (es.bsc.compss.comm.fake.FakeMethodAdaptor)1 FakeServiceAdaptor (es.bsc.compss.comm.fake.FakeServiceAdaptor)1 ConstructConfigurationException (es.bsc.compss.exceptions.ConstructConfigurationException)1 ActionOrchestrator (es.bsc.compss.scheduler.types.ActionOrchestrator)1 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)1 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)1 es.bsc.compss.types.project.jaxb (es.bsc.compss.types.project.jaxb)1 CloudMethodWorker (es.bsc.compss.types.resources.CloudMethodWorker)1 Worker (es.bsc.compss.types.resources.Worker)1 Processor (es.bsc.compss.types.resources.components.Processor)1 ServiceConfiguration (es.bsc.compss.types.resources.configuration.ServiceConfiguration)1 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)1 ProcessorPropertyType (es.bsc.compss.types.resources.jaxb.ProcessorPropertyType)1