use of es.bsc.compss.types.resources.MethodResourceDescription in project compss by bsc-wdc.
the class MOResourceOptimizer method createResourceForCreationRequest.
private Resource<?> createResourceForCreationRequest(ResourceCreationRequest rcr) {
CloudMethodResourceDescription cmrd = rcr.getRequested();
Resource<?> r = new Resource<>(null);
Map<CloudInstanceTypeDescription, int[]> composition = cmrd.getTypeComposition();
r.capacity = new int[CoreManager.getCoreCount()];
r.profiles = new MOProfile[CoreManager.getCoreCount()];
for (Map.Entry<CloudInstanceTypeDescription, int[]> component : composition.entrySet()) {
CloudInstanceTypeDescription type = component.getKey();
int count = component.getValue()[0];
MethodResourceDescription rd = type.getResourceDescription();
MOCloudTypeProfile moCloudTypeProf = (MOCloudTypeProfile) getCloudTypeProfile(type);
r.idlePower += moCloudTypeProf.getIdlePower() * count;
r.idlePrice += moCloudTypeProf.getIdlePrice() * count;
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
MOProfile[] profiles = new MOProfile[impls.size()];
for (int i = 0; i < impls.size(); i++) {
profiles[i] = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impls.get(i).getImplementationId());
}
Implementation impl = getBestImplementation(impls, profiles);
r.capacity[coreId] += rd.canHostSimultaneously((MethodResourceDescription) impl.getRequirements()) * count;
MOProfile bestImplProf = (MOProfile) moCloudTypeProf.getImplProfiles(coreId, impl.getImplementationId());
if (r.profiles[coreId] == null) {
r.profiles[coreId] = bestImplProf;
} else {
r.profiles[coreId].accumulate(bestImplProf);
}
}
}
r.startTime = (cmrd.getImage().getCreationTime() * 1000) - (System.currentTimeMillis() - rcr.getRequestedTime());
if (r.startTime < 0) {
r.startTime = 0;
}
r.clear();
return r;
}
use of es.bsc.compss.types.resources.MethodResourceDescription 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.resources.MethodResourceDescription in project compss by bsc-wdc.
the class ResourceOptimizer method selectContainingInstance.
private static CloudInstanceTypeDescription selectContainingInstance(List<CloudInstanceTypeDescription> instances, MethodResourceDescription constraints, int amount) {
CloudInstanceTypeDescription result = null;
MethodResourceDescription bestDescription = null;
float bestDistance = Integer.MIN_VALUE;
for (CloudInstanceTypeDescription type : instances) {
MethodResourceDescription rd = type.getResourceDescription();
int slots = rd.canHostSimultaneously(constraints);
float distance = slots - amount;
RUNTIME_LOGGER.debug("[Resource Optimizer] Can host: slots = " + slots + " amount = " + amount + " distance = " + distance + " bestDistance = " + bestDistance);
if (distance > 0.0) {
continue;
}
if (distance > bestDistance) {
result = type;
bestDescription = type.getResourceDescription();
bestDistance = distance;
} else if (distance == bestDistance && bestDescription != null) {
if (bestDescription.getValue() != null && rd.getValue() != null && bestDescription.getValue() > rd.getValue()) {
// Evaluate optimal candidate
result = type;
bestDescription = type.getResourceDescription();
bestDistance = distance;
}
}
}
if (result == null) {
return null;
}
return result;
}
use of es.bsc.compss.types.resources.MethodResourceDescription 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.resources.MethodResourceDescription 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);
}
Aggregations