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

Determines the per-Newton3-state, per-direction-type particle-count threshold at which using a sorted cell-pair interaction path becomes faster than the unsorted path, separately for the AoS path (SortedCellView vs. More...

#include <SortingThresholdBenchmark.h>

Public Member Functions

 SortingThresholdBenchmark (size_t aosSortingThresholdDefault, size_t soaSortingThresholdDefault)
 Constructs a benchmark whose thresholds default to the given uniform values until/unless a benchmark run overwrites them.
 
std::shared_ptr< const SortingThresholdInfoInterfacegetSoAThreshold () const
 Return all per-Newton3-state, per-direction-type SoA sorting thresholds if hasRunSoA() is true, otherwise the uniform default passed to the constructor.
 
std::shared_ptr< const SortingThresholdInfoInterfacegetAoSThreshold () const
 Return all per-Newton3-state, per-direction-type AoS pair-sorting thresholds if hasRunAoS() is true, otherwise the uniform default passed to the constructor.
 
bool hasRunSoA () const
 Returns whether runSoABenchmark() has already been called.
 
bool hasRunAoS () const
 Returns whether runAoSBenchmark() has already been called.
 
template<class Functor_T , class Particle_T >
void runSoABenchmark (Functor_T &functor, const Particle_T &defaultParticle)
 Runs the micro-benchmark for the SoA sorting threshold, sweeping both Newton3 (and bidirectional for N3Off) states and all three direction types, and storing the resulting thresholds.
 
template<class Functor_T , class Particle_T >
void runAoSBenchmark (Functor_T &functor, const Particle_T &defaultParticle)
 Runs the micro-benchmark for the AoS sorting threshold, sweeping both Newton3 (and bidirectional for N3Off) states and all three direction types, and storing the resulting thresholds.
 

Detailed Description

Determines the per-Newton3-state, per-direction-type particle-count threshold at which using a sorted cell-pair interaction path becomes faster than the unsorted path, separately for the AoS path (SortedCellView vs.

the unsorted double loop) and the SoA path (SoAFunctorPairSorted vs. SoAFunctorPair).

The AoS half is benchmarked for any pairwise functor. The SoA half is only benchmarked for functors with Functor_T::supportsSoASorting == true (see runSoABenchmark()).

Stores one threshold per Newton3 state and direction type.

The search performed in runSearch() is deliberately biased towards a conservative (higher) threshold, to avoid noisy measurements influencing the threshold to be too low. A too low threshold would actively regress performance while a too high threshold would at worst still perform the same as baseline. One goal of these thresholds is to avoid any performance regression against the non sorted case.

Constructor & Destructor Documentation

◆ SortingThresholdBenchmark()

autopas::SortingThresholdBenchmark::SortingThresholdBenchmark ( size_t  aosSortingThresholdDefault,
size_t  soaSortingThresholdDefault 
)
inline

Constructs a benchmark whose thresholds default to the given uniform values until/unless a benchmark run overwrites them.

The defaults are stored as a SortingThresholdInfoSingle rather than a SortingThresholdInfo2B so that getAoSThreshold()/getSoAThreshold() are always safe to hand to either CellFunctor or CellFunctor3B.

Parameters
aosSortingThresholdDefaultUniform AoS threshold used before/without a benchmark run.
soaSortingThresholdDefaultUniform SoA threshold used before/without a benchmark run.

Member Function Documentation

◆ getAoSThreshold()

std::shared_ptr< const SortingThresholdInfoInterface > autopas::SortingThresholdBenchmark::getAoSThreshold ( ) const
inline

Return all per-Newton3-state, per-direction-type AoS pair-sorting thresholds if hasRunAoS() is true, otherwise the uniform default passed to the constructor.

Returns
Shared pointer to the internal threshold values.

◆ getSoAThreshold()

std::shared_ptr< const SortingThresholdInfoInterface > autopas::SortingThresholdBenchmark::getSoAThreshold ( ) const
inline

Return all per-Newton3-state, per-direction-type SoA sorting thresholds if hasRunSoA() is true, otherwise the uniform default passed to the constructor.

Returns
Shared pointer to the internal threshold values.

◆ hasRunAoS()

bool autopas::SortingThresholdBenchmark::hasRunAoS ( ) const
inline

Returns whether runAoSBenchmark() has already been called.

Returns
True if the AoS benchmark has run.

◆ hasRunSoA()

bool autopas::SortingThresholdBenchmark::hasRunSoA ( ) const
inline

Returns whether runSoABenchmark() has already been called.

Returns
True if the SoA benchmark has run.

◆ runAoSBenchmark()

template<class Functor_T , class Particle_T >
void autopas::SortingThresholdBenchmark::runAoSBenchmark ( Functor_T &  functor,
const Particle_T &  defaultParticle 
)
inline

Runs the micro-benchmark for the AoS sorting threshold, sweeping both Newton3 (and bidirectional for N3Off) states and all three direction types, and storing the resulting thresholds.

Sets hasRunAoS() to true.

Template Parameters
Functor_TPairwise functor type.
Particle_TParticle type.
Parameters
functorFunctor instance used to drive the benchmark cells.
defaultParticleTemplate particle (e.g. sampled from the particle container) whose non-positional properties are copied onto every particle generated for the benchmark cells.

◆ runSoABenchmark()

template<class Functor_T , class Particle_T >
void autopas::SortingThresholdBenchmark::runSoABenchmark ( Functor_T &  functor,
const Particle_T &  defaultParticle 
)
inline

Runs the micro-benchmark for the SoA sorting threshold, sweeping both Newton3 (and bidirectional for N3Off) states and all three direction types, and storing the resulting thresholds.

Sets hasRunSoA() to true. Callers should only instantiate this for functors with Functor_T::supportsSoASorting == true.

Template Parameters
Functor_TPairwise functor type.
Particle_TParticle type.
Parameters
functorFunctor instance used to drive the benchmark cells.
defaultParticleTemplate particle (e.g. sampled from the particle container) whose non-positional properties are copied onto every particle generated for the benchmark cells.

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