Search in sources :

Example 11 with Processor

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

the class CExecutor method getTaskExecutionCommand.

@Override
public ArrayList<String> getTaskExecutionCommand(NIOWorker nw, NIOTask nt, String sandBox, int[] assignedCoreUnits, int[] assignedGPUs) {
    ArrayList<String> lArgs = new ArrayList<>();
    // NX_ARGS string built from the Resource Description
    StringBuilder reqs = new StringBuilder();
    int numCUs = nt.getResourceDescription().getTotalCPUComputingUnits();
    reqs.append("NX_ARGS='--smp-cpus=").append(numCUs);
    String compss_nx_args;
    if ((compss_nx_args = System.getenv("COMPSS_NX_ARGS")) != null) {
        reqs.append(" " + compss_nx_args);
    }
    // Debug mode on
    if (WORKER_DEBUG) {
        reqs.append(" --summary --verbose");
    }
    StringBuilder cuda_visible = new StringBuilder();
    StringBuilder opencl_visible = new StringBuilder();
    if (assignedGPUs.length > 0) {
        String quotes = "\"";
        cuda_visible.append("CUDA_VISIBLE_DEVICES=").append(quotes);
        opencl_visible.append("GPU_DEVICE_ORDINAL=").append(quotes);
        reqs.append(" --gpu-warmup=no");
        for (int i = 0; i < (assignedGPUs.length - 1); i++) {
            cuda_visible.append(assignedGPUs[i]).append(",");
            opencl_visible.append(assignedGPUs[i]).append(",");
        }
        cuda_visible.append(assignedGPUs[assignedGPUs.length - 1]).append(quotes).append(" ");
        opencl_visible.append(assignedGPUs[assignedGPUs.length - 1]).append(quotes).append(" ");
        for (int j = 0; j < nt.getResourceDescription().getProcessors().size(); j++) {
            Processor p = nt.getResourceDescription().getProcessors().get(j);
            if (p.getType().equals("GPU") && p.getInternalMemory() > 0.00001) {
                // MB to byte conversion
                float bytes = p.getInternalMemory() * 1048576;
                int b_int = Math.round(bytes);
                reqs.append(" --gpu-max-memory=").append(b_int);
            }
        }
    } else {
        reqs.append(" --disable-cuda=yes");
        reqs.append(" --disable-opencl=yes");
    }
    reqs.append("' ");
    // Taskset string to bind the job
    StringBuilder taskset = new StringBuilder();
    if (assignedCoreUnits != null && assignedCoreUnits.length > 0) {
        taskset.append("taskset -c ");
        for (int i = 0; i < (numCUs - 1); i++) {
            taskset.append(assignedCoreUnits[i]).append(",");
        }
        taskset.append(assignedCoreUnits[numCUs - 1]).append(" ");
    }
    lArgs.add(cuda_visible.toString() + opencl_visible.toString() + reqs.toString() + taskset.toString() + nw.getAppDir() + WORKER_C_RELATIVE_PATH);
    return lArgs;
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor) ArrayList(java.util.ArrayList)

Example 12 with Processor

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

the class IDLParserTest method loadIDLTest.

@Test
public void loadIDLTest() {
    CoreManager.clear();
    String constraintsFile = this.getClass().getResource("test.idl").getPath();
    IDLParser.parseIDLMethods(constraintsFile);
    assertEquals(CoreManager.getCoreCount(), CORECOUNT_RESULT);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 0");
    List<Implementation> implList = CoreManager.getCoreImplementations(0);
    assertNotNull(implList);
    MethodImplementation impl = (MethodImplementation) implList.get(0);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (1)");
    assertEquals(implList.size(), CORE0_2_3_4_5_IMPLS_RESULT);
    Processor p = impl.getRequirements().getProcessors().get(0);
    assertEquals(p.getComputingUnits(), COMPUTING_UNITS_RESULT);
    assertEquals(p.getArchitecture(), "x86_64");
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 1");
    implList = CoreManager.getCoreImplementations(1);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (3)");
    assertEquals(implList.size(), CORE1_6_IMPLS_RESULT);
    impl = (MethodImplementation) implList.get(0);
    assertEquals(impl.getRequirements().getMemorySize(), 2.0f, 0);
    assertEquals(impl.getRequirements().getStorageSize(), 10.0f, 0);
    impl = (MethodImplementation) implList.get(1);
    p = impl.getRequirements().getProcessors().get(0);
    assertEquals(p.getComputingUnits(), COMPUTING_UNITS_RESULT);
    assertEquals(impl.getRequirements().getMemorySize(), 4.0f, 0);
    impl = (MethodImplementation) implList.get(2);
    p = impl.getRequirements().getProcessors().get(0);
    assertEquals(p.getComputingUnits(), 1);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 2");
    implList = CoreManager.getCoreImplementations(2);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (1)");
    assertEquals(implList.size(), CORE0_2_3_4_5_IMPLS_RESULT);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 3");
    implList = CoreManager.getCoreImplementations(3);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (1)");
    assertEquals(implList.size(), CORE0_2_3_4_5_IMPLS_RESULT);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 4");
    implList = CoreManager.getCoreImplementations(4);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (1)");
    assertEquals(implList.size(), CORE0_2_3_4_5_IMPLS_RESULT);
    impl = (MethodImplementation) implList.get(0);
    LOGGER.debug("[IDL-Loader]: Checking Number of processors (2)");
    assertEquals(impl.getRequirements().getProcessors().size(), PROCESSOR_COUNT);
    Processor p1 = impl.getRequirements().getProcessors().get(0);
    Processor p2 = impl.getRequirements().getProcessors().get(1);
    LOGGER.debug("[IDL-Loader]: Checking Processor 1 parameters (4)");
    assertEquals(p1.getType(), "CPU");
    assertEquals(p1.getComputingUnits(), 2);
    assertEquals(p1.getArchitecture(), "x86_64");
    assertEquals(p1.getInternalMemory(), 0.6f, 0);
    LOGGER.debug("[IDL-Loader]: Checking Processor 2 parameters (4)");
    assertEquals(p2.getType(), "GPU");
    assertEquals(p2.getComputingUnits(), 256);
    assertEquals(p2.getArchitecture(), "k40");
    assertEquals(p2.getInternalMemory(), 0.024f, 0);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 5");
    implList = CoreManager.getCoreImplementations(5);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (1)");
    assertEquals(implList.size(), CORE0_2_3_4_5_IMPLS_RESULT);
    impl = (MethodImplementation) implList.get(0);
    LOGGER.debug("[IDL-Loader]: Checking Number of processors (1)");
    assertEquals(impl.getRequirements().getProcessors().size(), 1);
    p = impl.getRequirements().getProcessors().get(0);
    LOGGER.debug("[IDL-Loader]: Checking Processor parameters (2)");
    assertEquals(p.getType(), "CPU");
    assertEquals(p.getComputingUnits(), 2);
    LOGGER.debug("[IDL-Loader]: *** Checking Core Element 6");
    implList = CoreManager.getCoreImplementations(6);
    assertNotNull(implList);
    LOGGER.debug("[IDL-Loader]: Checking Number of implementations (3)");
    assertEquals(implList.size(), CORE1_6_IMPLS_RESULT);
    impl = (MethodImplementation) implList.get(0);
    LOGGER.debug("[IDL-Loader]: Checking Number of first implementation processors (1)");
    assertEquals(impl.getRequirements().getProcessors().size(), 1);
    p = impl.getRequirements().getProcessors().get(0);
    assertEquals(p.getType(), "CPU");
    assertEquals(p.getComputingUnits(), 4);
    impl = (MethodImplementation) implList.get(1);
    LOGGER.debug("[IDL-Loader]: Checking Number of second implementation processors (2)");
    assertEquals(impl.getRequirements().getProcessors().size(), PROCESSOR_COUNT);
    p1 = impl.getRequirements().getProcessors().get(0);
    p2 = impl.getRequirements().getProcessors().get(1);
    LOGGER.debug("[IDL-Loader]: Checking Processor 1 parameters (4)");
    assertEquals(p1.getType(), "CPU");
    assertEquals(p1.getComputingUnits(), 2);
    LOGGER.debug("[IDL-Loader]: Checking Processor 2 parameters (4)");
    assertEquals(p2.getType(), "CPU");
    assertEquals(p2.getComputingUnits(), 2);
    impl = (MethodImplementation) implList.get(2);
    LOGGER.debug("[IDL-Loader]: Checking Number of third implementation processors (2)");
    assertEquals(impl.getRequirements().getProcessors().size(), PROCESSOR_COUNT);
    p1 = impl.getRequirements().getProcessors().get(0);
    p2 = impl.getRequirements().getProcessors().get(1);
    LOGGER.debug("[IDL-Loader]: Checking Processor 1 parameters (4)");
    assertEquals(p1.getType(), "CPU");
    assertEquals(p1.getComputingUnits(), 1);
    LOGGER.debug("[IDL-Loader]: Checking Processor 2 parameters (4)");
    assertEquals(p2.getType(), "GPU");
    assertEquals(p2.getComputingUnits(), 1);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Processor(es.bsc.compss.types.resources.components.Processor) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Implementation(es.bsc.compss.types.implementations.Implementation) Test(org.junit.Test)

Example 13 with Processor

use of es.bsc.compss.types.resources.components.Processor 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)

