This class manages all logic related to the auto tuning mechanic. More...
#include <AutoTuner.h>
Public Types | |
using | TuningStrategiesListType = std::vector< std::unique_ptr< TuningStrategyInterface > > |
Type for the member holding all tuning strategies. | |
using | SearchSpaceType = std::set< Configuration > |
Type for the search space holding all possible configurations. | |
Public Member Functions | |
AutoTuner (TuningStrategiesListType &tuningStrategies, const SearchSpaceType &searchSpace, const AutoTunerInfo &autoTunerInfo, unsigned int rebuildFrequency, const std::string &outputSuffix) | |
Constructor for the AutoTuner that generates all configurations from the given options. | |
AutoTuner & | operator= (AutoTuner &&other) noexcept |
Move assignment operator. | |
void | forceRetune () |
Force the internal tuner to enter a new tuning phase upon the next call to computeInteractions(). | |
const TuningMetricOption & | getTuningMetric () const |
Getter for the primary metric for tuning. | |
void | receiveLiveInfo (const LiveInfo &liveInfo) |
Pass live info on to all tuning strategies. | |
bool | needsHomogeneityAndMaxDensityBeforePrepare () const |
Indicator whether tuner needs homogeneity and max density information before the next call to prepareIteration(). | |
bool | prepareIteration () |
Determines what live infos are needed and passes collected live info to the tuning strategies. | |
void | bumpIterationCounters (bool needToWait=false) |
Increase internal iteration counters by one. | |
bool | willRebuildNeighborLists () const |
Returns whether rebuildNeighborLists() should be triggered in the next iteration. | |
const Configuration & | getCurrentConfig () const |
Get the currently selected configuration. | |
std::tuple< Configuration, bool > | getNextConfig () |
Ask the tuner for the next configuration to use. | |
std::tuple< Configuration, bool > | rejectConfig (const Configuration &rejectedConfig, bool indefinitely) |
Tell the tuner that the given config is not applicable. | |
bool | searchSpaceIsTrivial () const |
Indicator function whether the search space consists of exactly one configuration. | |
bool | searchSpaceIsEmpty () const |
Indicator function whether the search space has no configurations in it. | |
void | logTuningResult (bool tuningIteration, long tuningTime) const |
After a tuning phase has finished, write the result to a file. | |
bool | initEnergy () |
Initialize pmt sensor. | |
bool | resetEnergy () |
Reset the rapl meter to prepare for a new measurement. | |
std::tuple< double, double, double, long > | sampleEnergy () |
Take an energy measurement. | |
void | addMeasurement (long sample, bool neighborListRebuilt) |
Save the runtime of a given traversal. | |
void | addHomogeneityAndMaxDensity (double homogeneity, double maxDensity, long time) |
Adds measurements of homogeneity and maximal density to the vector of measurements. | |
const std::vector< Configuration > & | getConfigQueue () const |
Getter for the current queue of configurations. | |
const std::vector< std::unique_ptr< TuningStrategyInterface > > & | getTuningStrategies () const |
Get the list of tuning strategies that are used. | |
bool | inTuningPhase () const |
Indicate if the tuner considers itself currently in a tuning phase according to its internal counters. | |
bool | inFirstTuningIteration () const |
Indicate if the tuner is in the first iteration of a tuning phase. | |
bool | inLastTuningIteration () const |
Indicate if the tuner is in the last iteration of the tuning phase. | |
const EvidenceCollection & | getEvidenceCollection () const |
Getter for the internal evidence collection. | |
bool | canMeasureEnergy () const |
Returns whether the AutoTuner can take energy measurements. | |
void | setRebuildFrequency (double rebuildFrequency) |
Sets the _rebuildFrequency. | |
void | checkEarlyStoppingCondition () |
Checks whether the current configuration performs so poorly that it shouldn't be resampled further within this tuning phase. | |
This class manages all logic related to the auto tuning mechanic.
This involves:
The tuner can be in one of two states. If it currently should look for a new optimum, it is in the so-called tuning phase. During a tuning phase, for each Configuration, multiple measurements can be taken, which are called samples. To reduce noise, the samples for one configuration are then condensed to one value for the current tuning phase, called evidence. The evidences are handed on to a tuningStrategy, which selects a) what Configuration to test next and b) which configuration is the best in this tuning phase. If it should not look for a new optimum it is not in a tuning phase.
autopas::AutoTuner::AutoTuner | ( | TuningStrategiesListType & | tuningStrategies, |
const SearchSpaceType & | searchSpace, | ||
const AutoTunerInfo & | autoTunerInfo, | ||
unsigned int | rebuildFrequency, | ||
const std::string & | outputSuffix | ||
) |
Constructor for the AutoTuner that generates all configurations from the given options.
tuningStrategies | Vector of object implementing the modelling and exploration of a search space. Will be moved into the tuner. |
searchSpace | All possible configurations. |
autoTunerInfo | Struct containing more configuration information. |
rebuildFrequency | The number of iterations after which the neighbor lists are rebuilt. |
outputSuffix | Suffix for all output files produced by this object. |
void autopas::AutoTuner::addHomogeneityAndMaxDensity | ( | double | homogeneity, |
double | maxDensity, | ||
long | time | ||
) |
Adds measurements of homogeneity and maximal density to the vector of measurements.
homogeneity | |
maxDensity | |
time | Time it took to obtain these measurements. |
void autopas::AutoTuner::addMeasurement | ( | long | sample, |
bool | neighborListRebuilt | ||
) |
Save the runtime of a given traversal.
Samples are collected and reduced to one single value according to _selectorStrategy. Only then the value is passed on to the tuning strategy. This function expects that samples of the same configuration are taken consecutively. The sample argument is a long because std::chrono::duration::count returns a long.
sample | |
neighborListRebuilt | If the neighbor list as been rebuilt during the given time. |
void autopas::AutoTuner::bumpIterationCounters | ( | bool | needToWait = false | ) |
Increase internal iteration counters by one.
Should be called at the end of an iteration.
needToWait | If tuner should wait for other tuners. |
bool autopas::AutoTuner::canMeasureEnergy | ( | ) | const |
Returns whether the AutoTuner can take energy measurements.
void autopas::AutoTuner::checkEarlyStoppingCondition | ( | ) |
Checks whether the current configuration performs so poorly that it shouldn't be resampled further within this tuning phase.
If the currently sampled configuration is worse than the current best configuration by more than the earlyStoppingFactor factor, it will not be sampled again this tuning phase. Uses the _estimateRuntimeFromSamples() function to estimate the runtimes.
void autopas::AutoTuner::forceRetune | ( | ) |
Force the internal tuner to enter a new tuning phase upon the next call to computeInteractions().
const std::vector< Configuration > & autopas::AutoTuner::getConfigQueue | ( | ) | const |
Getter for the current queue of configurations.
const Configuration & autopas::AutoTuner::getCurrentConfig | ( | ) | const |
Get the currently selected configuration.
const EvidenceCollection & autopas::AutoTuner::getEvidenceCollection | ( | ) | const |
Getter for the internal evidence collection.
std::tuple< Configuration, bool > autopas::AutoTuner::getNextConfig | ( | ) |
Ask the tuner for the next configuration to use.
This either returns the already selected config or triggers a step of the tuning process.
const TuningMetricOption & autopas::AutoTuner::getTuningMetric | ( | ) | const |
Getter for the primary metric for tuning.
const std::vector< std::unique_ptr< TuningStrategyInterface > > & autopas::AutoTuner::getTuningStrategies | ( | ) | const |
Get the list of tuning strategies that are used.
bool autopas::AutoTuner::inFirstTuningIteration | ( | ) | const |
Indicate if the tuner is in the first iteration of a tuning phase.
bool autopas::AutoTuner::initEnergy | ( | ) |
Initialize pmt sensor.
bool autopas::AutoTuner::inLastTuningIteration | ( | ) | const |
Indicate if the tuner is in the last iteration of the tuning phase.
bool autopas::AutoTuner::inTuningPhase | ( | ) | const |
Indicate if the tuner considers itself currently in a tuning phase according to its internal counters.
void autopas::AutoTuner::logTuningResult | ( | bool | tuningIteration, |
long | tuningTime | ||
) | const |
After a tuning phase has finished, write the result to a file.
tuningIteration | |
tuningTime |
bool autopas::AutoTuner::needsHomogeneityAndMaxDensityBeforePrepare | ( | ) | const |
Indicator whether tuner needs homogeneity and max density information before the next call to prepareIteration().
Move assignment operator.
other |
bool autopas::AutoTuner::prepareIteration | ( | ) |
Determines what live infos are needed and passes collected live info to the tuning strategies.
void autopas::AutoTuner::receiveLiveInfo | ( | const LiveInfo & | liveInfo | ) |
Pass live info on to all tuning strategies.
liveInfo |
std::tuple< Configuration, bool > autopas::AutoTuner::rejectConfig | ( | const Configuration & | rejectedConfig, |
bool | indefinitely | ||
) |
Tell the tuner that the given config is not applicable.
Since this operation might change the suggestion what configuration to try next, this next suggestion is returned.
rejectedConfig | |
indefinitely | Whether the given config should be completely removed from the search space (aka rejected indefinitely). |
bool autopas::AutoTuner::resetEnergy | ( | ) |
Reset the rapl meter to prepare for a new measurement.
std::tuple< double, double, double, long > autopas::AutoTuner::sampleEnergy | ( | ) |
Take an energy measurement.
bool autopas::AutoTuner::searchSpaceIsEmpty | ( | ) | const |
Indicator function whether the search space has no configurations in it.
bool autopas::AutoTuner::searchSpaceIsTrivial | ( | ) | const |
Indicator function whether the search space consists of exactly one configuration.
void autopas::AutoTuner::setRebuildFrequency | ( | double | rebuildFrequency | ) |
Sets the _rebuildFrequency.
This is the average number of iterations per rebuild. This is used to dynamically change the _rebuildFrequency based on estimate in case of dynamic containers.
rebuildFrequency | Current rebuild frequency in this instance of autopas, used by autopas for weighing rebuild and non-rebuild iterations |
bool autopas::AutoTuner::willRebuildNeighborLists | ( | ) | const |
Returns whether rebuildNeighborLists() should be triggered in the next iteration.
This indicates a configuration change. In the non-tuning phase, the rebuildNeighborLists() is triggered in LogicHandler.