use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceOptimizer method optionalIncrease.
private boolean optionalIncrease(float[] creationRecommendations) {
PriorityQueue<ValueResourceDescription> pq = new PriorityQueue<>();
for (int coreId = 0; coreId < creationRecommendations.length; coreId++) {
if (creationRecommendations[coreId] > 1) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
if (impl.getTaskType() == TaskType.SERVICE) {
continue;
}
MethodResourceDescription constraints = ((MethodImplementation) impl).getRequirements();
ValueResourceDescription v = new ValueResourceDescription(constraints, creationRecommendations[coreId], false);
pq.add(v);
}
}
}
ResourceCreationRequest rcr = requestOneCreation(pq, false);
return (rcr != null);
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceOptimizer method mandatoryIncrease.
private void mandatoryIncrease(float[] creationRecommendations, List<Integer> requiredVMs) {
PriorityQueue<ValueResourceDescription> pq = new PriorityQueue<>();
boolean[] required = new boolean[creationRecommendations.length];
for (int coreId : requiredVMs) {
required[coreId] = true;
}
for (int coreId = 0; coreId < creationRecommendations.length; coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
if (impl.getTaskType() == TaskType.SERVICE) {
continue;
}
MethodResourceDescription constraints = ((MethodImplementation) impl).getRequirements();
ValueResourceDescription v = new ValueResourceDescription(constraints, creationRecommendations[coreId], false);
pq.add(v);
}
}
requestOneCreation(pq, true);
}
use of es.bsc.compss.types.implementations.Implementation 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.implementations.Implementation in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodB.
@Test
public void testMethodB() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodB test");
}
}
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodASetNull.
@Test
public void testMethodASetNull() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "}}"), null);
List<Implementation> impls = CoreManager.getCoreImplementations(0);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
if (impl.getImplementationId() == 1) {
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
} else {
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
}
}
impls = CoreManager.getCoreImplementations(1);
for (Implementation impl : impls) {
Profile p = rs.getProfile(impl);
try {
checkUnsetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA set-null test");
}
}
}
Aggregations