AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
autopas::AutoTuner Class Reference

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.
 
AutoTuneroperator= (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 TuningMetricOptiongetTuningMetric () 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 ConfigurationgetCurrentConfig () 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 EvidenceCollectiongetEvidenceCollection () 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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ AutoTuner()

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.

Parameters
tuningStrategiesVector of object implementing the modelling and exploration of a search space. Will be moved into the tuner.
searchSpaceAll possible configurations.
autoTunerInfoStruct containing more configuration information.
rebuildFrequencyThe number of iterations after which the neighbor lists are rebuilt.
outputSuffixSuffix for all output files produced by this object.

Member Function Documentation

◆ addHomogeneityAndMaxDensity()

void autopas::AutoTuner::addHomogeneityAndMaxDensity ( double  homogeneity,
double  maxDensity,
long  time 
)

Adds measurements of homogeneity and maximal density to the vector of measurements.

Parameters
homogeneity
maxDensity
timeTime it took to obtain these measurements.

◆ addMeasurement()

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.

Parameters
sample
neighborListRebuiltIf the neighbor list as been rebuilt during the given time.

◆ bumpIterationCounters()

void autopas::AutoTuner::bumpIterationCounters ( bool  needToWait = false)

Increase internal iteration counters by one.

Should be called at the end of an iteration.

Parameters
needToWaitIf tuner should wait for other tuners.

◆ canMeasureEnergy()

bool autopas::AutoTuner::canMeasureEnergy ( ) const

Returns whether the AutoTuner can take energy measurements.

Returns

◆ checkEarlyStoppingCondition()

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.

◆ forceRetune()

void autopas::AutoTuner::forceRetune ( )

Force the internal tuner to enter a new tuning phase upon the next call to computeInteractions().

◆ getConfigQueue()

const std::vector< Configuration > & autopas::AutoTuner::getConfigQueue ( ) const

Getter for the current queue of configurations.

Returns

◆ getCurrentConfig()

const Configuration & autopas::AutoTuner::getCurrentConfig ( ) const

Get the currently selected configuration.

Returns

◆ getEvidenceCollection()

const EvidenceCollection & autopas::AutoTuner::getEvidenceCollection ( ) const

Getter for the internal evidence collection.

Returns

◆ getNextConfig()

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.

Returns
Tuple<Next configuration to use, still tuning>.

◆ getTuningMetric()

const TuningMetricOption & autopas::AutoTuner::getTuningMetric ( ) const

Getter for the primary metric for tuning.

Returns

◆ getTuningStrategies()

const std::vector< std::unique_ptr< TuningStrategyInterface > > & autopas::AutoTuner::getTuningStrategies ( ) const

Get the list of tuning strategies that are used.

Returns

◆ inFirstTuningIteration()

bool autopas::AutoTuner::inFirstTuningIteration ( ) const

Indicate if the tuner is in the first iteration of a tuning phase.

Returns

◆ initEnergy()

bool autopas::AutoTuner::initEnergy ( )

Initialize pmt sensor.

Returns
True if energy measurements are enabled and possible.

◆ inLastTuningIteration()

bool autopas::AutoTuner::inLastTuningIteration ( ) const

Indicate if the tuner is in the last iteration of the tuning phase.

Returns

◆ inTuningPhase()

bool autopas::AutoTuner::inTuningPhase ( ) const

Indicate if the tuner considers itself currently in a tuning phase according to its internal counters.

Returns

◆ logTuningResult()

void autopas::AutoTuner::logTuningResult ( bool  tuningIteration,
long  tuningTime 
) const

After a tuning phase has finished, write the result to a file.

Parameters
tuningIteration
tuningTime

◆ needsHomogeneityAndMaxDensityBeforePrepare()

bool autopas::AutoTuner::needsHomogeneityAndMaxDensityBeforePrepare ( ) const

Indicator whether tuner needs homogeneity and max density information before the next call to prepareIteration().

Returns

◆ operator=()

AutoTuner & autopas::AutoTuner::operator= ( AutoTuner &&  other)
noexcept

Move assignment operator.

Parameters
other
Returns

◆ prepareIteration()

bool autopas::AutoTuner::prepareIteration ( )

Determines what live infos are needed and passes collected live info to the tuning strategies.

Note
The live info is not gathered here because then we would need the container.
Returns
Bool indicating if live Infos are needed before the next call to tune

◆ receiveLiveInfo()

void autopas::AutoTuner::receiveLiveInfo ( const LiveInfo liveInfo)

Pass live info on to all tuning strategies.

Parameters
liveInfo

◆ rejectConfig()

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.

Note
The applicability checking logic was moved out of the tuner because it needed the container, thus raising the compile complexity.
Parameters
rejectedConfig
indefinitelyWhether the given config should be completely removed from the search space (aka rejected indefinitely).
Returns
Tuple<Next configuration to use, still tuning>.

◆ resetEnergy()

bool autopas::AutoTuner::resetEnergy ( )

Reset the rapl meter to prepare for a new measurement.

Returns
True if energy measurements are possible on this system.

◆ sampleEnergy()

std::tuple< double, double, double, long > autopas::AutoTuner::sampleEnergy ( )

Take an energy measurement.

Returns
Tuple<PsysEnergy, PkgEnergy, RamEnergy, TotalEnergy>

◆ searchSpaceIsEmpty()

bool autopas::AutoTuner::searchSpaceIsEmpty ( ) const

Indicator function whether the search space has no configurations in it.

Returns

◆ searchSpaceIsTrivial()

bool autopas::AutoTuner::searchSpaceIsTrivial ( ) const

Indicator function whether the search space consists of exactly one configuration.

Returns

◆ setRebuildFrequency()

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.

Parameters
rebuildFrequencyCurrent rebuild frequency in this instance of autopas, used by autopas for weighing rebuild and non-rebuild iterations

◆ willRebuildNeighborLists()

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.

Returns
True if the current iteration counters indicate a rebuild in the next iteration due to a configuration change.

The documentation for this class was generated from the following files: