Commit a58c4742 authored by Ahmad Siavashi's avatar Ahmad Siavashi

updateVmProcessing revised

parent 9d6af996
......@@ -176,23 +176,23 @@ public class GpuHost extends Host {
@Override
public double updateVmsProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE;
// Update resident VMs
for (Vm vm : getVmList()) {
GpuVm gpuVm = (GpuVm) 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);
double time = vm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
if (time > 0.0 && time < smallerTime) {
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;
}
......
......@@ -18,7 +18,8 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
/**
* {@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
*
......@@ -44,38 +45,36 @@ public class PerformanceGpuHost extends GpuHost {
@Override
public double updateVmsProcessing(double currentTime) {
// To collect Vm that are probably sharing a resource
// Update resident VMs
double smallerTime = Double.MAX_VALUE;
for (Vm vm : getVmList()) {
double time = vm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(vm));
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
}
if (getVideoCardAllocationPolicy() != null) {
// To collect VMs that are probably sharing a resource
List<Vgpu> runningVgpus = new ArrayList<Vgpu>();
// Collect running gpu vms
for (Vm vm : getVmList()) {
GpuVm gpuVm = (GpuVm) vm;
Vgpu vgpu = gpuVm.getVgpu();
if (vgpu != null && vgpu.getGpuTaskScheduler().runningTasks() > 0) {
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
if (vgpu.getGpuTaskScheduler().runningTasks() > 0) {
runningVgpus.add(vgpu);
}
}
double smallerTime = Double.MAX_VALUE;
for (Vm vm : getVmList()) {
GpuVm gpuVm = (GpuVm) vm;
double time = gpuVm.updateVmProcessing(currentTime, getVmScheduler().getAllocatedMipsForVm(gpuVm));
if (gpuVm.getVgpu() != null) {
// Update resident vGPUs
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
@SuppressWarnings("unchecked")
PerformanceScheduler<Vgpu> vgpuScheduler = (PerformanceScheduler<Vgpu>) getVideoCardAllocationPolicy()
.getVgpuVideoCardMap().get(gpuVm.getVgpu()).getVgpuScheduler();
double deviceTime = gpuVm.getVgpu().updateTaskProcessing(currentTime,
vgpuScheduler.getAvailableMips(gpuVm.getVgpu(), runningVgpus));
if (gpuVm.getVgpu().getGpuTaskScheduler().runningTasks() > 0) {
if (time == 0) {
time = deviceTime;
} else {
time = ((deviceTime < time) ? deviceTime : time);
}
}
}
.getVgpuVideoCardMap().get(vgpu).getVgpuScheduler();
double time = vgpu.updateTaskProcessing(currentTime,
vgpuScheduler.getAvailableMips(vgpu, runningVgpus));
if (time > 0.0 && time < smallerTime) {
smallerTime = time;
}
}
}
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