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
public abstract class AbstractDemandStrategy extends Object implements IDemandStrategy
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
Nested Classes Modifier and Type Class Description static interface
AbstractDemandStrategy.ProcessingRate
static interface
AbstractDemandStrategy.Work
-
Field Summary
Fields Modifier and Type Field Description static String
CALIBRATION_PATH_CONFIG_KEY
protected long
defaultIterationCount
Iteration count for calibrationprotected DegreeOfAccuracyEnum
degreeOfAccuracy
static javax.measure.unit.Unit<AbstractDemandStrategy.Work>
WORKUNITS
-
Constructor Summary
Constructors Constructor Description AbstractDemandStrategy(int low, int medium, int high, int iterationCount, int warmups)
Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description CalibrationTable
calibrate()
Create 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
debugEnabled()
Checks whether debug mode is enabled.void
ensureCalibrationExists()
static String
formatDuration(org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> t)
protected String
getCalibrationFileName()
Returns the name of the file used to store the calibration table Filename depends on paramters of this classprotected File
getCalibrationPath()
Query the calibration path from the properties of this objectabstract String
getName()
Template method to return the name of this strategyabstract ResourceTypeEnum
getStrategysResource()
Template method to return the real hardware resource type simulated by this strategyboolean
hasCalibrationTable()
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
setCalibrationTable(CalibrationTable table)
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 Detail
-
WORKUNITS
public static final javax.measure.unit.Unit<AbstractDemandStrategy.Work> WORKUNITS
-
CALIBRATION_PATH_CONFIG_KEY
public static final String CALIBRATION_PATH_CONFIG_KEY
- See Also:
- Constant Field Values
-
defaultIterationCount
protected long defaultIterationCount
Iteration count for calibration
-
degreeOfAccuracy
protected DegreeOfAccuracyEnum degreeOfAccuracy
-
-
Constructor Detail
-
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 Detail
-
initializeStrategy
public void initializeStrategy(DegreeOfAccuracyEnum degree, double initProcessingRate)
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:
IDemandStrategy.initializeStrategy(DegreeOfAccuracyEnum, double)
-
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:
IDemandStrategy.initializeStrategy(DegreeOfAccuracyEnum, double, String)
-
setProperties
public void setProperties(Properties properties)
Description copied from interface:IDemandStrategy
Do not use default properties, but set properties externally.- Specified by:
setProperties
in interfaceIDemandStrategy
- See Also:
IDemandStrategy.setProperties(Properties)
-
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:
IDemandStrategy.consume(double)
-
getStrategysResource
public abstract ResourceTypeEnum 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:
IDemandStrategy.getStrategysResource()
-
getName
public abstract String 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:
IDemandStrategy.getName()
-
getCalibrationFileName
protected String 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
protected File 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
public CalibrationTable 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
public void setCalibrationListener(ICalibrationListener listener)
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
public void setCalibrationTable(CalibrationTable table)
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 public void watchConsume(double demand)
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)
-
-