use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class ResourceSchedulerTest method testMethodAUpdatedNull.
@Test
public void testMethodAUpdatedNull() {
ResourceScheduler<MethodResourceDescription> rs = new ResourceScheduler<>(worker, new JSONObject("{\"implementations\":{\"ClassA.methodA\":" + SET_AND_UPDATED_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 updated-null test");
}
} else {
try {
this.checkSetAndIncreasedProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for set implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on MethodA updated-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 updated-null test");
}
}
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class MOScheduleOptimizer method move.
private boolean move(AllocatableAction action, OptimizationWorker donor, OptimizationWorker receiver) {
LOGGER.debug(LOG_PREFIX + "Trying to move " + action + " from " + donor.getName() + " to " + receiver.getName());
List<AllocatableAction> dataPreds = action.getDataPredecessors();
long dataAvailable = 0;
try {
for (AllocatableAction dataPred : dataPreds) {
MOSchedulingInformation dsi = (MOSchedulingInformation) dataPred.getSchedulingInfo();
dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
}
} catch (ConcurrentModificationException cme) {
dataAvailable = 0;
dataPreds = action.getDataPredecessors();
}
Implementation bestImpl = null;
List<Implementation> impls = action.getCompatibleImplementations(receiver.getResource());
Score bestScore = null;
for (Implementation impl : impls) {
MOScore actionScore = MOScheduler.getActionScore(action);
MOScore score = ((MOResourceScheduler<?>) (receiver.getResource())).generateMoveImplementationScore(action, null, impl, actionScore, (long) (OPTIMIZATION_THRESHOLD * 2.5));
if (Score.isBetter(score, bestScore)) {
bestImpl = impl;
bestScore = score;
}
}
Implementation currentImpl = action.getAssignedImplementation();
MOScore actionScore = MOScheduler.getActionScore(action);
LOGGER.debug(LOG_PREFIX + "Calculating score for current execution");
MOScore currentScore = ((MOResourceScheduler<?>) (action.getAssignedResource())).generateCurrentImplementationScore(action, currentImpl, actionScore);
LOGGER.debug(LOG_PREFIX + "Comparing scores: \n" + bestScore + "\n " + currentScore);
if (bestImpl != null && Score.isBetter(bestScore, currentScore)) {
try {
LOGGER.debug(LOG_PREFIX + "Moving " + action + " from " + donor.getName() + " to " + receiver.getName());
unscheduleFromWorker(action);
scheduleOnWorker(action, bestImpl, receiver);
} catch (ActionNotFoundException anfe) {
// Action was already moved from the resource. Recompute Optimizations!!!
}
return true;
} else {
LOGGER.debug(LOG_PREFIX + "Action " + action + " not moved because new position is not better than actual");
}
return false;
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class LocalOptimizationState method pollActionForGap.
public AllocatableAction pollActionForGap(Gap gap) {
AllocatableAction gapAction = null;
PriorityQueue<AllocatableAction> peeks = selectableActions.peekAll();
// Get Main action to fill the gap
while (!peeks.isEmpty() && gapAction == null) {
AllocatableAction candidate = peeks.poll();
// Check times
MOSchedulingInformation candidateDSI = (MOSchedulingInformation) candidate.getSchedulingInfo();
long start = candidateDSI.getExpectedStart();
if (start > gap.getEndTime()) {
continue;
}
Implementation impl = candidate.getAssignedImplementation();
Profile p = worker.getProfile(impl);
long expectedLength = p.getAverageExecutionTime();
if ((gap.getEndTime() - gap.getInitialTime()) < expectedLength) {
continue;
}
if ((start + expectedLength) > gap.getEndTime()) {
continue;
}
// Check description
if (gap.getResources().canHostDynamic(impl)) {
selectableActions.removeFirst(candidate.getCoreId());
gapAction = candidate;
}
}
return gapAction;
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class InitialSchedulingTest method setUpClass.
@BeforeClass
public static void setUpClass() {
CoreManager.clear();
CoreManager.registerNewCoreElement("fakeSignature00");
CoreManager.registerNewCoreElement("fakeSignature10");
CoreManager.registerNewCoreElement("fakeSignature20");
FakeImplementation impl00 = new FakeImplementation(0, 0, new FakeResourceDescription(2));
List<Implementation<?>> impls0 = new LinkedList<>();
impls0.add(impl00);
List<String> signatures0 = new LinkedList<>();
signatures0.add("fakeSignature00");
CoreManager.registerNewImplementations(0, impls0, signatures0);
FakeImplementation impl10 = new FakeImplementation(1, 0, new FakeResourceDescription(3));
List<Implementation<?>> impls1 = new LinkedList<>();
impls1.add(impl10);
List<String> signatures1 = new LinkedList<>();
signatures1.add("fakeSignature10");
CoreManager.registerNewImplementations(1, impls1, signatures1);
FakeImplementation impl20 = new FakeImplementation(2, 0, new FakeResourceDescription(1));
List<Implementation<?>> impls2 = new LinkedList<>();
impls2.add(impl20);
List<String> signatures2 = new LinkedList<>();
signatures2.add("fakeSignature20");
CoreManager.registerNewImplementations(2, impls2, signatures2);
int maxSlots = 4;
FakeResourceDescription frd = new FakeResourceDescription(maxSlots);
FakeWorker fw = new FakeWorker("worker1", frd, maxSlots);
drs = new FakeResourceScheduler(fw, fao, 0);
drs.profiledExecution(impl00, new FakeProfile(50));
drs.profiledExecution(impl10, new FakeProfile(50));
drs.profiledExecution(impl20, new FakeProfile(30));
CORE0 = drs.getProfile(impl00).getAverageExecutionTime();
CORE1 = drs.getProfile(impl10).getAverageExecutionTime();
CORE2 = drs.getProfile(impl20).getAverageExecutionTime();
// debugConfiguration();
}
use of es.bsc.compss.types.implementations.Implementation in project compss by bsc-wdc.
the class MOResourceSchedulerTest method testAllSetCopy.
@Test
public void testAllSetCopy() {
MOResourceScheduler<MethodResourceDescription> rs = new MOResourceScheduler<MethodResourceDescription>(worker, new JSONObject("{\"idlePower\": " + SET_IDLE_POWER + ", \"idlePrice\": " + SET_IDLE_PRICE + ", \"implementations\":{\"ClassA.methodA\":" + SET_PROFILE + "," + "\"ClassB.methodA\":" + SET_PROFILE + "," + "\"ClassA.methodB\":" + SET_PROFILE + "}}"), null);
JSONObject jo = rs.toJSONObject();
rs = new MOResourceScheduler<MethodResourceDescription>(worker, jo, null);
for (int coreId = 0; coreId < CoreManager.getCoreCount(); coreId++) {
List<Implementation> impls = CoreManager.getCoreImplementations(coreId);
for (Implementation impl : impls) {
MOProfile p = (MOProfile) rs.getProfile(impl);
try {
checkSetProfile(p);
} catch (CheckerException ce) {
fail("Invalid " + ce.getFeature() + " for unset implementation " + impl.getImplementationId() + " core " + impl.getCoreId() + " on all set test");
}
}
}
if (rs.getIdlePower() != SET_IDLE_POWER) {
fail("Invalid idle Power for copy test");
}
if (rs.getIdlePrice() != SET_IDLE_PRICE) {
fail("Invalid idle Price for copy test");
}
}
Aggregations