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
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interface -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringprotected longIteration count for calibrationprotected DegreeOfAccuracyEnumstatic final javax.measure.unit.Unit<AbstractDemandStrategy.Work> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractDemandStrategy(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 tablevoidconsume(double demand) Consume a resource according to its demand & processing rate(specified in initaliseStrategy) WARNING: initializeStrategy() has to be run firstbooleanChecks whether debug mode is enabled.voidstatic StringformatDuration(org.jscience.physics.amount.Amount<javax.measure.quantity.Duration> t) protected StringReturns the name of the file used to store the calibration table Filename depends on paramters of this classprotected FileQuery the calibration path from the properties of this objectabstract StringgetName()Template method to return the name of this strategyabstract ResourceTypeEnumTemplate method to return the real hardware resource type simulated by this strategybooleanChecks whether the strategy has a calibration table.voidinitializeStrategy(DegreeOfAccuracyEnum degree, double initProcessingRate) Initialize the strategy and perform necessary calibrationsvoidinitializeStrategy(DegreeOfAccuracyEnum degreeOfAccuracy, double processingRate, String calibrationPath) Initialize the strategy and perform necessary calibrationsprotected abstract voidrun(long load) Template method.voidsetCalibrationListener(ICalibrationListener listener) Sets the calibration listener that receives progress updates during the calibration.voidSets the calibration table.voidsetDebug(boolean enable) Enables or disables debug mode.voidsetProperties(Properties properties) Do not use default properties, but set properties externally.voidwatchConsume(double demand) Deprecated.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:IDemandStrategyInitialize the strategy and perform necessary calibrations- Specified by:
initializeStrategyin 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:IDemandStrategyInitialize the strategy and perform necessary calibrations- Specified by:
initializeStrategyin 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:IDemandStrategyDo not use default properties, but set properties externally.- Specified by:
setPropertiesin interfaceIDemandStrategy- See Also:
-
consume
public void consume(double demand) Description copied from interface:IDemandStrategyConsume a resource according to its demand & processing rate(specified in initaliseStrategy) WARNING: initializeStrategy() has to be run first- Specified by:
consumein 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:
getStrategysResourcein interfaceIDemandStrategy- Returns:
- The resource type we can simulate
- See Also:
-
getName
Template method to return the name of this strategy- Specified by:
getNamein 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:
ensureCalibrationExistsin 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:
calibratein interfaceIDemandStrategy- Returns:
- a calibration table containing the results of the calibration
-
setCalibrationListener
Description copied from interface:IDemandStrategySets the calibration listener that receives progress updates during the calibration.- Specified by:
setCalibrationListenerin interfaceIDemandStrategy- Parameters:
listener- the calibration listener to receive the updates
-
setCalibrationTable
Description copied from interface:IDemandStrategySets the calibration table.- Specified by:
setCalibrationTablein interfaceIDemandStrategy- Parameters:
table- the calibration table
-
hasCalibrationTable
public boolean hasCalibrationTable()Description copied from interface:IDemandStrategyChecks whether the strategy has a calibration table.- Specified by:
hasCalibrationTablein interfaceIDemandStrategy- Returns:
- true if the strategy has a calibration table, otherwise false
-
setDebug
public void setDebug(boolean enable) Description copied from interface:IDemandStrategyEnables or disables debug mode. When debug mode is enabled, the calibration returns dummy results instead of actually calibrating the strategy.- Specified by:
setDebugin interfaceIDemandStrategy- Parameters:
enable- true if debug mode should be enabled, otherwise false
-
debugEnabled
public boolean debugEnabled()Description copied from interface:IDemandStrategyChecks whether debug mode is enabled.- Specified by:
debugEnabledin 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)
-