12#ifndef ARCANE_CORE_SIMDITEM_H
13#define ARCANE_CORE_SIMDITEM_H
22#ifndef ARCANE_SIMD_BENCH
42template <
typename ItemType>
78 typedef SimdInfo::SimdInt32IndexType SimdIndexType;
86 ARCANE_DEPRECATED_REASON(
"Y2022: Use another constructor")
87 SimdItemBase(const ItemInternalPtr* items, const SimdIndexType* ids)
88 : m_simd_local_ids(*ids)
95 : m_simd_local_ids(*ids)
96 , m_shared_info(shared_info)
102 ARCANE_DEPRECATED_REASON(
"Y2022: Use method SimdItem::item() instead")
105 ARCANE_DEPRECATED_REASON(
"Y2022: Use method SimdItem::operator[]() instead")
106 ItemInternal* operator[](
Integer si)
const {
return m_shared_info->m_items_internal[localId(si)]; }
109 const SimdIndexType& ARCANE_RESTRICT
simdLocalIds()
const {
return m_simd_local_ids; }
119 SimdIndexType m_simd_local_ids;
126class SimdItemDirectBase
134 ARCANE_DEPRECATED_REASON(
"Y2022: Use another constructor")
135 SimdItemDirectBase(
const ItemInternalPtr* items,
Int32 base_local_id,
Integer nb_valid)
136 : m_base_local_id(base_local_id)
137 , m_nb_valid(nb_valid)
138 , m_shared_info(ItemInternalCompatibility::_getSharedInfo(items, nb_valid))
144 : m_base_local_id(base_local_id)
145 , m_nb_valid(nb_valid)
146 , m_shared_info(shared_info)
150 SimdItemDirectBase(
Int32 base_local_id,
Integer nb_valid,
const ItemInternalPtr* items)
151 : m_base_local_id(base_local_id)
152 , m_nb_valid(nb_valid)
153 , m_shared_info(ItemInternalCompatibility::_getSharedInfo(items, nb_valid))
166 Int32 m_base_local_id;
180template <
typename ItemType>
185 typedef SimdInfo::SimdInt32IndexType SimdIndexType;
189 SimdItemIndexT(
const SimdIndexType& ARCANE_RESTRICT local_ids)
190 : m_local_ids(local_ids)
192 SimdItemIndexT(
const SimdIndexType* ARCANE_RESTRICT local_ids)
193 : m_local_ids(*local_ids)
199 const SimdIndexType& ARCANE_RESTRICT
simdLocalIds()
const {
return m_local_ids; }
203 const SimdIndexType& ARCANE_RESTRICT m_local_ids;
212template <
typename ItemType>
213class SimdItemDirectIndexT
217 SimdItemDirectIndexT(
Int32 base_local_id)
218 : m_base_local_id(base_local_id)
223 inline Int32 baseLocalId()
const {
return m_base_local_id; }
227 Int32 m_base_local_id;
242 ARCANE_DEPRECATED_REASON(
"Y2022: Use another constructor")
243 SimdItem(
const ItemInternalPtr* items,
const SimdInfo::SimdInt32IndexType* ids)
244 :
SimdItemBase(ItemInternalCompatibility::_getSharedInfo(items, 1), ids)
249 SimdItem(
ItemSharedInfo* shared_info,
const SimdInfo::SimdInt32IndexType* ids)
269template <
typename ItemType>
282 ARCANE_DEPRECATED_REASON(
"Y2022: Use another constructor")
283 SimdItemT(
const ItemInternalPtr* items,
const SimdInfo::SimdInt32IndexType* ids)
284 : SimdItem(items,ids) { }
289 SimdItemT(
ItemSharedInfo* shared_info,
const SimdInfo::SimdInt32IndexType* ids)
290 : SimdItem(shared_info, ids)
298 return ItemType(
localId(si), m_shared_info);
304 return ItemType(
localId(si), m_shared_info);
320template <
typename ItemType>
322:
public SimdItemDirectBase
332 ARCANE_DEPRECATED_REASON(
"Y2022: Use another constructor")
333 SimdItemDirectT(
const ItemInternalPtr* items,
Int32 base_local_id,
Integer nb_valid)
334 : SimdItemDirectBase(base_local_id, nb_valid, items)
340 : SimdItemDirectBase(shared_info, base_local_id, nb_valid)
359template <
typename DataType>
362 typedef typename SimdTypeTraits<DataType>::SimdType SimdType;
366 SimdSetter(DataType* ARCANE_RESTRICT _data,
367 const SimdInfo::SimdInt32IndexType& ARCANE_RESTRICT _indexes)
375 void operator=(
const SimdType& vr)
379 void operator=(
const DataType& v)
387 const SimdInfo::SimdInt32IndexType& ARCANE_RESTRICT idx;
388 DataType* ARCANE_RESTRICT m_data;
398template <
typename DataType>
399class SimdDirectSetter
401 typedef typename SimdTypeTraits<DataType>::SimdType SimdType;
405 SimdDirectSetter(DataType* ARCANE_RESTRICT _data)
411 void operator=(
const SimdType& vr)
418 DataType* ARCANE_RESTRICT m_data;
431class ARCANE_CORE_EXPORT SimdItemEnumeratorBase
432:
public SimdEnumeratorBase
440 typedef SimdInfo::SimdInt32IndexType SimdIndexType;
449 SimdItemEnumeratorBase() =
default;
453 : SimdEnumeratorBase(view.
localIds())
454 , m_shared_info(view.m_shared_info)
458 : SimdEnumeratorBase(rhs.m_view.m_local_ids, rhs.
count())
463 SimdItemEnumeratorBase(
const ItemInternalPtr* items,
const Int32* local_ids,
Integer n)
464 : SimdEnumeratorBase(local_ids, n)
465 , m_shared_info(ItemInternalCompatibility::_getSharedInfo(items, n))
468 SimdItemEnumeratorBase(
const ItemInternalArrayView& items,
const Int32ConstArrayView& local_ids)
469 : SimdEnumeratorBase(local_ids)
470 , m_shared_info(ItemInternalCompatibility::_getSharedInfo(items.data(), local_ids.size()))
477 const ItemInternalPtr*
unguardedItems()
const {
return m_shared_info->m_items_internal.data(); }
491template <
typename ItemType>
492class SimdItemEnumeratorT
493:
public SimdItemEnumeratorBase
503 SimdItemEnumeratorT()
504 : SimdItemEnumeratorBase()
507 : SimdItemEnumeratorBase(rhs)
510 : SimdItemEnumeratorBase(rhs)
513 : SimdItemEnumeratorBase(rhs)
517 SimdItemEnumeratorT(
const ItemInternalPtr* items,
const Int32* local_ids,
Integer n)
518 : SimdItemEnumeratorBase(items, local_ids, n)
521 SimdItemEnumeratorT(
const ItemInternalArrayView& items,
const Int32ConstArrayView& local_ids)
522 : SimdItemEnumeratorBase(items, local_ids)
527 SimdItemType operator*()
const
529 return SimdItemType(m_shared_info, _currentSimdIndex());
542#ifndef ARCANE_SIMD_BENCH
555#ifndef ARCANE_SIMD_BENCH
592template <
typename ItemType>
605 return g.enumerator();
611 template <
typename T>
614 return g.enumerator();
621#define ENUMERATE_SIMD_(type, iname, view) \
622 for (A_TRACE_ITEM_ENUMERATOR(SimdItemEnumeratorT<type>) iname(::Arcane::SimdItemEnumeratorContainerTraits<type>::getSimdEnumerator(view) A_TRACE_ENUMERATOR_WHERE); iname.hasNext(); ++iname)
625#define ENUMERATE_SIMD_GENERIC(type, iname, view) \
626 ENUMERATE_SIMD_(type, iname, view)
632#define ENUMERATE_SIMD_NODE(name, group) ENUMERATE_SIMD_(::Arcane::Node, name, group)
638#define ENUMERATE_SIMD_EDGE(name, group) ENUMERATE_SIMD_(::Arcane::Edge, name, group)
644#define ENUMERATE_SIMD_FACE(name, group) ENUMERATE_SIMD_(::Arcane::Face, name, group)
650#define ENUMERATE_SIMD_CELL(name, group) ENUMERATE_SIMD_(::Arcane::Cell, name, group)
656#define ENUMERATE_SIMD_PARTICLE(name, group) ENUMERATE_SIMD_(::Arcane::Particle, name, group)
Reference to a group of a given kind.
ItemEnumerator _simdEnumerator() const
Enumerator over the group entities for vectorization.
Methods for conversions between different entity management classes.
Internal view on an array of entities.
Int32ConstArrayView localIds() const
Array of local entity IDs.
Internal structure of a mesh entity.
Internal shared structure of a mesh entity.
View on a typed array of entities.
Base class for a mesh element.
ItemSharedInfo * m_shared_info
Shared information among all entities with the same characteristics.
Integer nbValid() const
Number of valid values for the current iterator.
Class managing a SIMD vector of entities.
const Int32 *ARCANE_RESTRICT localIds() const
List of local IDs of the instance entities.
const SimdIndexType &ARCANE_RESTRICT simdLocalIds() const
List of local IDs of the instance entities.
Int32 localId(Int32 index) const
Local ID of the entity at index index.
ItemInternal * item(Integer si) const
Internal part (for internal use only).
SimdItemBase(const ItemInternalPtr *items, const SimdIndexType *ids)
Constructs an instance.
Int32 baseLocalId() const
List of local IDs of the instance entities.
Integer nbValid() const
Number of valid entities in the instance.
Vector index without indirection for an entity type.
Manages a vector of ItemType entities.
Vector index with indirection for an entity type. TODO: store the indices in a vector register to be ...
const SimdIndexType &ARCANE_RESTRICT simdLocalIds() const
List of local IDs of the instance entities.
Manages a vector of ItemType entities.
ItemType operator[](Integer si) const
Returns the si-th entity of the instance.
ItemType item(Integer si) const
Returns the si-th entity of the instance.
Item item(Int32 si) const
inline si-th entity of the instance
Item operator[](Int32 si) const
inline si-th entity of the instance
SimdItemT< Edge > SimdEdge
SIMD vector of Edge.
SimdItemT< Cell > SimdCell
SIMD vector of Cell.
SimdItemT< Face > SimdFace
SIMD vector of Face.
SimdItemT< Particle > SimdParticle
SIMD vector of Particle.
SimdItemT< Node > SimdNode
SIMD vector of Node.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
std::int32_t Int32
Signed integer type of 32 bits.