use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class PriorityActionSetTest method testInitialScheduling.
@SuppressWarnings("unchecked")
@Test
public void testInitialScheduling() throws BlockedActionException, UnassignedActionException {
PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation> pas = new PriorityActionSet<>(new Comparator<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>>() {
@Override
public int compare(AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> o1, AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> o2) {
return Long.compare(o1.getId(), o2.getId());
}
});
PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> peeks;
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).setToReschedule(true);
pas.offer(action1);
if (action1 != pas.peek()) {
fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
}
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).setToReschedule(true);
pas.offer(action2);
if (action1 != pas.peek()) {
fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
}
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 0, null);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action3.getSchedulingInfo()).setToReschedule(true);
pas.offer(action3);
if (action1 != pas.peek()) {
fail(action1 + " expected to be the most prioritary action and " + pas.peek() + " was.");
}
peeks = pas.peekAll();
AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>[] expectedPeeks = new AllocatableAction[] { action1, action3 };
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(1));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action4.getSchedulingInfo()).setToReschedule(true);
pas.offer(action4);
peeks = pas.peekAll();
expectedPeeks = new AllocatableAction[] { action1, action3, action4 };
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation> action = pas.poll();
if (action1 != action) {
fail(action1 + " expected to be the most prioritary action and " + action + " was.");
}
peeks = pas.peekAll();
expectedPeeks = new AllocatableAction[] { action2, action3, action4 };
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
action = pas.poll();
if (action2 != action) {
fail(action2 + " expected to be the most prioritary action and " + action + " was.");
}
peeks = pas.peekAll();
expectedPeeks = new AllocatableAction[] { action3, action4 };
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
action = pas.poll();
if (action3 != action) {
fail(action3 + " expected to be the most prioritary action and " + action + " was.");
}
peeks = pas.peekAll();
expectedPeeks = new AllocatableAction[] { action4 };
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
action = pas.poll();
if (action4 != action) {
fail(action4 + " expected to be the most prioritary action and " + action + " was.");
}
peeks = pas.peekAll();
expectedPeeks = new AllocatableAction[] {};
Verifiers.verifyPriorityActions(peeks, expectedPeeks);
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 0, CoreManager.getCoreImplementations(1));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).setToReschedule(true);
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 0, CoreManager.getCoreImplementations(1));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).setToReschedule(true);
pas.offer(action6);
action = pas.peek();
if (action6 != action) {
fail(action6 + " expected to be the most prioritary action and " + action + " was.");
}
pas.offer(action5);
action = pas.peek();
if (action5 != action) {
fail(action5 + " expected to be the most prioritary action and " + action + " was.");
}
}
use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class ScheduleOptimizer method move.
private boolean move(AllocatableAction<P, T, I> action, OptimizationWorker<P, T, I> donor, OptimizationWorker<P, T, I> receiver) {
LinkedList<AllocatableAction<P, T, I>> dataPreds = action.getDataPredecessors();
long dataAvailable = 0;
try {
for (AllocatableAction<P, T, I> dataPred : dataPreds) {
FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) dataPred.getSchedulingInfo();
dataAvailable = Math.max(dataAvailable, dsi.getExpectedEnd());
}
} catch (ConcurrentModificationException cme) {
dataAvailable = 0;
dataPreds = action.getDataPredecessors();
}
I bestImpl = null;
long bestTime = Long.MAX_VALUE;
LinkedList<I> impls = action.getCompatibleImplementations(receiver.getResource());
for (I impl : impls) {
Profile p = receiver.getResource().getProfile(impl);
long avgTime = p.getAverageExecutionTime();
if (avgTime < bestTime) {
bestTime = avgTime;
bestImpl = impl;
}
}
FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
long currentEnd = dsi.getExpectedEnd();
if (bestImpl != null && currentEnd > receiver.getResource().getLastGapExpectedStart() + bestTime) {
unschedule(action);
schedule(action, bestImpl, receiver);
return true;
}
return false;
}
Aggregations