use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class OptimizationTest method testLocalOptimization.
@SuppressWarnings("static-access")
@Test
public void testLocalOptimization() {
drs1.clear();
drs2.clear();
FakeAllocatableAction external10 = new FakeAllocatableAction(fao, 13, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).setExpectedEnd(10);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).scheduled();
external10.selectExecution(drs2, (FakeImplementation) external10.getImplementations()[0]);
FakeAllocatableAction external20 = new FakeAllocatableAction(fao, 14, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).setExpectedEnd(20);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).scheduled();
external20.selectExecution(drs2, (FakeImplementation) external20.getImplementations()[0]);
FakeAllocatableAction external90 = new FakeAllocatableAction(fao, 15, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).setExpectedEnd(90);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).scheduled();
external90.selectExecution(drs2, (FakeImplementation) external90.getImplementations()[0]);
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(4));
action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
drs1.scheduleAction(action1);
try {
action1.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(4));
action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
drs1.scheduleAction(action2);
try {
action2.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 1, CoreManager.getCoreImplementations(4));
action3.addDataPredecessor(external90);
action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
drs1.scheduleAction(action3);
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(5));
action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
drs1.scheduleAction(action4);
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 1, CoreManager.getCoreImplementations(4));
action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
drs1.scheduleAction(action5);
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 1, CoreManager.getCoreImplementations(6));
action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
drs1.scheduleAction(action6);
FakeAllocatableAction action7 = new FakeAllocatableAction(fao, 7, 0, CoreManager.getCoreImplementations(5));
action7.addDataPredecessor(external10);
action7.selectExecution(drs1, (FakeImplementation) action7.getImplementations()[0]);
drs1.scheduleAction(action7);
FakeAllocatableAction action8 = new FakeAllocatableAction(fao, 8, 0, CoreManager.getCoreImplementations(5));
action8.addDataPredecessor(external20);
action8.selectExecution(drs1, (FakeImplementation) action8.getImplementations()[0]);
drs1.scheduleAction(action8);
FakeAllocatableAction action9 = new FakeAllocatableAction(fao, 9, 0, CoreManager.getCoreImplementations(4));
action9.addDataPredecessor(external90);
action9.selectExecution(drs1, (FakeImplementation) action9.getImplementations()[0]);
drs1.scheduleAction(action9);
FakeAllocatableAction action10 = new FakeAllocatableAction(fao, 10, 0, CoreManager.getCoreImplementations(4));
action10.addDataPredecessor(action5);
action10.selectExecution(drs1, (FakeImplementation) action10.getImplementations()[0]);
drs1.scheduleAction(action10);
FakeAllocatableAction action11 = new FakeAllocatableAction(fao, 11, 0, CoreManager.getCoreImplementations(4));
action11.addDataPredecessor(action6);
action11.selectExecution(drs1, (FakeImplementation) action11.getImplementations()[0]);
drs1.scheduleAction(action11);
FakeAllocatableAction action12 = new FakeAllocatableAction(fao, 12, 0, CoreManager.getCoreImplementations(4));
action12.addDataPredecessor(action5);
action12.addDataPredecessor(action6);
action12.selectExecution(drs1, (FakeImplementation) action12.getImplementations()[0]);
drs1.scheduleAction(action12);
// Simulate Scan results
LinkedList<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> runningActions = new LinkedList<>();
PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> readyActions = new PriorityQueue<>(1, drs1.getReadyComparator());
PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation> selectableActions = new PriorityActionSet<>(ScheduleOptimizer.getSelectionComparator());
long updateId = System.currentTimeMillis();
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action1.getSchedulingInfo()).lock();
runningActions.add(action1);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action2.getSchedulingInfo()).lock();
runningActions.add(action2);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action3.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action3.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action3.getSchedulingInfo()).setExpectedStart(90);
readyActions.offer(action3);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action4.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action4.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action4.getSchedulingInfo()).setExpectedStart(0);
selectableActions.offer(action4);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).optimizingSuccessor(action12);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action5.getSchedulingInfo()).optimizingSuccessor(action10);
selectableActions.offer(action5);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).optimizingSuccessor(action12);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action6.getSchedulingInfo()).optimizingSuccessor(action11);
selectableActions.offer(action6);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action7.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action7.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action7.getSchedulingInfo()).setExpectedStart(10);
readyActions.offer(action7);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action8.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action8.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action8.getSchedulingInfo()).setExpectedStart(20);
readyActions.offer(action8);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action9.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action9.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action9.getSchedulingInfo()).setExpectedStart(90);
readyActions.offer(action9);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action10.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action10.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action10.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action11.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action11.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action11.getSchedulingInfo()).setExpectedStart(0);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action12.getSchedulingInfo()).setOnOptimization(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action12.getSchedulingInfo()).setToReschedule(true);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) action12.getSchedulingInfo()).setExpectedStart(0);
PriorityQueue<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> donationActions = new PriorityQueue<>(1, ScheduleOptimizer.getDonationComparator());
drs1.rescheduleTasks(updateId, readyActions, selectableActions, runningActions, donationActions);
}
use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class OptimizationTest method testPendingActions.
// @Test
@SuppressWarnings("unchecked")
public void testPendingActions() {
LinkedList<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>> pendingActions = new LinkedList<>();
FakeAllocatableAction external10 = new FakeAllocatableAction(fao, 13, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).setExpectedEnd(10);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).scheduled();
external10.selectExecution(drs2, (FakeImplementation) external10.getImplementations()[0]);
FakeAllocatableAction external20 = new FakeAllocatableAction(fao, 14, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).setExpectedEnd(20);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).scheduled();
external20.selectExecution(drs2, (FakeImplementation) external20.getImplementations()[0]);
FakeAllocatableAction external90 = new FakeAllocatableAction(fao, 15, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).setExpectedEnd(90);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).scheduled();
external90.selectExecution(drs2, (FakeImplementation) external90.getImplementations()[0]);
drs1.clear();
drs2.clear();
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(4));
action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
drs1.scheduleAction(action1);
try {
action1.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(4));
action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
drs1.scheduleAction(action2);
try {
action2.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 1, CoreManager.getCoreImplementations(4));
action3.addDataPredecessor(external90);
action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
drs1.scheduleAction(action3);
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(5));
action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
drs1.scheduleAction(action4);
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 1, CoreManager.getCoreImplementations(4));
action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
drs1.scheduleAction(action5);
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 1, CoreManager.getCoreImplementations(6));
action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
drs1.scheduleAction(action6);
FakeAllocatableAction action7 = new FakeAllocatableAction(fao, 7, 0, CoreManager.getCoreImplementations(5));
action7.addDataPredecessor(external10);
action7.selectExecution(drs1, (FakeImplementation) action7.getImplementations()[0]);
pendingActions.add(action7);
FakeAllocatableAction action8 = new FakeAllocatableAction(fao, 8, 0, CoreManager.getCoreImplementations(5));
action8.addDataPredecessor(external20);
action8.selectExecution(drs1, (FakeImplementation) action8.getImplementations()[0]);
pendingActions.add(action8);
FakeAllocatableAction action9 = new FakeAllocatableAction(fao, 9, 0, CoreManager.getCoreImplementations(4));
action9.addDataPredecessor(external90);
action9.selectExecution(drs1, (FakeImplementation) action9.getImplementations()[0]);
pendingActions.add(action9);
FakeAllocatableAction action10 = new FakeAllocatableAction(fao, 10, 0, CoreManager.getCoreImplementations(4));
action10.addDataPredecessor(action5);
action10.selectExecution(drs1, (FakeImplementation) action10.getImplementations()[0]);
pendingActions.add(action10);
FakeAllocatableAction action11 = new FakeAllocatableAction(fao, 11, 0, CoreManager.getCoreImplementations(4));
action11.addDataPredecessor(action6);
action11.selectExecution(drs1, (FakeImplementation) action11.getImplementations()[0]);
pendingActions.add(action11);
FakeAllocatableAction action12 = new FakeAllocatableAction(fao, 12, 0, CoreManager.getCoreImplementations(4));
action12.addDataPredecessor(action5);
action12.addDataPredecessor(action6);
action12.selectExecution(drs1, (FakeImplementation) action12.getImplementations()[0]);
pendingActions.add(action12);
// 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());
drs1.scanActions(readyActions, selectableActions);
drs1.classifyPendingSchedulings(pendingActions, readyActions, selectableActions, new LinkedList<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>>());
HashMap<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>, Long> expectedReady = new HashMap<>();
expectedReady.put(action7, 10l);
expectedReady.put(action8, 20l);
expectedReady.put(action9, 90l);
expectedReady.put(action3, 90l);
Verifiers.verifyReadyActions(new PriorityQueue<>(readyActions), expectedReady);
AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>[] expectedSelectable = new AllocatableAction[] { action5, action6, action4 };
Verifiers.verifyPriorityActions(new PriorityActionSet<FakeProfile, FakeResourceDescription, FakeImplementation>(selectableActions), expectedSelectable);
}
use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class FullGraphResourceScheduler method scheduleUsingGaps.
private void scheduleUsingGaps(AllocatableAction<P, T, I> action, LinkedList<Gap<P, T, I>> gaps) {
long expectedStart = 0;
// Compute start time due to data dependencies
for (AllocatableAction<P, T, I> predecessor : action.getDataPredecessors()) {
FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
if (predDSI.isScheduled()) {
long predEnd = predDSI.getExpectedEnd();
expectedStart = Math.max(expectedStart, predEnd);
}
}
FullGraphSchedulingInformation<P, T, I> schedInfo = (FullGraphSchedulingInformation<P, T, I>) action.getSchedulingInfo();
I impl = action.getAssignedImplementation();
Profile p = getProfile(impl);
ResourceDescription constraints = impl.getRequirements().copy();
LinkedList<AllocatableAction<P, T, I>> predecessors = new LinkedList<>();
Iterator<Gap<P, T, I>> gapIt = gaps.descendingIterator();
boolean fullyCoveredReqs = false;
// Check gaps before data start
while (gapIt.hasNext() && !fullyCoveredReqs) {
Gap<P, T, I> gap = gapIt.next();
if (gap.getInitialTime() <= expectedStart) {
AllocatableAction<P, T, I> predecessor = (AllocatableAction<P, T, I>) gap.getOrigin();
if (predecessor != null) {
FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
predDSI.lock();
predecessors.add(predecessor);
}
ResourceDescription gapResource = gap.getResources();
ResourceDescription.reduceCommonDynamics(gapResource, constraints);
if (gapResource.isDynamicUseless()) {
gapIt.remove();
}
if (constraints.isDynamicUseless()) {
fullyCoveredReqs = true;
}
}
}
// Check gaps after data start
gapIt = gaps.iterator();
while (gapIt.hasNext() && !fullyCoveredReqs) {
Gap<P, T, I> gap = gapIt.next();
AllocatableAction<P, T, I> predecessor = (AllocatableAction<P, T, I>) gap.getOrigin();
if (predecessor != null) {
FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
predDSI.lock();
predecessors.add(predecessor);
}
ResourceDescription gapResource = gap.getResources();
ResourceDescription.reduceCommonDynamics(gapResource, constraints);
if (gapResource.isDynamicUseless()) {
gapIt.remove();
}
if (constraints.isDynamicUseless()) {
fullyCoveredReqs = true;
}
}
// Lock acces to the current task
schedInfo.lock();
schedInfo.scheduled();
// Unlock access to predecessor
for (AllocatableAction<P, T, I> predecessor : predecessors) {
FullGraphSchedulingInformation<P, T, I> predDSI = ((FullGraphSchedulingInformation<P, T, I>) predecessor.getSchedulingInfo());
if (predDSI.isScheduled()) {
long predEnd = predDSI.getExpectedEnd();
expectedStart = Math.max(expectedStart, predEnd);
schedInfo.addPredecessor(predecessor);
predDSI.addSuccessor(action);
}
predDSI.unlock();
}
// Compute end time
schedInfo.setExpectedStart(expectedStart);
long expectedEnd = expectedStart;
if (p != null) {
expectedEnd += p.getAverageExecutionTime();
}
schedInfo.setExpectedEnd(expectedEnd);
// Unlock access to current task
schedInfo.unlock();
// Create new Gap correspondin to the resources released by the action
addGap(new Gap<P, T, I>(expectedEnd, Long.MAX_VALUE, action, impl.getRequirements().copy(), 0));
}
use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction in project compss by bsc-wdc.
the class OptimizationTest method testScan.
// @Test
@SuppressWarnings("unchecked")
public void testScan() {
FakeAllocatableAction external10 = new FakeAllocatableAction(fao, 13, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).setExpectedEnd(10);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external10.getSchedulingInfo()).scheduled();
external10.selectExecution(drs2, (FakeImplementation) external10.getImplementations()[0]);
FakeAllocatableAction external20 = new FakeAllocatableAction(fao, 14, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).setExpectedEnd(20);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external20.getSchedulingInfo()).scheduled();
external20.selectExecution(drs2, (FakeImplementation) external20.getImplementations()[0]);
FakeAllocatableAction external90 = new FakeAllocatableAction(fao, 15, 0, CoreManager.getCoreImplementations(4));
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).setExpectedEnd(90);
((FullGraphSchedulingInformation<FakeProfile, FakeResourceDescription, FakeImplementation>) external90.getSchedulingInfo()).scheduled();
external90.selectExecution(drs2, (FakeImplementation) external90.getImplementations()[0]);
drs1.clear();
drs2.clear();
FakeAllocatableAction action1 = new FakeAllocatableAction(fao, 1, 0, CoreManager.getCoreImplementations(4));
action1.selectExecution(drs1, (FakeImplementation) action1.getImplementations()[0]);
drs1.scheduleAction(action1);
try {
action1.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action2 = new FakeAllocatableAction(fao, 2, 0, CoreManager.getCoreImplementations(4));
action2.selectExecution(drs1, (FakeImplementation) action2.getImplementations()[0]);
drs1.scheduleAction(action2);
try {
action2.tryToLaunch();
} catch (Exception e) {
}
FakeAllocatableAction action3 = new FakeAllocatableAction(fao, 3, 1, CoreManager.getCoreImplementations(4));
action3.addDataPredecessor(external90);
action3.selectExecution(drs1, (FakeImplementation) action3.getImplementations()[0]);
drs1.scheduleAction(action3);
FakeAllocatableAction action4 = new FakeAllocatableAction(fao, 4, 0, CoreManager.getCoreImplementations(5));
action4.selectExecution(drs1, (FakeImplementation) action4.getImplementations()[0]);
drs1.scheduleAction(action4);
FakeAllocatableAction action5 = new FakeAllocatableAction(fao, 5, 1, CoreManager.getCoreImplementations(4));
action5.selectExecution(drs1, (FakeImplementation) action5.getImplementations()[0]);
drs1.scheduleAction(action5);
FakeAllocatableAction action6 = new FakeAllocatableAction(fao, 6, 1, CoreManager.getCoreImplementations(6));
action6.selectExecution(drs1, (FakeImplementation) action6.getImplementations()[0]);
drs1.scheduleAction(action6);
FakeAllocatableAction action7 = new FakeAllocatableAction(fao, 7, 0, CoreManager.getCoreImplementations(5));
action7.addDataPredecessor(external10);
action7.selectExecution(drs1, (FakeImplementation) action7.getImplementations()[0]);
drs1.scheduleAction(action7);
FakeAllocatableAction action8 = new FakeAllocatableAction(fao, 8, 0, CoreManager.getCoreImplementations(5));
action8.addDataPredecessor(external20);
action8.selectExecution(drs1, (FakeImplementation) action8.getImplementations()[0]);
drs1.scheduleAction(action8);
FakeAllocatableAction action9 = new FakeAllocatableAction(fao, 9, 0, CoreManager.getCoreImplementations(4));
action9.addDataPredecessor(external90);
action9.selectExecution(drs1, (FakeImplementation) action9.getImplementations()[0]);
drs1.scheduleAction(action9);
FakeAllocatableAction action10 = new FakeAllocatableAction(fao, 10, 0, CoreManager.getCoreImplementations(4));
action10.addDataPredecessor(action5);
action10.selectExecution(drs1, (FakeImplementation) action10.getImplementations()[0]);
drs1.scheduleAction(action10);
FakeAllocatableAction action11 = new FakeAllocatableAction(fao, 11, 0, CoreManager.getCoreImplementations(4));
action11.addDataPredecessor(action6);
action11.selectExecution(drs1, (FakeImplementation) action11.getImplementations()[0]);
drs1.scheduleAction(action11);
FakeAllocatableAction action12 = new FakeAllocatableAction(fao, 12, 0, CoreManager.getCoreImplementations(4));
action12.addDataPredecessor(action5);
action12.addDataPredecessor(action6);
action12.selectExecution(drs1, (FakeImplementation) action12.getImplementations()[0]);
drs1.scheduleAction(action12);
// 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());
drs1.scanActions(readyActions, selectableActions);
HashMap<AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>, Long> expectedReady = new HashMap<>();
expectedReady.put(action7, 10l);
expectedReady.put(action8, 20l);
expectedReady.put(action9, 90l);
expectedReady.put(action3, 90l);
Verifiers.verifyReadyActions(new PriorityQueue<>(readyActions), expectedReady);
AllocatableAction<FakeProfile, FakeResourceDescription, FakeImplementation>[] expectedSelectable = new AllocatableAction[] { action5, action6, action4 };
Verifiers.verifyPriorityActions(new PriorityActionSet<>(selectableActions), expectedSelectable);
}
use of es.bsc.es.bsc.compss.scheduler.types.AllocatableAction 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);
*/
}
Aggregations