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
189e9254
Commit
189e9254
authored
Nov 15, 2018
by
Ahmad Siavashi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finished. untested yet
parent
bfeda768
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
108 additions
and
76 deletions
+108
-76
VgpuScheduler.java
...rc/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
+7
-10
VideoCardAllocationPolicy.java
...us/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
+5
-5
VideoCardAllocationPolicyLeastLoad.java
...im/gpu/allocation/VideoCardAllocationPolicyLeastLoad.java
+5
-5
RemoteGpuVmAllocationPolicyFirstFit.java
...udsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
+28
-12
RemoteGpuVmAllocationPolicyLeastLoad.java
...dsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
+59
-35
PgpuSelectionPolicyLeastLoad.java
.../cloudsim/gpu/selection/PgpuSelectionPolicyLeastLoad.java
+4
-9
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
View file @
189e9254
...
...
@@ -143,25 +143,22 @@ public abstract class VgpuScheduler {
}
/**
* Returns
pGPUs allocated memories in ascending order
.
* Returns
the available memory for all on-board pGPUs
.
*/
public
Map
<
Pgpu
,
Integer
>
getPgpusA
llocated
Memory
()
{
Map
<
Pgpu
,
Integer
>
pgpusA
llocated
Memory
=
new
HashMap
<>();
public
Map
<
Pgpu
,
Integer
>
getPgpusA
vailable
Memory
()
{
Map
<
Pgpu
,
Integer
>
pgpusA
vailable
Memory
=
new
HashMap
<>();
for
(
Pgpu
pgpu
:
getPgpuList
())
{
Integer
allocatedMemory
=
0
;
for
(
Vgpu
vgpu
:
getPgpuVgpuMap
().
get
(
pgpu
))
{
allocatedMemory
+=
vgpu
.
getGddram
();
Integer
availableMemory
=
pgpu
.
getGddramProvisioner
().
getAvailableGddram
();
pgpusAvailableMemory
.
put
(
pgpu
,
availableMemory
);
}
pgpusAllocatedMemory
.
put
(
pgpu
,
allocatedMemory
);
}
return
pgpusAllocatedMemory
;
return
pgpusAvailableMemory
;
}
/**
* Returns maximum free memory on GPUs. Assuming all on-board GPUs are the same.
*/
public
int
getMaxFreeMemory
()
{
Integer
minAllocatedMemory
=
Collections
.
min
(
getPgpusA
llocated
Memory
().
values
());
Integer
minAllocatedMemory
=
Collections
.
min
(
getPgpusA
vailable
Memory
().
values
());
int
maxFreeMemory
=
getPgpuList
().
get
(
0
).
getGddramProvisioner
().
getGddram
()
-
minAllocatedMemory
;
return
maxFreeMemory
;
}
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
View file @
189e9254
...
...
@@ -35,13 +35,13 @@ public abstract class VideoCardAllocationPolicy {
/**
* Return allocated memory of every video card's least loaded GPU.
*/
public
Map
<
VideoCard
,
Integer
>
getVideoCardsA
llocated
Memory
(){
Map
<
VideoCard
,
Integer
>
videoCardsA
llocated
Memory
=
new
HashMap
<>();
public
Map
<
VideoCard
,
Integer
>
getVideoCardsA
vailable
Memory
(){
Map
<
VideoCard
,
Integer
>
videoCardsA
vailable
Memory
=
new
HashMap
<>();
for
(
VideoCard
videoCard
:
getVideoCards
())
{
Integer
allocatedMemoryPgpu
=
Collections
.
min
(
videoCard
.
getVgpuScheduler
().
getPgpusAllocated
Memory
().
values
());
videoCardsA
llocatedMemory
.
put
(
videoCard
,
allocatedMemoryPgpu
);
Integer
pgpuAvailableMemory
=
Collections
.
min
(
videoCard
.
getVgpuScheduler
().
getPgpusAvailable
Memory
().
values
());
videoCardsA
vailableMemory
.
put
(
videoCard
,
pgpuAvailableMemory
);
}
return
videoCardsA
llocated
Memory
;
return
videoCardsA
vailable
Memory
;
}
/**
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicyLeastLoad.java
View file @
189e9254
...
...
@@ -48,11 +48,11 @@ public class VideoCardAllocationPolicyLeastLoad extends VideoCardAllocationPolic
VideoCard
videoCard
=
Collections
.
min
(
candidates
,
new
Comparator
<
VideoCard
>()
{
@Override
public
int
compare
(
VideoCard
videoCard1
,
VideoCard
videoCard2
)
{
Integer
minAllocatedMemoryVideoCard1
=
Collections
.
m
in
(
videoCard1
.
getVgpuScheduler
().
getPgpusAllocated
Memory
().
values
());
Integer
minAllocatedMemoryVideoCard2
=
Collections
.
m
in
(
videoCard2
.
getVgpuScheduler
().
getPgpusAllocated
Memory
().
values
());
return
Integer
.
compare
(
minAllocatedMemoryVideoCard1
,
minAllocatedMemoryVideoCard2
);
Integer
videoCard1maxAvailableMemory
=
Collections
.
m
ax
(
videoCard1
.
getVgpuScheduler
().
getPgpusAvailable
Memory
().
values
());
Integer
videoCard2maxAvailableMemory
=
Collections
.
m
ax
(
videoCard2
.
getVgpuScheduler
().
getPgpusAvailable
Memory
().
values
());
return
Integer
.
compare
(
videoCard1maxAvailableMemory
,
videoCard2maxAvailableMemory
);
}
});
// Allocate the given vGPU on the selected video card
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
View file @
189e9254
...
...
@@ -9,6 +9,7 @@ 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
;
...
...
@@ -23,8 +24,8 @@ import org.cloudbus.cloudsim.gpu.power.PowerGpuHost;
*/
public
class
RemoteGpuVmAllocationPolicyFirstFit
extends
GpuVmAllocationPolicySimple
{
private
List
<
PowerGpuHost
>
gpuHosts
;
private
Map
<
Vgpu
,
Remote
GpuHost
>
remoteVgpuHosts
;
private
List
<
GpuHost
>
gpuHostList
;
private
Map
<
Vgpu
,
GpuHost
>
remoteVgpuHosts
;
/**
* This class extends {@link GpuVmAllocationPolicySimple} to add support for GPU
...
...
@@ -35,7 +36,7 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
public
RemoteGpuVmAllocationPolicyFirstFit
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
setRemoteVgpuHosts
(
new
HashMap
<>());
setGpuHost
s
(
new
ArrayList
<>());
setGpuHost
List
(
new
ArrayList
<>());
updateGpuHosts
(
getHostList
());
}
...
...
@@ -56,6 +57,7 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
+
", 'host': "
+
host
.
getId
()
+
"}"
);
return
true
;
}
// else if it has a remote vGPU, then
if
(
allocateRemoteVgpu
(
vgpu
))
{
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
formatLine
(
"%.2f: VM #"
+
vm
.
getId
()
+
" has been allocated to the host #"
+
host
.
getId
(),
...
...
@@ -73,11 +75,14 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
// Allocates a remote vGPU on a GPU-equipped host
protected
boolean
allocateRemoteVgpu
(
Vgpu
vgpu
)
{
// if Vm has a remote Vgpu
for
(
PowerGpuHost
gpuHost
:
getGpuHosts
())
{
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
;
}
}
...
...
@@ -93,27 +98,38 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
// Add GPU-equipped hosts
protected
void
updateGpuHosts
(
List
<
PowerGpuHost
>
hosts
)
{
getGpuHost
s
().
clear
();
getGpuHost
List
().
clear
();
for
(
PowerGpuHost
host
:
hosts
)
{
if
(
host
.
getVideoCardAllocationPolicy
()
!=
null
)
{
getGpuHost
s
().
add
(
host
);
getGpuHost
List
().
add
(
host
);
}
}
}
public
List
<
PowerGpuHost
>
getGpuHosts
()
{
return
gpuHosts
;
@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
setGpuHost
s
(
List
<
Power
GpuHost
>
gpuHosts
)
{
this
.
gpuHost
s
=
gpuHosts
;
protected
void
setGpuHost
List
(
List
<
GpuHost
>
gpuHosts
)
{
this
.
gpuHost
List
=
gpuHosts
;
}
public
Map
<
Vgpu
,
Remote
GpuHost
>
getRemoteVgpuHosts
()
{
public
Map
<
Vgpu
,
GpuHost
>
getRemoteVgpuHosts
()
{
return
remoteVgpuHosts
;
}
protected
void
setRemoteVgpuHosts
(
Map
<
Vgpu
,
Remote
GpuHost
>
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 @
189e9254
...
...
@@ -37,44 +37,68 @@ public class RemoteGpuVmAllocationPolicyLeastLoad extends RemoteGpuVmAllocationP
@Override
public
boolean
allocateHostForVm
(
Vm
vm
)
{
GpuVm
gpuVm
=
(
GpuVm
)
vm
;
if
(
gpuVm
.
getVgpu
()
!=
null
)
{
sortHosts
();
Vgpu
vgpu
=
((
GpuVm
)
vm
).
getVgpu
();
if
(
vgpu
==
null
)
{
for
(
Host
host
:
getHostList
())
{
boolean
result
=
host
.
vmCreate
(
vm
);
if
(
result
)
{
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
formatLine
(
"%.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
()
+
"}"
);
return
true
;
}
return
super
.
allocateHostForVm
(
vm
);
}
@Override
public
boolean
allocateHostForVm
(
Vm
vm
,
Host
host
)
{
GpuVm
gpuVm
=
(
GpuVm
)
vm
;
if
(
gpuVm
.
getVgpu
()
!=
null
)
{
sortHosts
();
}
else
{
// Sort GPU-equipped hosts based on video cards' available memory in descending
// order.
sortGpuHosts
();
if
(!
isVgpuRemote
(
vgpu
))
{
for
(
Host
host
:
getGpuHostList
())
{
boolean
result
=
host
.
vmCreate
(
vm
);
if
(
result
)
{
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
formatLine
(
"%.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
()
+
"}"
);
return
true
;
}
return
super
.
allocateHostForVm
(
vm
,
host
);
}
protected
void
sortHosts
()
{
Collections
.
sort
(
getHostList
(),
new
Comparator
<
GpuHost
>()
{
@Override
public
int
compare
(
GpuHost
arg0
,
GpuHost
arg1
)
{
// TODO
return
0
;
return
false
;
}
else
{
for
(
Host
host
:
getGpuHostList
())
{
boolean
result
=
host
.
vmCreate
(
vm
);
if
(
result
)
{
result
=
allocateRemoteVgpu
(
vgpu
);
if
(
result
)
{
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
formatLine
(
"%.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
()
+
"}"
);
return
true
;
}
getRemoteVgpuHosts
().
get
(
vgpu
).
getVideoCardAllocationPolicy
().
deallocate
(
vgpu
);
}
});
}
}
}
return
false
;
}
@Override
protected
boolean
allocateRemoteVgpu
(
Vgpu
vgpu
)
{
Collections
.
sort
(
getGpuHosts
(),
new
Comparator
<
PowerGpuHost
>()
{
public
int
compare
(
PowerGpuHost
gpuHost1
,
PowerGpuHost
gpuHost2
)
{
Integer
minAllocatedMemoryHost1
=
Collections
.
min
(
gpuHost1
.
getVideoCardAllocationPolicy
().
getVideoCardsAllocatedMemory
().
values
());
Integer
minAllocatedMemoryHost2
=
Collections
.
min
(
gpuHost2
.
getVideoCardAllocationPolicy
().
getVideoCardsAllocatedMemory
().
values
());
return
Integer
.
compare
(
minAllocatedMemoryHost1
,
minAllocatedMemoryHost2
);
protected
void
sortGpuHosts
()
{
Collections
.
sort
(
getGpuHostList
(),
Collections
.
reverseOrder
(
new
Comparator
<
GpuHost
>()
{
public
int
compare
(
GpuHost
gpuHost1
,
GpuHost
gpuHost2
)
{
Integer
host1MaxAvailableMemory
=
Collections
.
max
(
gpuHost1
.
getVideoCardAllocationPolicy
().
getVideoCardsAvailableMemory
().
values
());
Integer
host2MaxAvailableMemory
=
Collections
.
max
(
gpuHost2
.
getVideoCardAllocationPolicy
().
getVideoCardsAvailableMemory
().
values
());
return
Integer
.
compare
(
host1MaxAvailableMemory
,
host2MaxAvailableMemory
);
};
});
return
super
.
allocateRemoteVgpu
(
vgpu
);
}));
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/selection/PgpuSelectionPolicyLeastLoad.java
View file @
189e9254
/**
*
*/
package
org
.
cloudbus
.
cloudsim
.
gpu
.
selection
;
import
java.util.Collections
;
...
...
@@ -12,7 +9,7 @@ import org.cloudbus.cloudsim.gpu.VgpuScheduler;
/**
* {@link PgpuSelectionPolicyLeastLoad} implements {@link PgpuSelectionPolicy}
* and selects the Pgpu with the
least allocated
memory.
* and selects the Pgpu with the
maximum available
memory.
*
* @author Ahmad Siavashi
*
...
...
@@ -37,11 +34,9 @@ public class PgpuSelectionPolicyLeastLoad implements PgpuSelectionPolicy {
return
Collections
.
min
(
pgpuList
,
new
Comparator
<
Pgpu
>()
{
@Override
public
int
compare
(
Pgpu
pgpu1
,
Pgpu
pgpu2
)
{
int
pgpu1AllocatedMemory
=
pgpu1
.
getGddramProvisioner
().
getGddram
()
-
pgpu1
.
getGddramProvisioner
().
getAvailableGddram
();
int
pgpu2AllocatedMemory
=
pgpu2
.
getGddramProvisioner
().
getGddram
()
-
pgpu2
.
getGddramProvisioner
().
getAvailableGddram
();
return
Integer
.
compare
(
pgpu1AllocatedMemory
,
pgpu2AllocatedMemory
);
int
pgpu1AvailableMemory
=
pgpu1
.
getGddramProvisioner
().
getAvailableGddram
();
int
pgpu2AvailableMemory
=
pgpu2
.
getGddramProvisioner
().
getAvailableGddram
();
return
Integer
.
compare
(
pgpu1AvailableMemory
,
pgpu2AvailableMemory
);
}
});
}
...
...
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