OpenLB 1.8.1
Loading...
Searching...
No Matches
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 >
void setField (const 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 111 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 127 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 126 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 130 of file operator.h.

130 :
131 _lattice(lattice),
132 _iCell(iCell),
133 _mask(mask)
134 {
135 rw_fields::for_each([&](auto field) {
136 using FIELD = typename decltype(field)::type;
137 auto& array = _lattice.template getField<FIELD>();
138 auto& pack = std::get<(rw_fields::template index<FIELD>())>(_fields);
139 //meta::call_n_times<(DESCRIPTOR::template size<FIELD>())>([&](unsigned iD) {
140 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
141 pack[iD] = cpu::simd::Pack<T>(&array[iD][_iCell]);
142 }
143 });
144 }
auto getField() const
Return pack-valued copy of FIELD.
Definition operator.h:167
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(), and olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField().

+ 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 147 of file operator.h.

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

References olb::meta::list< TYPES >::for_each(), olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField(), 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 167 of file operator.h.

167 {
168 if constexpr (rw_fields::template contains<FIELD>()) {
169 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
170 return std::get<(rw_fields::template index<FIELD>())>(_fields)[0];
171 } else {
172 return std::get<(rw_fields::template index<FIELD>())>(_fields);
173 }
174 } else {
175 auto& fieldArray = _lattice.template getField<FIELD>();
176 if constexpr (DESCRIPTOR::template size<FIELD>() == 1) {
177 return cpu::simd::Pack<T>(&fieldArray[0][_iCell]);
178 } else {
179 return FieldD<V,DESCRIPTOR,FIELD>([&](unsigned iD) {
180 return &fieldArray[iD][_iCell];
181 });
182 }
183 }
184 __builtin_unreachable();
185 }
Vector< typename FIELD::template value_type< T >, DESCRIPTOR::template size< FIELD >() > FieldD
Vector storing a single field instance.
Definition vector.h:480

References olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ 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 230 of file operator.h.

230 {
231 return std::get<(rw_fields::template index<FIELD>())>(_fields)[iD];
232 }

◆ 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 237 of file operator.h.

237 {
238 return &_lattice.template getField<FIELD>()[iD][_iCell];
239 }

References olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField().

+ Here is the call graph for this function:

◆ 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 216 of file operator.h.

216 {
217 return std::get<(rw_fields::template index<FIELD>())>(_fields);
218 }

◆ 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 223 of file operator.h.

223 {
224 return getField<FIELD>();
225 }

References olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField().

+ Here is the call graph for this function:

◆ 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 161 of file operator.h.

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

◆ setField() [1/2]

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

Set compoents of FIELD from pack-valued vector.

Definition at line 202 of file operator.h.

202 {
203 if constexpr (rw_fields::template contains<FIELD>()) {
204 std::get<(rw_fields::template index<FIELD>())>(_fields) = value;
205 } else {
206 auto& array = _lattice.template getField<FIELD>();
207 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
208 cpu::simd::maskstore(&array[iD][_iCell], _mask, value[iD]);
209 }
210 }
211 }
typename std::integral_constant< TYPE, VALUE >::type value
Identity type to wrap non-type template arguments.
Definition meta.h:96

References olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField(), and olb::cpu::simd::maskstore().

+ Here is the call graph for this function:

◆ setField() [2/2]

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 189 of file operator.h.

189 {
190 if constexpr (rw_fields::template contains<FIELD>()) {
191 std::get<(rw_fields::template index<FIELD>())>(_fields) = value;
192 } else {
193 auto& array = _lattice.template getField<FIELD>();
194 for (unsigned iD=0; iD < DESCRIPTOR::template size<FIELD>(); ++iD) {
195 cpu::simd::maskstore(&array[iD][_iCell], _mask, value[iD]);
196 }
197 }
198 }

References olb::cpu::simd::Cell< T, DESCRIPTOR, V, RW_FIELDS >::getField(), and olb::cpu::simd::maskstore().

+ Here is the call graph for this function:

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