Commit fd65b6c1 authored by Ahmad Siavashi's avatar Ahmad Siavashi

completed version

parent ad64ecd5
Pipeline #15 failed with stages
...@@ -37,6 +37,12 @@ ...@@ -37,6 +37,12 @@
<version>2.9.6</version> <version>2.9.6</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
......
...@@ -276,8 +276,8 @@ public class CloudSimGpuExample6 { ...@@ -276,8 +276,8 @@ public class CloudSimGpuExample6 {
double performanceLoss = 0.1; double performanceLoss = 0.1;
PerformanceModel<VgpuScheduler, Vgpu> performanceModel = new PerformanceModelGpuConstant(performanceLoss); PerformanceModel<VgpuScheduler, Vgpu> performanceModel = new PerformanceModelGpuConstant(performanceLoss);
// Scheduler // Scheduler
RemoteVgpuSchedulerFairShare vgpuScheduler = new RemoteVgpuSchedulerFairShare( RemoteVgpuSchedulerFairShare vgpuScheduler = new RemoteVgpuSchedulerFairShare(VideoCardTags.NVIDIA_K1_CARD,
VideoCardTags.NVIDIA_K1_CARD, pgpus, pgpuSelectionPolicy, performanceModel); pgpus, pgpuSelectionPolicy, performanceModel);
// PCI Express Bus Bw Provisioner // PCI Express Bus Bw Provisioner
VideoCardBwProvisioner videoCardBwProvisioner = new VideoCardBwProvisionerShared( VideoCardBwProvisioner videoCardBwProvisioner = new VideoCardBwProvisionerShared(
VideoCardTags.PCI_E_3_X16_BW); VideoCardTags.PCI_E_3_X16_BW);
...@@ -372,8 +372,8 @@ public class CloudSimGpuExample6 { ...@@ -372,8 +372,8 @@ public class CloudSimGpuExample6 {
// We need to create a Datacenter object. // We need to create a Datacenter object.
PowerGpuDatacenter datacenter = null; PowerGpuDatacenter datacenter = null;
try { try {
datacenter = new PowerGpuDatacenter(name, characteristics, new RemoteGpuVmAllocationPolicyFirstFit(hostList), datacenter = new PowerGpuDatacenter(name, characteristics,
storageList, schedulingInterval); new RemoteGpuVmAllocationPolicyFirstFit(hostList), storageList, schedulingInterval);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
......
package org.cloudbus.cloudsim.examples.gpu.lpds;
/***
*
* This class contains functions to translate integer entity types to their
* corresponding string representations.
*
* @author Ahmad Siavashi
*
*/
public class LpdsTags {
private final static int UNKNOWN_TYPE = -1;
private final static int DUAL_INTEL_XEON_E5_2666_V3 = 0;
private final static int DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80 = 1;
private final static int DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60 = 2;
private final static String UNKNOWN_STR = "Unknonw";
private final static String DUAL_INTEL_XEON_E5_2666_V3_STR = "Dual Intel Xeon E5 2666 V3";
private final static String DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80_STR = "Dual Intel Xeon E5 2666 V3 Dual Nvidia K80";
private final static String DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60_STR = "Dual Intel Xeon E5 2666 V3 Dual Nvidia M60";
private final static int TESLA_K80 = 0;
private final static int TESLA_M60 = 1;
private final static String TESLA_K80_STR = "Tesla K80";
private final static String TESLA_M60_STR = "Tesla M60";
private final static int C4_LARGE = 0;
private final static int C4_XLARGE = 1;
private final static int C4_2XLARGE = 2;
private final static int C4_4XLARGE = 3;
private final static int C4_8XLARGE = 4;
private final static String C4_LARGE_STR = "c4.large";
private final static String C4_XLARGE_STR = "c4.xlarge";
private final static String C4_2XLARGE_STR = "c4.2xlarge";
private final static String C4_4XLARGE_STR = "c4.4xlarge";
private final static String C4_8XLARGE_STR = "c4.8xlarge";
public static int getHostType(String type) {
switch (type) {
case DUAL_INTEL_XEON_E5_2666_V3_STR:
return DUAL_INTEL_XEON_E5_2666_V3;
case DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60_STR:
return DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60;
case DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80_STR:
return DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80;
default:
return UNKNOWN_TYPE;
}
}
public static String getHostType(int type) {
switch (type) {
case DUAL_INTEL_XEON_E5_2666_V3:
return DUAL_INTEL_XEON_E5_2666_V3_STR;
case DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60:
return DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60_STR;
case DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80:
return DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_K80_STR;
default:
return UNKNOWN_STR;
}
}
public static String getVideoCardType(int type) {
switch (type) {
case TESLA_K80:
return TESLA_K80_STR;
case TESLA_M60:
return TESLA_M60_STR;
default:
return UNKNOWN_STR;
}
}
public static int getVideoCardType(String type) {
switch (type) {
case TESLA_K80_STR:
return TESLA_K80;
case TESLA_M60_STR:
return TESLA_M60;
default:
return UNKNOWN_TYPE;
}
}
public static String getVmType(int type) {
switch (type) {
case C4_LARGE:
return C4_LARGE_STR;
case C4_XLARGE:
return C4_XLARGE_STR;
case C4_2XLARGE:
return C4_2XLARGE_STR;
case C4_4XLARGE:
return C4_4XLARGE_STR;
case C4_8XLARGE:
return C4_8XLARGE_STR;
default:
return UNKNOWN_STR;
}
}
public static int getVmType(String type) {
switch (type) {
case C4_LARGE_STR:
return C4_LARGE;
case C4_XLARGE_STR:
return C4_XLARGE;
case C4_2XLARGE_STR:
return C4_2XLARGE;
case C4_4XLARGE_STR:
return C4_4XLARGE;
case C4_8XLARGE_STR:
return C4_8XLARGE;
default:
return UNKNOWN_TYPE;
}
}
}
package org.cloudbus.cloudsim.examples.gpu.lpds;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
public class LpdsWorkload {
@JsonSerialize
@JsonDeserialize
public List<LpdsDatacenter> datacenters;
@JsonSerialize
@JsonDeserialize
public Map<Integer, Integer> gpu_cloudlet_vm_map;
@JsonSerialize
@JsonDeserialize
public List<LpdsGpuCloudlet> gpu_cloudlets;
@JsonSerialize
@JsonDeserialize
public List<LpdsVm> vms;
@JsonSerialize
@JsonDeserialize
public LpdsBroker broker;
}
class LpdsVgpu {
public int type;
public int memory;
}
class LpdsVm {
public int id;
public int num_vcpus;
public String type;
public float ram;
@JsonSerialize
@JsonDeserialize
public LpdsVgpu vgpu;
}
class LpdsGpuTask {
public int block_length;
public int num_blocks;;
public int gddram;
public String gddram_utilization_model;
public String gpu_utilization_model;
}
class LpdsGpuCloudlet {
public int id;
public int length;
public int num_pes;
public String tag;
public String cpu_utilization_model;
@JsonSerialize
@JsonDeserialize
public LpdsGpuTask gpu_task;
}
class LpdsBroker {
public String name;
}
class LpdsDatacenter {
public String name;
public double scheduling_interval;
@JsonSerialize
@JsonDeserialize
public List<LpdsHost> hosts;
public String vm_allocation_policy;
}
class LpdsHost {
public String type;
public int num_pes;
public int pe_mips;
public int ram;
public int peak_power;
public String video_card_allocation_policy;
@JsonSerialize
@JsonDeserialize
public List<LpdsVideoCard> video_cards;
}
class LpdsVideoCard {
@JsonSerialize
@JsonDeserialize
public LpdsGpu gpu;
public int num_gpus;
public String type;
public String gpu_selection_policy;
@JsonSerialize
@JsonDeserialize
public LpdsVideoCardPowerModel power_model;
}
class LpdsVideoCardPowerModel{
public double a3;
public double a2;
public double a1;
public double a0;
}
class LpdsGpu {
public int num_pes;
public int gddram;
public int pe_mips;
}
...@@ -32,7 +32,7 @@ import org.cloudbus.cloudsim.lists.VmList; ...@@ -32,7 +32,7 @@ import org.cloudbus.cloudsim.lists.VmList;
public class GpuDatacenterBroker extends DatacenterBroker { public class GpuDatacenterBroker extends DatacenterBroker {
/** A structure to maintain VM-GpuCloudlet mapping */ /** A structure to maintain VM-GpuCloudlet mapping */
private HashMap<String, List<GpuCloudlet>> VmGpuCloudletMap; private HashMap<String, List<GpuCloudlet>> vmGpuCloudletMap;
/** The number of submitted gpuCloudlets in each vm. */ /** The number of submitted gpuCloudlets in each vm. */
private HashMap<String, Integer> vmGpuCloudletsSubmitted; private HashMap<String, Integer> vmGpuCloudletsSubmitted;
...@@ -107,11 +107,6 @@ public class GpuDatacenterBroker extends DatacenterBroker { ...@@ -107,11 +107,6 @@ public class GpuDatacenterBroker extends DatacenterBroker {
getCloudletList().removeAll(vmCloudlets); getCloudletList().removeAll(vmCloudlets);
getVmGpuCloudletMap().get(vmUid).removeAll(vmCloudlets); getVmGpuCloudletMap().get(vmUid).removeAll(vmCloudlets);
getVmGpuCloudletMap().remove(vmUid); getVmGpuCloudletMap().remove(vmUid);
// If this was the last cloudlet, then there is no need to hold
// vm-gpucloudlet mapping anymore.
if (getCloudletList().size() == 0) {
getVmGpuCloudletMap().clear();
}
} else { } else {
Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Creation of VM #", vmId, Log.printConcatLine(CloudSim.clock(), ": ", getName(), ": Creation of VM #", vmId,
" failed in Datacenter #", datacenterId); " failed in Datacenter #", datacenterId);
...@@ -196,10 +191,17 @@ public class GpuDatacenterBroker extends DatacenterBroker { ...@@ -196,10 +191,17 @@ public class GpuDatacenterBroker extends DatacenterBroker {
throw new IllegalArgumentException("no such vm (Id #" + cloudlet.getVmId() + ") exists for cloudlet (#" throw new IllegalArgumentException("no such vm (Id #" + cloudlet.getVmId() + ") exists for cloudlet (#"
+ cloudlet.getCloudletId() + ")"); + cloudlet.getCloudletId() + ")");
} }
getVmGpuCloudletMap().get(vm.getUid()).add((GpuCloudlet) cloudlet);
}
}
@Override
public void submitVmList(List<? extends Vm> list) {
super.submitVmList(list);
for (Vm vm : vmList) {
if (!getVmGpuCloudletMap().containsKey(vm.getUid())) { if (!getVmGpuCloudletMap().containsKey(vm.getUid())) {
getVmGpuCloudletMap().put(vm.getUid(), new ArrayList<GpuCloudlet>()); getVmGpuCloudletMap().put(vm.getUid(), new ArrayList<>());
} }
getVmGpuCloudletMap().get(vm.getUid()).add((GpuCloudlet) cloudlet);
} }
} }
...@@ -222,7 +224,7 @@ public class GpuDatacenterBroker extends DatacenterBroker { ...@@ -222,7 +224,7 @@ public class GpuDatacenterBroker extends DatacenterBroker {
* @return the vmGpuCloudletMap * @return the vmGpuCloudletMap
*/ */
protected HashMap<String, List<GpuCloudlet>> getVmGpuCloudletMap() { protected HashMap<String, List<GpuCloudlet>> getVmGpuCloudletMap() {
return VmGpuCloudletMap; return vmGpuCloudletMap;
} }
/** /**
...@@ -230,6 +232,6 @@ public class GpuDatacenterBroker extends DatacenterBroker { ...@@ -230,6 +232,6 @@ public class GpuDatacenterBroker extends DatacenterBroker {
* the vmGpuCloudletMap to set * the vmGpuCloudletMap to set
*/ */
protected void setGpuVmCloudletMap(HashMap<String, List<GpuCloudlet>> vmGpuCloudletMap) { protected void setGpuVmCloudletMap(HashMap<String, List<GpuCloudlet>> vmGpuCloudletMap) {
VmGpuCloudletMap = vmGpuCloudletMap; this.vmGpuCloudletMap = vmGpuCloudletMap;
} }
} }
...@@ -132,7 +132,7 @@ public class GpuHost extends Host { ...@@ -132,7 +132,7 @@ public class GpuHost extends Host {
} }
// if the VM has a vGPU but the host has no local video card -> fail. // if the VM has a vGPU but the host has no local video card -> fail.
else if (getVideoCardAllocationPolicy() == null) { else if (getVideoCardAllocationPolicy() == null) {
rollbackHostResourceAllocation(vm); super.vmDeallocate(vm);
return false; return false;
} }
// if the VM has a vGPU and the host has local video card(s) -> check // if the VM has a vGPU and the host has local video card(s) -> check
...@@ -141,7 +141,7 @@ public class GpuHost extends Host { ...@@ -141,7 +141,7 @@ public class GpuHost extends Host {
if (!isVgpuAllocated) { if (!isVgpuAllocated) {
Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), " to Host #", Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), " to Host #",
getId(), " failed due to vgpu allocation failure."); getId(), " failed due to vgpu allocation failure.");
rollbackHostResourceAllocation(vm); super.vmDeallocate(vm);
return false; return false;
} // else -> success } // else -> success
getVmList().add(vm); getVmList().add(vm);
...@@ -149,29 +149,15 @@ public class GpuHost extends Host { ...@@ -149,29 +149,15 @@ public class GpuHost extends Host {
return true; return true;
} }
/**
* Deallocation of host resources for a given vm
*
* @param vm
* the vm
*/
protected void rollbackHostResourceAllocation(Vm vm) {
getRamProvisioner().deallocateRamForVm(vm);
getBwProvisioner().deallocateBwForVm(vm);
getVmScheduler().deallocatePesForVm(vm);
setStorage(getStorage() + vm.getSize());
}
@Override @Override
protected void vmDeallocate(Vm vm) { protected void vmDeallocate(Vm vm) {
// Vm deallocation */ // Vm deallocation */
rollbackHostResourceAllocation(vm); super.vmDeallocate(vm);
// Vgpu deallocation // Vgpu deallocation
if (getVideoCardAllocationPolicy() != null) { Vgpu vgpu = ((GpuVm) vm).getVgpu();
getVideoCardAllocationPolicy().deallocate(((GpuVm) vm).getVgpu()); if (vgpu != null && getVideoCardAllocationPolicy() != null) {
getVideoCardAllocationPolicy().deallocate(vgpu);
} }
// vm removal
getVmList().remove(vm);
} }
@Override @Override
......
...@@ -42,7 +42,7 @@ public abstract class GpuVmAllocationPolicy extends VmAllocationPolicy { ...@@ -42,7 +42,7 @@ public abstract class GpuVmAllocationPolicy extends VmAllocationPolicy {
public void deallocateHostForVm(Vm vm) { public void deallocateHostForVm(Vm vm) {
Host host = getVmTable().remove(vm.getUid()); Host host = getVmTable().remove(vm.getUid());
if (host != null) { if (host != null) {
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm deallocation', 'vm': " + vm.getId() System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm deallocation', 'vm': " + vm.getId()
+ ", 'host': " + host.getId() + "}"); + ", 'host': " + host.getId() + "}");
host.vmDestroy(vm); host.vmDestroy(vm);
} }
......
...@@ -44,7 +44,7 @@ public class GpuVmAllocationPolicySimple extends GpuVmAllocationPolicy { ...@@ -44,7 +44,7 @@ public class GpuVmAllocationPolicySimple extends GpuVmAllocationPolicy {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),
CloudSim.clock()); CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId() System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
+ ", 'host': " + host.getId() + "}"); + ", 'host': " + host.getId() + "}");
return true; return true;
} }
......
...@@ -107,6 +107,9 @@ public abstract class VideoCardAllocationPolicy { ...@@ -107,6 +107,9 @@ public abstract class VideoCardAllocationPolicy {
*/ */
public boolean deallocate(Vgpu vgpu) { public boolean deallocate(Vgpu vgpu) {
VideoCard videoCard = getVgpuVideoCardMap().get(vgpu); VideoCard videoCard = getVgpuVideoCardMap().get(vgpu);
if(videoCard == null) {
return false;
}
videoCard.getVgpuScheduler().deallocatePgpuForVgpu(vgpu); videoCard.getVgpuScheduler().deallocatePgpuForVgpu(vgpu);
getVgpuVideoCardMap().remove(vgpu); getVgpuVideoCardMap().remove(vgpu);
return true; return true;
......
...@@ -128,7 +128,7 @@ public class RemoteGpuHost extends PowerGpuHost { ...@@ -128,7 +128,7 @@ public class RemoteGpuHost extends PowerGpuHost {
} }
// if the VM has a local vGPU but the host has no local video card -> fail. // if the VM has a local vGPU but the host has no local video card -> fail.
else if (getVideoCardAllocationPolicy() == null) { else if (getVideoCardAllocationPolicy() == null) {
rollbackHostResourceAllocation(vm); super.vmDeallocate(vm);
return false; return false;
} }
// if the VM has a local vGPU and the host has local video card(s) -> check // if the VM has a local vGPU and the host has local video card(s) -> check
...@@ -137,7 +137,7 @@ public class RemoteGpuHost extends PowerGpuHost { ...@@ -137,7 +137,7 @@ public class RemoteGpuHost extends PowerGpuHost {
if (!isVgpuAllocated) { if (!isVgpuAllocated) {
Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), " to Host #", Log.printConcatLine("[VmScheduler.vmCreate] Allocation of GPU accelerated VM #", vm.getId(), " to Host #",
getId(), " failed due to vgpu allocation failure."); getId(), " failed due to vgpu allocation failure.");
rollbackHostResourceAllocation(vm); super.vmDeallocate(vm);
return false; return false;
} // else -> success } // else -> success
getVmList().add(vm); getVmList().add(vm);
...@@ -145,23 +145,6 @@ public class RemoteGpuHost extends PowerGpuHost { ...@@ -145,23 +145,6 @@ public class RemoteGpuHost extends PowerGpuHost {
return true; return true;
} }
@Override
protected void vmDeallocate(Vm vm) {
// vm removal
getVmList().remove(vm);
// Vm deallocation */
rollbackHostResourceAllocation(vm);
// get vgpu
Vgpu vgpu = ((GpuVm) vm).getVgpu();
// if the VM has no vGPU -> done
if (vgpu == null) {
return;
} else if (isVgpuLocal(vgpu) && getVideoCardAllocationPolicy() != null) {
// Vgpu deallocation
getVideoCardAllocationPolicy().deallocate(vgpu);
}
}
protected boolean isVgpuLocal(Vgpu vgpu) { protected boolean isVgpuLocal(Vgpu vgpu) {
if (vgpu.getType() == RemoteVgpuTags.LOCAL_EXCLUSIVE || vgpu.getType() == RemoteVgpuTags.LOCAL_SHARED) { if (vgpu.getType() == RemoteVgpuTags.LOCAL_EXCLUSIVE || vgpu.getType() == RemoteVgpuTags.LOCAL_SHARED) {
return true; return true;
......
...@@ -48,9 +48,7 @@ public abstract class RemoteGpuVmAllocationPolicy extends GpuVmAllocationPolicy{ ...@@ -48,9 +48,7 @@ public abstract class RemoteGpuVmAllocationPolicy extends GpuVmAllocationPolicy{
boolean isVgpuAllocated = gpuHost.getVideoCardAllocationPolicy().allocate(vgpu, vgpu.getPCIeBw()); boolean isVgpuAllocated = gpuHost.getVideoCardAllocationPolicy().allocate(vgpu, vgpu.getPCIeBw());
getRemoteVgpuHosts().put(vgpu, gpuHost); getRemoteVgpuHosts().put(vgpu, gpuHost);
if (isVgpuAllocated) { if (isVgpuAllocated) {
Log.formatLine("%.2f: Vgpu of VM #" + vgpu.getVm().getId() + " has been allocated to the host #" System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vgpu allocation', 'vm': "
+ gpuHost.getId(), CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vgpu allocation', 'vm': "
+ vgpu.getVm().getId() + ", 'host': " + gpuHost.getId() + "}"); + vgpu.getVm().getId() + ", 'host': " + gpuHost.getId() + "}");
return true; return true;
} }
......
...@@ -40,18 +40,14 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends RemoteGpuVmAllocationPo ...@@ -40,18 +40,14 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends RemoteGpuVmAllocationPo
// if Vm has no Vgpu or has a local Vgpu which is allocated in vmCreate // if Vm has no Vgpu or has a local Vgpu which is allocated in vmCreate
else if (vgpu == null || !isVgpuRemote(vgpu)) { else if (vgpu == null || !isVgpuRemote(vgpu)) {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
+ ", 'host': " + host.getId() + "}"); + ", 'host': " + host.getId() + "}");
return true; return true;
} }
// else if it has a remote vGPU, then // else if it has a remote vGPU, then
if (allocateRemoteVgpu(vgpu)) { if (allocateRemoteVgpu(vgpu)) {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
+ ", 'host': " + host.getId() + "}"); + ", 'host': " + host.getId() + "}");
return true; return true;
} }
......
...@@ -41,9 +41,7 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP ...@@ -41,9 +41,7 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP
boolean result = host.vmCreate(vm); boolean result = host.vmCreate(vm);
if (result) { if (result) {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': " + vm.getId()
+ ", 'host': " + host.getId() + "}"); + ", 'host': " + host.getId() + "}");
return true; return true;
} }
...@@ -57,9 +55,7 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP ...@@ -57,9 +55,7 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP
boolean result = host.vmCreate(vm); boolean result = host.vmCreate(vm);
if (result) { if (result) {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine("%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(), System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': "
CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': "
+ vm.getId() + ", 'host': " + host.getId() + "}"); + vm.getId() + ", 'host': " + host.getId() + "}");
return true; return true;
} }
...@@ -72,14 +68,12 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP ...@@ -72,14 +68,12 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP
result = allocateRemoteVgpu(vgpu); result = allocateRemoteVgpu(vgpu);
if (result) { if (result) {
getVmTable().put(vm.getUid(), host); getVmTable().put(vm.getUid(), host);
Log.formatLine( System.out.println("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': "
"%.2f: VM #" + vm.getId() + " has been allocated to the host #" + host.getId(),
CloudSim.clock());
Log.printLine("{'clock': " + CloudSim.clock() + ", 'event': 'vm allocation', 'vm': "
+ vm.getId() + ", 'host': " + host.getId() + "}"); + vm.getId() + ", 'host': " + host.getId() + "}");
return true; return true;
} }
getRemoteVgpuHosts().get(vgpu).getVideoCardAllocationPolicy().deallocate(vgpu); // failed to find a remote GPU -> free allocated resources
host.vmDestroy(vm);
} }
} }
} }
......
...@@ -12,4 +12,20 @@ public class RemoteVgpuTags { ...@@ -12,4 +12,20 @@ public class RemoteVgpuTags {
public static final int REMOTE_SHARED = 1; public static final int REMOTE_SHARED = 1;
public static final int LOCAL_EXCLUSIVE = 2; public static final int LOCAL_EXCLUSIVE = 2;
public static final int LOCAL_SHARED = 3; public static final int LOCAL_SHARED = 3;
public static String getVgpuMode(int vgpuMode) {
switch (vgpuMode) {
case RemoteVgpuTags.REMOTE_EXCLUSIVE:
return "Remote Exclusive";
case RemoteVgpuTags.REMOTE_SHARED:
return "Remote Shared";
case RemoteVgpuTags.LOCAL_EXCLUSIVE:
return "Remote Exclusive";
case RemoteVgpuTags.LOCAL_SHARED:
return "Remote Shared";
default:
return "Unknown";
}
}
} }
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