12#ifndef ARCANE_UTILS_ARRAYEXTENTS_H
13#define ARCANE_UTILS_ARRAYEXTENTS_H
17#include "arcane/utils/ArrayView.h"
18#include "arcane/utils/ArrayIndex.h"
19#include "arcane/utils/ArrayLayout.h"
20#include "arcane/utils/ArrayExtentsValue.h"
22#include "arccore/base/Span.h"
62template <
int RankValue>
69 ARCCORE_HOST_DEVICE Int32
stride(
int i)
const {
return m_strides[i]; }
70 ARCCORE_HOST_DEVICE Int32 operator()(
int i)
const {
return m_strides[i]; }
71 ARCCORE_HOST_DEVICE SmallSpan<const Int32> asSpan()
const {
return { m_strides.data(), RankValue }; }
100 std::array<Int32, RankValue> m_strides = {};
133template <
typename Extents>
135:
protected Extents::ArrayExtentsValueType
139 using BaseClass =
typename Extents::ArrayExtentsValueType;
141 using DynamicDimsType =
typename Extents::DynamicDimsType;
145 using BaseClass::asStdArray;
146 using BaseClass::constExtent;
147 using BaseClass::dynamicExtents;
148 using BaseClass::getIndices;
149 using BaseClass::totalNbElement;
164 explicit constexpr ARCCORE_HOST_DEVICE
ArrayExtentsBase(DynamicDimsType extents)
172 ARCCORE_HOST_DEVICE
void setExtent0(Int32 v) { this->m_extent0.v = v; }
175 ARCCORE_HOST_DEVICE ArrayExtentsPreviousRank removeFirstExtent()
const
177 auto x = BaseClass::_removeFirstExtent();
178 return ArrayExtentsPreviousRank::fromSpan(x);
182 template <Int32 I>
constexpr ARCCORE_HOST_DEVICE
Int64 constLargeExtent()
const
184 return BaseClass::template constExtent<I>();
201template <
typename SizeType_,
int X0>
209 using BaseClass::totalNbElement;
210 using DynamicDimsType =
typename ExtentsType::DynamicDimsType;
218 constexpr ARCCORE_HOST_DEVICE
ArrayExtents(
const DynamicDimsType& extents)
223 constexpr ARCCORE_HOST_DEVICE
explicit ArrayExtents(Int32 dim1_size)
225 static_assert(ExtentsType::nb_dynamic == 1,
"This method is only allowed for full dynamic extents");
226 this->m_extent0.v = dim1_size;
235template <
typename SizeType_,
int X0,
int X1>
243 using BaseClass::totalNbElement;
244 using DynamicDimsType =
typename ExtentsType::DynamicDimsType;
252 constexpr ARCCORE_HOST_DEVICE
ArrayExtents(
const DynamicDimsType& extents)
257 constexpr ARCCORE_HOST_DEVICE
ArrayExtents(Int32 dim1_size, Int32 dim2_size)
259 static_assert(ExtentsType::nb_dynamic == 2,
"This method is only allowed for full dynamic extents");
260 this->m_extent0.v = dim1_size;
261 this->m_extent1.v = dim2_size;
270template <
typename SizeType_,
int X0,
int X1,
int X2>
278 using BaseClass::totalNbElement;
279 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
287 constexpr ARCCORE_HOST_DEVICE
ArrayExtents(
const DynamicDimsType& extents)
294 static_assert(ExtentsType::nb_dynamic == 3,
"This method is only allowed for full dynamic extents");
295 this->m_extent0.v = dim1_size;
296 this->m_extent1.v = dim2_size;
306template <
typename SizeType_,
int X0,
int X1,
int X2,
int X3>
314 using BaseClass::totalNbElement;
315 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
323 constexpr ARCCORE_HOST_DEVICE
ArrayExtents(
const DynamicDimsType& extents)
330 static_assert(ExtentsType::nb_dynamic == 4,
"This method is only allowed for full dynamic extents");
331 this->m_extent0.v = dim1_size;
332 this->m_extent1.v = dim2_size;
346template <
typename SizeType_,
int X0,
typename LayoutType>
354 using BaseClass::asStdArray;
355 using BaseClass::extent0;
356 using BaseClass::getIndices;
357 using BaseClass::totalNbElement;
358 using Layout =
typename LayoutType::Layout1Type;
359 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
360 using MDIndexType =
typename BaseClass::MDIndexType;
363 using IndexType =
typename BaseClass::IndexType;
377 constexpr ARCCORE_HOST_DEVICE Int64 offset(Int32 i)
const
379 BaseClass::_checkIndex(i);
382 constexpr ARCCORE_HOST_DEVICE Int64 offset(IndexType idx)
const
384 BaseClass::_checkIndex(idx.id0());
399template <
typename SizeType_,
int X0,
int X1,
typename LayoutType>
407 using BaseClass::asStdArray;
408 using BaseClass::extent0;
409 using BaseClass::extent1;
410 using BaseClass::getIndices;
411 using BaseClass::totalNbElement;
412 using Layout =
typename LayoutType::Layout2Type;
413 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
414 using MDIndexType =
typename BaseClass::MDIndexType;
417 using IndexType =
typename BaseClass::IndexType;
431 constexpr ARCCORE_HOST_DEVICE Int64 offset(Int32 i, Int32
j)
const
433 return offset({ i,
j });
435 constexpr ARCCORE_HOST_DEVICE Int64 offset(IndexType idx)
const
437 BaseClass::_checkIndex(idx);
452template <
typename SizeType_,
int X0,
int X1,
int X2,
typename LayoutType>
460 using BaseClass::asStdArray;
461 using BaseClass::extent0;
462 using BaseClass::extent1;
463 using BaseClass::extent2;
464 using BaseClass::getIndices;
465 using BaseClass::totalNbElement;
466 using Layout =
typename LayoutType::Layout3Type;
467 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
468 using MDIndexType =
typename BaseClass::MDIndexType;
471 using IndexType =
typename BaseClass::IndexType;
487 constexpr ARCCORE_HOST_DEVICE Int64 offset(Int32 i, Int32
j, Int32
k)
const
489 return offset({ i,
j,
k });
491 constexpr ARCCORE_HOST_DEVICE Int64 offset(IndexType idx)
const
493 this->_checkIndex(idx);
504 ARCCORE_HOST_DEVICE
void _computeOffsets()
507 m_dim23_size = Layout::computeOffsetIndexes(
b);
512 Int64 m_dim23_size = 0;
520template <
typename SizeType_,
int X0,
int X1,
int X2,
int X3,
typename LayoutType>
522:
private ArrayExtents<ExtentsV<SizeType_, X0, X1, X2, X3>>
528 using BaseClass::asStdArray;
529 using BaseClass::extent0;
530 using BaseClass::extent1;
531 using BaseClass::extent2;
532 using BaseClass::extent3;
533 using BaseClass::getIndices;
534 using BaseClass::totalNbElement;
535 using Layout =
typename LayoutType::Layout4Type;
536 using DynamicDimsType =
typename BaseClass::DynamicDimsType;
537 using MDIndexType =
typename BaseClass::MDIndexType;
540 using IndexType =
typename BaseClass::IndexType;
556 constexpr ARCCORE_HOST_DEVICE Int64 offset(Int32 i, Int32
j, Int32
k, Int32 l)
const
558 return offset({ i,
j,
k, l });
560 constexpr ARCCORE_HOST_DEVICE Int64 offset(IndexType idx)
const
562 this->_checkIndex(idx);
563 return (m_dim234_size * idx.largeId0()) + m_dim34_size * idx.largeId1() + this->m_extent3.v * idx.largeId2() + idx.largeId3();
573 ARCCORE_HOST_DEVICE
void _computeOffsets()
575 m_dim34_size = Int64(this->m_extent2.v) * Int64(this->m_extent3.v);
576 m_dim234_size = Int64(m_dim34_size) * Int64(this->m_extent1.v);
581 Int64 m_dim34_size = 0;
582 Int64 m_dim234_size = 0;
constexpr ARCCORE_HOST_DEVICE SmallSpan< const Int32 > asSpan() const
Nombre d'élément de la i-ème dimension.
constexpr ARCCORE_HOST_DEVICE Int32 totalNbElement() const
Nombre total d'eléments.
Classe pour conserver le nombre d'éléments dans chaque dimension.
ARCCORE_HOST_DEVICE void setExtent0(Int32 v)
TEMPORARY: Positionne à v le nombre d'éléments de la dimension 0.
static ARCCORE_HOST_DEVICE ArrayExtentsBase< Extents > fromSpan(SmallSpan< const Int32 > extents)
Construit une instance à partir des valeurs données dans extents.
ARCCORE_HOST_DEVICE Int64 totalStride() const
Value totale du pas.
ARCCORE_HOST_DEVICE SmallSpan< const Int32 > asSpan() const
Valeur du pas de la i-ème dimension.
Classe pour conserver le pas dans chaque dimension.
ARCCORE_HOST_DEVICE Int64 totalStride() const
Valeur totale du pas.
ARCCORE_HOST_DEVICE Int32 stride(int i) const
Valeur du pas de la i-ème dimension.
static ARCCORE_HOST_DEVICE ArrayStridesBase< RankValue > fromSpan(Span< const Int32 > strides)
Construit une instance à partir des valeurs données dans stride.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-