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
bfeda768
Commit
bfeda768
authored
Nov 12, 2018
by
Ahmad Siavashi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LeastLoad VM allocation not completed. FirstFit need remote vGPU deallocation
parent
a873dea4
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
281 additions
and
16 deletions
+281
-16
VgpuScheduler.java
...rc/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
+32
-4
VideoCardAllocationPolicy.java
...us/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
+13
-0
VideoCardAllocationPolicyDepthFirst.java
...m/gpu/allocation/VideoCardAllocationPolicyDepthFirst.java
+7
-0
VideoCardAllocationPolicyLeastLoad.java
...im/gpu/allocation/VideoCardAllocationPolicyLeastLoad.java
+79
-0
RemoteGpuVmAllocationPolicyFirstFit.java
...udsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
+21
-12
RemoteGpuVmAllocationPolicyLeastLoad.java
...dsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
+80
-0
PgpuSelectionPolicyLeastLoad.java
.../cloudsim/gpu/selection/PgpuSelectionPolicyLeastLoad.java
+49
-0
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
View file @
bfeda768
package
org
.
cloudbus
.
cloudsim
.
gpu
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -101,9 +102,9 @@ public abstract class VgpuScheduler {
public
abstract
void
deallocatePgpuForVgpu
(
Vgpu
vgpu
);
/**
* Releases PEs allocated to all the Vgpus of the video card the VgpuScheduler
is
*
associated to. After that, all PEs will be available to be used on demand for
* requesting Vgpus.
* Releases PEs allocated to all the Vgpus of the video card the VgpuScheduler
*
is associated to. After that, all PEs will be available to be used on demand
*
for
requesting Vgpus.
*/
public
void
deallocatePgpusForAllVgpus
()
{
getMipsMap
().
clear
();
...
...
@@ -141,6 +142,31 @@ public abstract class VgpuScheduler {
return
getMipsMap
().
get
(
vgpu
);
}
/**
* Returns pGPUs allocated memories in ascending order.
*/
public
Map
<
Pgpu
,
Integer
>
getPgpusAllocatedMemory
()
{
Map
<
Pgpu
,
Integer
>
pgpusAllocatedMemory
=
new
HashMap
<>();
for
(
Pgpu
pgpu
:
getPgpuList
())
{
Integer
allocatedMemory
=
0
;
for
(
Vgpu
vgpu
:
getPgpuVgpuMap
().
get
(
pgpu
))
{
allocatedMemory
+=
vgpu
.
getGddram
();
}
pgpusAllocatedMemory
.
put
(
pgpu
,
allocatedMemory
);
}
return
pgpusAllocatedMemory
;
}
/**
* Returns maximum free memory on GPUs. Assuming all on-board GPUs are the same.
*/
public
int
getMaxFreeMemory
()
{
Integer
minAllocatedMemory
=
Collections
.
min
(
getPgpusAllocatedMemory
().
values
());
int
maxFreeMemory
=
getPgpuList
().
get
(
0
).
getGddramProvisioner
().
getGddram
()
-
minAllocatedMemory
;
return
maxFreeMemory
;
}
/**
* Gets the total allocated MIPS for a Vgpu along all its allocated PEs.
*
...
...
@@ -187,7 +213,9 @@ public abstract class VgpuScheduler {
/**
* Returns the Pgpu allocated to the given Vgpu.
* @param vgpu the vgpu
*
* @param vgpu
* the vgpu
* @return the pgpu allocated to the given vgpu
*/
public
Pgpu
getPgpuForVgpu
(
Vgpu
vgpu
)
{
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicy.java
View file @
bfeda768
...
...
@@ -4,6 +4,7 @@
package
org
.
cloudbus
.
cloudsim
.
gpu
.
allocation
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -31,6 +32,18 @@ public abstract class VideoCardAllocationPolicy {
setVideoCards
(
videoCards
);
}
/**
* Return allocated memory of every video card's least loaded GPU.
*/
public
Map
<
VideoCard
,
Integer
>
getVideoCardsAllocatedMemory
(){
Map
<
VideoCard
,
Integer
>
videoCardsAllocatedMemory
=
new
HashMap
<>();
for
(
VideoCard
videoCard
:
getVideoCards
())
{
Integer
allocatedMemoryPgpu
=
Collections
.
min
(
videoCard
.
getVgpuScheduler
().
getPgpusAllocatedMemory
().
values
());
videoCardsAllocatedMemory
.
put
(
videoCard
,
allocatedMemoryPgpu
);
}
return
videoCardsAllocatedMemory
;
}
/**
* Allocate PCIe bandwidth to the vgpu
*
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicyDepthFirst.java
View file @
bfeda768
...
...
@@ -59,6 +59,13 @@ public class VideoCardAllocationPolicyDepthFirst extends VideoCardAllocationPoli
return
result
;
}
@Override
public
boolean
deallocate
(
Vgpu
vgpu
)
{
VideoCard
videoCard
=
getVgpuVideoCardMap
().
get
(
vgpu
);
getVideoCardVgpuMap
().
get
(
videoCard
).
remove
(
vgpu
);
return
super
.
deallocate
(
vgpu
);
}
/**
* @return the videoCardVgpuMap
*/
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/allocation/VideoCardAllocationPolicyLeastLoad.java
0 → 100644
View file @
bfeda768
package
org
.
cloudbus
.
cloudsim
.
gpu
.
allocation
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
/**
* Selects the video card with GPU with least allocated memory.
*
* @author Ahmad Siavashi
*
*/
public
class
VideoCardAllocationPolicyLeastLoad
extends
VideoCardAllocationPolicy
{
private
Map
<
VideoCard
,
List
<
Vgpu
>>
videoCardVgpuMap
;
/**
* Selects the video card with GPU with least allocated memory.
*/
public
VideoCardAllocationPolicyLeastLoad
(
List
<?
extends
VideoCard
>
videoCards
)
{
super
(
videoCards
);
setVideoCardVgpuMap
(
new
HashMap
<>());
for
(
VideoCard
videoCard
:
getVideoCards
())
{
getVideoCardVgpuMap
().
put
(
videoCard
,
new
ArrayList
<>());
}
}
@Override
public
boolean
allocate
(
Vgpu
vgpu
,
int
PCIeBw
)
{
List
<
VideoCard
>
candidates
=
new
ArrayList
<>();
// Collect candidates
for
(
VideoCard
videoCard
:
getVideoCards
())
{
if
(
videoCard
.
getVgpuScheduler
().
isSuitable
(
vgpu
))
{
candidates
.
add
(
videoCard
);
}
}
// If not suitable card was found then return false
if
(
candidates
.
size
()
==
0
)
{
return
false
;
}
// Find the one with the least allocated GPU memory
VideoCard
videoCard
=
Collections
.
min
(
candidates
,
new
Comparator
<
VideoCard
>()
{
@Override
public
int
compare
(
VideoCard
videoCard1
,
VideoCard
videoCard2
)
{
Integer
minAllocatedMemoryVideoCard1
=
Collections
.
min
(
videoCard1
.
getVgpuScheduler
().
getPgpusAllocatedMemory
().
values
());
Integer
minAllocatedMemoryVideoCard2
=
Collections
.
min
(
videoCard2
.
getVgpuScheduler
().
getPgpusAllocatedMemory
().
values
());
return
Integer
.
compare
(
minAllocatedMemoryVideoCard1
,
minAllocatedMemoryVideoCard2
);
}
});
// Allocate the given vGPU on the selected video card
videoCard
.
getVgpuScheduler
().
allocatePgpuForVgpu
(
vgpu
,
vgpu
.
getCurrentRequestedMips
(),
vgpu
.
getCurrentRequestedGddram
(),
vgpu
.
getCurrentRequestedBw
());
getVgpuVideoCardMap
().
put
(
vgpu
,
videoCard
);
return
true
;
}
@Override
public
boolean
deallocate
(
Vgpu
vgpu
)
{
VideoCard
videoCard
=
getVgpuVideoCardMap
().
get
(
vgpu
);
getVideoCardVgpuMap
().
get
(
videoCard
).
remove
(
vgpu
);
return
super
.
deallocate
(
vgpu
);
}
public
Map
<
VideoCard
,
List
<
Vgpu
>>
getVideoCardVgpuMap
()
{
return
videoCardVgpuMap
;
}
public
void
setVideoCardVgpuMap
(
Map
<
VideoCard
,
List
<
Vgpu
>>
videoCardVgpuMap
)
{
this
.
videoCardVgpuMap
=
videoCardVgpuMap
;
};
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyFirstFit.java
View file @
bfeda768
...
...
@@ -55,12 +55,8 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
Log
.
printLine
(
"{'clock': "
+
CloudSim
.
clock
()
+
", 'event': 'vm allocation', 'vm': "
+
vm
.
getId
()
+
", 'host': "
+
host
.
getId
()
+
"}"
);
return
true
;
}
// if Vm has a remote Vgpu
for
(
PowerGpuHost
gpuHost
:
getGpuHosts
())
{
boolean
isVgpuAllocated
=
gpuHost
.
getVideoCardAllocationPolicy
().
allocate
(
vgpu
,
vgpu
.
getPCIeBw
());
if
(
isVgpuAllocated
)
{
if
(
allocateRemoteVgpu
(
vgpu
))
{
getVmTable
().
put
(
vm
.
getUid
(),
host
);
Log
.
formatLine
(
"%.2f: VM #"
+
vm
.
getId
()
+
" has been allocated to the host #"
+
host
.
getId
(),
CloudSim
.
clock
());
...
...
@@ -68,13 +64,26 @@ public class RemoteGpuVmAllocationPolicyFirstFit extends GpuVmAllocationPolicySi
+
", 'host': "
+
host
.
getId
()
+
"}"
);
return
true
;
}
}
// failed to find a remote GPU -> free allocated resources
host
.
vmDestroy
(
vm
);
}
return
false
;
}
// Allocates a remote vGPU on a GPU-equipped host
protected
boolean
allocateRemoteVgpu
(
Vgpu
vgpu
)
{
// if Vm has a remote Vgpu
for
(
PowerGpuHost
gpuHost
:
getGpuHosts
())
{
boolean
isVgpuAllocated
=
gpuHost
.
getVideoCardAllocationPolicy
().
allocate
(
vgpu
,
vgpu
.
getPCIeBw
());
if
(
isVgpuAllocated
)
{
Log
.
formatLine
(
"%.2f: Vgpu of VM #"
+
vgpu
.
getVm
().
getId
()
+
" has been allocated to the host #"
+
gpuHost
.
getId
(),
CloudSim
.
clock
());
return
true
;
}
}
return
false
;
}
protected
boolean
isVgpuRemote
(
Vgpu
vgpu
)
{
if
(
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_EXCLUSIVE
||
vgpu
.
getType
()
==
RemoteVgpuTags
.
REMOTE_SHARED
)
{
return
true
;
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/remote/RemoteGpuVmAllocationPolicyLeastLoad.java
0 → 100644
View file @
bfeda768
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
;
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.Vgpu
;
import
org.cloudbus.cloudsim.gpu.power.PowerGpuHost
;
/**
* This class extends {@link RemoteGpuVmAllocationPolicyFirstFit} and allocates
* GPU-enabled VMs on GPU hosts with least loaded (i.t.o. allocated memory)
* pGPUs.
*
* @author Ahmad Siavashi
*
*/
public
class
RemoteGpuVmAllocationPolicyLeastLoad
extends
RemoteGpuVmAllocationPolicyFirstFit
{
/**
* This class extends {@link RemoteGpuVmAllocationPolicyFirstFit} and allocates
* GPU-enabled VMs on GPU hosts with least loaded (i.t.o. allocated memory)
* pGPUs.
*
* @see {@link RemoteGpuVmAllocationPolicyLeastLoad}
*/
public
RemoteGpuVmAllocationPolicyLeastLoad
(
List
<?
extends
Host
>
list
)
{
super
(
list
);
}
@Override
public
boolean
allocateHostForVm
(
Vm
vm
)
{
GpuVm
gpuVm
=
(
GpuVm
)
vm
;
if
(
gpuVm
.
getVgpu
()
!=
null
)
{
sortHosts
();
}
return
super
.
allocateHostForVm
(
vm
);
}
@Override
public
boolean
allocateHostForVm
(
Vm
vm
,
Host
host
)
{
GpuVm
gpuVm
=
(
GpuVm
)
vm
;
if
(
gpuVm
.
getVgpu
()
!=
null
)
{
sortHosts
();
}
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
;
}
});
}
@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
);
};
});
return
super
.
allocateRemoteVgpu
(
vgpu
);
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/selection/PgpuSelectionPolicyLeastLoad.java
0 → 100644
View file @
bfeda768
/**
*
*/
package
org
.
cloudbus
.
cloudsim
.
gpu
.
selection
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
org.cloudbus.cloudsim.gpu.Pgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
/**
* {@link PgpuSelectionPolicyLeastLoad} implements {@link PgpuSelectionPolicy}
* and selects the Pgpu with the least allocated memory.
*
* @author Ahmad Siavashi
*
*/
public
class
PgpuSelectionPolicyLeastLoad
implements
PgpuSelectionPolicy
{
public
PgpuSelectionPolicyLeastLoad
()
{
super
();
}
/*
* (non-Javadoc)
*
* @see org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy#selectPgpu(org.
* cloudbus.cloudsim.gpu.VgpuScheduler, java.util.List)
*/
@Override
public
<
T
extends
VgpuScheduler
>
Pgpu
selectPgpu
(
T
scheduler
,
List
<?
extends
Pgpu
>
pgpuList
)
{
if
(
pgpuList
.
isEmpty
())
{
return
null
;
}
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
);
}
});
}
}
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