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. | |
| ~AutoTuner () | |
| Default destructor defined in .cpp as it's too big to be inlined. | |
| 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, bool isStartOfTuningPhase) |
| Pass live info on to all tuning strategies. | |
| bool | needsLiveInfo () const |
| Returns true if the AutoTuner needs live info. | |
| bool | needsDomainSimilarityStatistics () const |
| Returns true if the AutoTuner needs domain similarity statistics. | |
| bool | willRebuildNeighborLists () const |
| Returns whether rebuildNeighborLists() should be triggered in the next iteration. | |
| const Configuration & | getCurrentConfig () const |
| Get the currently selected configuration. | |
| Configuration | rejectConfig (const Configuration &rejectedConfig, bool indefinitely, size_t tuningPhase) |
| 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 (long tuningTime, size_t currentIteration) 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 sampleRebuild, long sampleTraverseParticles, bool neighborListRebuilt, size_t iteration, size_t tuningPhase) |
| Save the runtime of a given traversal. | |
| void | addDomainSimilarityStatistics (double pdBinDensityStdDev, double pdBinMaxDensity) |
| Adds domain similarity statistics to a vector of measurements, which can be smoothed for use in MPI Tuning to find similar domains. | |
| 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 | inLastTuningIteration () const |
| Indicates 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 (size_t tuningPhase) |
| Checks whether the current configuration performs so poorly that it shouldn't be resampled further within this tuning phase. | |
| bool | tuneConfiguration (size_t currentIteration, size_t tuningPhase, bool isStartOfTuningPhase) |
| Tune available algorithm configurations. | |
| void | setOptimalConfiguration (const Configuration &optimalConfig) |
| Pushes the provided config into the _configQueue and ends tuning immediately. | |
| const std::set< Configuration > & | getSearchSpace () const |
| Return the search space as a const reference. | |
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::addDomainSimilarityStatistics | ( | double | pdBinDensityStdDev, |
| double | pdBinMaxDensity | ||
| ) |
Adds domain similarity statistics to a vector of measurements, which can be smoothed for use in MPI Tuning to find similar domains.
| pdBinDensityStdDev | particle-dependent bin density standard deviation. See LiveInfo::gather for more information. |
| pdBinMaxDensity | particle-dependent bin maximum density. See LiveInfo::gather for more information. |
| void autopas::AutoTuner::addMeasurement | ( | long | sampleRebuild, |
| long | sampleTraverseParticles, | ||
| bool | neighborListRebuilt, | ||
| size_t | iteration, | ||
| size_t | tuningPhase | ||
| ) |
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.
| sampleRebuild | time or energy sample for rebuild part of the iteration. |
| sampleTraverseParticles | time or energy sample for traverse interaction part of the iteration. This includes computeInteraction and remainderTraversal call. |
| neighborListRebuilt | If the neighbor list as been rebuilt during the given time. |
| iteration | Current LogicHandler iteration. |
| tuningPhase | Current tuning phase number from the TuningManager |
| bool autopas::AutoTuner::canMeasureEnergy | ( | ) | const |
Returns whether the AutoTuner can take energy measurements.
| void autopas::AutoTuner::checkEarlyStoppingCondition | ( | size_t | tuningPhase | ) |
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.
| tuningPhase | Current tuning phase number. |
| 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.
| const std::set< Configuration > & autopas::AutoTuner::getSearchSpace | ( | ) | const |
Return the search space as a const reference.
| 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::initEnergy | ( | ) |
Initialize pmt sensor.
| bool autopas::AutoTuner::inLastTuningIteration | ( | ) | const |
Indicates 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 | ( | long | tuningTime, |
| size_t | currentIteration | ||
| ) | const |
After a tuning phase has finished, write the result to a file.
| tuningTime | Measured tuning time in nanoseconds. |
| currentIteration | Current LogicHandler iteration number. |
| bool autopas::AutoTuner::needsDomainSimilarityStatistics | ( | ) | const |
| bool autopas::AutoTuner::needsLiveInfo | ( | ) | const |
Move assignment operator.
| other |
| void autopas::AutoTuner::receiveLiveInfo | ( | const LiveInfo & | liveInfo, |
| bool | isStartOfTuningPhase | ||
| ) |
Pass live info on to all tuning strategies.
| liveInfo | |
| isStartOfTuningPhase | True, if the next iteration starts a new tuning phase. |
| Configuration autopas::AutoTuner::rejectConfig | ( | const Configuration & | rejectedConfig, |
| bool | indefinitely, | ||
| size_t | tuningPhase | ||
| ) |
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). |
| tuningPhase | Current tuning phase. |
| 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::setOptimalConfiguration | ( | const Configuration & | optimalConfig | ) |
Pushes the provided config into the _configQueue and ends tuning immediately.
Used by the TuningManager, when we want a different configuration than the one determined by one AutoTuner in isolation.
| optimalConfig | The configuration to be used from now on until the next tuning phase. |
| 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::tuneConfiguration | ( | size_t | currentIteration, |
| size_t | tuningPhase, | ||
| bool | isStartOfTuningPhase | ||
| ) |
Tune available algorithm configurations.
It is assumed this function is only called for relevant functors and that at least two configurations are allowed. When in tuning phase selects next config to test. At the end of the tuning phase select optimum. The function returns true if the selected config is not yet the optimum but something that should be sampled.
| currentIteration | Current LogicHandler iteration number. |
| tuningPhase | Current tuning phase number. |
| isStartOfTuningPhase | True if this is the start of a new tuning phase. |
| 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.