Example 14 with Processor

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

the class MethodResourceDescriptionTest method testC2.

@Test
public void testC2() throws Exception {
    MethodResourceDescription mrd = new MethodResourceDescription(constraints2);
    assertEquals(mrd.getTotalCPUComputingUnits(), 8);
    assertEquals(mrd.getTotalGPUComputingUnits(), 1);
    assertEquals(mrd.getTotalFPGAComputingUnits(), 0);
    for (Processor p : mrd.getProcessors()) {
        if (p.getType().equals(Constants.CPU_TYPE)) {
            assertEquals(p.getComputingUnits(), 8);
        } else if (p.getType().equals(Constants.GPU_TYPE)) {
            assertEquals(p.getComputingUnits(), 1);
            assertEquals(p.getInternalMemory(), 20, 0);
        } else {
            throw new Exception("Error processor not defined");
        }
    }
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor) Test(org.junit.Test)

Example 15 with Processor

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

the class MethodResourceDescription method canHostSimultaneously.

public Integer canHostSimultaneously(MethodResourceDescription rc2) {
    int min = Integer.MAX_VALUE;
    // Global CUs restriction
    if (rc2.getTotalCPUComputingUnits() >= 1) {
        float ratio = this.getTotalCPUComputingUnits() / (float) rc2.getTotalCPUComputingUnits();
        min = (int) ratio;
    }
    if (rc2.getTotalGPUComputingUnits() >= 1) {
        float ratio = this.getTotalGPUComputingUnits() / (float) rc2.getTotalGPUComputingUnits();
        min = (int) ratio;
    }
    if (rc2.getTotalFPGAComputingUnits() >= 1) {
        float ratio = this.getTotalFPGAComputingUnits() / (float) rc2.getTotalFPGAComputingUnits();
        min = (int) ratio;
    }
    // Per processor CUs restriction
    for (Processor p : rc2.processors) {
        for (Processor pThis : this.processors) {
            if (checkProcessorCompatibility(pThis, p)) {
                float ratio = pThis.getComputingUnits() / p.getComputingUnits();
                min = Math.min(min, (int) ratio);
            }
        }
    }
    // Memory restriction
    if (this.memorySize != UNASSIGNED_FLOAT && rc2.memorySize != UNASSIGNED_FLOAT && rc2.memorySize > 0.0f) {
        float ratio = this.memorySize / rc2.memorySize;
        min = Math.min(min, (int) ratio);
    }
    return min;
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor)

Aggregations

Processor (es.bsc.compss.types.resources.components.Processor)22 MethodImplementation (es.bsc.compss.types.implementations.MethodImplementation)4 MethodResourceDescription (es.bsc.compss.types.resources.MethodResourceDescription)4 Implementation (es.bsc.compss.types.implementations.Implementation)3 LinkedList (java.util.LinkedList)3 BeforeClass (org.junit.BeforeClass)3 Test (org.junit.Test)3 FakeWorker (es.bsc.compss.types.fake.FakeWorker)2 TaskScheduler (es.bsc.compss.components.impl.TaskScheduler)1 FakeWorker (es.bsc.compss.scheduler.types.fake.FakeWorker)1 FakeActionOrchestrator (es.bsc.compss.types.fake.FakeActionOrchestrator)1 FakeResourceScheduler (es.bsc.compss.types.fake.FakeResourceScheduler)1 ServiceImplementation (es.bsc.compss.types.implementations.ServiceImplementation)1 MethodWorker (es.bsc.compss.types.resources.MethodWorker)1 ServiceResourceDescription (es.bsc.compss.types.resources.ServiceResourceDescription)1 ServiceWorker (es.bsc.compss.types.resources.ServiceWorker)1 CloudMethodResourceDescription (es.bsc.compss.types.resources.description.CloudMethodResourceDescription)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1