39template <
class Particle_T,
class CRTP_T>
55 explicit Functor(
double cutoff) : _cutoff(cutoff){};
77 constexpr static std::array<typename Particle_T::AttributeNames, 0>
getNeededAttr() {
78 return std::array<typename Particle_T::AttributeNames, 0>{};
86 constexpr static std::array<typename Particle_T::AttributeNames, 0>
getNeededAttr(std::false_type) {
87 return Functor_T::getNeededAttr();
95 constexpr static std::array<typename Particle_T::AttributeNames, 0>
getComputedAttr() {
96 return std::array<typename Particle_T::AttributeNames, 0>{};
111 template <
class ParticleCell>
113 SoALoaderImpl(cell, soa, offset, skipSoAResize, std::make_index_sequence<Functor_T::getNeededAttr().size()>{});
125 template <
typename ParticleCell>
127 SoAExtractorImpl(cell, soa, offset, std::make_index_sequence<Functor_T::getComputedAttr().size()>{});
168 [[nodiscard]]
double getCutoff()
const {
return _cutoff; }
177 [[nodiscard]]
virtual size_t getNumFLOPs()
const {
return std::numeric_limits<size_t>::max(); }
187 [[nodiscard]]
virtual double getHitRate()
const {
return std::numeric_limits<double>::quiet_NaN(); }
202 template <
typename cell_t, std::size_t... I>
204 std::index_sequence<I...>) {
205 if (not skipSoAResize) {
209 if (cell.isEmpty())
return;
216 [[maybe_unused]]
auto const pointer = std::make_tuple(soa.template begin<Functor_T::getNeededAttr()[I]>()...);
218 auto cellIter = cell.begin();
220 for (
size_t i = offset; cellIter != cell.end(); ++cellIter, ++i) {
228 ((std::get<I>(pointer)[i] = cellIter->template get<Functor_T::getNeededAttr()[I]>()), ...);
240 template <
typename cell_t, std::size_t... I>
242 if (cell.isEmpty())
return;
249 [[maybe_unused]]
auto const pointer = std::make_tuple(soa.template begin<Functor_T::getComputedAttr()[I]>()...);
251 auto cellIter = cell.begin();
253 for (
size_t i = offset; cellIter != cell.end(); ++cellIter, ++i) {
262 (cellIter->template set<Functor_T::getComputedAttr()[I]>(std::get<I>(pointer)[i]), ...);
Functor base class.
Definition: Functor.h:40
void SoALoader(ParticleCell &cell, SoA< SoAArraysType > &soa, size_t offset, bool skipSoAResize)
Copies the AoS data of the given cell in the given soa.
Definition: Functor.h:112
virtual size_t getNumFLOPs() const
Get the number of FLOPs.
Definition: Functor.h:177
CRTP_T Functor_T
Make the Implementation type template publicly available.
Definition: Functor.h:50
virtual bool allowsNewton3()=0
Specifies whether the functor is capable of Newton3-like functors.
void SoAExtractor(ParticleCell &cell, SoA< SoAArraysType > &soa, size_t offset)
Copies the data stored in the soa back into the cell.
Definition: Functor.h:126
virtual void initTraversal()
This function is called at the start of each traversal.
Definition: Functor.h:63
virtual bool allowsNonNewton3()=0
Specifies whether the functor is capable of non-Newton3-like functors.
virtual void endTraversal(bool newton3)
This function is called at the end of each traversal.
Definition: Functor.h:70
double getCutoff() const
Getter for the functor's cutoff.
Definition: Functor.h:168
virtual bool isRelevantForTuning()=0
Specifies whether the functor should be considered for the auto-tuning process.
virtual std::string getName()=0
Returns name of functor.
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getNeededAttr(std::false_type)
Get attributes needed for computation without N3 optimization.
Definition: Functor.h:86
virtual double getHitRate() const
Get the hit rate.
Definition: Functor.h:187
typename Particle_T::SoAArraysType SoAArraysType
Structure of the SoAs defined by the particle.
Definition: Functor.h:45
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getNeededAttr()
Get attributes needed for computation.
Definition: Functor.h:77
static constexpr std::array< typename Particle_T::AttributeNames, 0 > getComputedAttr()
Get attributes computed by this functor.
Definition: Functor.h:95
Functor(double cutoff)
Constructor.
Definition: Functor.h:55
Class for Cells of Particles.
Definition: ParticleCell.h:51
Structur of the array class.
Definition: SoA.h:28
void resizeArrays(size_t length)
Resizes all Vectors to the given length.
Definition: SoA.h:45
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
FunctorN3Modes
Newton 3 modes for the Functor.
Definition: Functor.h:22