Search in sources :

Example 1 with Processor

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

the class ResourceOptimizer method reassignUnassignedConstraints.

private static void reassignUnassignedConstraints(Map<String, List<ConstraintsCore>> arch2Ctrs) {
    /*
         * ATTENTION: Since this method is only evaluated from constraints, there is only 1 PROCESSOR and 1 ARCHITECTURE
         */
    List<ConstraintsCore> unassignedList = arch2Ctrs.get(CloudMethodResourceDescription.UNASSIGNED_STR);
    if (unassignedList == null) {
        return;
    }
    if (arch2Ctrs.size() == 1) {
        return;
    }
    if (arch2Ctrs.size() == 2) {
        for (Entry<String, List<ConstraintsCore>> ctrs : arch2Ctrs.entrySet()) {
            if (ctrs.getKey().compareTo(CloudMethodResourceDescription.UNASSIGNED_STR) == 0) {
                continue;
            } else {
                ctrs.getValue().addAll(unassignedList);
                return;
            }
        }
    }
    List<ConstraintsCore> assignedList = new LinkedList<>();
    for (Entry<String, List<ConstraintsCore>> ctrs : arch2Ctrs.entrySet()) {
        if (ctrs.getKey().compareTo(CloudMethodResourceDescription.UNASSIGNED_STR) == 0) {
            continue;
        } else {
            assignedList.addAll(ctrs.getValue());
        }
    }
    while (!unassignedList.isEmpty()) {
        ConstraintsCore unassigned = unassignedList.remove(0);
        CloudMethodResourceDescription candidate = unassigned.desc;
        String bestArch = CloudMethodResourceDescription.UNASSIGNED_STR;
        Float bestDifference = Float.MAX_VALUE;
        for (ConstraintsCore assigned : assignedList) {
            CloudMethodResourceDescription option = assigned.desc;
            float difference = candidate.difference(option);
            if (bestDifference < 0) {
                if (difference < 0) {
                    if (difference > bestDifference) {
                        List<String> avail_archs = option.getArchitectures();
                        if (avail_archs != null && !avail_archs.isEmpty()) {
                            bestArch = avail_archs.get(0);
                        }
                        bestDifference = difference;
                    }
                }
            } else if (difference < bestDifference) {
                List<String> avail_archs = option.getArchitectures();
                if (avail_archs != null && !avail_archs.isEmpty()) {
                    bestArch = avail_archs.get(0);
                }
                bestDifference = difference;
            }
        }
        // Add
        List<Processor> procs = unassigned.desc.getProcessors();
        if (procs == null) {
            procs = new LinkedList<>();
        }
        if (!procs.isEmpty()) {
            procs.get(0).setArchitecture(bestArch);
        } else {
            Processor p = new Processor();
            p.setArchitecture(bestArch);
            procs.add(p);
        }
        arch2Ctrs.get(bestArch).add(unassigned);
    }
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor) CloudMethodResourceDescription(es.bsc.compss.types.resources.description.CloudMethodResourceDescription) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) List(java.util.List)

Example 2 with Processor

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

the class ResourceSchedulerTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    // Method resource description and its slots
    Processor p = new Processor();
    p.setComputingUnits(4);
    MethodResourceDescription description = new MethodResourceDescription();
    description.addProcessor(p);
    worker = new FakeWorker(description, 4);
    int coreId = CoreManager.registerNewCoreElement("methodA");
    LinkedList<Implementation> impls = new LinkedList<>();
    LinkedList<String> signs = new LinkedList<>();
    Implementation impl = new MethodImplementation("ClassA", "methodA", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodA");
    impl = new MethodImplementation("ClassB", "methodA", coreId, 1, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassB.methodA");
    CoreManager.registerNewImplementations(coreId, impls, signs);
    coreId = CoreManager.registerNewCoreElement("methodB");
    impls = new LinkedList<>();
    signs = new LinkedList<>();
    impl = new MethodImplementation("ClassA", "methodB", coreId, 0, new MethodResourceDescription());
    impls.add(impl);
    signs.add("ClassA.methodB");
    CoreManager.registerNewImplementations(coreId, impls, signs);
}
Also used : MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) Processor(es.bsc.compss.types.resources.components.Processor) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) FakeWorker(es.bsc.compss.types.fake.FakeWorker) Implementation(es.bsc.compss.types.implementations.Implementation) MethodImplementation(es.bsc.compss.types.implementations.MethodImplementation) LinkedList(java.util.LinkedList) BeforeClass(org.junit.BeforeClass)

