Commit b0f5a68b authored by Ahmad Siavashi's avatar Ahmad Siavashi

Remote GPU partial commit.

parent e1e89aec
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 double 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 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;
}
class LpdsGpu {
public int num_pes;
public int gddram;
public int pe_mips;
}
{
"broker": {
"name": "portal"
},
"datacenters": [
{
"hosts": [
{
"num_pes": 40,
"pe_mips": 46400,
"ram": 60,
"type": "DUAL_INTEL_XEON_E5_2666_V3",
"video_card_allocation_policy": "simple",
"video_cards": []
},
{
"num_pes": 40,
"pe_mips": 46400,
"ram": 60,
"type": "DUAL_INTEL_XEON_E5_2666_V3_DUAL_NVIDIA_M60",
"video_card_allocation_policy": "simple",
"video_cards": [
{
"gpu": {
"gddram": 8192,
"num_pes": 16,
"pe_mips": 142592
},
"gpu_selection_policy": "simple",
"num_gpus": 2,
"type": "Tesla M60"
}
]
}
],
"name": "DC",
"scheduling_interval": 1.0,
"vm_allocation_policy": "simple"
}
],
"gpu_cloudlet_vm_map": {
"0": 0
},
"gpu_cloudlets": [
{
"cpu_utilization_model": "high",
"gpu_task": {
"block_length": 132813,
"gddram": 512,
"gddram_utilization_model": "medium",
"gpu_utilization_model": "low",
"num_blocks": 128
},
"id": 0,
"length": 652977327,
"num_pes": 1,
"tag": "BFS"
}
],
"vms": [
{
"id": 0,
"num_vcpus": 2,
"ram": 3.75,
"type": 1,
"vgpu": {
"memory": 1024,
"type": null
}
}
]
}
\ No newline at end of file
......@@ -61,6 +61,7 @@ public class GpuHost extends Host {
List<? extends Pe> peList, VmScheduler vmScheduler) {
super(id, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
setType(type);
setVideoCardAllocationPolicy(null);
}
@Override
......
package org.cloudbus.cloudsim.gpu;
import java.util.Random;
import org.cloudbus.cloudsim.UtilizationModel;
public class UtilizationModelGaussian implements UtilizationModel{
private Random random;
private double mean;
private double std;
public UtilizationModelGaussian(double mean, double std) {
setMean(mean);
setStd(std);
setRandom(new Random());
}
public UtilizationModelGaussian(double mean, double std, long seed) {
setMean(mean);
setStd(std);
setRandom(new Random(seed));
}
public UtilizationModelGaussian(long seed) {
this(0, 1, seed);
}
public UtilizationModelGaussian() {
this(0, 1);
}
@Override
public double getUtilization(double time) {
return getRandom().nextGaussian() * getStd() + getMean();
}
public Random getRandom() {
return random;
}
protected void setRandom(Random random) {
this.random = random;
}
public double getMean() {
return mean;
}
protected void setMean(double mean) {
this.mean = mean;
}
public double getStd() {
return std;
}
protected void setStd(double std) {
this.std = std;
}
}
/**
*
*/
package org.cloudbus.cloudsim.gpu.performance;
import java.util.ArrayList;
......@@ -10,7 +7,6 @@ import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmScheduler;
import org.cloudbus.cloudsim.gpu.GpuHost;
import org.cloudbus.cloudsim.gpu.GpuVm;
import org.cloudbus.cloudsim.gpu.Vgpu;
import org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy;
import org.cloudbus.cloudsim.provisioners.BwProvisioner;
......
......@@ -10,6 +10,7 @@ import org.cloudbus.cloudsim.gpu.GpuVm;
import org.cloudbus.cloudsim.gpu.VideoCard;
import org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy;
import org.cloudbus.cloudsim.gpu.performance.PerformanceGpuHost;
import org.cloudbus.cloudsim.gpu.power.models.GpuHostPowerModelNull;
import org.cloudbus.cloudsim.power.models.PowerModel;
import org.cloudbus.cloudsim.provisioners.BwProvisioner;
import org.cloudbus.cloudsim.provisioners.RamProvisioner;
......@@ -42,6 +43,19 @@ public class PowerGpuHost extends PerformanceGpuHost {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler, videoCardAllocationPolicy);
setPowerModel(powerModel);
}
/**
*
* @see PerformanceGpuHost#PerformanceGpuHost(int, int, RamProvisioner,
* BwProvisioner, long, List, VmScheduler, VideoCardAllocationPolicy)
* erformanceGpuHost(int, int, RamProvisioner, BwProvisioner, long, List,
* VmScheduler, VideoCardAllocationPolicy)
*/
public PowerGpuHost(int id, int type, RamProvisioner ramProvisioner, BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler, VideoCardAllocationPolicy videoCardAllocationPolicy) {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler, videoCardAllocationPolicy);
setPowerModel(new GpuHostPowerModelNull());
}
/**
*
......@@ -54,6 +68,18 @@ public class PowerGpuHost extends PerformanceGpuHost {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
setPowerModel(powerModel);
}
/**
*
* @see PerformanceGpuHost#PerformanceGpuHost(int, int, RamProvisioner,
* BwProvisioner, long, List, VmScheduler) erformanceGpuHost(int, int,
* RamProvisioner, BwProvisioner, long, List, VmScheduler)
*/
public PowerGpuHost(int id, int type, RamProvisioner ramProvisioner, BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler) {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
setPowerModel(new GpuHostPowerModelNull());
}
/**
* Returns the current total utilization of host's CPUs.
......
package org.cloudbus.cloudsim.gpu.power.models;
import org.cloudbus.cloudsim.power.models.PowerModel;
/**
* Implements a power model where the power consumption is zeroed out.
*
* @author Ahmad Siavashi
*
*/
public class GpuHostPowerModelNull implements PowerModel {
/**
* The host will be zeroed out.
*/
public GpuHostPowerModelNull() {
}
@Override
public double getPower(double utilization) throws IllegalArgumentException {
return 0;
}
}
package org.cloudbus.cloudsim.gpu.power.models;
import java.util.Map;
import org.cloudbus.cloudsim.gpu.Pgpu;
/**
* Implements a power model for which zeroes out the video card power
* consumption.
*
* @author Ahmad Siavashi
*
*/
public class VideoCardPowerModelNull implements VideoCardPowerModel {
/**
* Implements a power model for which zeroes out the video card power
* consumption. *
*/
public VideoCardPowerModelNull() {
}
@Override
public double getPower(Map<Pgpu, Double> pgpuUtilization, Map<Pgpu, Double> gddramUtilization,
double bwUtilization) {
return 0;
}
}
......@@ -26,6 +26,16 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
*/
public class RemoteGpuHost extends PowerGpuHost {
public RemoteGpuHost(int id, int type, RamProvisioner ramProvisioner, BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler, VideoCardAllocationPolicy videoCardAllocationPolicy) {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler, videoCardAllocationPolicy);
}
public RemoteGpuHost(int id, int type, RamProvisioner ramProvisioner, BwProvisioner bwProvisioner, long storage,
List<? extends Pe> peList, VmScheduler vmScheduler) {
super(id, type, ramProvisioner, bwProvisioner, storage, peList, vmScheduler);
}
/**
* A {@link PowerGpuHost} which supports GPU remoting.
*/
......
package org.cloudbus.cloudsim.gpu.remote;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.cloudbus.cloudsim.Pe;
import org.cloudbus.cloudsim.Vm;
import org.cloudbus.cloudsim.VmSchedulerSpaceShared;
public class RemoteGpuVmSchedulerSpaceShared extends VmSchedulerSpaceShared {
public RemoteGpuVmSchedulerSpaceShared(List<? extends Pe> pelist) {
super(pelist);
}
@Override
public boolean allocatePesForVm(Vm vm, List<Double> mipsShare) {
// if there is no enough free PEs, fails
if (getFreePes().size() < vm.getNumberOfPes()) {
return false;
}
List<Pe> selectedPes = new ArrayList<Pe>();
Iterator<Pe> peIterator = getFreePes().iterator();
Pe pe = peIterator.next();
double totalMips = 0;
for(int i = 0; i < vm.getNumberOfPes(); i++) {
selectedPes.add(pe);
if (!peIterator.hasNext()) {
break;
}
pe = peIterator.next();
totalMips += pe.getPeProvisioner().getMips();
}
if (vm.getNumberOfPes() > selectedPes.size()) {
return false;
}
List<Double> allocatedMips = new ArrayList<>();
for(Pe selectedPe : selectedPes) {
allocatedMips.add(selectedPe.getPeProvisioner().getMips());
}
vm.setCurrentAllocatedMips(allocatedMips);
getFreePes().removeAll(selectedPes);
getPeAllocationMap().put(vm.getUid(), selectedPes);
getMipsMap().put(vm.getUid(), allocatedMips);
setAvailableMips(getAvailableMips() - totalMips);
return true;
}
}
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