OpenLB 1.7
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS > Class Template Reference

Implementation of the Cell concept for vectorized collision operators. More...

#include <operator.h>

+ Collaboration diagram for olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >:

Public Types

using value_t = V
 
using descriptor_t = DESCRIPTOR
 

Public Member Functions

 Cell (ConcreteBlockLattice< T, DESCRIPTOR, Platform::CPU_SIMD > &lattice, std::size_t iCell, Mask< T > &mask)
 Load r/w fields into SIMD packs.
 
 ~Cell ()
 Store modified r/w fields back into lattice taking into account the mask.
 
V & operator[] (unsigned iPop)
 Return reference to iPop population pack.
 
template<typename FIELD >
auto getField () const
 Return pack-valued copy of FIELD.
 
template<typename FIELD >
void setField (FieldD< V, DESCRIPTOR, FIELD > &&value)
 Set compoents of FIELD from pack-valued vector.
 
template<typename FIELD >
std::enable_if_t< rw_fields::template contains< FIELD >(), FieldD< V, DESCRIPTOR, FIELD > & > getFieldPointer ()
 Return reference to pack-valued interim storage vector of r/w field.
 
template<typename FIELD >
std::enable_if_t<!rw_fields::template contains< FIELD >(), FieldD< V, DESCRIPTOR, FIELD > > getFieldPointer ()
 Return pack-valued copy of non r/w field.
 
template<typename FIELD >
std::enable_if_t< rw_fields::template contains< FIELD >(), V & > getFieldComponent (unsigned iD)
 Return reference to pack-valued interim storage component of r/w field.
 
template<typename FIELD >
std::enable_if_t<!rw_fields::template contains< FIELD >(), V > getFieldComponent (unsigned iD)
 Return pack-valued copy of non r/w field component.
 

Detailed Description

template<typename T, typename DESCRIPTOR, typename V, typename... RW_FIELDS>
class olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >

Implementation of the Cell concept for vectorized collision operators.

Any fields that are potentially changed by a specific collision operator must be declared as RW_FIELDS to mask any writeback operations.

Read-only fields require no special consideration.

Definition at line 109 of file operator.h.

Member Typedef Documentation

◆ descriptor_t

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
using olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::descriptor_t = DESCRIPTOR

Definition at line 125 of file operator.h.

◆ value_t

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
using olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::value_t = V

Definition at line 124 of file operator.h.

Constructor & Destructor Documentation

◆ Cell()

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::Cell ( ConcreteBlockLattice< T, DESCRIPTOR, Platform::CPU_SIMD > & lattice,
std::size_t iCell,
Mask< T > & mask )
inline

Load r/w fields into SIMD packs.

Definition at line 128 of file operator.h.

128 :
129 _lattice(lattice),
130 _iCell(iCell),
131 _mask(mask)
132 {
133 rw_fields::for_each([&](auto field) {
134 using FIELD = typename decltype(field)::type;
135 auto& array = _lattice.template getField<FIELD>();
136 auto& pack = std::get<(rw_fields::template index<FIELD>())>(_fields);
137 //meta::call_n_times<(DESCRIPTOR::template size<FIELD>())>([&](unsigned iD) {
138 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
139 pack[iD] = cpu::simd::Pack<T>(&array[iD][_iCell]);
140 }
141 });
142 }
std::enable_if_t< DESCRIPTOR::d==2, std::shared_ptr< SuperF2D< T > > > field(SuperLattice< T, DESCRIPTOR > &sLattice)
Returns external field functor.
static constexpr void for_each(F f)
Calls f for each type of TYPES by-value (in reversed order!)
Definition meta.h:331

References olb::meta::list< TYPES >::for_each().

+ Here is the call graph for this function:

◆ ~Cell()

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::~Cell ( )
inline

Store modified r/w fields back into lattice taking into account the mask.

Definition at line 145 of file operator.h.

