Search in sources :

Example 16 with Processor

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

the class MethodResourceDescription method getDynamicCommons.

@Override
public ResourceDescription getDynamicCommons(ResourceDescription other) {
    MethodResourceDescription otherMRD = (MethodResourceDescription) other;
    MethodResourceDescription common = new MethodResourceDescription();
    // Processor
    for (Processor p : otherMRD.getProcessors()) {
        boolean isProcessorCompatible = false;
        int i = 0;
        while (i < this.processors.size() && !isProcessorCompatible) {
            Processor pThis = this.processors.get(i);
            // Only checks compatibility, not inclusion
            if (checkProcessorCompatibility(pThis, p)) {
                // Satisfies compatibility
                isProcessorCompatible = true;
                // Include commons
                Processor commonProcessor = getDynamicCommonsProcessor(pThis, p);
                if (commonProcessor.getComputingUnits() > 0) {
                    common.addProcessor(commonProcessor);
                }
            }
            i = i + 1;
        }
    }
    // Only checks compatibility, not inclusion
    if (checkCompatibility(this.memoryType, otherMRD.memoryType)) {
        // Copy the assignable memory type (no the requested)
        common.setMemoryType(this.getMemoryType());
        common.setMemorySize(Math.min(this.memorySize, otherMRD.getMemorySize()));
    }
    return common;
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor)

Example 17 with Processor

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

the class MethodResourceDescription method treatProcessorInList.

private void treatProcessorInList(String processor) {
    String[] processorConstraints = processor.split(",");
    Processor proc = new Processor();
    for (int j = 0; j < processorConstraints.length; ++j) {
        String key = processorConstraints[j].split(":")[0].trim();
        String val = processorConstraints[j].split(":")[1].trim();
        addConstraints(key, val, proc);
    }
    // CU must be 1 if not defined
    if (proc.getComputingUnits() == 0) {
        proc.setComputingUnits(ONE_INT);
    }
    this.addProcessor(proc);
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor)

Example 18 with Processor

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

the class MethodResourceDescription method getProcessorFromProcessorsConstraint.

private Processor getProcessorFromProcessorsConstraint(es.bsc.compss.types.annotations.Processor processorConstraints) {
    Processor p = new Processor();
    String procName = processorConstraints.name();
    if (procName != null && !procName.equals(UNASSIGNED_STR)) {
        procName = EnvironmentLoader.loadFromEnvironment(procName);
        p.setName(procName);
    }
    String cuSTR = processorConstraints.computingUnits();
    cuSTR = EnvironmentLoader.loadFromEnvironment(cuSTR);
    int cu = (cuSTR != null && !cuSTR.isEmpty() && !cuSTR.equals(UNASSIGNED_STR)) ? Integer.valueOf(cuSTR) : ONE_INT;
    if (cu > ONE_INT) {
        p.setComputingUnits(cu);
    } else {
        // When loading from constraints, always use at least one computing unit
        p.setComputingUnits(ONE_INT);
    }
    String speedSTR = processorConstraints.speed();
    speedSTR = EnvironmentLoader.loadFromEnvironment(speedSTR);
    float speed = (speedSTR != null && !speedSTR.isEmpty() && !speedSTR.equals(UNASSIGNED_STR)) ? Float.valueOf(speedSTR) : UNASSIGNED_FLOAT;
    if (speed != UNASSIGNED_FLOAT) {
        p.setSpeed(speed);
    }
    String arch = processorConstraints.architecture();
    arch = EnvironmentLoader.loadFromEnvironment(arch);
    if (arch != null && !arch.equals(UNASSIGNED_STR)) {
        p.setArchitecture(arch);
    }
    String type = processorConstraints.type();
    type = EnvironmentLoader.loadFromEnvironment(type);
    if (type != null) {
        p.setType(type);
    }
    String internalMemorySTR = processorConstraints.internalMemorySize();
    internalMemorySTR = EnvironmentLoader.loadFromEnvironment(internalMemorySTR);
    float internalMemory = (internalMemorySTR != null && !internalMemorySTR.isEmpty() && !internalMemorySTR.equals(UNASSIGNED_STR)) ? Float.valueOf(internalMemorySTR) : UNASSIGNED_FLOAT;
    if (internalMemory != UNASSIGNED_FLOAT) {
        p.setInternalMemory(internalMemory);
    }
    String propName = processorConstraints.propertyName();
    propName = EnvironmentLoader.loadFromEnvironment(propName);
    if (propName != null && !propName.equals(UNASSIGNED_STR)) {
        p.setPropName(propName);
    }
    String propvalue = processorConstraints.propertyValue();
    propvalue = EnvironmentLoader.loadFromEnvironment(propvalue);
    if (propvalue != null && !propvalue.equals(UNASSIGNED_STR)) {
        p.setPropValue(propvalue);
    }
    return p;
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor)

Example 19 with Processor

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

the class MethodResourceDescription method mergeMultiConstraints.

/*
     * ******************************************* METHOD-RESOURCE OPERATIONS
     *******************************************/
// This method tries to substitute the implicit default values by defined mr2 values.
// Keeps the already defined values (do NOT overwrite)
// ONLY CALLED FROM CONSTRAINTS (1 processor always)
public void mergeMultiConstraints(MethodResourceDescription mr2) {
    // Processor constraints
    for (Processor pmr2 : mr2.processors) {
        String type = pmr2.getType();
        Processor pthis = lookForProcessorType(type);
        if (pthis != null) {
            if (pthis.getComputingUnits() <= ONE_INT) {
                int newCus = pmr2.getComputingUnits();
                int currentCUs = pthis.getComputingUnits();
                pthis.setComputingUnits(newCus);
                if (type.equals(Constants.CPU_TYPE)) {
                    this.totalCPUComputingUnits += (newCus - currentCUs);
                } else if (type.equals(Constants.GPU_TYPE)) {
                    this.totalGPUComputingUnits += (newCus - currentCUs);
                } else if (type.equals(Constants.FPGA_TYPE)) {
                    this.totalFPGAComputingUnits += (newCus - currentCUs);
                } else {
                    this.totalOTHERComputingUnits += (newCus - currentCUs);
                }
            }
            if (pthis.getSpeed() == UNASSIGNED_FLOAT) {
                pthis.setSpeed(pmr2.getSpeed());
            }
            if (pthis.getInternalMemory() == UNASSIGNED_FLOAT) {
                pthis.setInternalMemory(pmr2.getInternalMemory());
            }
            if (pthis.getName().equals(UNASSIGNED_STR)) {
                pthis.setName(pmr2.getName());
            }
            if (pthis.getArchitecture().equals(UNASSIGNED_STR)) {
                pthis.setArchitecture(pmr2.getArchitecture());
            }
            if (pthis.getPropName().equals(UNASSIGNED_STR)) {
                pthis.setPropName(pmr2.getPropName());
            }
            if (pthis.getPropValue().equals(UNASSIGNED_STR)) {
                pthis.setPropValue(pmr2.getPropValue());
            }
        } else {
            this.addProcessor(pmr2);
        }
    }
    // Memory
    if (this.memorySize == UNASSIGNED_FLOAT) {
        this.setMemorySize(mr2.getMemorySize());
    }
    if (this.memoryType.equals(UNASSIGNED_STR)) {
        this.setMemoryType(mr2.getMemoryType());
    }
    // Storage
    if (this.storageSize == UNASSIGNED_FLOAT) {
        this.setStorageSize(mr2.getStorageSize());
    }
    if (this.storageType.equals(UNASSIGNED_STR)) {
        this.setStorageType(mr2.getStorageType());
    }
    // Operating System
    if (this.operatingSystemType.equals(UNASSIGNED_STR)) {
        this.setOperatingSystemType(mr2.getOperatingSystemType());
    }
    if (this.operatingSystemDistribution.equals(UNASSIGNED_STR)) {
        this.setOperatingSystemDistribution(mr2.getOperatingSystemDistribution());
    }
    if (this.operatingSystemVersion.equals(UNASSIGNED_STR)) {
        this.setOperatingSystemVersion(mr2.getOperatingSystemVersion());
    }
    // Applications
    for (String app : mr2.appSoftware) {
        if (!this.appSoftware.contains(app)) {
            this.appSoftware.add(app);
        }
    }
    // Host queues
    for (String queue : mr2.hostQueues) {
        if (!this.hostQueues.contains(queue)) {
            this.hostQueues.add(queue);
        }
    }
    // Price
    if (this.pricePerUnit == UNASSIGNED_FLOAT) {
        if (mr2.pricePerUnit > (float) 0.0) {
            this.pricePerUnit = mr2.pricePerUnit;
        }
    }
    if (this.priceTimeUnit == UNASSIGNED_INT) {
        if (mr2.priceTimeUnit > 0) {
            this.priceTimeUnit = mr2.priceTimeUnit;
        }
    }
    // WallClock limit
    if (this.wallClockLimit == UNASSIGNED_INT) {
        this.setWallClockLimit(mr2.getWallClockLimit());
    }
    // Internal fields
    this.value = mr2.value;
}
Also used : Processor(es.bsc.compss.types.resources.components.Processor)

Example 20 with Processor

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

the class MethodResourceDescription method addProcessor.

public void addProcessor(String procName, int computingUnits, String architecture, float speed, String type, float internalMemory, String propName, String propValue) {
    // This method is called from XML: empty and null values must be checked
    Processor p = new Processor();
    if (procName != null && !procName.isEmpty()) {
        p.setName(procName);
    }
    if (computingUnits > 0) {
        p.setComputingUnits(computingUnits);
    }
    if (architecture != null && !architecture.isEmpty()) {
        p.setArchitecture(architecture);
    }
    if (speed > (float) 0.0) {
        p.setSpeed(speed);
    }
    if (type != null && !type.isEmpty()) {
        p.setType(type);
    }
    if (internalMemory > (float) 0.0) {
        p.setInternalMemory(internalMemory);
    }
    if (propName != null && !propName.isEmpty()) {
        p.setPropName(propName);
    }
    if (propValue != null && !propValue.isEmpty()) {
        p.setPropValue(propValue);
    }
    this.addProcessor(p);
}
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