Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gpucloudsim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LPDS
gpucloudsim
Commits
fd65b6c1
Commit
fd65b6c1
authored
6 years ago
by
Ahmad Siavashi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
completed version
parent
ad64ecd5
No related merge requests found
Pipeline
#15
failed with stages
Changes
15
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
826 additions
and
78 deletions
+826
-78
pom.xml
modules/cloudsim-examples/pom.xml
+8
-2
CloudSimGpuExample6.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample6.java
+4
-4
Lpds.java
...in/java/org/cloudbus/cloudsim/examples/gpu/lpds/Lpds.java
+530
-0
LpdsTags.java
...ava/org/cloudbus/cloudsim/examples/gpu/lpds/LpdsTags.java
+124
-0
LpdsWorkload.java
...org/cloudbus/cloudsim/examples/gpu/lpds/LpdsWorkload.java
+110
-0
GpuDatacenterBroker.java
...n/java/org/cloudbus/cloudsim/gpu/GpuDatacenterBroker.java
+13
-11
GpuHost.java
...dsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuHost.java
+6
-20
GpuVmAllocationPolicy.java
...java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicy.java
+1
-1
GpuVmAllocationPolicySimple.java
...rg/cloudbus/cloudsim/gpu/GpuVmAllocationPolicySimple.java
+1
-1
VideoCardAllocationPolicy.java
...us/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
+3
-0
RemoteGpuHost.java
.../java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuHost.java
+2
-19
RemoteGpuVmAllocationPolicy.java
...dbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicy.java
+1
-3
RemoteGpuVmAllocationPolicyFirstFit.java
...udsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
+2
-6
RemoteGpuVmAllocationPolicyLeastLoad.java
...dsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
+5
-11
RemoteVgpuTags.java
...java/org/cloudbus/cloudsim/gpu/remote/RemoteVgpuTags.java
+16
-0
No files found.
modules/cloudsim-examples/pom.xml
View file @
fd65b6c1
...
@@ -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>
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample6.java
View file @
fd65b6c1
...
@@ -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
();
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/lpds/Lpds.java
0 → 100644
View file @
fd65b6c1
package
org
.
cloudbus
.
cloudsim
.
examples
.
gpu
.
lpds
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.PrintStream
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.Calendar
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
org.apache.commons.io.output.TeeOutputStream
;
import
org.cloudbus.cloudsim.Cloudlet
;
import
org.cloudbus.cloudsim.CloudletSchedulerTimeShared
;
import
org.cloudbus.cloudsim.DatacenterCharacteristics
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Storage
;
import
org.cloudbus.cloudsim.UtilizationModel
;
import
org.cloudbus.cloudsim.UtilizationModelFull
;
import
org.cloudbus.cloudsim.VmAllocationPolicy
;
import
org.cloudbus.cloudsim.VmScheduler
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.gpu.GpuCloudlet
;
import
org.cloudbus.cloudsim.gpu.GpuDatacenter
;
import
org.cloudbus.cloudsim.gpu.GpuDatacenterBroker
;
import
org.cloudbus.cloudsim.gpu.GpuHost
;
import
org.cloudbus.cloudsim.gpu.GpuTask
;
import
org.cloudbus.cloudsim.gpu.GpuTaskScheduler
;
import
org.cloudbus.cloudsim.gpu.GpuTaskSchedulerLeftover
;
import
org.cloudbus.cloudsim.gpu.GpuVm
;
import
org.cloudbus.cloudsim.gpu.Pgpu
;
import
org.cloudbus.cloudsim.gpu.UtilizationModelGaussian
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicyLeastLoad
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicySimple
;
import
org.cloudbus.cloudsim.gpu.performance.models.PerformanceModelGpuNull
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuDatacenter
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuDatacenterBroker
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuHost
;
import
org.cloudbus.cloudsim.gpu.power.PowerVideoCard
;
import
org.cloudbus.cloudsim.gpu.power.models.GpuHostPowerModelLinear
;
import
org.cloudbus.cloudsim.gpu.power.models.VideoCardPowerModel
;
import
org.cloudbus.cloudsim.gpu.power.models.VideoCardPowerModelLinear
;
import
org.cloudbus.cloudsim.gpu.provisioners.GpuBwProvisionerSimple
;
import
org.cloudbus.cloudsim.gpu.provisioners.GpuGddramProvisionerSimple
;
import
org.cloudbus.cloudsim.gpu.provisioners.VideoCardBwProvisioner
;
import
org.cloudbus.cloudsim.gpu.provisioners.VideoCardBwProvisionerShared
;
import
org.cloudbus.cloudsim.gpu.remote.RemoteGpuHost
;
import
org.cloudbus.cloudsim.gpu.remote.RemoteGpuVmAllocationPolicyFirstFit
;
import
org.cloudbus.cloudsim.gpu.remote.RemoteGpuVmAllocationPolicyLeastLoad
;
import
org.cloudbus.cloudsim.gpu.remote.RemoteGpuVmSchedulerSpaceShared
;
import
org.cloudbus.cloudsim.gpu.remote.RemoteVgpuSchedulerFairShare
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicyLeastLoad
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicySimple
;
import
org.cloudbus.cloudsim.power.models.PowerModel
;
import
org.cloudbus.cloudsim.provisioners.BwProvisioner
;
import
org.cloudbus.cloudsim.provisioners.BwProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.PeProvisioner
;
import
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
import
org.cloudbus.cloudsim.provisioners.RamProvisionerSimple
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
public
class
Lpds
{
public
static
final
long
SEED
=
1
;
public
static
void
main
(
String
[]
args
)
{
try
{
String
workloadName
=
"lpds_workload_1"
;
// Set output stream
FileOutputStream
fileOutputStream
=
new
FileOutputStream
(
workloadName
+
"_output.txt"
);
TeeOutputStream
teeOutputStream
=
new
TeeOutputStream
(
System
.
out
,
fileOutputStream
);
PrintStream
printStream
=
new
PrintStream
(
teeOutputStream
,
true
);
System
.
setOut
(
printStream
);
// Loading workload description from file...
ObjectMapper
mapper
=
new
ObjectMapper
();
LpdsWorkload
workloadManifest
=
mapper
.
readValue
(
new
File
(
"//home//gpu//gitrepos//gpucloudsim//modules//cloudsim-examples//src//main//java//org//cloudbus//cloudsim//examples//gpu//lpds//"
+
workloadName
+
".json"
),
LpdsWorkload
.
class
);
// number of cloud users
int
num_user
=
1
;
Calendar
calendar
=
Calendar
.
getInstance
();
// trace events
boolean
trace_flag
=
true
;
// CloudSim initialization
CloudSim
.
init
(
num_user
,
calendar
,
trace_flag
);
// Creation of Datacenters
List
<
GpuDatacenter
>
datacenters
=
createDatacenters
(
workloadManifest
);
// Creation of Datacenter Broker
GpuDatacenterBroker
broker
=
createBroker
(
workloadManifest
.
broker
.
name
);
// Creation of VMs
List
<
GpuVm
>
vms
=
createVms
(
broker
.
getId
(),
workloadManifest
.
vms
);
broker
.
submitVmList
(
vms
);
// Creation of GpuCloudlets
List
<
GpuCloudlet
>
gpuCloudlets
=
createGpuCloudlets
(
broker
.
getId
(),
workloadManifest
.
gpu_cloudlets
,
workloadManifest
.
gpu_cloudlet_vm_map
);
broker
.
submitCloudletList
(
gpuCloudlets
);
Log
.
disable
();
System
.
out
.
println
(
"+ Start"
);
System
.
out
.
println
(
"+ Events"
);
CloudSim
.
startSimulation
();
CloudSim
.
stopSimulation
();
System
.
out
.
println
(
"+ Finish"
);
System
.
out
.
println
(
"+ Results"
);
List
<
Cloudlet
>
cloudlets
=
broker
.
getCloudletReceivedList
();
printCloudletList
(
cloudlets
,
vms
,
datacenters
);
System
.
out
.
println
(
"+ End"
);
teeOutputStream
.
close
();
}
catch
(
Exception
ex
)
{
Log
.
printLine
(
ex
.
getMessage
());
ex
.
printStackTrace
();
}
}
private
static
Vgpu
createVgpu
(
LpdsVgpu
vgpuManifest
)
{
final
int
DONT_CARE
=
0
;
final
int
type
=
vgpuManifest
.
type
;
// GPU Clock: 850 MHz
final
double
mips
=
DONT_CARE
;
// SMX count: 1
final
int
numberOfPes
=
DONT_CARE
;
// GDDRAM: 256 MB
final
int
gddram
=
vgpuManifest
.
memory
;
// Bandwidth: 28 GB/s
final
long
bw
=
DONT_CARE
;
GpuTaskScheduler
gpuTaskScheduler
=
new
GpuTaskSchedulerLeftover
();
Vgpu
vgpu
=
new
Vgpu
(
0
,
mips
,
numberOfPes
,
gddram
,
bw
,
type
,
gpuTaskScheduler
,
VideoCardTags
.
PCI_E_3_X16_BW
);
return
vgpu
;
}
private
static
List
<
GpuVm
>
createVms
(
int
brokerId
,
List
<
LpdsVm
>
vmsManifest
)
{
final
int
DONT_CARE
=
0
;
List
<
GpuVm
>
vms
=
new
ArrayList
<>();
int
vm_id
=
0
;
for
(
LpdsVm
vmManifest
:
vmsManifest
)
{
// VM type
int
vmType
=
LpdsTags
.
getVmType
(
vmManifest
.
type
);
// vGPU
LpdsVgpu
vgpuManifest
=
vmManifest
.
vgpu
;
// VM description
double
mips
=
0
;
// image size (MB)
long
size
=
0
;
// vm memory (MB)
int
ram
=
(
int
)
(
vmManifest
.
ram
*
1024
);
long
bw
=
DONT_CARE
;
// number of cpus
int
pesNumber
=
vmManifest
.
num_vcpus
;
// VMM name
String
vmm
=
"Xen"
;
// create VM
GpuVm
vm
=
new
GpuVm
(
vm_id
,
brokerId
,
mips
,
pesNumber
,
ram
,
bw
,
size
,
vmm
,
vmType
,
new
CloudletSchedulerTimeShared
());
vm_id
+=
1
;
if
(
vgpuManifest
!=
null
)
{
Vgpu
vgpu
=
createVgpu
(
vgpuManifest
);
vm
.
setVgpu
(
vgpu
);
}
vms
.
add
(
vm
);
}
return
vms
;
}
private
static
GpuTask
createGpuTask
(
int
gpuCloudletId
,
LpdsGpuTask
gpuTaskManifest
)
{
// GpuTask properties
long
blockLength
=
gpuTaskManifest
.
block_length
;
long
inputSize
=
512
;
long
outputSize
=
512
;
long
requestedGddramSize
=
inputSize
+
outputSize
;
int
numberOfBlocks
=
gpuTaskManifest
.
num_blocks
;
UtilizationModel
gpuUtilizationModel
=
null
;
UtilizationModel
gddramUtilizationModel
=
null
;
UtilizationModel
bwUtilizationModel
=
new
UtilizationModelFull
();
switch
(
gpuTaskManifest
.
gpu_utilization_model
)
{
case
"full"
:
gpuUtilizationModel
=
new
UtilizationModelFull
();
break
;
case
"low"
:
gpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.2
,
0.05
,
SEED
);
break
;
case
"medium"
:
gpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.5
,
0.05
,
SEED
);
break
;
case
"high"
:
gpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.8
,
0.05
,
SEED
);
break
;
default
:
throw
new
IllegalArgumentException
(
"[-] Unknown GPU Utilization Model for GpuTask."
);
}
switch
(
gpuTaskManifest
.
gddram_utilization_model
)
{
case
"full"
:
gddramUtilizationModel
=
new
UtilizationModelFull
();
break
;
case
"low"
:
gddramUtilizationModel
=
new
UtilizationModelGaussian
(
0.2
,
0.05
,
SEED
);
break
;
case
"medium"
:
gddramUtilizationModel
=
new
UtilizationModelGaussian
(
0.5
,
0.05
,
SEED
);
break
;
case
"high"
:
gddramUtilizationModel
=
new
UtilizationModelGaussian
(
0.8
,
0.05
,
SEED
);
break
;
default
:
throw
new
IllegalArgumentException
(
"[-] Unknown GDDRAM Utilization Model for GpuTask."
);
}
GpuTask
gpuTask
=
new
GpuTask
(
gpuCloudletId
,
blockLength
,
numberOfBlocks
,
inputSize
,
outputSize
,
requestedGddramSize
,
gpuUtilizationModel
,
gddramUtilizationModel
,
bwUtilizationModel
);
return
gpuTask
;
}
private
static
List
<
GpuCloudlet
>
createGpuCloudlets
(
int
brokerId
,
List
<
LpdsGpuCloudlet
>
gpuCloudletsManifest
,
Map
<
Integer
,
Integer
>
gpuCloudletVmMap
)
{
List
<
GpuCloudlet
>
gpuCloudlets
=
new
ArrayList
<>();
for
(
LpdsGpuCloudlet
gpuCloudletManifest
:
gpuCloudletsManifest
)
{
// Cloudlet properties
long
length
=
gpuCloudletManifest
.
length
;
long
inputSize
=
0
;
long
outputSize
=
0
;
int
pesNumber
=
gpuCloudletManifest
.
num_pes
;
UtilizationModel
cpuUtilizationModel
=
null
;
UtilizationModel
ramUtilizationModel
=
new
UtilizationModelFull
();
UtilizationModel
bwUtilizationModel
=
new
UtilizationModelFull
();
switch
(
gpuCloudletManifest
.
cpu_utilization_model
)
{
case
"full"
:
cpuUtilizationModel
=
new
UtilizationModelFull
();
break
;
case
"low"
:
cpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.2
,
0.05
,
SEED
);
break
;
case
"medium"
:
cpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.5
,
0.05
,
SEED
);
break
;
case
"high"
:
cpuUtilizationModel
=
new
UtilizationModelGaussian
(
0.8
,
0.05
,
SEED
);
break
;
default
:
throw
new
IllegalArgumentException
(
"[-] Unknown CPU Utilization Model for Cloudlet."
);
}
LpdsGpuTask
gpuTaskManifest
=
gpuCloudletManifest
.
gpu_task
;
GpuTask
gpuTask
=
null
;
if
(
gpuTaskManifest
!=
null
)
{
gpuTask
=
createGpuTask
(
gpuCloudletManifest
.
id
,
gpuTaskManifest
);
}
GpuCloudlet
gpuCloudlet
=
new
GpuCloudlet
(
gpuCloudletManifest
.
id
,
length
,
pesNumber
,
inputSize
,
outputSize
,
cpuUtilizationModel
,
ramUtilizationModel
,
bwUtilizationModel
,
gpuTask
);
gpuCloudlet
.
setTag
(
gpuCloudletManifest
.
tag
);
gpuCloudlet
.
setUserId
(
brokerId
);
gpuCloudlet
.
setVmId
(
gpuCloudletVmMap
.
get
(
gpuCloudlet
.
getCloudletId
()));
gpuCloudlets
.
add
(
gpuCloudlet
);
}
return
gpuCloudlets
;
}
private
static
GpuDatacenterBroker
createBroker
(
String
name
)
{
GpuDatacenterBroker
broker
=
null
;
try
{
broker
=
new
PowerGpuDatacenterBroker
(
name
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
return
broker
;
}
private
static
List
<
GpuDatacenter
>
createDatacenters
(
LpdsWorkload
workloadManifest
)
{
List
<
GpuDatacenter
>
datacenters
=
new
ArrayList
<>();
// unique across all datacenters
int
hostId
=
0
;
int
peId
=
0
;
int
videoCardId
=
0
;
int
pgpuId
=
0
;
for
(
LpdsDatacenter
datacenterManifest
:
workloadManifest
.
datacenters
)
{
// We need to create a list to store our machine
List
<
GpuHost
>
hostList
=
new
ArrayList
<>();
for
(
LpdsHost
hostManifest
:
datacenterManifest
.
hosts
)
{
// A Machine contains one or more PEs or CPUs/Cores.
List
<
Pe
>
hostPes
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
hostManifest
.
num_pes
;
i
++)
{
hostPes
.
add
(
new
Pe
(
peId
,
new
PeProvisionerSimple
(
hostManifest
.
pe_mips
)));
peId
+=
1
;
}
VmScheduler
vmScheduler
=
new
RemoteGpuVmSchedulerSpaceShared
(
hostPes
);
RamProvisioner
ramProvisioner
=
new
RamProvisionerSimple
(
hostManifest
.
ram
*
1024
);
BwProvisioner
bwProvisioner
=
new
BwProvisionerSimple
(
Long
.
MAX_VALUE
);
// Adding video cards with pgpus
List
<
VideoCard
>
videoCards
=
new
ArrayList
<>();
for
(
LpdsVideoCard
videoCardManifest
:
hostManifest
.
video_cards
)
{
List
<
Pgpu
>
pgpus
=
new
ArrayList
<>();
LpdsGpu
gpu
=
videoCardManifest
.
gpu
;
for
(
int
j
=
0
;
j
<
videoCardManifest
.
num_gpus
;
j
++)
{
List
<
Pe
>
pgpuPes
=
new
ArrayList
<
Pe
>();
for
(
int
k
=
0
;
k
<
videoCardManifest
.
gpu
.
num_pes
;
k
++)
{
PeProvisioner
peProvisioner
=
new
PeProvisionerSimple
(
gpu
.
pe_mips
);
pgpuPes
.
add
(
new
Pe
(
peId
,
peProvisioner
));
peId
+=
1
;
}
pgpus
.
add
(
new
Pgpu
(
pgpuId
,
pgpuPes
,
new
GpuGddramProvisionerSimple
(
gpu
.
gddram
),
new
GpuBwProvisionerSimple
(
Long
.
MAX_VALUE
)));
pgpuId
+=
1
;
}
VideoCardBwProvisioner
videoCardBwProvisioner
=
new
VideoCardBwProvisionerShared
(
Long
.
MAX_VALUE
);
PgpuSelectionPolicy
pgpuSelectionPolicy
=
null
;
switch
(
videoCardManifest
.
gpu_selection_policy
)
{
case
"simple"
:
pgpuSelectionPolicy
=
new
PgpuSelectionPolicySimple
();
break
;
case
"least_load"
:
pgpuSelectionPolicy
=
new
PgpuSelectionPolicyLeastLoad
();
break
;
default
:
throw
new
IllegalArgumentException
(
"[!] Unknown GpuSelection Policy: "
+
videoCardManifest
.
gpu_selection_policy
);
}
int
videoCardType
=
LpdsTags
.
getVideoCardType
(
videoCardManifest
.
type
);
RemoteVgpuSchedulerFairShare
vgpuScheduler
=
new
RemoteVgpuSchedulerFairShare
(
videoCardType
,
pgpus
,
pgpuSelectionPolicy
,
new
PerformanceModelGpuNull
());
int
pgpuFrequency
=
pgpus
.
get
(
0
).
getPeList
().
get
(
0
).
getMips
();
LpdsVideoCardPowerModel
videoCardPowerModelManifest
=
videoCardManifest
.
power_model
;
VideoCardPowerModel
videoCardPowerModel
=
new
VideoCardPowerModelLinear
(
pgpuFrequency
,
videoCardPowerModelManifest
.
a3
,
videoCardPowerModelManifest
.
a2
,
videoCardPowerModelManifest
.
a1
,
videoCardPowerModelManifest
.
a0
,
false
);
VideoCard
videoCard
=
new
PowerVideoCard
(
videoCardId
,
videoCardType
,
vgpuScheduler
,
videoCardBwProvisioner
,
videoCardPowerModel
);
videoCardId
+=
1
;
videoCards
.
add
(
videoCard
);
}
VideoCardAllocationPolicy
videoCardAllocationPolicy
=
null
;
switch
(
hostManifest
.
video_card_allocation_policy
)
{
case
"simple"
:
videoCardAllocationPolicy
=
new
VideoCardAllocationPolicySimple
(
videoCards
);
break
;
case
"least_load"
:
videoCardAllocationPolicy
=
new
VideoCardAllocationPolicyLeastLoad
(
videoCards
);
break
;
}
PowerModel
powerModel
=
new
GpuHostPowerModelLinear
(
hostManifest
.
peak_power
,
hostManifest
.
peak_power
*
0.7
);
int
hostType
=
LpdsTags
.
getHostType
(
hostManifest
.
type
);
GpuHost
host
=
new
RemoteGpuHost
(
hostId
,
hostType
,
ramProvisioner
,
bwProvisioner
,
Long
.
MAX_VALUE
,
hostPes
,
vmScheduler
,
videoCardAllocationPolicy
,
powerModel
);
hostList
.
add
(
host
);
hostId
+=
1
;
}
String
datacenterName
=
datacenterManifest
.
name
;
VmAllocationPolicy
vmAllocationPolicy
=
null
;
switch
(
datacenterManifest
.
vm_allocation_policy
)
{
case
"simple"
:
vmAllocationPolicy
=
new
RemoteGpuVmAllocationPolicyFirstFit
(
hostList
);
break
;
case
"least_load"
:
vmAllocationPolicy
=
new
RemoteGpuVmAllocationPolicyLeastLoad
(
hostList
);
break
;
default
:
throw
new
IllegalArgumentException
(
"[-] Vm Allocation Policy for Datacenter "
+
datacenterName
+
" is unknown."
);
}
// Create a DatacenterCharacteristics object that stores the
// properties of a data center: architecture, OS, list of
// Machines, allocation policy: time- or space-shared, time zone
// and its price (G$/Pe time unit).
// system architecture
String
arch
=
"x86"
;
// operating system
String
os
=
"Linux"
;
// VM Manager
String
vmm
=
"Xen"
;
// time zone this resource located
double
time_zone
=
3.5
;
// the cost of using processing in this resource
double
cost
=
0.0
;
// the cost of using memory in this resource
double
costPerMem
=
0.0
;
// the cost of using storage in this resource
double
costPerStorage
=
0.0
;
// the cost of using bw in this resource
double
costPerBw
=
0.0
;
// we are not adding SAN devices by now
LinkedList
<
Storage
>
storageList
=
new
LinkedList
<
Storage
>();
DatacenterCharacteristics
characteristics
=
new
DatacenterCharacteristics
(
arch
,
os
,
vmm
,
hostList
,
time_zone
,
cost
,
costPerMem
,
costPerStorage
,
costPerBw
);
// 6. Finally, we need to create a Datacenter object.
GpuDatacenter
datacenter
=
null
;
final
double
schedulingInterval
=
datacenterManifest
.
scheduling_interval
;
try
{
datacenter
=
new
PowerGpuDatacenter
(
datacenterManifest
.
name
,
characteristics
,
vmAllocationPolicy
,
storageList
,
schedulingInterval
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
datacenters
.
add
(
datacenter
);
}
return
datacenters
;
}
@SuppressWarnings
(
"unchecked"
)
private
static
void
printCloudletList
(
List
<
Cloudlet
>
cloudlets
,
List
<
GpuVm
>
vms
,
List
<
GpuDatacenter
>
datacenters
)
{
DecimalFormat
dft
=
new
DecimalFormat
(
"###.##"
);
System
.
out
.
println
(
"+ GpuCloudlets"
);
for
(
Cloudlet
gpuCloudlet
:
cloudlets
)
{
int
id
=
gpuCloudlet
.
getCloudletId
();
String
tag
=
((
GpuCloudlet
)
gpuCloudlet
).
getTag
();
int
vmId
=
gpuCloudlet
.
getVmId
();
double
duration
=
gpuCloudlet
.
getActualCPUTime
();
double
startTime
=
gpuCloudlet
.
getExecStartTime
();
double
finishTime
=
gpuCloudlet
.
getFinishTime
();
GpuTask
gpuTask
=
((
GpuCloudlet
)
gpuCloudlet
).
getGpuTask
();
boolean
hasGpuTask
=
(
gpuTask
==
null
?
false
:
true
);
String
task
=
"{}"
;
String
memoryTransfers
=
"{}"
;
if
(
hasGpuTask
)
{
int
taskId
=
gpuTask
.
getTaskId
();
double
taskDuration
=
gpuTask
.
getActualGPUTime
();
double
taskStartTime
=
gpuTask
.
getExecStartTime
();
double
taskFinishTime
=
gpuTask
.
getFinishTime
();
task
=
"{'id': "
+
taskId
+
", "
+
"'duration': "
+
dft
.
format
(
taskDuration
).
toString
()
+
", "
+
"'start_time': "
+
dft
.
format
(
taskStartTime
).
toString
()
+
", "
+
"'finish_time': "
+
dft
.
format
(
taskFinishTime
).
toString
()
+
"}"
;
// H2D memory transfer
String
h2d
;
{
double
h2dDuration
=
gpuTask
.
getMemoryTransferHostToDevice
().
getTime
();
double
h2dStartTime
=
gpuTask
.
getMemoryTransferHostToDevice
().
startTime
;
double
h2dFinishTime
=
gpuTask
.
getMemoryTransferHostToDevice
().
endTime
;
h2d
=
"{"
+
"'duration':"
+
dft
.
format
(
h2dDuration
).
toString
()
+
", "
+
"'start_time': "
+
dft
.
format
(
h2dStartTime
).
toString
()
+
", "
+
"'finish_time': "
+
dft
.
format
(
h2dFinishTime
).
toString
()
+
"}"
;
}
// D2H memory transfer
String
d2h
;
{
double
d2hDuration
=
gpuTask
.
getMemoryTransferDeviceToHost
().
getTime
();
double
d2hStartTime
=
gpuTask
.
getMemoryTransferDeviceToHost
().
startTime
;
double
d2hFinishTime
=
gpuTask
.
getMemoryTransferDeviceToHost
().
endTime
;
d2h
=
"{"
+
"'duration':"
+
dft
.
format
(
d2hDuration
).
toString
()
+
", "
+
"'start_time': "
+
dft
.
format
(
d2hStartTime
).
toString
()
+
", "
+
"'finish_time': "
+
dft
.
format
(
d2hFinishTime
).
toString
()
+
"}"
;
}
memoryTransfers
=
"{"
+
"'h2d': "
+
h2d
+
", "
+
"'d2h': "
+
d2h
+
"}"
;
}
String
line
=
"{'id': "
+
id
+
", "
+
"'tag': '"
+
tag
+
"',"
+
"'vm': "
+
vmId
+
", "
+
"'duration': "
+
dft
.
format
(
duration
).
toString
()
+
", "
+
"'start_time': "
+
dft
.
format
(
startTime
).
toString
()
+
", "
+
"'finish_time': "
+
dft
.
format
(
finishTime
).
toString
()
+
", "
+
"'gpu_task': "
+
task
+
", "
+
"'memory_transfer': "
+
memoryTransfers
+
"}"
;
System
.
out
.
println
(
line
);
}
System
.
out
.
println
(
"+ VMs"
);
for
(
GpuVm
vm
:
vms
)
{
int
vm_id
=
vm
.
getId
();
String
type
=
LpdsTags
.
getVmType
(
vm
.
getType
());
Vgpu
vgpu
=
vm
.
getVgpu
();
int
vgpuMemory
=
0
;
if
(
vgpu
!=
null
)
{
vgpuMemory
=
vgpu
.
getGddram
();
}
String
line
=
"{"
+
"'id': "
+
vm_id
+
", "
+
"'type': '"
+
type
+
"', "
+
"'vgpu_memory': "
+
vgpuMemory
+
"}"
;
System
.
out
.
println
(
line
);
}
for
(
PowerGpuDatacenter
datacenter
:
(
List
<
PowerGpuDatacenter
>)
(
List
<?>)
datacenters
)
{
System
.
out
.
println
(
"+ Datacenter"
);
{
int
id
=
datacenter
.
getId
();
String
name
=
datacenter
.
getName
();
double
energy
=
datacenter
.
getConsumedEnergy
();
String
line
=
"{"
+
"'id': "
+
id
+
", "
+
"'name': '"
+
name
+
"', "
+
"'energy': "
+
energy
+
"}"
;
System
.
out
.
println
(
line
);
}
for
(
PowerGpuHost
host
:
(
List
<
PowerGpuHost
>)
(
List
<?>)
datacenter
.
getHostList
())
{
{
System
.
out
.
println
(
"+ Host"
);
int
id
=
host
.
getId
();
double
cpuEnergy
=
datacenter
.
getHostCpuEnergyMap
().
get
(
host
);
double
totalEnergy
=
datacenter
.
getHostEnergyMap
().
get
(
host
);
String
hostType
=
LpdsTags
.
getHostType
(
host
.
getType
());
String
line
=
"{'id': "
+
id
+
", "
+
"'type': '"
+
hostType
+
"', "
+
"'cpu_energy': "
+
dft
.
format
(
cpuEnergy
).
toString
()
+
", "
+
"'total_energy': "
+
dft
.
format
(
totalEnergy
).
toString
()
+
"}"
;
System
.
out
.
println
(
line
);
}
if
(
host
.
getVideoCardAllocationPolicy
()
!=
null
)
{
for
(
PowerVideoCard
videoCard
:
(
List
<
PowerVideoCard
>)
host
.
getVideoCardAllocationPolicy
()
.
getVideoCards
())
{
System
.
out
.
println
(
"+ VideoCard"
);
int
id
=
videoCard
.
getId
();
String
type
=
LpdsTags
.
getVideoCardType
(
videoCard
.
getType
());
double
energy
=
datacenter
.
getHostVideoCardEnergyMap
().
get
(
host
).
get
(
videoCard
);
String
line
=
"{"
+
"'id': "
+
id
+
", "
+
"'type': '"
+
type
+
"', "
+
"'energy': "
+
dft
.
format
(
energy
).
toString
()
+
"}"
;
System
.
out
.
println
(
line
);
}
}
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/lpds/LpdsTags.java
0 → 100644
View file @
fd65b6c1
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
;
}
}
}
This diff is collapsed.
Click to expand it.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/lpds/LpdsWorkload.java
0 → 100644
View file @
fd65b6c1
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
;
}
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuDatacenterBroker.java
View file @
fd65b6c1
...
@@ -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
>>
V
mGpuCloudletMap
;
private
HashMap
<
String
,
List
<
GpuCloudlet
>>
v
mGpuCloudletMap
;
/** 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
V
mGpuCloudletMap
;
return
v
mGpuCloudletMap
;
}
}
/**
/**
...
@@ -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
)
{
V
mGpuCloudletMap
=
vmGpuCloudletMap
;
this
.
v
mGpuCloudletMap
=
vmGpuCloudletMap
;
}
}
}
}
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuHost.java
View file @
fd65b6c1
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicy.java
View file @
fd65b6c1
...
@@ -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
);
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicySimple.java
View file @
fd65b6c1
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
View file @
fd65b6c1
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuHost.java
View file @
fd65b6c1
...
@@ -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
;
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicy.java
View file @
fd65b6c1
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
View file @
fd65b6c1
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
View file @
fd65b6c1
...
@@ -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
);
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteVgpuTags.java
View file @
fd65b6c1
...
@@ -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"
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment