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);
}
}
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);
}
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);
}
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);
}
}
}
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;
}
}
Aggregations