Example 3 with Processor

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

the class AllocatableActionTest method setUpClass.

@BeforeClass
public static void setUpClass() {
    ResourceManager.clear(rus);
    // Method resource description and its slots
    int maxSlots = 3;
    Processor p = new Processor();
    p.setComputingUnits(maxSlots);
    description = new MethodResourceDescription();
    description.addProcessor(p);
    // Task Scheduler
    ts = new TaskScheduler();
    // Task Dispatcher
    fao = new FakeActionOrchestrator(ts);
    ts.setOrchestrator(fao);
    // Resource Scheduler
    rs = new FakeResourceScheduler(new FakeWorker(description, maxSlots), null, null);
}
Also used : FakeActionOrchestrator(es.bsc.compss.types.fake.FakeActionOrchestrator) Processor(es.bsc.compss.types.resources.components.Processor) FakeResourceScheduler(es.bsc.compss.types.fake.FakeResourceScheduler) MethodResourceDescription(es.bsc.compss.types.resources.MethodResourceDescription) TaskScheduler(es.bsc.compss.components.impl.TaskScheduler) FakeWorker(es.bsc.compss.types.fake.FakeWorker) BeforeClass(org.junit.BeforeClass)

Example 4 with Processor

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

the class MethodResourceDescriptionTest method testC1.

@Test
public void testC1() {
    MethodResourceDescription mrd = new MethodResourceDescription(constraints1);
    assertEquals(mrd.getTotalCPUComputingUnits(), 2);
    assertEquals(mrd.getTotalGPUComputingUnits(), 3);
    assertEquals(mrd.getTotalFPGAComputingUnits(), 4);
    assertEquals(mrd.getWallClockLimit(), 30);
    assertEquals(mrd.getMemorySize(), 20, 0);
    assertEquals(mrd.getStorageSize(), 100, 0);
    assertEquals(mrd.getOperatingSystemType(), "Linux");
    assertEquals(mrd.getHostQueues().get(0), "debug".toUpperCase());
    assertEquals(mrd.getAppSoftware().get(0), "Paraver".toUpperCase());
    for (Processor p : mrd.getProcessors()) {
        if (p.getType().equals(Constants.CPU_TYPE)) {
            assertEquals(p.getComputingUnits(), 2);
            assertEquals(p.getName(), "Big");
            assertEquals(p.getArchitecture(), "x86_64");
            assertEquals(p.getSpeed(), 2.3f, 0);
        } else if (p.getType().equals(Constants.GPU_TYPE)) {
            assertEquals(p.getComputingUnits(), 3);
            assertEquals(p.getInternalMemory(), 20, 0);
        } else if (p.getType().equals(Constants.FPGA_TYPE)) {
            assertEquals(p.getComputingUnits(), 4);
        }
    }
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor) Test(org.junit.Test)

Example 5 with Processor

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

the class MethodResourceDescription method increaseDynamic.

@Override
public void increaseDynamic(ResourceDescription rd2) {
    MethodResourceDescription mrd2 = (MethodResourceDescription) rd2;
    // Processor
    for (Processor p : mrd2.processors) {
        // Looks for a mergeable processor
        boolean processorMerged = false;
        for (Processor pThis : this.processors) {
            if (checkProcessorCompatibility(pThis, p)) {
                processorMerged = true;
                // Increase current
                int cus = p.getComputingUnits();
                pThis.addComputingUnits(cus);
                this.increaseComputingUnits(pThis.getType(), cus);
                // Go for next processor
                break;
            }
        }
        if (!processorMerged) {
            Processor newProc = new Processor(p);
            // Increases totalCUs
            this.addProcessor(newProc);
        }
    }
    // Memory
    if ((this.memorySize != UNASSIGNED_FLOAT) && (mrd2.memorySize != UNASSIGNED_FLOAT)) {
        this.memorySize += mrd2.memorySize;
    }
}
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