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
f61914d1
Commit
f61914d1
authored
May 03, 2011
by
Anton Beloglazov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Modified: energy for a time frame is calculated using linear interpolation
parent
42a8080d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
96 additions
and
21 deletions
+96
-21
HostDynamicWorkload.java
.../main/java/org/cloudbus/cloudsim/HostDynamicWorkload.java
+39
-2
PowerDatacenter.java
...ain/java/org/cloudbus/cloudsim/power/PowerDatacenter.java
+7
-15
PowerHost.java
.../src/main/java/org/cloudbus/cloudsim/power/PowerHost.java
+25
-1
PowerHostTest.java
.../test/java/org/cloudbus/cloudsim/power/PowerHostTest.java
+25
-3
No files found.
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/HostDynamicWorkload.java
View file @
f61914d1
...
...
@@ -18,6 +18,7 @@ import org.cloudbus.cloudsim.lists.PeList;
import
org.cloudbus.cloudsim.provisioners.BwProvisioner
;
import
org.cloudbus.cloudsim.provisioners.RamProvisioner
;
// TODO: Auto-generated Javadoc
/**
* The Class HostDynamicWorkload.
*
...
...
@@ -28,6 +29,9 @@ public class HostDynamicWorkload extends Host {
/** The utilization mips. */
private
double
utilizationMips
;
/** The previous utilization mips. */
private
double
previousUtilizationMips
;
/** The under allocated mips. */
private
Map
<
String
,
List
<
List
<
Double
>>>
underAllocatedMips
;
...
...
@@ -51,6 +55,7 @@ public class HostDynamicWorkload extends Host {
VmScheduler
vmScheduler
)
{
super
(
id
,
ramProvisioner
,
bwProvisioner
,
storage
,
peList
,
vmScheduler
);
setUtilizationMips
(
0
);
setPreviousUtilizationMips
(
0
);
setUnderAllocatedMips
(
new
HashMap
<
String
,
List
<
List
<
Double
>>>());
setVmsMigratingIn
(
new
ArrayList
<
Vm
>());
}
...
...
@@ -64,6 +69,7 @@ public class HostDynamicWorkload extends Host {
Log
.
printLine
();
}
double
smallerTime
=
super
.
updateVmsProcessing
(
currentTime
);
setPreviousUtilizationMips
(
getUtilizationMips
());
setUtilizationMips
(
0
);
for
(
Vm
vm
:
getVmList
())
{
...
...
@@ -197,7 +203,7 @@ public class HostDynamicWorkload extends Host {
}
/**
* Get current utilization of CPU in percent
s
.
* Get current utilization of CPU in percent
age
.
*
* @return current utilization of CPU in percents
*/
...
...
@@ -208,6 +214,19 @@ public class HostDynamicWorkload extends Host {
}
return
utilization
;
}
/**
* Gets the previous utilization of CPU in percentage.
*
* @return the previous utilization of cpu
*/
public
double
getPreviousUtilizationOfCpu
()
{
double
utilization
=
getPreviousUtilizationMips
()
/
getTotalMips
();
if
(
utilization
>
1
&&
utilization
<
1.01
)
{
utilization
=
1
;
}
return
utilization
;
}
/**
* Get current utilization of CPU in MIPS.
...
...
@@ -223,7 +242,7 @@ public class HostDynamicWorkload extends Host {
*
* @return the utilization mips
*/
p
rotected
double
getUtilizationMips
()
{
p
ublic
double
getUtilizationMips
()
{
return
utilizationMips
;
}
...
...
@@ -234,6 +253,24 @@ public class HostDynamicWorkload extends Host {
*/
protected
void
setUtilizationMips
(
double
utilizationMips
)
{
this
.
utilizationMips
=
utilizationMips
;
}
/**
* Gets the previous utilization mips.
*
* @return the previous utilization mips
*/
public
double
getPreviousUtilizationMips
()
{
return
previousUtilizationMips
;
}
/**
* Sets the previous utilization mips.
*
* @param previousUtilizationMips the new previous utilization mips
*/
protected
void
setPreviousUtilizationMips
(
double
previousUtilizationMips
)
{
this
.
previousUtilizationMips
=
previousUtilizationMips
;
}
/**
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerDatacenter.java
View file @
f61914d1
...
...
@@ -137,29 +137,21 @@ public class PowerDatacenter extends Datacenter {
double
currentTime
=
CloudSim
.
clock
();
double
minTime
=
Double
.
MAX_VALUE
;
double
timeDiff
=
currentTime
-
getLastProcessTime
();
double
time
framePower
=
0.0
;
double
time
FrameDatacenterEnergy
=
0.0
;
if
(
timeDiff
>
0
)
{
Log
.
formatLine
(
"\nEnergy consumption for the last time frame from %.2f to %.2f:"
,
getLastProcessTime
(),
currentTime
);
for
(
PowerHost
host
:
this
.<
PowerHost
>
getHostList
())
{
Log
.
printLine
();
double
hostPower
=
0.0
;
if
(
host
.
getUtilizationOfCpu
()
>
0
)
{
try
{
hostPower
=
host
.
getPower
()
*
timeDiff
;
timeframePower
+=
hostPower
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
double
timeFrameHostEnergy
=
host
.
getEnergyLinearInterpolation
(
host
.
getPreviousUtilizationOfCpu
(),
host
.
getUtilizationOfCpu
(),
timeDiff
);
timeFrameDatacenterEnergy
+=
timeFrameHostEnergy
;
Log
.
printLine
();
Log
.
formatLine
(
"%.2f: [Host #%d] utilization is %.2f%%"
,
currentTime
,
host
.
getId
(),
host
.
getUtilizationOfCpu
()
*
100
);
Log
.
formatLine
(
"%.2f: [Host #%d] energy is %.2f W*sec"
,
currentTime
,
host
.
getId
(),
hostPower
);
Log
.
formatLine
(
"%.2f: [Host #%d] energy is %.2f W*sec"
,
currentTime
,
host
.
getId
(),
timeFrameHostEnergy
);
}
Log
.
formatLine
(
"\n%.2f: Consumed energy is %.2f W*sec\n"
,
currentTime
,
time
framePower
);
Log
.
formatLine
(
"\n%.2f: Consumed energy is %.2f W*sec\n"
,
currentTime
,
time
FrameDatacenterEnergy
);
}
Log
.
printLine
(
"\n\n--------------------------------------------------------------\n\n"
);
...
...
@@ -176,7 +168,7 @@ public class PowerDatacenter extends Datacenter {
Log
.
formatLine
(
"%.2f: [Host #%d] utilization is %.2f%%"
,
currentTime
,
host
.
getId
(),
host
.
getUtilizationOfCpu
()
*
100
);
}
setPower
(
getPower
()
+
time
framePower
);
setPower
(
getPower
()
+
time
FrameDatacenterEnergy
);
checkCloudletCompletion
();
...
...
modules/cloudsim/src/main/java/org/cloudbus/cloudsim/power/PowerHost.java
View file @
f61914d1
...
...
@@ -56,9 +56,19 @@ public class PowerHost extends HostDynamicWorkload {
* @return the power
*/
public
double
getPower
()
{
return
getPower
(
getUtilizationOfCpu
());
}
/**
* Gets the power. For this moment only consumed by all PEs.
*
* @param utilization the utilization
* @return the power
*/
protected
double
getPower
(
double
utilization
)
{
double
power
=
0
;
try
{
power
=
getPowerModel
().
getPower
(
getUtilizationOfCpu
()
);
power
=
getPowerModel
().
getPower
(
utilization
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
System
.
exit
(
0
);
...
...
@@ -82,6 +92,20 @@ public class PowerHost extends HostDynamicWorkload {
return
power
;
}
/**
* Gets the energy consumption using linear interpolation of the utilization change.
*
* @param fromUtilization the from utilization
* @param toUtilization the to utilization
* @param time the time
* @return the energy
*/
public
double
getEnergyLinearInterpolation
(
double
fromUtilization
,
double
toUtilization
,
double
time
)
{
double
fromPower
=
getPower
(
fromUtilization
);
double
toPower
=
getPower
(
toUtilization
);
return
(
fromPower
+
(
toPower
-
fromPower
)
/
2
)
*
time
;
}
/**
* Sets the power model.
*
...
...
modules/cloudsim/src/test/java/org/cloudbus/cloudsim/power/PowerHostTest.java
View file @
f61914d1
...
...
@@ -9,6 +9,7 @@
package
org
.
cloudbus
.
cloudsim
.
power
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
fail
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -16,6 +17,7 @@ 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.Before
;
import
org.junit.Test
;
/**
...
...
@@ -27,13 +29,33 @@ 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
;
private
static
final
double
TIME
=
10
;
private
PowerHost
host
;
@Before
public
void
setUp
()
throws
Exception
{
List
<
Pe
>
peList
=
new
ArrayList
<
Pe
>();
peList
.
add
(
new
Pe
(
0
,
new
PeProvisionerSimple
(
MIPS
)));
host
=
new
PowerHost
(
0
,
null
,
null
,
0
,
peList
,
null
,
new
PowerModelLinear
(
MAX_POWER
,
STATIC_POWER_PERCENT
));
}
@Test
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
);
}
@Test
public
void
testGetEnergy
()
{
assertEquals
(
0
,
host
.
getEnergyLinearInterpolation
(
0
,
0
,
TIME
),
0
);
double
expectedEnergy
=
0
;
try
{
expectedEnergy
=
(
host
.
getPowerModel
().
getPower
(
0.2
)
+
(
host
.
getPowerModel
().
getPower
(
0.9
)
-
host
.
getPowerModel
().
getPower
(
0.2
))
/
2
)
*
TIME
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
fail
();
}
assertEquals
(
expectedEnergy
,
host
.
getEnergyLinearInterpolation
(
0.2
,
0.9
,
TIME
),
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