Commit c60cb4d2 authored by Ahmad Siavashi's avatar Ahmad Siavashi

Fix GpuTaskSchedulerLeftover

parent 5ed1fc12
......@@ -30,6 +30,25 @@ public class GpuTaskSchedulerLeftover extends GpuTaskScheduler {
setUsedPes(new ArrayList<Integer>());
}
protected boolean redistributeGpuTaskMips(ResGpuTask rgt) {
int numberOfCurrentAvailablePEs = getCurrentMipsShare().size() - getUsedPes().size();
int numberOfAllocatedPes = rgt.getPeIdList().size();
if (numberOfAllocatedPes < rgt.getGpuTask().getPesLimit() && numberOfCurrentAvailablePEs > numberOfAllocatedPes) {
for (int i = 0; i < getCurrentMipsShare().size(); i++) {
if (!getUsedPes().contains(i)) {
rgt.setPeId(i);
getUsedPes().add(i);
numberOfAllocatedPes++;
if (numberOfAllocatedPes == rgt.getGpuTask().getPesLimit()) {
break;
}
}
}
return true;
}
return false;
}
@Override
public double updateGpuTaskProcessing(double currentTime, List<Double> mipsShare) {
setCurrentMipsShare(mipsShare);
......@@ -58,6 +77,13 @@ public class GpuTaskSchedulerLeftover extends GpuTaskScheduler {
}
getTaskExecList().removeAll(toRemove);
// Redistribute freed resources
if(!toRemove.isEmpty()) {
for (ResGpuTask rcl : getTaskExecList()) {
redistributeGpuTaskMips(rcl);
}
}
// for each finished task, add a new one from the waiting list
if (!getTaskWaitingList().isEmpty()) {
for (int i = 0; i < finished; i++) {
......@@ -203,7 +229,7 @@ public class GpuTaskSchedulerLeftover extends GpuTaskScheduler {
rcl.setTaskStatus(GpuTask.SUCCESS);
rcl.finalizeTask();
List<Integer> pesToRemove = new ArrayList<>();
for (Integer peId : getUsedPes()) {
for (Integer peId : rcl.getPeIdList()) {
pesToRemove.add(peId);
}
getUsedPes().removeAll(pesToRemove);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment