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
e1e89aec
Commit
e1e89aec
authored
Nov 17, 2018
by
Ahmad Siavashi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm allocation revised. not tested yet.
parent
c5aee0a8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
257 additions
and
155 deletions
+257
-155
pom.xml
modules/cloudsim-examples/pom.xml
+45
-24
GpuDatacenter.java
...rc/main/java/org/cloudbus/cloudsim/gpu/GpuDatacenter.java
+2
-1
GpuVmAllocationPolicy.java
...java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicy.java
+80
-0
GpuVmAllocationPolicyMaxMipsFirst.java
...udbus/cloudsim/gpu/GpuVmAllocationPolicyMaxMipsFirst.java
+1
-1
GpuVmAllocationPolicySimple.java
...rg/cloudbus/cloudsim/gpu/GpuVmAllocationPolicySimple.java
+2
-54
RemoteGpuVmAllocationPolicy.java
...dbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicy.java
+114
-0
RemoteGpuVmAllocationPolicyFirstFit.java
...udsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
+13
-73
RemoteGpuVmAllocationPolicyLeastLoad.java
...dsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
+0
-2
No files found.
modules/cloudsim-examples/pom.xml
View file @
e1e89aec
<?xml version="1.0"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<artifactId>
modules
</artifactId>
...
...
@@ -16,11 +18,30 @@
<artifactId>
cloudsim
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
de.vandermeer
</groupId>
<artifactId>
asciitable
</artifactId>
<version>
0.3.2
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-core
</artifactId>
<version>
2.9.6
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-annotations
</artifactId>
<version>
2.9.6
</version>
</dependency>
<dependency>
<groupId>
com.fasterxml.jackson.core
</groupId>
<artifactId>
jackson-databind
</artifactId>
<version>
2.9.6
</version>
</dependency>
</dependencies>
</project>
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuDatacenter.java
View file @
e1e89aec
...
...
@@ -221,8 +221,9 @@ public class GpuDatacenter extends Datacenter {
vm
.
updateVmProcessing
(
CloudSim
.
clock
(),
getVmAllocationPolicy
().
getHost
(
vm
).
getVmScheduler
().
getAllocatedMipsForVm
(
vm
));
GpuHost
gpuHost
=
(
GpuHost
)
getVmAllocationPolicy
().
getHost
(
vm
);
if
(
vgpu
!=
null
)
{
GpuVmAllocationPolicy
gpuVmAllocationPolicy
=
(
GpuVmAllocationPolicy
)
getVmAllocationPolicy
();
GpuHost
gpuHost
=
(
GpuHost
)
gpuVmAllocationPolicy
.
getHost
(
vgpu
);
vgpu
.
updateTaskProcessing
(
CloudSim
.
clock
(),
gpuHost
.
getVideoCardAllocationPolicy
().
getVgpuVideoCardMap
()
.
get
(
vgpu
).
getVgpuScheduler
().
getAllocatedMipsForVgpu
(
vgpu
));
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicy.java
0 → 100644
View file @
e1e89aec
package
org
.
cloudbus
.
cloudsim
.
gpu
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmAllocationPolicy
;
import
org.cloudbus.cloudsim.core.CloudSim
;
/**
* {@link GpuVmAllocationPolicy} extends {@link VmAllocationPolicy} to support GPU-enabled VM placement.
*
* @author Ahmad Siavashi
*
*/
public
abstract
class
GpuVmAllocationPolicy
extends
VmAllocationPolicy
{
/**
* The map between each VM and its allocated host. The map key is a VM UID and
* the value is the allocated host for that VM.
*/
private
Map
<
String
,
Host
>
vmTable
;
/**
* @param list
*/
public
GpuVmAllocationPolicy
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
setVmTable
(
new
HashMap
<
String
,
Host
>());
}
@Override
public
List
<
Map
<
String
,
Object
>>
optimizeAllocation
(
List
<?
extends
Vm
>
vmList
)
{
// TODO Auto-generated method stub
return
null
;
}
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
Host
host
=
getVmTable
().
remove
(
vm
.
getUid
());
if
(
host
!=
null
)
{
Log
.
printLine
(
"{'clock': "
+
CloudSim
.
clock
()
+
", 'event': 'vm deallocation', 'vm': "
+
vm
.
getId
()
+
", 'host': "
+
host
.
getId
()
+
"}"
);
host
.
vmDestroy
(
vm
);
}
}
public
Host
getHost
(
Vgpu
vgpu
)
{
return
getVmTable
().
get
(
vgpu
.
getVm
().
getUid
());
}
@Override
public
Host
getHost
(
Vm
vm
)
{
return
getVmTable
().
get
(
vm
.
getUid
());
}
@Override
public
Host
getHost
(
int
vmId
,
int
userId
)
{
return
getVmTable
().
get
(
Vm
.
getUid
(
userId
,
vmId
));
}
/**
* @return the vmTable
*/
protected
Map
<
String
,
Host
>
getVmTable
()
{
return
vmTable
;
}
/**
* @param vmTable
* the vmTable to set
*/
protected
void
setVmTable
(
Map
<
String
,
Host
>
vmTable
)
{
this
.
vmTable
=
vmTable
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicyMaxMipsFirst.java
View file @
e1e89aec
...
...
@@ -12,7 +12,7 @@ import org.cloudbus.cloudsim.lists.PeList;
* {@link GpuVmAllocationPolicyMaxMipsFirst} extends
* {@link GpuVmAllocationPolicySimple} to implement a VM placement algorithm.
* Initially, it sorts {@link GpuHost GpuHosts} based on their fastest
* {@link Pgpu GPU}, then employ
e
s first-fit algorithm to place VMs. sorts
* {@link Pgpu GPU}, then employs first-fit algorithm to place VMs. sorts
*
* @author Ahmad Siavashi
*
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmAllocationPolicySimple.java
View file @
e1e89aec
package
org
.
cloudbus
.
cloudsim
.
gpu
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.VmAllocationPolicy
;
import
org.cloudbus.cloudsim.core.CloudSim
;
/**
* {@link GpuVmAllocationPolicySimple} extends {@link VmAllocationPolicy} and
* {@link GpuVmAllocationPolicySimple} extends {@link
Gpu
VmAllocationPolicy} and
* implements first-fit algorithm for VM placement.
*
* @author Ahmad Siavashi
*
*/
public
class
GpuVmAllocationPolicySimple
extends
VmAllocationPolicy
{
/**
* The map between each VM and its allocated host. The map key is a VM UID and
* the value is the allocated host for that VM.
*/
private
Map
<
String
,
Host
>
vmTable
;
public
class
GpuVmAllocationPolicySimple
extends
GpuVmAllocationPolicy
{
/**
* @param list
*/
public
GpuVmAllocationPolicySimple
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
setVmTable
(
new
HashMap
<
String
,
Host
>());
}
@Override
...
...
@@ -61,46 +51,4 @@ public class GpuVmAllocationPolicySimple extends VmAllocationPolicy {
}
return
false
;
}
@Override
public
List
<
Map
<
String
,
Object
>>
optimizeAllocation
(
List
<?
extends
Vm
>
vmList
)
{
// TODO Auto-generated method stub
return
null
;
}
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
Host
host
=
getVmTable
().
remove
(
vm
.
getUid
());
if
(
host
!=
null
)
{
Log
.
printLine
(
"{'clock': "
+
CloudSim
.
clock
()
+
", 'event': 'vm deallocation', 'vm': "
+
vm
.
getId
()
+
", 'host': "
+
host
.
getId
()
+
"}"
);
host
.
vmDestroy
(
vm
);
}
}
@Override
public
Host
getHost
(
Vm
vm
)
{
return
getVmTable
().
get
(
vm
.
getUid
());
}
@Override
public
Host
getHost
(
int
vmId
,
int
userId
)
{
return
getVmTable
().
get
(
Vm
.
getUid
(
userId
,
vmId
));
}
/**
* @return the vmTable
*/
protected
Map
<
String
,
Host
>
getVmTable
()
{
return
vmTable
;
}
/**
* @param vmTable
* the vmTable to set
*/
protected
void
setVmTable
(
Map
<
String
,
Host
>
vmTable
)
{
this
.
vmTable
=
vmTable
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicy.java
0 → 100644
View file @
e1e89aec
package
org
.
cloudbus
.
cloudsim
.
gpu
.
remote
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.gpu.GpuHost
;
import
org.cloudbus.cloudsim.gpu.GpuVm
;
import
org.cloudbus.cloudsim.gpu.GpuVmAllocationPolicy
;
import
org.cloudbus.cloudsim.gpu.GpuVmAllocationPolicySimple
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuHost
;
/**
* This class extends {@link GpuVmAllocationPolicy} to add support for GPU
* remoting.
*
* @author Ahmad Siavashi
*
*/
public
abstract
class
RemoteGpuVmAllocationPolicy
extends
GpuVmAllocationPolicy
{
private
List
<
GpuHost
>
gpuHostList
;
private
Map
<
Vgpu
,
GpuHost
>
remoteVgpuHosts
;
/**
* This class extends {@link GpuVmAllocationPolicySimple} to add support for GPU
* remoting.
*
* @see {@link GpuVmAllocationPolicySimple}
*/
public
RemoteGpuVmAllocationPolicy
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
setRemoteVgpuHosts
(
new
HashMap
<>());
setGpuHostList
(
new
ArrayList
<>());
updateGpuHosts
(
getHostList
());
}
// Allocates a remote vGPU on a GPU-equipped host
protected
boolean
allocateRemoteVgpu
(
Vgpu
vgpu
)
{
// if Vm has a remote Vgpu
for
(
GpuHost
gpuHost
:
getGpuHostList
())
{
boolean
isVgpuAllocated
=
gpuHost
.
getVideoCardAllocationPolicy
().
allocate
(
vgpu
,
vgpu
.
getPCIeBw
());
getRemoteVgpuHosts
().
put
(
vgpu
,
gpuHost
);
if
(
isVgpuAllocated
)
{
Log
.
formatLine
(
"%.2f: Vgpu of VM #"
+
vgpu
.
getVm
().
getId
()
+
" has been allocated to the host #"
+
gpuHost
.
getId
(),
CloudSim
.
clock
());
Log
.
printLine
(
"{'clock': "
+
CloudSim
.
clock
()
+
", 'event': 'vgpu allocation', 'vm': "
+
vgpu
.
getVm
().
getId
()
+
", 'host': "
+
gpuHost
.
getId
()
+
"}"
);
return
true
;
}
}
return
false
;
}
protected
boolean
isVgpuRemote
(
Vgpu
vgpu
)
{
if
(
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_EXCLUSIVE
||
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_SHARED
)
{
return
true
;
}
return
false
;
}
// Add GPU-equipped hosts
protected
void
updateGpuHosts
(
List
<
PowerGpuHost
>
hosts
)
{
getGpuHostList
().
clear
();
for
(
PowerGpuHost
host
:
hosts
)
{
if
(
host
.
getVideoCardAllocationPolicy
()
!=
null
)
{
getGpuHostList
().
add
(
host
);
}
}
}
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
super
.
deallocateHostForVm
(
vm
);
Vgpu
vgpu
=
((
GpuVm
)
vm
).
getVgpu
();
if
(
vgpu
==
null
||
!
isVgpuRemote
(
vgpu
))
{
return
;
}
getRemoteVgpuHosts
().
get
(
vgpu
).
getVideoCardAllocationPolicy
().
deallocate
(
vgpu
);
getRemoteVgpuHosts
().
remove
(
vgpu
);
}
@Override
public
Host
getHost
(
Vgpu
vgpu
)
{
if
(
isVgpuRemote
(
vgpu
))
{
return
getRemoteVgpuHosts
().
get
(
vgpu
);
}
else
{
return
super
.
getHost
(
vgpu
);
}
}
public
List
<
GpuHost
>
getGpuHostList
()
{
return
gpuHostList
;
}
protected
void
setGpuHostList
(
List
<
GpuHost
>
gpuHosts
)
{
this
.
gpuHostList
=
gpuHosts
;
}
public
Map
<
Vgpu
,
GpuHost
>
getRemoteVgpuHosts
()
{
return
remoteVgpuHosts
;
}
protected
void
setRemoteVgpuHosts
(
Map
<
Vgpu
,
GpuHost
>
remoteVgpuHosts
)
{
this
.
remoteVgpuHosts
=
remoteVgpuHosts
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
View file @
e1e89aec
package
org
.
cloudbus
.
cloudsim
.
gpu
.
remote
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.core.CloudSim
;
import
org.cloudbus.cloudsim.gpu.GpuHost
;
import
org.cloudbus.cloudsim.gpu.GpuVm
;
import
org.cloudbus.cloudsim.gpu.GpuVmAllocationPolicySimple
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuHost
;
/**
* This class extends {@link
GpuVmAllocationPolicySimple} to add support for GPU
*
remoting
.
* This class extends {@link
RemoteGpuVmAllocationPolicy} and implements
*
first-fit GPU host allocation
.
*
* @author Ahmad Siavashi
*
*/
public
class
RemoteGpuVmAllocationPolicyFirstFit
extends
GpuVmAllocationPolicySimple
{
private
List
<
GpuHost
>
gpuHostList
;
private
Map
<
Vgpu
,
GpuHost
>
remoteVgpuHosts
;
public
class
RemoteGpuVmAllocationPolicyFirstFit
extends
RemoteGpuVmAllocationPolicy
{
/**
* This class extends {@link
GpuVmAllocationPolicySimple} to add support for GPU
*
remoting
.
* This class extends {@link
RemoteGpuVmAllocationPolicy} and implements
*
first-fit GPU host allocation
.
*
* @see {@link GpuVmAllocationPolicySimple}
*/
public
RemoteGpuVmAllocationPolicyFirstFit
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
setRemoteVgpuHosts
(
new
HashMap
<>());
setGpuHostList
(
new
ArrayList
<>());
updateGpuHosts
(
getHostList
());
}
@Override
...
...
@@ -72,65 +61,16 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
return
false
;
}
// Allocates a remote vGPU on a GPU-equipped host
protected
boolean
allocateRemoteVgpu
(
Vgpu
vgpu
)
{
// if Vm has a remote Vgpu
for
(
GpuHost
gpuHost
:
getGpuHostList
())
{
boolean
isVgpuAllocated
=
gpuHost
.
getVideoCardAllocationPolicy
().
allocate
(
vgpu
,
vgpu
.
getPCIeBw
());
getRemoteVgpuHosts
().
put
(
vgpu
,
gpuHost
);
if
(
isVgpuAllocated
)
{
Log
.
formatLine
(
"%.2f: Vgpu of VM #"
+
vgpu
.
getVm
().
getId
()
+
" has been allocated to the host #"
+
gpuHost
.
getId
(),
CloudSim
.
clock
());
Log
.
printLine
(
"{'clock': "
+
CloudSim
.
clock
()
+
", 'event': 'vgpu allocation', 'vm': "
+
vgpu
.
getVm
().
getId
()
+
", 'host': "
+
gpuHost
.
getId
()
+
"}"
);
@Override
public
boolean
allocateHostForVm
(
Vm
vm
)
{
if
(!
getVmTable
().
containsKey
(
vm
.
getUid
()))
{
for
(
Host
host
:
getHostList
())
{
boolean
result
=
allocateHostForVm
(
vm
,
host
);
if
(
result
)
{
return
true
;
}
}
return
false
;
}
protected
boolean
isVgpuRemote
(
Vgpu
vgpu
)
{
if
(
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_EXCLUSIVE
||
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_SHARED
)
{
return
true
;
}
return
false
;
}
// Add GPU-equipped hosts
protected
void
updateGpuHosts
(
List
<
PowerGpuHost
>
hosts
)
{
getGpuHostList
().
clear
();
for
(
PowerGpuHost
host
:
hosts
)
{
if
(
host
.
getVideoCardAllocationPolicy
()
!=
null
)
{
getGpuHostList
().
add
(
host
);
}
}
}
@Override
public
void
deallocateHostForVm
(
Vm
vm
)
{
super
.
deallocateHostForVm
(
vm
);
Vgpu
vgpu
=
((
GpuVm
)
vm
).
getVgpu
();
if
(
vgpu
==
null
||
!
isVgpuRemote
(
vgpu
))
{
return
;
}
getRemoteVgpuHosts
().
get
(
vgpu
).
getVideoCardAllocationPolicy
().
deallocate
(
vgpu
);
getRemoteVgpuHosts
().
remove
(
vgpu
);
}
public
List
<
GpuHost
>
getGpuHostList
()
{
return
gpuHostList
;
}
protected
void
setGpuHostList
(
List
<
GpuHost
>
gpuHosts
)
{
this
.
gpuHostList
=
gpuHosts
;
}
public
Map
<
Vgpu
,
GpuHost
>
getRemoteVgpuHosts
()
{
return
remoteVgpuHosts
;
}
protected
void
setRemoteVgpuHosts
(
Map
<
Vgpu
,
GpuHost
>
remoteVgpuHosts
)
{
this
.
remoteVgpuHosts
=
remoteVgpuHosts
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
View file @
e1e89aec
...
...
@@ -3,7 +3,6 @@ package org.cloudbus.cloudsim.gpu.remote;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.Host
;
import
org.cloudbus.cloudsim.Log
;
...
...
@@ -12,7 +11,6 @@ import org.cloudbus.cloudsim.core.CloudSim;
import
org.cloudbus.cloudsim.gpu.GpuHost
;
import
org.cloudbus.cloudsim.gpu.GpuVm
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuHost
;
/**
* This class extends {@link RemoteGpuVmAllocationPolicyFirstFit} and allocates
...
...
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