146 {
147 rw_fields::for_each([&](auto field) {
148 using FIELD = typename decltype(field)::type;
149 auto& array = _lattice.template getField<FIELD>();
150 auto& pack = std::get<(rw_fields::template index<FIELD>())>(_fields);
151 //meta::call_n_times<(DESCRIPTOR::template size<FIELD>())>([&](unsigned iD) {
152 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
153 cpu::simd::maskstore(&array[iD][_iCell], _mask, pack[iD]);
154 }
155 });
156 }
void maskstore(T *target, Mask< T > mask, Pack< T > value)

References olb::meta::list< TYPES >::for_each(), and olb::cpu::simd::maskstore().

+ Here is the call graph for this function:

Member Function Documentation

◆ getField()

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
auto olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField ( ) const
inline

Return pack-valued copy of FIELD.

Definition at line 165 of file operator.h.

165 {
166 if constexpr (rw_fields::template contains<FIELD>()) {
167 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
168 return std::get<(rw_fields::template index<FIELD>())>(_fields)[0];
169 } else {
170 return std::get<(rw_fields::template index<FIELD>())>(_fields);
171 }
172 } else {
173 auto& fieldArray = _lattice.template getField<FIELD>();
174 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
175 return cpu::simd::Pack<T>(&fieldArray[0][_iCell]);
176 } else {
177 return FieldD<V,DESCRIPTOR,FIELD>([&](unsigned iD) {
178 return &fieldArray[iD][_iCell];
179 });
180 }
181 }
182 __builtin_unreachable();
183 }

◆ getFieldComponent() [1/2]

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
std::enable_if_t< rw_fields::template contains< FIELD >(), V & > olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getFieldComponent ( unsigned iD)
inline

Return reference to pack-valued interim storage component of r/w field.

Definition at line 215 of file operator.h.

215 {
216 return std::get<(rw_fields::template index<FIELD>())>(_fields)[iD];
217 }

◆ getFieldComponent() [2/2]

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
std::enable_if_t<!rw_fields::template contains< FIELD >(), V > olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getFieldComponent ( unsigned iD)
inline

Return pack-valued copy of non r/w field component.

Definition at line 222 of file operator.h.

222 {
223 return &_lattice.template getField<FIELD>()[iD][_iCell];
224 }

◆ getFieldPointer() [1/2]

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
std::enable_if_t< rw_fields::template contains< FIELD >(), FieldD< V, DESCRIPTOR, FIELD > & > olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getFieldPointer ( )
inline

Return reference to pack-valued interim storage vector of r/w field.

Definition at line 201 of file operator.h.

201 {
202 return std::get<(rw_fields::template index<FIELD>())>(_fields);
203 }

◆ getFieldPointer() [2/2]

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
std::enable_if_t<!rw_fields::template contains< FIELD >(), FieldD< V, DESCRIPTOR, FIELD > > olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getFieldPointer ( )
inline

Return pack-valued copy of non r/w field.

Definition at line 208 of file operator.h.

208 {
209 return getField<FIELD>();
210 }

◆ operator[]()

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
V & olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::operator[] ( unsigned iPop)
inline

Return reference to iPop population pack.

Definition at line 159 of file operator.h.

159 {
160 return std::get<(rw_fields::template index<descriptors::POPULATION>())>(_fields)[iPop];
161 }

◆ setField()

template<typename T , typename DESCRIPTOR , typename V , typename... RW_FIELDS>
template<typename FIELD >
void olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::setField ( FieldD< V, DESCRIPTOR, FIELD > && value)
inline

Set compoents of FIELD from pack-valued vector.

Definition at line 187 of file operator.h.

187 {
188 if constexpr (rw_fields::template contains<FIELD>()) {
189 std::get<(rw_fields::template index<FIELD>())>(_fields) = value;
190 } else {
191 auto& array = _lattice.template getField<FIELD>();
192 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
193 cpu::simd::maskstore(&array[iD][_iCell], _mask, value[iD]);
194 }
195 }
196 }
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96

References olb::cpu::simd::maskstore().

+ Here is the call graph for this function:

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