Arcane
v3.15.3.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
ArrayLayout.h
1
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2
//-----------------------------------------------------------------------------
3
// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4
// See the top-level COPYRIGHT file for details.
5
// SPDX-License-Identifier: Apache-2.0
6
//-----------------------------------------------------------------------------
7
/*---------------------------------------------------------------------------*/
8
/* ArrayLayout.h (C) 2000-2022 */
9
/* */
10
/* Gestion de la disposition mémoire pour les tableaux N-dimensions. */
11
/*---------------------------------------------------------------------------*/
12
#ifndef ARCANE_UTILS_ARRAYLAYOUT_H
13
#define ARCANE_UTILS_ARRAYLAYOUT_H
14
/*---------------------------------------------------------------------------*/
15
/*---------------------------------------------------------------------------*/
16
17
#include "arcane/utils/ArrayBoundsIndex.h"
18
#include "arcane/utils/ArrayExtentsValue.h"
19
#include "arcane/utils/MDDim.h"
20
21
#include <array>
22
23
/*
24
* ATTENTION:
25
*
26
* Toutes les classes de ce fichier sont expérimentales et l'API n'est pas
27
* figée. A NE PAS UTILISER EN DEHORS DE ARCANE.
28
*/
29
/*---------------------------------------------------------------------------*/
30
/*---------------------------------------------------------------------------*/
31
32
namespace
Arcane
33
{
34
35
/*---------------------------------------------------------------------------*/
36
/*---------------------------------------------------------------------------*/
37
38
template
<Int32 I,Int32 J>
39
class
ArrayLayout2
40
{
41
public
:
42
43
static
constexpr
Int64 LastExtent =
J
;
44
45
static
ARCCORE_HOST_DEVICE
constexpr
Int64
46
offset(
ArrayIndex<2>
idx,Int64 extent1)
47
{
48
return
(extent1 * idx[
I
]) + Int64(idx[
J
]);
49
}
50
51
static
constexpr
std::array<Int32,2> layoutInfo() {
return
{
I
,
J
}; }
52
static
constexpr
ARCCORE_HOST_DEVICE
Int32 layout0() {
return
I
; }
53
static
constexpr
ARCCORE_HOST_DEVICE
Int32 layout1() {
return
J
; }
54
};
55
56
/*---------------------------------------------------------------------------*/
57
/*---------------------------------------------------------------------------*/
58
59
template
<Int32 I,Int32 J,Int32 K>
60
class
ArrayLayout3
61
{
62
public
:
63
64
static
constexpr
Int64 LastExtent =
K
;
65
66
static
ARCCORE_HOST_DEVICE
constexpr
Int64
67
offset(
ArrayIndex<3>
idx,Int64 extent1,Int64 extent2)
68
{
69
return
(extent2 * idx[
I
]) + (extent1*idx[
J
]) + idx.asInt64(
K
);
70
}
71
72
template
<
typename
ExtentType>
static
ARCCORE_HOST_DEVICE
constexpr
Int64
73
computeOffsetIndexes(
const
ExtentType
& extents)
74
{
75
return
extents.template
constLargeExtent<J>
() * extents.template
constLargeExtent<K>
();
76
}
77
78
static
constexpr
std::array<Int32,3> layoutInfo() {
return
{
I
,
J
,
K
}; }
79
80
static
constexpr
ARCCORE_HOST_DEVICE
Int32 layout0() {
return
I
; }
81
static
constexpr
ARCCORE_HOST_DEVICE
Int32 layout1() {
return
J
; }
82
static
constexpr
ARCCORE_HOST_DEVICE
Int32 layout2() {
return
K
; }
83
};
84
85
/*---------------------------------------------------------------------------*/
86
/*---------------------------------------------------------------------------*/
87
// Layout par défaut pour chaque dimension
88
89
template
<
int
N>
class
RightLayoutN
;
90
template
<
int
N>
class
LeftLayoutN
;
91
92
class
RightLayout
93
{
94
public
:
95
//! Implémentation pour le rang N
96
template
<
int
Rank>
using
LayoutType
=
RightLayoutN<Rank>
;
97
using
Layout1Type
=
LayoutType<1>
;
98
using
Layout2Type
=
LayoutType<2>
;
99
using
Layout3Type
=
LayoutType<3>
;
100
using
Layout4Type
=
LayoutType<4>
;
101
};
102
103
class
LeftLayout
104
{
105
public
:
106
template
<
int
Rank>
using
LayoutType
=
LeftLayoutN<Rank>
;
107
using
Layout1Type
=
LayoutType<1>
;
108
using
Layout2Type
=
LayoutType<2>
;
109
using
Layout3Type
=
LayoutType<3>
;
110
using
Layout4Type
=
LayoutType<4>
;
111
};
112
113
template
<>
class
RightLayoutN
<2> :
public
ArrayLayout2
<0,1> {};
114
template
<>
class
RightLayoutN
<3> :
public
ArrayLayout3
<0,1,2> {};
115
116
template
<>
class
LeftLayoutN
<2> :
public
ArrayLayout2
<1,0> {};
117
template
<>
class
LeftLayoutN
<3> :
public
ArrayLayout3
<2,1,0> {};
118
119
// Les 4 using suivants sont pour compatibilité. A supprimer dans la 3.9
120
using
LeftLayout2
=
LeftLayout
;
121
using
LeftLayout3
=
LeftLayout
;
122
using
RightLayout2
=
RightLayout
;
123
using
RightLayout3
=
RightLayout
;
124
125
//! Le layout par défaut est toujours RightLayout
126
class
DefaultLayout
:
public
RightLayout
{};
127
128
/*---------------------------------------------------------------------------*/
129
/*---------------------------------------------------------------------------*/
130
131
}
// End namespace Arcane
132
133
/*---------------------------------------------------------------------------*/
134
/*---------------------------------------------------------------------------*/
135
136
#endif
Arcane::ArrayLayout2
Definition
ArrayLayout.h:40
Arcane::ArrayLayout3
Definition
ArrayLayout.h:61
Arcane::DefaultLayout
Le layout par défaut est toujours RightLayout.
Definition
ArrayLayout.h:126
Arcane::LeftLayoutN
Definition
ArrayLayout.h:90
Arcane::LeftLayout
Definition
ArrayLayout.h:104
Arcane::RightLayoutN
Definition
ArrayLayout.h:89
Arcane::RightLayout
Definition
ArrayLayout.h:93
Arccore::Ref
Référence à une instance.
Definition
arccore/src/base/arccore/base/Ref.h:143
Arcane
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Definition
AbstractCaseDocumentVisitor.cc:20
arcane
utils
ArrayLayout.h
Généré le Lundi 10 Février 2025 02:47:12 pour Arcane par
1.9.8