Commit a58c4742 authored by Ahmad Siavashi's avatar Ahmad Siavashi

updateVmProcessing revised

parent 9d6af996
...@@ -176,23 +176,23 @@ public class GpuHost extends Host { ...@@ -176,23 +176,23 @@ public class GpuHost extends Host {
@Override @Override
public double updateVmsProcessing(double currentTime) { public double updateVmsProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE; double smallerTime = Double.MAX_VALUE;
// Update resident VMs
for (Vm vm : getVmList()) { for (Vm vm : getVmList()) {
GpuVm gpuVm = (GpuVm) vm; double time = vm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
double time = gpuVm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(gpuVm));
Vgpu vgpu = gpuVm.getVgpu();
double deviceTime = vgpu.updateTaskProcessing(currentTime, getVideoCardAllocationPolicy()
.getVgpuVideoCardMap().get(vgpu).getVgpuScheduler().getAllocatedMipsForVgpu(vgpu));
if (vgpu.getGpuTaskScheduler().runningTasks() > 0) {
if (time == 0) {
time = deviceTime;
} else {
time = ((deviceTime < time) ? deviceTime : time);
}
}
if (time > 0.0 && time < smallerTime) { if (time > 0.0 && time < smallerTime) {
smallerTime = time; smallerTime = time;
} }
} }
if (getVideoCardAllocationPolicy() != null) {
// Update resident vGPUs
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
double time = vgpu.updateTaskProcessing(currentTime, getVideoCardAllocationPolicy()
.getVgpuVideoCardMap().get(vgpu).getVgpuScheduler().getAllocatedMipsForVgpu(vgpu));
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
}
}
return smallerTime; return smallerTime;
} }
......
...@@ -18,7 +18,8 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner; ...@@ -18,7 +18,8 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/** /**
* {@link PerformanceGpuHost} extends {@link GpuHost} to add support for * {@link PerformanceGpuHost} extends {@link GpuHost} to add support for
* schedulers that implement {@link PerformanceScheduler PerformanceScheduler} interface. * schedulers that implement {@link PerformanceScheduler PerformanceScheduler}
* interface.
* *
* @author Ahmad Siavashi * @author Ahmad Siavashi
* *
...@@ -33,7 +34,7 @@ public class PerformanceGpuHost extends GpuHost { ...@@ -33,7 +34,7 @@ public class PerformanceGpuHost extends GpuHost {
VideoCardAllocationPolicy videoCardAllocationPolicy) { VideoCardAllocationPolicy videoCardAllocationPolicy) {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler, videoCardAllocationPolicy); super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler, videoCardAllocationPolicy);
} }
/** /**
* @see org.cloudbus.cloudsim.gpu.GpuHost#GpuHost GpuHost * @see org.cloudbus.cloudsim.gpu.GpuHost#GpuHost GpuHost
*/ */
...@@ -44,39 +45,37 @@ public class PerformanceGpuHost extends GpuHost { ...@@ -44,39 +45,37 @@ public class PerformanceGpuHost extends GpuHost {
@Override @Override
public double updateVmsProcessing(double currentTime) { public double updateVmsProcessing(double currentTime) {
// To collect Vm that are probably sharing a resource // Update resident VMs
List<Vgpu> runningVgpus = new ArrayList<Vgpu>(); double smallerTime = Double.MAX_VALUE;
// Collect running gpu vms
for (Vm vm : getVmList()) { for (Vm vm : getVmList()) {
GpuVm gpuVm = (GpuVm) vm; double time = vm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
Vgpu vgpu = gpuVm.getVgpu(); if (time > 0.0 && time < smallerTime) {
if (vgpu != null && vgpu.getGpuTaskScheduler().runningTasks() > 0) { smallerTime = time;
runningVgpus.add(vgpu);
} }
} }
double smallerTime = Double.MAX_VALUE;
for (Vm vm : getVmList()) { if (getVideoCardAllocationPolicy() != null) {
GpuVm gpuVm = (GpuVm) vm; // To collect VMs that are probably sharing a resource
double time = gpuVm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(gpuVm)); List<Vgpu> runningVgpus = new ArrayList<Vgpu>();
if (gpuVm.getVgpu() != null) { // Collect running gpu vms
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
if (vgpu.getGpuTaskScheduler().runningTasks() > 0) {
runningVgpus.add(vgpu);
}
}
// Update resident vGPUs
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
PerformanceScheduler<Vgpu> vgpuScheduler = (PerformanceScheduler<Vgpu>) getVideoCardAllocationPolicy() PerformanceScheduler<Vgpu> vgpuScheduler = (PerformanceScheduler<Vgpu>) getVideoCardAllocationPolicy()
.getVgpuVideoCardMap().get(gpuVm.getVgpu()).getVgpuScheduler(); .getVgpuVideoCardMap().get(vgpu).getVgpuScheduler();
double deviceTime = gpuVm.getVgpu().updateTaskProcessing(currentTime, double time = vgpu.updateTaskProcessing(currentTime,
vgpuScheduler.getAvailableMips(gpuVm.getVgpu(), runningVgpus)); vgpuScheduler.getAvailableMips(vgpu, runningVgpus));
if (gpuVm.getVgpu().getGpuTaskScheduler().runningTasks() > 0) { if (time > 0.0 && time < smallerTime) {
if (time == 0) { smallerTime = time;
time = deviceTime;
} else {
time = ((deviceTime < time) ? deviceTime : time);
}
} }
} }
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
} }
return smallerTime; return smallerTime;
} }
......
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