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
5c168e18
Commit
5c168e18
authored
May 03, 2011
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Moved PowerModel from PowerPe to PowerHost
- Removed PowerPe and Power.PeList
parent
d61e8d1d
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
92 additions
and
204 deletions
+92
-204
HostDynamicWorkload.java
.../main/java/org/cloudbus/cloudsim/HostDynamicWorkload.java
+5
-1
PowerHost.java
.../src/main/java/org/cloudbus/cloudsim/power/PowerHost.java
+44
-7
PowerPe.java
...im/src/main/java/org/cloudbus/cloudsim/power/PowerPe.java
+0
-57
PowerPeList.java
...n/java/org/cloudbus/cloudsim/power/lists/PowerPeList.java
+0
-62
HostDynamicWorkloadTest.java
...t/java/org/cloudbus/cloudsim/HostDynamicWorkloadTest.java
+2
-7
HostTest.java
...loudsim/src/test/java/org/cloudbus/cloudsim/HostTest.java
+2
-7
PowerHostTest.java
.../test/java/org/cloudbus/cloudsim/power/PowerHostTest.java
+39
-0
PeListTest.java
...st/java/org/cloudbus/cloudsim/power/lists/PeListTest.java
+0
-63
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/HostDynamicWorkload.java
View file @
5c168e18
...
...
@@ -199,7 +199,11 @@ public class HostDynamicWorkload extends Host {
* @return current utilization of CPU in percents
*/
public
double
getUtilizationOfCpu
()
{
return
getUtilizationMips
()
/
getTotalMips
();
double
utilization
=
getUtilizationMips
()
/
getTotalMips
();
if
(
utilization
>
1
&&
utilization
<
1.01
)
{
utilization
=
1
;
}
return
utilization
;
}
/**
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerHost.java
View file @
5c168e18
...
...
@@ -13,7 +13,7 @@ import java.util.List;
import
org.cloudbus.cloudsim.HostDynamicWorkload
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.VmScheduler
;
import
org.cloudbus.cloudsim.power.
lists.PowerPeList
;
import
org.cloudbus.cloudsim.power.
models.PowerModel
;
import
org.cloudbus.cloudsim.provisioners.BwProvisioner
;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
...
...
@@ -24,6 +24,9 @@ import org.cloudbus.cloudsim.provisioners.RamProvisioner;
* @since CloudSim Toolkit 2.0
*/
public
class
PowerHost
extends
HostDynamicWorkload
{
/** The power model. */
private
PowerModel
powerModel
;
/**
* Instantiates a new host.
...
...
@@ -41,8 +44,10 @@ public class PowerHost extends HostDynamicWorkload {
BwProvisioner
bwProvisioner
,
long
storage
,
List
<?
extends
Pe
>
peList
,
VmScheduler
vmScheduler
)
{
VmScheduler
vmScheduler
,
PowerModel
powerModel
)
{
super
(
id
,
ramProvisioner
,
bwProvisioner
,
storage
,
peList
,
vmScheduler
);
setPowerModel
(
powerModel
);
}
/**
...
...
@@ -51,16 +56,48 @@ public class PowerHost extends HostDynamicWorkload {
* @return the power
*/
public
double
getPower
()
{
return
PowerPeList
.
getPower
(
this
.<
PowerPe
>
getPeList
());
double
power
=
0
;
try
{
power
=
getPowerModel
().
getPower
(
getUtilizationOfCpu
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
exit
(
0
);
}
return
power
;
}
/**
* Gets the max
imum power. For this moment only consumed by all PEs
.
* Gets the max
power that can be consumed by the host
.
*
* @return the power
* @return the
max
power
*/
public
double
getMaxPower
()
{
return
PowerPeList
.
getMaxPower
(
this
.<
PowerPe
>
getPeList
());
double
power
=
0
;
try
{
power
=
getPowerModel
().
getPower
(
1
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
exit
(
0
);
}
return
power
;
}
/**
* Sets the power model.
*
* @param powerModel the new power model
*/
protected
void
setPowerModel
(
PowerModel
powerModel
)
{
this
.
powerModel
=
powerModel
;
}
/**
* Gets the power model.
*
* @return the power model
*/
public
PowerModel
getPowerModel
()
{
return
powerModel
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerPe.java
deleted
100644 → 0
View file @
d61e8d1d
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package
org
.
cloudbus
.
cloudsim
.
power
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.power.models.PowerModel
;
import
org.cloudbus.cloudsim.provisioners.PeProvisioner
;
/**
* PowerPe class enables simulation of power-aware PEs.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public
class
PowerPe
extends
Pe
{
// TODO: move power model to PowerHost
/** The power model. */
private
PowerModel
powerModel
;
/**
* Instantiates a new PowerPe.
*
* @param id the id
* @param peProvisioner the PowerPe provisioner
* @param powerModel the power model
*/
public
PowerPe
(
int
id
,
PeProvisioner
peProvisioner
,
PowerModel
powerModel
)
{
super
(
id
,
peProvisioner
);
setPowerModel
(
powerModel
);
}
/**
* Sets the power model.
*
* @param powerModel the new power model
*/
protected
void
setPowerModel
(
PowerModel
powerModel
)
{
this
.
powerModel
=
powerModel
;
}
/**
* Gets the power model.
*
* @return the power model
*/
public
PowerModel
getPowerModel
()
{
return
powerModel
;
}
}
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/lists/PowerPeList.java
deleted
100644 → 0
View file @
d61e8d1d
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package
org
.
cloudbus
.
cloudsim
.
power
.
lists
;
import
java.util.List
;
import
org.cloudbus.cloudsim.lists.PeList
;
import
org.cloudbus.cloudsim.power.PowerPe
;
/**
* PowerPeList is a collection of operations on lists of Power-enabled PEs.
*
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public
class
PowerPeList
extends
PeList
{
/**
* Gets the power. For this moment only consumed by all PEs.
*
* @param peList the pe list
*
* @return the power
*/
public
static
<
T
extends
PowerPe
>
double
getPower
(
List
<
PowerPe
>
peList
)
{
double
power
=
0
;
for
(
PowerPe
pe
:
peList
)
{
try
{
power
+=
pe
.
getPowerModel
().
getPower
(
pe
.
getPeProvisioner
().
getUtilization
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
power
;
}
/**
* Gets the maximum power. For this moment only consumed by all PEs.
*
* @param peList the pe list
*
* @return the power
*/
public
static
<
T
extends
PowerPe
>
double
getMaxPower
(
List
<
PowerPe
>
peList
)
{
double
power
=
0
;
for
(
PowerPe
pe
:
peList
)
{
try
{
power
+=
pe
.
getPowerModel
().
getPower
(
1.0
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
power
;
}
}
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/HostDynamicWorkloadTest.java
View file @
5c168e18
...
...
@@ -14,8 +14,6 @@ import static org.junit.Assert.assertTrue;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.power.PowerPe
;
import
org.cloudbus.cloudsim.power.models.PowerModelSqrt
;
import
org.cloudbus.cloudsim.provisioners.BwProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.RamProvisionerSimple
;
...
...
@@ -34,17 +32,14 @@ public class HostDynamicWorkloadTest {
private
static
final
int
BW
=
10000
;
private
static
final
double
MIPS
=
1000
;
private
static
final
double
MAX_POWER
=
200
;
private
static
final
double
STATIC_POWER_PERCENT
=
0.3
;
private
HostDynamicWorkload
host
;
private
List
<
Pe
>
peList
;
@Before
public
void
setUp
()
throws
Exception
{
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
P
owerPe
(
0
,
new
PeProvisionerSimple
(
MIPS
),
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
)));
peList
.
add
(
new
P
owerPe
(
1
,
new
PeProvisionerSimple
(
MIPS
),
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
)));
peList
.
add
(
new
P
e
(
0
,
new
PeProvisionerSimple
(
MIPS
)));
peList
.
add
(
new
P
e
(
1
,
new
PeProvisionerSimple
(
MIPS
)));
host
=
new
HostDynamicWorkload
(
ID
,
...
...
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/HostTest.java
View file @
5c168e18
...
...
@@ -17,8 +17,6 @@ import static org.junit.Assert.assertTrue;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.power.PowerPe
;
import
org.cloudbus.cloudsim.power.models.PowerModelSqrt
;
import
org.cloudbus.cloudsim.provisioners.BwProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple
;
import
org.cloudbus.cloudsim.provisioners.RamProvisionerSimple
;
...
...
@@ -40,9 +38,6 @@ public class HostTest {
//private static final int PES_NUMBER = 2;
private
static
final
double
MAX_POWER
=
200
;
private
static
final
double
STATIC_POWER_PERCENT
=
0.3
;
//private static final double CLOUDLET_LENGTH = 1000;
//private static final long CLOUDLET_FILE_SIZE = 300;
//private static final long CLOUDLET_OUTPUT_SIZE = 300;
...
...
@@ -53,8 +48,8 @@ public class HostTest {
@Before
public
void
setUp
()
throws
Exception
{
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
P
owerPe
(
0
,
new
PeProvisionerSimple
(
MIPS
),
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
)));
peList
.
add
(
new
P
owerPe
(
1
,
new
PeProvisionerSimple
(
MIPS
),
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
)));
peList
.
add
(
new
P
e
(
0
,
new
PeProvisionerSimple
(
MIPS
)));
peList
.
add
(
new
P
e
(
1
,
new
PeProvisionerSimple
(
MIPS
)));
host
=
new
Host
(
ID
,
...
...
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/power/P
e
Test.java
→
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/power/P
owerHost
Test.java
View file @
5c168e18
...
...
@@ -8,26 +8,32 @@
package
org
.
cloudbus
.
cloudsim
.
power
;
import
static
org
.
junit
.
Assert
.
assertNull
;
import
static
org
.
junit
.
Assert
.
assertSame
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
org.cloudbus.cloudsim.power.models.PowerModel
;
import
org.cloudbus.cloudsim.power.models.PowerModelSqrt
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.Pe
;
import
org.cloudbus.cloudsim.power.models.PowerModelLinear
;
import
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple
;
import
org.junit.Test
;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public
class
PeTest
{
public
class
PowerHostTest
{
private
static
final
double
MIPS
=
1000
;
private
static
final
double
MAX_POWER
=
200
;
private
static
final
double
STATIC_POWER_PERCENT
=
0.3
;
@Test
public
void
testGetPowerModel
()
{
PowerPe
powerPe
=
new
PowerPe
(
0
,
null
,
null
);
assertNull
(
powerPe
.
getPowerModel
());
PowerModel
powerModel
=
new
PowerModelSqrt
(
0
,
0
);
powerPe
.
setPowerModel
(
powerModel
);
assertSame
(
powerModel
,
powerPe
.
getPowerModel
());
public
void
testGetMaxPower
()
{
List
<
Pe
>
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
Pe
(
0
,
new
PeProvisionerSimple
(
MIPS
)));
PowerHost
host
=
new
PowerHost
(
0
,
null
,
null
,
0
,
peList
,
null
,
new
PowerModelLinear
(
MAX_POWER
,
STATIC_POWER_PERCENT
));
assertEquals
(
MAX_POWER
,
host
.
getMaxPower
(),
0
);
}
}
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/power/lists/PeListTest.java
deleted
100644 → 0
View file @
d61e8d1d
/*
* Title: CloudSim Toolkit
* Description: CloudSim (Cloud Simulation) Toolkit for Modeling and Simulation of Clouds
* Licence: GPL - http://www.gnu.org/copyleft/gpl.html
*
* Copyright (c) 2009-2010, The University of Melbourne, Australia
*/
package
org
.
cloudbus
.
cloudsim
.
power
.
lists
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.cloudbus.cloudsim.Vm
;
import
org.cloudbus.cloudsim.power.PowerPe
;
import
org.cloudbus.cloudsim.power.models.PowerModel
;
import
org.cloudbus.cloudsim.power.models.PowerModelSqrt
;
import
org.cloudbus.cloudsim.provisioners.PeProvisionerSimple
;
import
org.junit.Before
;
import
org.junit.Test
;
/**
* @author Anton Beloglazov
* @since CloudSim Toolkit 2.0
*/
public
class
PeListTest
{
private
static
final
double
MIPS
=
1000
;
private
static
final
double
MAX_POWER
=
200
;
private
static
final
double
STATIC_POWER_PERCENT
=
0.3
;
private
List
<
PowerPe
>
peList
;
private
PowerModel
powerModel0
;
private
PowerModel
powerModel1
;
@Before
public
void
setUp
()
throws
Exception
{
peList
=
new
ArrayList
<
PowerPe
>();
powerModel0
=
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
);
powerModel1
=
new
PowerModelSqrt
(
MAX_POWER
,
STATIC_POWER_PERCENT
);
peList
.
add
(
new
PowerPe
(
0
,
new
PeProvisionerSimple
(
MIPS
),
powerModel0
));
peList
.
add
(
new
PowerPe
(
1
,
new
PeProvisionerSimple
(
MIPS
),
powerModel1
));
}
@Test
public
void
testGetPower
()
throws
Exception
{
Vm
vm0
=
new
Vm
(
0
,
0
,
MIPS
/
2
,
1
,
0
,
0
,
0
,
""
,
null
);
Vm
vm1
=
new
Vm
(
1
,
0
,
MIPS
/
2
,
1
,
0
,
0
,
0
,
""
,
null
);
assertTrue
(
peList
.
get
(
0
).
getPeProvisioner
().
allocateMipsForVm
(
vm0
,
MIPS
/
3
));
assertTrue
(
peList
.
get
(
1
).
getPeProvisioner
().
allocateMipsForVm
(
vm1
,
MIPS
/
5
));
double
expectedPower
=
powerModel0
.
getPower
((
MIPS
/
3
)
/
MIPS
)
+
powerModel1
.
getPower
((
MIPS
/
5
)
/
MIPS
);
assertEquals
(
expectedPower
,
PowerPeList
.
getPower
(
peList
),
0
);
}
}
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