use of es.bsc.es.bsc.compss.scheduler.types.Gap 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.Gap in project compss by bsc-wdc.
the class Verifiers method verifyGaps.
public static <P extends Profile, T extends WorkerResourceDescription, I extends Implementation<T>> void verifyGaps(LinkedList<Gap<P, T, I>> gaps, Gap<P, T, I>[] expectedGaps) {
for (Gap<P, T, I> eg : expectedGaps) {
boolean found = false;
/*
* Iterator<OptimizationElement<Gap>> gapsIt = gaps.iterator(); while (gapsIt.hasNext()) {
* OptimizationElement<Gap> oe = gapsIt.next(); Gap g = oe.getElement();
*/
Iterator<Gap<P, T, I>> gapsIt = gaps.iterator();
while (gapsIt.hasNext()) {
Gap<P, T, I> g = gapsIt.next();
if (g.getInitialTime() == eg.getInitialTime() && g.getEndTime() == eg.getEndTime() && g.getOrigin() == eg.getOrigin()) {
FakeResourceDescription frd1 = (FakeResourceDescription) g.getResources();
FakeResourceDescription frd2 = (FakeResourceDescription) eg.getResources();
if (frd1.checkEquals(frd2)) {
gapsIt.remove();
found = true;
break;
}
}
}
if (!found) {
System.out.println("GAP " + eg + " not found");
fail("GAP " + eg + " not found");
}
}
if (gaps.size() > 0) {
System.out.println("Obtianed unexpected gaps " + gaps);
fail("Obtianed unexpected gaps " + gaps);
}
}
Aggregations