use of es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation in project compss by bsc-wdc.
the class OptimizationTest method testNoDataDependencies.
// @Test
@SuppressWarnings("unchecked")
public void testNoDataDependencies() throws BlockedActionException, UnassignedActionException, InvalidSchedulingException, InterruptedException {
// Build graph
/*
* 1 --> 3 --> 5 -->6 --> 8 -->9 ----->11 -->12 --> 13 2 --> 4 ┘ └->7 ┘ └->10 ---| └-----┘ | |
* ------------------------------------------------------- 14┘ 15┘
*/
drs1.clear();
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 0, CoreManager.getCoreImplementations(1));
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action7 = new FakeAllocatableAction(fao, 7, 0, CoreManager.getCoreImplementations(2));
FakeAllocatableAction action8 = new FakeAllocatableAction(fao, 8, 0, CoreManager.getCoreImplementations(3));
FakeAllocatableAction action9 = new FakeAllocatableAction(fao, 9, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action10 = new FakeAllocatableAction(fao, 10, 0, CoreManager.getCoreImplementations(2));
FakeAllocatableAction action11 = new FakeAllocatableAction(fao, 11, 0, CoreManager.getCoreImplementations(3));
FakeAllocatableAction action12 = new FakeAllocatableAction(fao, 12, 0, CoreManager.getCoreImplementations(0));
FakeAllocatableAction action13 = new FakeAllocatableAction(fao, 13, 0, CoreManager.getCoreImplementations(1));
FakeAllocatableAction action14 = new FakeAllocatableAction(fao, 14, 0, CoreManager.getCoreImplementations(0));
action14.selectExecution(drs2, (FakeImplementation) action14.getImplementations()[0]);
FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation> dsi14 = (FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action14.getSchedulingInfo();
dsi14.setExpectedEnd(10_000);
FakeAllocatableAction action15 = new FakeAllocatableAction(fao, 15, 0, CoreManager.getCoreImplementations(0));
action15.selectExecution(drs2, (FakeImplementation) action15.getImplementations()[0]);
FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation> dsi15 = (FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action15.getSchedulingInfo();
dsi15.setExpectedEnd(12_000);
action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
action1.tryToLaunch();
action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
action2.tryToLaunch();
action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
addSchedulingDependency(action1, action3);
action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
addSchedulingDependency(action2, action4);
action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
action5.addDataPredecessor(action2);
addSchedulingDependency(action3, action5);
addSchedulingDependency(action4, action5);
action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
action6.addDataPredecessor(action2);
addSchedulingDependency(action5, action6);
action7.selectExecution(drs1, (FakeImplementation) action7.getImplementations()[0]);
action7.addDataPredecessor(action2);
addSchedulingDependency(action5, action7);
action8.selectExecution(drs1, (FakeImplementation) action8.getImplementations()[0]);
action8.addDataPredecessor(action5);
addSchedulingDependency(action6, action8);
addSchedulingDependency(action7, action8);
action9.selectExecution(drs1, (FakeImplementation) action9.getImplementations()[0]);
addSchedulingDependency(action8, action9);
action9.addDataPredecessor(action5);
action10.selectExecution(drs1, (FakeImplementation) action10.getImplementations()[0]);
addSchedulingDependency(action8, action10);
action11.selectExecution(drs1, (FakeImplementation) action11.getImplementations()[0]);
addSchedulingDependency(action9, action11);
addSchedulingDependency(action10, action11);
action11.addDataPredecessor(action14);
action12.selectExecution(drs1, (FakeImplementation) action12.getImplementations()[0]);
addSchedulingDependency(action11, action12);
action13.selectExecution(drs1, (FakeImplementation) action13.getImplementations()[0]);
addSchedulingDependency(action11, action13);
addSchedulingDependency(action12, action13);
action13.addDataPredecessor(action15);
// debugActions(action1, action2, action3, action4, action5, action6, action7, action8, action9, action10,
// action11, action12, action13 );
LinkedList<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>>[] actions = new LinkedList[CoreManager.getCoreCount()];
for (int i = 0; i < actions.length; i++) {
actions[i] = new LinkedList<>();
}
// Actions not depending on other actions scheduled on the same resource
// Sorted by data dependencies release
PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> readyActions = new PriorityQueue<>(1, FullGraphResourceScheduler.getReadyComparator());
// Actions that can be selected to be scheduled on the node
// Sorted by data dependencies release
PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation> selectableActions = new PriorityActionSet<>(FullGraphResourceScheduler.getScanComparator());
LinkedList<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> runningActions = drs1.scanActions(readyActions, selectableActions);
HashMap<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>, Long> expectedReady = new HashMap<>();
expectedReady.put(action11, 10_000l);
expectedReady.put(action13, 12_000l);
Verifiers.verifyReadyActions(new PriorityQueue<>(readyActions), expectedReady);
AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>[] expectedSelectable = new AllocatableAction[] { action3, action4, action10, action12 };
Verifiers.verifyPriorityActions(new PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation>(selectableActions), expectedSelectable);
PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> donationActions = new PriorityQueue<>(1, ScheduleOptimizer.getDonationComparator());
drs1.rescheduleTasks(System.currentTimeMillis(), readyActions, selectableActions, runningActions, donationActions);
/*
* drs.seekGaps(System.currentTimeMillis(), gaps, actions);
*
* long[][][] times = { new long[][]{//CORE 0 new long[]{0, CORE0}, //1 new long[]{0, CORE0}, //2 new
* long[]{CORE0, 2 * CORE0}, //3 new long[]{CORE0, 2 * CORE0}, //4 new long[]{2 * CORE0 + CORE1, 3 * CORE0 +
* CORE1}, //6 new long[]{3 * CORE0 + CORE1 + CORE3, 4 * CORE0 + CORE1 + CORE3}, //9 new long[]{10_000 + CORE3,
* 10_000 + CORE3 + CORE0}, //12 }, new long[][]{//CORE 1 new long[]{2 * CORE0, 2 * CORE0 + CORE1}, //5 new
* long[]{12_000, 12_000 + CORE1}, //13 }, new long[][]{//CORE 2 new long[]{2 * CORE0 + CORE1, 2 * CORE0 + CORE1
* + CORE2}, //7 new long[]{3 * CORE0 + CORE1 + CORE3, 3 * CORE0 + CORE1 + CORE2 + CORE3}, //10 }, new
* long[][]{//CORE 3 new long[]{3 * CORE0 + CORE1, 3 * CORE0 + CORE1 + CORE3}, //8 new long[]{10_000, 10_000 +
* CORE3}, //11 },}; Verifiers.verifyUpdate(actions, times);
*
* Gap[] expectedGaps = { new Gap(2 * CORE0, 3 * CORE0 + CORE1, action3, new FakeResourceDescription(1), 0), new
* Gap(2 * CORE0 + CORE1 + CORE2, 3 * CORE0 + CORE1, action7, new FakeResourceDescription(1), 0), new Gap(3 *
* CORE0 + CORE1 + CORE3, 10_000, action8, new FakeResourceDescription(1), 0), new Gap(3 * CORE0 + CORE1 + CORE2
* + CORE3, 10_000, action10, new FakeResourceDescription(1), 0), new Gap(4 * CORE0 + CORE1 + CORE3, 10_000,
* action9, new FakeResourceDescription(2), 0), new Gap(10_000 + CORE3 + CORE0, 12_000, action12, new
* FakeResourceDescription(2), 0), new Gap(10_000 + CORE3, 12_000, action11, new FakeResourceDescription(1), 0),
* new Gap(10_000 + CORE3, Long.MAX_VALUE, action11, new FakeResourceDescription(1), 0), new Gap(12_000 + CORE1,
* Long.MAX_VALUE, action13, new FakeResourceDescription(3), 0),}; Verifiers.verifyGaps(gaps, expectedGaps);
*/
}
use of es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation 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.fullGraphScheduler.FullGraphSchedulingInformation in project compss by bsc-wdc.
the class LocalOptimizationState method releaseResources.
public void releaseResources(long expectedStart, AllocatableAction<P, T, I> action) {
Gap<P, T, I> gap = new Gap<>(expectedStart, Long.MAX_VALUE, action, action.getAssignedImplementation().getRequirements(), 0);
FullGraphSchedulingInformation<P, T, I> dsi = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
dsi.addGap();
gaps.add(gap);
if (missingResources != null) {
ResourceDescription empty = gap.getResources().copy();
topStartTime = gap.getInitialTime();
ResourceDescription.reduceCommonDynamics(empty, missingResources);
}
}
use of es.bsc.es.bsc.compss.scheduler.fullGraphScheduler.FullGraphSchedulingInformation in project compss by bsc-wdc.
the class LocalOptimizationState method checkGapForReserve.
private boolean checkGapForReserve(Gap<P, T, I> g, ResourceDescription requirements, long reserveStart, LinkedList<Gap<P, T, I>> previousGaps) {
boolean remove = false;
AllocatableAction<P, T, I> gapAction = g.getOrigin();
ResourceDescription rd = g.getResources();
ResourceDescription reduction = ResourceDescription.reduceCommonDynamics(rd, requirements);
Gap<P, T, I> tmpGap = new Gap<>(g.getInitialTime(), reserveStart, g.getOrigin(), reduction, 0);
previousGaps.add(tmpGap);
if (gapAction != null) {
FullGraphSchedulingInformation<P, T, I> gapDSI = (FullGraphSchedulingInformation<P, T, I>) gapAction.getSchedulingInfo();
// Remove resources from the first gap
gapDSI.addGap();
}
// If the gap has been fully used
if (rd.isDynamicUseless()) {
// Remove the gap
remove = true;
if (gapAction != null) {
FullGraphSchedulingInformation<P, T, I> gapDSI = (FullGraphSchedulingInformation<P, T, I>) gapAction.getSchedulingInfo();
gapDSI.removeGap();
}
}
return remove;
}
Aggregations