Commit 65eb3e16 authored by Ahmad Siavashi's avatar Ahmad Siavashi

Add isGpuEquipped method to GpuHost

Update classes to use isGpuEquipped method
parent c3a72367
...@@ -443,7 +443,7 @@ public class CloudSimGpuExample5 { ...@@ -443,7 +443,7 @@ public class CloudSimGpuExample5 {
at.addRow("Host " + depth, dft.format(datacenter.getHostCpuEnergyMap().get(host)).toString() + " / " at.addRow("Host " + depth, dft.format(datacenter.getHostCpuEnergyMap().get(host)).toString() + " / "
+ dft.format(datacenter.getHostEnergyMap().get(host)).toString()); + dft.format(datacenter.getHostEnergyMap().get(host)).toString());
at.addRule(); at.addRule();
if (host.getVideoCardAllocationPolicy() != null) { if (host.isGpuEquipped()) {
for (PowerVideoCard videoCard : (List<PowerVideoCard>) host.getVideoCardAllocationPolicy() for (PowerVideoCard videoCard : (List<PowerVideoCard>) host.getVideoCardAllocationPolicy()
.getVideoCards()) { .getVideoCards()) {
depth = "#" + videoCard.getId() + " / " + depth; depth = "#" + videoCard.getId() + " / " + depth;
......
...@@ -452,7 +452,7 @@ public class CloudSimGpuExample6 { ...@@ -452,7 +452,7 @@ public class CloudSimGpuExample6 {
at.addRow("Host " + depth, dft.format(datacenter.getHostCpuEnergyMap().get(host)).toString() + " / " at.addRow("Host " + depth, dft.format(datacenter.getHostCpuEnergyMap().get(host)).toString() + " / "
+ dft.format(datacenter.getHostEnergyMap().get(host)).toString()); + dft.format(datacenter.getHostEnergyMap().get(host)).toString());
at.addRule(); at.addRule();
if (host.getVideoCardAllocationPolicy() != null) { if (host.isGpuEquipped()) {
for (PowerVideoCard videoCard : (List<PowerVideoCard>) host.getVideoCardAllocationPolicy() for (PowerVideoCard videoCard : (List<PowerVideoCard>) host.getVideoCardAllocationPolicy()
.getVideoCards()) { .getVideoCards()) {
depth = "#" + videoCard.getId() + " / " + depth; depth = "#" + videoCard.getId() + " / " + depth;
......
...@@ -60,7 +60,7 @@ public class GpuHost extends Host { ...@@ -60,7 +60,7 @@ public class GpuHost extends Host {
public double updateVgpusProcessing(double currentTime) { public double updateVgpusProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE; double smallerTime = Double.MAX_VALUE;
if (getVideoCardAllocationPolicy() != null) { if (isGpuEquipped()) {
// Update resident vGPUs // Update resident vGPUs
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) { for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
double time = vgpu.updateGpuTaskProcessing(currentTime, getVideoCardAllocationPolicy() double time = vgpu.updateGpuTaskProcessing(currentTime, getVideoCardAllocationPolicy()
......
...@@ -42,7 +42,7 @@ public class PerformanceGpuHost extends GpuHost { ...@@ -42,7 +42,7 @@ public class PerformanceGpuHost extends GpuHost {
public double updateVgpusProcessing(double currentTime) { public double updateVgpusProcessing(double currentTime) {
double smallerTime = Double.MAX_VALUE; double smallerTime = Double.MAX_VALUE;
if (getVideoCardAllocationPolicy() != null) { if (isGpuEquipped()) {
List<Vgpu> runningVgpus = new ArrayList<Vgpu>(); List<Vgpu> runningVgpus = new ArrayList<Vgpu>();
for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) { for (Vgpu vgpu : getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet()) {
if (vgpu.getGpuTaskScheduler().runningTasks() > 0) { if (vgpu.getGpuTaskScheduler().runningTasks() > 0) {
......
...@@ -54,7 +54,7 @@ public class PowerGpuDatacenter extends GpuDatacenter { ...@@ -54,7 +54,7 @@ public class PowerGpuDatacenter extends GpuDatacenter {
getHostCpuEnergyMap().put(powerGpuHost, 0.0); getHostCpuEnergyMap().put(powerGpuHost, 0.0);
getHostVideoCardEnergyMap().put(powerGpuHost, new HashMap<PowerVideoCard, Double>()); getHostVideoCardEnergyMap().put(powerGpuHost, new HashMap<PowerVideoCard, Double>());
VideoCardAllocationPolicy videoCardAllocationPolicy = powerGpuHost.getVideoCardAllocationPolicy(); VideoCardAllocationPolicy videoCardAllocationPolicy = powerGpuHost.getVideoCardAllocationPolicy();
if (videoCardAllocationPolicy != null) { if (powerGpuHost.isGpuEquipped()) {
for (PowerVideoCard videoCard : (List<PowerVideoCard>) videoCardAllocationPolicy.getVideoCards()) { for (PowerVideoCard videoCard : (List<PowerVideoCard>) videoCardAllocationPolicy.getVideoCards()) {
getHostVideoCardEnergyMap().get(powerGpuHost).put(videoCard, 0.0); getHostVideoCardEnergyMap().get(powerGpuHost).put(videoCard, 0.0);
} }
......
...@@ -125,7 +125,7 @@ public class PowerGpuHost extends PerformanceGpuHost { ...@@ -125,7 +125,7 @@ public class PowerGpuHost extends PerformanceGpuHost {
*/ */
public Map<VideoCard, Double> getCurrentVideoCardsPower() { public Map<VideoCard, Double> getCurrentVideoCardsPower() {
Map<VideoCard, Double> videoCardsPower = new HashMap<VideoCard, Double>(); Map<VideoCard, Double> videoCardsPower = new HashMap<VideoCard, Double>();
if (getVideoCardAllocationPolicy() != null) { if (isGpuEquipped()) {
for (VideoCard videoCard : getVideoCardAllocationPolicy().getVideoCards()) { for (VideoCard videoCard : getVideoCardAllocationPolicy().getVideoCards()) {
PowerVideoCard powerVideoCard = (PowerVideoCard) videoCard; PowerVideoCard powerVideoCard = (PowerVideoCard) videoCard;
videoCardsPower.put(powerVideoCard, powerVideoCard.getPower()); videoCardsPower.put(powerVideoCard, powerVideoCard.getPower());
......
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