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
f61781a8
Commit
f61781a8
authored
Nov 09, 2018
by
Ahmad Siavashi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VgpuScheduler revised
parent
34be0190
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
249 additions
and
201 deletions
+249
-201
CloudSimGpuExample1.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample1.java
+3
-3
CloudSimGpuExample2.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample2.java
+3
-3
CloudSimGpuExample3.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample3.java
+4
-4
CloudSimGpuExample4.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample4.java
+3
-3
CloudSimGpuExample5.java
...g/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample5.java
+3
-3
GpuVmTags.java
...im/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmTags.java
+6
-6
GridVgpuTags.java
...src/main/java/org/cloudbus/cloudsim/gpu/GridVgpuTags.java
+2
-2
VgpuScheduler.java
...rc/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
+1
-20
VgpuSchedulerFairShare.java
...ava/org/cloudbus/cloudsim/gpu/VgpuSchedulerFairShare.java
+55
-31
VgpuSchedulerSpaceShared.java
...a/org/cloudbus/cloudsim/gpu/VgpuSchedulerSpaceShared.java
+76
-54
VgpuSchedulerTimeShared.java
...va/org/cloudbus/cloudsim/gpu/VgpuSchedulerTimeShared.java
+68
-47
PerformanceModelGpuConstant.java
...m/gpu/performance/models/PerformanceModelGpuConstant.java
+2
-2
GridVgpuUtil.java
...ain/java/org/cloudbus/cloudsim/gpu/util/GridVgpuUtil.java
+23
-23
No files found.
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample1.java
View file @
f61781a8
...
...
@@ -32,7 +32,7 @@ import org.cloudbus.cloudsim.gpu.Pgpu;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.VgpuSchedulerFairShare
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
...
...
@@ -227,7 +227,7 @@ public class CloudSimGpuExample1 {
// Create GpuTask Scheduler
GpuTaskSchedulerLeftover
gpuTaskScheduler
=
new
GpuTaskSchedulerLeftover
();
// Create a Vgpu
Vgpu
vgpu
=
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
Vgpu
vgpu
=
Grid
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
vm
.
setVgpu
(
vgpu
);
return
vm
;
}
...
...
@@ -397,7 +397,7 @@ public class CloudSimGpuExample1 {
at
.
addRule
();
if
(
gpuTask
.
getTaskStatus
()
==
GpuTask
.
FINISHED
)
{
at
.
addRow
(
gpuTask
.
getTaskId
(),
gpuTask
.
getCloudlet
().
getCloudletId
(),
"SUCCESS"
,
VgpuTags
.
getVgpuTypeString
(
Grid
VgpuTags
.
getVgpuTypeString
(
((
GpuVm
)
VmList
.
getById
(
vmlist
,
gpuTask
.
getCloudlet
().
getVmId
())).
getVgpu
().
getType
()),
dft
.
format
(
gpuTask
.
getActualGPUTime
()).
toString
(),
dft
.
format
(
gpuTask
.
getExecStartTime
()).
toString
(),
...
...
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample2.java
View file @
f61781a8
...
...
@@ -33,7 +33,7 @@ import org.cloudbus.cloudsim.gpu.ResGpuTask;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.VgpuSchedulerFairShare
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
...
...
@@ -233,7 +233,7 @@ public class CloudSimGpuExample2 {
// Create GpuTask Scheduler
GpuTaskSchedulerLeftover
gpuTaskScheduler
=
new
InterferenceGpuTaskSchedulerLeftover
(
interferenceModel
);
// Create a Vgpu
Vgpu
vgpu
=
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
);
Vgpu
vgpu
=
Grid
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
);
vm
.
setVgpu
(
vgpu
);
return
vm
;
}
...
...
@@ -403,7 +403,7 @@ public class CloudSimGpuExample2 {
at
.
addRule
();
if
(
gpuTask
.
getTaskStatus
()
==
GpuTask
.
FINISHED
)
{
at
.
addRow
(
gpuTask
.
getTaskId
(),
gpuTask
.
getCloudlet
().
getCloudletId
(),
"SUCCESS"
,
VgpuTags
.
getVgpuTypeString
(
Grid
VgpuTags
.
getVgpuTypeString
(
((
GpuVm
)
VmList
.
getById
(
vmlist
,
gpuTask
.
getCloudlet
().
getVmId
())).
getVgpu
().
getType
()),
dft
.
format
(
gpuTask
.
getActualGPUTime
()).
toString
(),
dft
.
format
(
gpuTask
.
getExecStartTime
()).
toString
(),
...
...
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample3.java
View file @
f61781a8
...
...
@@ -32,7 +32,7 @@ import org.cloudbus.cloudsim.gpu.Pgpu;
import
org.cloudbus.cloudsim.gpu.ResGpuTask
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
...
...
@@ -171,8 +171,8 @@ public class CloudSimGpuExample3 {
interferenceModel
);
// Create a Vgpu
int
vgpuId
=
i
;
Vgpu
vgpu
=
i
<
1
?
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
)
:
VgpuTags
.
getK260Q
(
vgpuId
,
gpuTaskScheduler
);
Vgpu
vgpu
=
i
<
1
?
Grid
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
)
:
Grid
VgpuTags
.
getK260Q
(
vgpuId
,
gpuTaskScheduler
);
vm
.
setVgpu
(
vgpu
);
vmlist
.
add
(
vm
);
}
...
...
@@ -376,7 +376,7 @@ public class CloudSimGpuExample3 {
at
.
addRule
();
if
(
gpuTask
.
getTaskStatus
()
==
GpuTask
.
FINISHED
)
{
at
.
addRow
(
gpuTask
.
getTaskId
(),
gpuTask
.
getCloudlet
().
getCloudletId
(),
"SUCCESS"
,
VgpuTags
.
getVgpuTypeString
(
Grid
VgpuTags
.
getVgpuTypeString
(
((
GpuVm
)
VmList
.
getById
(
vmlist
,
gpuTask
.
getCloudlet
().
getVmId
())).
getVgpu
().
getType
()),
dft
.
format
(
gpuTask
.
getActualGPUTime
()).
toString
(),
dft
.
format
(
gpuTask
.
getExecStartTime
()).
toString
(),
...
...
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample4.java
View file @
f61781a8
...
...
@@ -30,7 +30,7 @@ import org.cloudbus.cloudsim.gpu.GpuVmTags;
import
org.cloudbus.cloudsim.gpu.Pgpu
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
...
...
@@ -225,7 +225,7 @@ public class CloudSimGpuExample4 {
// Create GpuTask Scheduler
GpuTaskSchedulerLeftover
gpuTaskScheduler
=
new
GpuTaskSchedulerLeftover
();
// Create a Vgpu
Vgpu
vgpu
=
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
Vgpu
vgpu
=
Grid
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
vm
.
setVgpu
(
vgpu
);
return
vm
;
}
...
...
@@ -405,7 +405,7 @@ public class CloudSimGpuExample4 {
at
.
addRule
();
if
(
gpuTask
.
getTaskStatus
()
==
GpuTask
.
FINISHED
)
{
at
.
addRow
(
gpuTask
.
getTaskId
(),
gpuTask
.
getCloudlet
().
getCloudletId
(),
"SUCCESS"
,
VgpuTags
.
getVgpuTypeString
(
Grid
VgpuTags
.
getVgpuTypeString
(
((
GpuVm
)
VmList
.
getById
(
vmlist
,
gpuTask
.
getCloudlet
().
getVmId
())).
getVgpu
().
getType
()),
dft
.
format
(
gpuTask
.
getActualGPUTime
()).
toString
(),
dft
.
format
(
gpuTask
.
getExecStartTime
()).
toString
(),
...
...
modules/cloudsim-examples/src/main/java/org/cloudbus/cloudsim/examples/gpu/CloudSimGpuExample5.java
View file @
f61781a8
...
...
@@ -30,7 +30,7 @@ import org.cloudbus.cloudsim.gpu.GpuVmTags;
import
org.cloudbus.cloudsim.gpu.Pgpu
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCard
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
import
org.cloudbus.cloudsim.gpu.allocation.VideoCardAllocationPolicy
;
...
...
@@ -225,7 +225,7 @@ public class CloudSimGpuExample5 {
// Create GpuTask Scheduler
GpuTaskSchedulerLeftover
gpuTaskScheduler
=
new
GpuTaskSchedulerLeftover
();
// Create a Vgpu
Vgpu
vgpu
=
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
Vgpu
vgpu
=
Grid
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
vm
.
setVgpu
(
vgpu
);
return
vm
;
}
...
...
@@ -428,7 +428,7 @@ public class CloudSimGpuExample5 {
at
.
addRule
();
if
(
gpuTask
.
getTaskStatus
()
==
GpuTask
.
FINISHED
)
{
at
.
addRow
(
gpuTask
.
getTaskId
(),
gpuTask
.
getCloudlet
().
getCloudletId
(),
"SUCCESS"
,
VgpuTags
.
getVgpuTypeString
(
Grid
VgpuTags
.
getVgpuTypeString
(
((
GpuVm
)
VmList
.
getById
(
vmlist
,
gpuTask
.
getCloudlet
().
getVmId
())).
getVgpu
().
getType
()),
dft
.
format
(
gpuTask
.
getActualGPUTime
()).
toString
(),
dft
.
format
(
gpuTask
.
getExecStartTime
()).
toString
(),
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/GpuVmTags.java
View file @
f61781a8
...
...
@@ -49,37 +49,37 @@ public class GpuVmTags {
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2690_V4_PE_MIPS
;
pesNumber
=
8
;
ram
=
16
;
vgpu
=
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK280Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
case
VCPU_4_E5_2620_V3_RAM_16_K180Q:
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2620_V3_PE_MIPS
;
pesNumber
=
4
;
ram
=
16
;
vgpu
=
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK180Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
case
VCPU_4_E5_2090_V4_RAM_8_K260Q:
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2690_V4_PE_MIPS
;
pesNumber
=
4
;
ram
=
8
;
vgpu
=
VgpuTags
.
getK260Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK260Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
case
VCPU_2_E5_2620_V3_RAM_8_K160Q:
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2620_V3_PE_MIPS
;
pesNumber
=
2
;
ram
=
8
;
vgpu
=
VgpuTags
.
getK160Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK160Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
case
VCPU_2_E5_2090_V4_RAM_4_K240Q:
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2690_V4_PE_MIPS
;
pesNumber
=
2
;
ram
=
4
;
vgpu
=
VgpuTags
.
getK240Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK240Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
case
VCPU_2_E5_2620_V3_RAM_4_K140Q:
mips
=
GpuHostTags
.
DUAL_INTEL_XEON_E5_2620_V3_PE_MIPS
;
pesNumber
=
2
;
ram
=
4
;
vgpu
=
VgpuTags
.
getK140Q
(
vgpuId
,
gpuTaskScheduler
);
vgpu
=
Grid
VgpuTags
.
getK140Q
(
vgpuId
,
gpuTaskScheduler
);
break
;
default
:
System
.
err
.
println
(
"[!] Unknown GpuVm Type: "
+
type
);
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuTags.java
→
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/
Grid
VgpuTags.java
View file @
f61781a8
...
...
@@ -11,7 +11,7 @@ package org.cloudbus.cloudsim.gpu;
*
*/
public
class
VgpuTags
{
public
class
Grid
VgpuTags
{
public
final
static
int
VGPU_CUSTOM
=
-
1
;
...
...
@@ -221,7 +221,7 @@ public class VgpuTags {
/**
* Singleton class (cannot be instantiated)
*/
private
VgpuTags
()
{
private
Grid
VgpuTags
()
{
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuScheduler.java
View file @
f61781a8
...
...
@@ -9,7 +9,7 @@ import java.util.Map.Entry;
import
org.cloudbus.cloudsim.Log
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy
;
import
org.cloudbus.cloudsim.gpu.util.VgpuUtil
;
import
org.cloudbus.cloudsim.gpu.util.
Grid
VgpuUtil
;
/**
* VgpuScheduler is an abstract class that represents the policy used by a
...
...
@@ -91,25 +91,6 @@ public abstract class VgpuScheduler {
*/
public
abstract
boolean
isSuitable
(
Vgpu
vgpu
);
/**
* Checks whether the vgpu type is supported by this video card type or not.
*
* @param vgpu
* the vgpu
* @return $true if the video card supports the vgpu type.
*/
public
boolean
isVideoCardSuitableForVgpu
(
Vgpu
vgpu
)
{
if
(!
VgpuUtil
.
isVideoCardSuitable
(
getVideoCardType
(),
vgpu
.
getType
()))
{
return
false
;
}
for
(
Entry
<
Pgpu
,
List
<
Vgpu
>>
entry
:
getPgpuVgpuMap
().
entrySet
())
{
if
(
VgpuUtil
.
isPgpuSuitable
(
entry
,
vgpu
))
{
return
true
;
}
}
return
false
;
}
/**
* Releases PEs allocated to a {@link Vgpu}. After that, the PEs may be used on
* demand by other Vgpus.
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuSchedulerFairShare.java
View file @
f61781a8
...
...
@@ -6,11 +6,13 @@ import java.util.Comparator;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy
;
import
org.cloudbus.cloudsim.gpu.util.GridVgpuUtil
;
import
org.cloudbus.cloudsim.lists.PeList
;
import
org.cloudbus.cloudsim.util.MathUtil
;
...
...
@@ -43,6 +45,54 @@ public class VgpuSchedulerFairShare extends VgpuSchedulerTimeShared {
setRequestedMipsMap
(
new
HashMap
<
Vgpu
,
List
<
Double
>>());
}
/**
* Checks whether the vgpu type is supported by this video card type or not.
*
* @param vgpu
* the vgpu
* @return $true if the video card supports the vgpu type.
*/
protected
boolean
isVideoCardSuitableForVgpu
(
Vgpu
vgpu
)
{
if
(!
GridVgpuUtil
.
isVideoCardSuitable
(
getVideoCardType
(),
vgpu
.
getType
()))
{
return
false
;
}
for
(
Entry
<
Pgpu
,
List
<
Vgpu
>>
entry
:
getPgpuVgpuMap
().
entrySet
())
{
if
(
GridVgpuUtil
.
isPgpuSuitable
(
entry
,
vgpu
))
{
return
true
;
}
}
return
false
;
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
if
(
pgpu
.
getPeList
().
size
()
<
mipsShare
.
size
())
{
return
false
;
}
return
true
;
}
});
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
@Override
@SuppressWarnings
(
"unchecked"
)
public
boolean
allocatePgpuForVgpu
(
final
Vgpu
vgpu
,
final
List
<
Double
>
mipsShare
,
final
int
gddramShare
,
...
...
@@ -85,8 +135,11 @@ public class VgpuSchedulerFairShare extends VgpuSchedulerTimeShared {
/**
* Rescales mips share of resident vgpus whenever a vgpu enters or leaves.
*
* @param pgpu the pgpu to redistribute the mips share of its resident vgpus
* @param mipsChange the amount of mips that has been changed in the pgpu; either added or removed.
* @param pgpu
* the pgpu to redistribute the mips share of its resident vgpus
* @param mipsChange
* the amount of mips that has been changed in the pgpu; either added
* or removed.
*/
protected
void
redistributeMipsDueToOverSubscription
(
final
Pgpu
pgpu
,
double
mipsChange
)
{
// calculating the scaling factor
...
...
@@ -156,35 +209,6 @@ public class VgpuSchedulerFairShare extends VgpuSchedulerTimeShared {
redistributeMipsDueToOverSubscription
(
pgpu
,
totalMipsChange
);
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
if
(
pgpu
.
getPeList
().
size
()
<
mipsShare
.
size
())
{
return
false
;
}
return
true
;
}
});
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
/**
* @return the requestedMipsMap
*/
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuSchedulerSpaceShared.java
View file @
f61781a8
...
...
@@ -4,12 +4,14 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy
;
import
org.cloudbus.cloudsim.gpu.util.GridVgpuUtil
;
/**
* VgpuSchedulerSpaceShared is a vgpu allocation policy that allocates one or
...
...
@@ -37,6 +39,80 @@ public class VgpuSchedulerSpaceShared extends VgpuScheduler {
super
(
videoCardType
,
pgpuList
,
pgpuSelectionPolicy
);
}
/**
* Checks whether the vgpu type is supported by this video card type or not.
*
* @param vgpu
* the vgpu
* @return $true if the video card supports the vgpu type.
*/
protected
boolean
isVideoCardSuitableForVgpu
(
Vgpu
vgpu
)
{
if
(!
GridVgpuUtil
.
isVideoCardSuitable
(
getVideoCardType
(),
vgpu
.
getType
()))
{
return
false
;
}
for
(
Entry
<
Pgpu
,
List
<
Vgpu
>>
entry
:
getPgpuVgpuMap
().
entrySet
())
{
if
(
GridVgpuUtil
.
isPgpuSuitable
(
entry
,
vgpu
))
{
return
true
;
}
}
return
false
;
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
List
<
Pe
>
pgpuPes
=
pgpu
.
getPeList
();
int
freePes
=
CollectionUtils
.
countMatches
(
pgpuPes
,
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pe
pe
=
(
Pe
)
arg
;
if
(
pe
.
getPeProvisioner
().
getTotalAllocatedMips
()
==
0
)
{
return
true
;
}
return
false
;
}
});
if
(
freePes
<
mipsShare
.
size
())
{
return
false
;
}
// PEs in the pgpu are sorted according to their
// available mips
Collections
.
sort
(
pgpuPes
,
Collections
.
reverseOrder
(
new
Comparator
<
Pe
>()
{
public
int
compare
(
Pe
pe1
,
Pe
pe2
)
{
return
Double
.
compare
(
pe1
.
getPeProvisioner
().
getAvailableMips
(),
pe2
.
getPeProvisioner
().
getAvailableMips
());
}
}));
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
if
(
mipsShare
.
get
(
i
)
>
pgpuPes
.
get
(
i
).
getPeProvisioner
().
getAvailableMips
())
{
return
false
;
}
}
return
true
;
}
});
// if there is no candidate,
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
allocatePgpuForVgpu
(
final
Vgpu
vgpu
,
final
List
<
Double
>
mipsShare
,
final
int
gddramShare
,
...
...
@@ -142,58 +218,4 @@ public class VgpuSchedulerSpaceShared extends VgpuScheduler {
vgpu
.
setCurrentAllocatedMips
(
null
);
}
@SuppressWarnings
(
"unchecked"
)
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
List
<
Pe
>
pgpuPes
=
pgpu
.
getPeList
();
int
freePes
=
CollectionUtils
.
countMatches
(
pgpuPes
,
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pe
pe
=
(
Pe
)
arg
;
if
(
pe
.
getPeProvisioner
().
getTotalAllocatedMips
()
==
0
)
{
return
true
;
}
return
false
;
}
});
if
(
freePes
<
mipsShare
.
size
())
{
return
false
;
}
// PEs in the pgpu are sorted according to their
// available mips
Collections
.
sort
(
pgpuPes
,
Collections
.
reverseOrder
(
new
Comparator
<
Pe
>()
{
public
int
compare
(
Pe
pe1
,
Pe
pe2
)
{
return
Double
.
compare
(
pe1
.
getPeProvisioner
().
getAvailableMips
(),
pe2
.
getPeProvisioner
().
getAvailableMips
());
}
}));
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
if
(
mipsShare
.
get
(
i
)
>
pgpuPes
.
get
(
i
).
getPeProvisioner
().
getAvailableMips
())
{
return
false
;
}
}
return
true
;
}
});
// if there is no candidate,
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/VgpuSchedulerTimeShared.java
View file @
f61781a8
...
...
@@ -4,11 +4,13 @@ import java.util.ArrayList;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
import
java.util.Map.Entry
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.collections.Predicate
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.gpu.selection.PgpuSelectionPolicy
;
import
org.cloudbus.cloudsim.gpu.util.GridVgpuUtil
;
/**
* VgpuSchedulerTimeShared is a vgpu allocation policy that allocates one or
...
...
@@ -30,6 +32,72 @@ public class VgpuSchedulerTimeShared extends VgpuScheduler {
super
(
videoCardType
,
pgpuList
,
pgpuSelectionPolicy
);
}
/**
* Checks whether the vgpu type is supported by this video card type or not.
*
* @param vgpu
* the vgpu
* @return $true if the video card supports the vgpu type.
*/
protected
boolean
isVideoCardSuitableForVgpu
(
Vgpu
vgpu
)
{
if
(!
GridVgpuUtil
.
isVideoCardSuitable
(
getVideoCardType
(),
vgpu
.
getType
()))
{
return
false
;
}
for
(
Entry
<
Pgpu
,
List
<
Vgpu
>>
entry
:
getPgpuVgpuMap
().
entrySet
())
{
if
(
GridVgpuUtil
.
isPgpuSuitable
(
entry
,
vgpu
))
{
return
true
;
}
}
return
false
;
}
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
@SuppressWarnings
(
"unchecked"
)
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
if
(
pgpu
.
getPeList
().
size
()
<
mipsShare
.
size
())
{
return
false
;
}
List
<
Pe
>
pgpuPes
=
pgpu
.
getPeList
();
// PEs in the pgpu are sorted according to their
// available mips
Collections
.
sort
(
pgpuPes
,
Collections
.
reverseOrder
(
new
Comparator
<
Pe
>()
{
public
int
compare
(
Pe
pe1
,
Pe
pe2
)
{
return
Double
.
compare
(
pe1
.
getPeProvisioner
().
getAvailableMips
(),
pe2
.
getPeProvisioner
().
getAvailableMips
());
}
}));
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
if
(
mipsShare
.
get
(
i
)
>
pgpuPes
.
get
(
i
).
getPeProvisioner
().
getAvailableMips
())
{
return
false
;
}
}
return
true
;
}
});
// No two Vgpu PEs are mapped to one Pgpu PE, hence there must
// exists one such possible mapping at least
// if no suitable pgpu found, exit
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
@Override
public
boolean
allocatePgpuForVgpu
(
final
Vgpu
vgpu
,
final
List
<
Double
>
mipsShare
,
final
int
gddramShare
,
final
long
bwShare
)
{
...
...
@@ -115,51 +183,4 @@ public class VgpuSchedulerTimeShared extends VgpuScheduler {
vgpu
.
setCurrentAllocatedMips
(
null
);
}
@Override
public
boolean
isSuitable
(
final
Vgpu
vgpu
)
{
if
(!
isVideoCardSuitableForVgpu
(
vgpu
))
{
return
false
;
}
final
List
<
Double
>
mipsShare
=
vgpu
.
getCurrentRequestedMips
();
final
int
gddramShare
=
vgpu
.
getCurrentRequestedGddram
();
final
long
bwShare
=
vgpu
.
getCurrentRequestedBw
();
@SuppressWarnings
(
"unchecked"
)
List
<
Pgpu
>
candidates
=
(
List
<
Pgpu
>)
CollectionUtils
.
select
(
getPgpuList
(),
new
Predicate
()
{
@Override
public
boolean
evaluate
(
Object
arg
)
{
Pgpu
pgpu
=
(
Pgpu
)
arg
;
if
(!
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
vgpu
,
gddramShare
)
||
!
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
vgpu
,
bwShare
))
{
return
false
;
}
if
(
pgpu
.
getPeList
().
size
()
<
mipsShare
.
size
())
{
return
false
;
}
List
<
Pe
>
pgpuPes
=
pgpu
.
getPeList
();
// PEs in the pgpu are sorted according to their
// available mips
Collections
.
sort
(
pgpuPes
,
Collections
.
reverseOrder
(
new
Comparator
<
Pe
>()
{
public
int
compare
(
Pe
pe1
,
Pe
pe2
)
{
return
Double
.
compare
(
pe1
.
getPeProvisioner
().
getAvailableMips
(),
pe2
.
getPeProvisioner
().
getAvailableMips
());
}
}));
for
(
int
i
=
0
;
i
<
mipsShare
.
size
();
i
++)
{
if
(
mipsShare
.
get
(
i
)
>
pgpuPes
.
get
(
i
).
getPeProvisioner
().
getAvailableMips
())
{
return
false
;
}
}
return
true
;
}
});
// No two Vgpu PEs are mapped to one Pgpu PE, hence there must
// exists one such possible mapping at least
// if no suitable pgpu found, exit
if
(
candidates
.
isEmpty
())
{
return
false
;
}
return
true
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/performance/models/PerformanceModelGpuConstant.java
View file @
f61781a8
...
...
@@ -8,7 +8,7 @@ import java.util.List;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuScheduler
;
import
org.cloudbus.cloudsim.gpu.util.VgpuUtil
;
import
org.cloudbus.cloudsim.gpu.util.
Grid
VgpuUtil
;
/**
* {@link PerformanceModelGpuConstant} imposes a constant performance
...
...
@@ -45,7 +45,7 @@ public class PerformanceModelGpuConstant implements PerformanceModel<VgpuSchedul
@Override
public
List
<
Double
>
getAvailableMips
(
VgpuScheduler
scheduler
,
Vgpu
vgpu
,
List
<
Vgpu
>
vgpus
)
{
List
<
Double
>
allocatedMips
=
scheduler
.
getAllocatedMipsForVgpu
(
vgpu
);
if
(
VgpuUtil
.
isPassThrough
(
vgpu
))
{
if
(
Grid
VgpuUtil
.
isPassThrough
(
vgpu
))
{
return
allocatedMips
;
}
List
<
Double
>
availableMips
=
new
ArrayList
<
Double
>(
allocatedMips
.
size
());
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/util/VgpuUtil.java
→
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/gpu/util/
Grid
VgpuUtil.java
View file @
f61781a8
...
...
@@ -6,16 +6,16 @@ import java.util.Map.Entry;
import
org.apache.commons.lang3.ArrayUtils
;
import
org.cloudbus.cloudsim.gpu.Pgpu
;
import
org.cloudbus.cloudsim.gpu.Vgpu
;
import
org.cloudbus.cloudsim.gpu.VgpuTags
;
import
org.cloudbus.cloudsim.gpu.
Grid
VgpuTags
;
import
org.cloudbus.cloudsim.gpu.VideoCardTags
;
/**
* A class containing multiple convenient functions to work with Vgpus.
* A class containing multiple convenient functions to work with
GRID
Vgpus.
*
* @author Ahmad Siavashi
*
*/
public
class
VgpuUtil
{
public
class
Grid
VgpuUtil
{
/**
* Checks whether a videoCard type supports a given vgpu type or not.
...
...
@@ -30,9 +30,9 @@ public class VgpuUtil {
public
static
boolean
isVideoCardSuitable
(
int
videoCardType
,
int
vgpuType
)
{
switch
(
videoCardType
)
{
case
VideoCardTags
.
NVIDIA_K1_CARD
:
return
ArrayUtils
.
contains
(
VgpuTags
.
K1_VGPUS
,
vgpuType
);
return
ArrayUtils
.
contains
(
Grid
VgpuTags
.
K1_VGPUS
,
vgpuType
);
case
VideoCardTags
.
NVIDIA_K2_CARD
:
return
ArrayUtils
.
contains
(
VgpuTags
.
K2_VGPUS
,
vgpuType
);
return
ArrayUtils
.
contains
(
Grid
VgpuTags
.
K2_VGPUS
,
vgpuType
);
default
:
return
true
;
}
...
...
@@ -58,22 +58,22 @@ public class VgpuUtil {
}
int
currentNumberOfVgpus
=
vgpus
.
size
();
switch
(
newVgpu
.
getType
())
{
case
VgpuTags
.
K1_K120Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K120Q_VGPUS_PER_K1_PGPU
;
case
VgpuTags
.
K1_K140Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K140Q_VGPUS_PER_K1_PGPU
;
case
VgpuTags
.
K1_K160Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K160Q_VGPUS_PER_K1_PGPU
;
case
VgpuTags
.
K1_K180Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K180Q_VGPUS_PER_K1_PGPU
;
case
VgpuTags
.
K2_K220Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K220Q_VGPUS_PER_K2_PGPU
;
case
VgpuTags
.
K2_K240Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K240Q_VGPUS_PER_K2_PGPU
;
case
VgpuTags
.
K2_K260Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K260Q_VGPUS_PER_K2_PGPU
;
case
VgpuTags
.
K2_K280Q
:
return
currentNumberOfVgpus
<
VgpuTags
.
MAX_K280Q_VGPUS_PER_K2_PGPU
;
case
Grid
VgpuTags
.
K1_K120Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K120Q_VGPUS_PER_K1_PGPU
;
case
Grid
VgpuTags
.
K1_K140Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K140Q_VGPUS_PER_K1_PGPU
;
case
Grid
VgpuTags
.
K1_K160Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K160Q_VGPUS_PER_K1_PGPU
;
case
Grid
VgpuTags
.
K1_K180Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K180Q_VGPUS_PER_K1_PGPU
;
case
Grid
VgpuTags
.
K2_K220Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K220Q_VGPUS_PER_K2_PGPU
;
case
Grid
VgpuTags
.
K2_K240Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K240Q_VGPUS_PER_K2_PGPU
;
case
Grid
VgpuTags
.
K2_K260Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K260Q_VGPUS_PER_K2_PGPU
;
case
Grid
VgpuTags
.
K2_K280Q
:
return
currentNumberOfVgpus
<
Grid
VgpuTags
.
MAX_K280Q_VGPUS_PER_K2_PGPU
;
}
if
(
pgpu
.
getGddramProvisioner
().
isSuitableForVgpu
(
newVgpu
,
newVgpu
.
getGddram
())
&&
pgpu
.
getBwProvisioner
().
isSuitableForVgpu
(
newVgpu
,
newVgpu
.
getBw
()))
{
...
...
@@ -90,13 +90,13 @@ public class VgpuUtil {
* @return $true if the vgpu type is a pass-through type; $false otherwise.
*/
public
static
boolean
isPassThrough
(
Vgpu
vgpu
)
{
return
ArrayUtils
.
contains
(
VgpuTags
.
PASS_THROUGH_VGPUS
,
vgpu
.
getType
());
return
ArrayUtils
.
contains
(
Grid
VgpuTags
.
PASS_THROUGH_VGPUS
,
vgpu
.
getType
());
}
/**
* Cannot be instantiated (Singleton).
*/
private
VgpuUtil
()
{
private
Grid
VgpuUtil
()
{
}
}
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