Class AbstractDemandStrategy
java.lang.Object
org.palladiosimulator.protocom.resourcestrategies.activeresource.AbstractDemandStrategy
- All Implemented Interfaces:
IDemandStrategy
- Direct Known Subclasses:
CalculatePrimesDemand
,CountNumbersDemand
,FFTDemand
,FibonacciDemand
,MandelbrotDemand
,ReadLargeChunksDemand
,SortArrayDemand
,VoidDemand
,WaitDemand
Abstract superclass of all active demand strategies.
c.f.: Steffen Becker, Tobias Dencker, and Jens Happe. Model-Driven Generation of Performance
Prototypes. In Performance Evaluation: Metrics, Models and Benchmarks (SIPEW 2008), volume 5119
of Lecture Notes in Computer Science, pages 79-98. Springer-Verlag Berlin Heidelberg, 2008.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
static interface
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
protected long
Iteration count for calibrationprotected DegreeOfAccuracyEnum
static final javax.measure.unit.Unit<AbstractDemandStrategy.Work>
-
Constructor Summary
ConstructorDescriptionAbstractDemandStrategy
(int low, int medium, int high, int iterationCount, int warmups) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionCreate a new calibration table for this host by measuring the execution times of our algorithm and creating an according calibration tablevoid
consume
(double demand) Consume a resource according to its demand & processing rate(specified in initaliseStrategy) WARNING: initializeStrategy() has to be run firstboolean
Checks whether debug mode is enabled.void
static String
formatDuration
(org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> t) protected String
Returns the name of the file used to store the calibration table Filename depends on paramters of this classprotected File
Query the calibration path from the properties of this objectabstract String
getName()
Template method to return the name of this strategyabstract ResourceTypeEnum
Template method to return the real hardware resource type simulated by this strategyboolean
Checks whether the strategy has a calibration table.void
initializeStrategy
(DegreeOfAccuracyEnum degree, double initProcessingRate) Initialize the strategy and perform necessary calibrationsvoid
initializeStrategy
(DegreeOfAccuracyEnum degreeOfAccuracy, double processingRate, String calibrationPath) Initialize the strategy and perform necessary calibrationsprotected abstract void
run
(long load) Template method.void
setCalibrationListener
(ICalibrationListener listener) Sets the calibration listener that receives progress updates during the calibration.void
Sets the calibration table.void
setDebug
(boolean enable) Enables or disables debug mode.void
setProperties
(Properties properties) Do not use default properties, but set properties externally.void
watchConsume
(double demand) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.palladiosimulator.protocom.resourcestrategies.activeresource.IDemandStrategy
cleanup
-
Field Details
-
WORKUNITS
-
CALIBRATION_PATH_CONFIG_KEY
- See Also:
-
defaultIterationCount
protected long defaultIterationCountIteration count for calibration -
degreeOfAccuracy
-
-
Constructor Details
-
AbstractDemandStrategy
public AbstractDemandStrategy(int low, int medium, int high, int iterationCount, int warmups) Constructor. Configures a demand strategy with low, medium and high modifier, as well as number of standard and warm-up cycles- Parameters:
low
- accuracy modifier for low precision calibrationmedium
- accuracy modifier for medium precision calibrationhigh
- accuracy modifier for high precision calibrationiterationCount
-warmups
-
-
-
Method Details
-
initializeStrategy
Description copied from interface:IDemandStrategy
Initialize the strategy and perform necessary calibrations- Specified by:
initializeStrategy
in interfaceIDemandStrategy
- Parameters:
degree
- The degree of accuracy used for calibration: HIGH, MEDIUM, LOW WARNING: The use of HIGH can result in a significant increase in the execution timeinitProcessingRate
- [units/seconds] The rate to initialize with (demand/processingRate = time)- See Also:
-
initializeStrategy
public void initializeStrategy(DegreeOfAccuracyEnum degreeOfAccuracy, double processingRate, String calibrationPath) Description copied from interface:IDemandStrategy
Initialize the strategy and perform necessary calibrations- Specified by:
initializeStrategy
in interfaceIDemandStrategy
- Parameters:
degreeOfAccuracy
- The degree of accuracy used for calibration: HIGH, MEDIUM, LOW WARNING: The use of HIGH can result in a significant increase in the execution timeprocessingRate
- [units/seconds] The rate to initialize with (demand/processingRate = time)calibrationPath
- Path where the calibration is stored- See Also:
-
setProperties
Description copied from interface:IDemandStrategy
Do not use default properties, but set properties externally.- Specified by:
setProperties
in interfaceIDemandStrategy
- See Also:
-
consume
public void consume(double demand) Description copied from interface:IDemandStrategy
Consume a resource according to its demand & processing rate(specified in initaliseStrategy) WARNING: initializeStrategy() has to be run first- Specified by:
consume
in interfaceIDemandStrategy
- Parameters:
demand
- [units] The demand to consume- See Also:
-
getStrategysResource
Template method to return the real hardware resource type simulated by this strategy- Specified by:
getStrategysResource
in interfaceIDemandStrategy
- Returns:
- The resource type we can simulate
- See Also:
-
getName
Template method to return the name of this strategy- Specified by:
getName
in interfaceIDemandStrategy
- Returns:
- a string containing the name of the strategy
- See Also:
-
getCalibrationFileName
Returns the name of the file used to store the calibration table Filename depends on paramters of this class- Returns:
- The calibration table file name
-
getCalibrationPath
Query the calibration path from the properties of this object- Returns:
- The file system path used to load and store the calibration data, or the current working directory if it is not set
-
run
protected abstract void run(long load) Template method. This starts running the strategy with the parameter load- Parameters:
load
- Complexity parameter. Algorithm should take longer if parameter is larger, i.e., ideally run(a) < run(b) <==> a < b
-
ensureCalibrationExists
public void ensureCalibrationExists()- Specified by:
ensureCalibrationExists
in interfaceIDemandStrategy
-
calibrate
Create a new calibration table for this host by measuring the execution times of our algorithm and creating an according calibration table- Specified by:
calibrate
in interfaceIDemandStrategy
- Returns:
- a calibration table containing the results of the calibration
-
setCalibrationListener
Description copied from interface:IDemandStrategy
Sets the calibration listener that receives progress updates during the calibration.- Specified by:
setCalibrationListener
in interfaceIDemandStrategy
- Parameters:
listener
- the calibration listener to receive the updates
-
setCalibrationTable
Description copied from interface:IDemandStrategy
Sets the calibration table.- Specified by:
setCalibrationTable
in interfaceIDemandStrategy
- Parameters:
table
- the calibration table
-
hasCalibrationTable
public boolean hasCalibrationTable()Description copied from interface:IDemandStrategy
Checks whether the strategy has a calibration table.- Specified by:
hasCalibrationTable
in interfaceIDemandStrategy
- Returns:
- true if the strategy has a calibration table, otherwise false
-
setDebug
public void setDebug(boolean enable) Description copied from interface:IDemandStrategy
Enables or disables debug mode. When debug mode is enabled, the calibration returns dummy results instead of actually calibrating the strategy.- Specified by:
setDebug
in interfaceIDemandStrategy
- Parameters:
enable
- true if debug mode should be enabled, otherwise false
-
debugEnabled
public boolean debugEnabled()Description copied from interface:IDemandStrategy
Checks whether debug mode is enabled.- Specified by:
debugEnabled
in interfaceIDemandStrategy
- Returns:
- true if debug mode is enabled, otherwise false
-
watchConsume
Deprecated.Consumes demands (only used for testing purpose!)- Parameters:
demand
-
-
formatDuration
public static String formatDuration(org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> t)
-