Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
SimdEMUL.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/* SimdEmulated.h (C) 2000-2016 */
9/* */
10/* Emulation de la vectorisation lorsque aucune mécanisme n'est disponible. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_UTILS_SIMDEMULATED_H
13#define ARCANE_UTILS_SIMDEMULATED_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16/*
17 * Ce fichier ne doit pas être inclus directement.
18 * Utiliser 'Simd.h' à la place.
19 */
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
22
23ARCANE_BEGIN_NAMESPACE
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
35{
36 public:
37 static const int BLOCK_SIZE = 2;
38 enum
39 {
40 Length = 2,
41 Alignment = 4
42 };
43 public:
44 Int32 v0;
45 Int32 v1;
47 explicit EMULSimdX2Int32(Int32 a) : v0(a), v1(a){}
48 private:
49 EMULSimdX2Int32(Int32 a1,Int32 a0)
50 : v0(a0), v1(a1){}
51 public:
52 EMULSimdX2Int32(const Int32* base,const Int32* idx)
53 : v0(base[idx[0]]), v1(base[idx[1]]){}
54 explicit EMULSimdX2Int32(const Int32* base)
55 : v0(base[0]), v1(base[1]){}
56
57 Int32 operator[](Integer i) const { return (&v0)[i]; }
58 Int32& operator[](Integer i) { return (&v0)[i]; }
59
60 void set(ARCANE_RESTRICT Int32* base,const ARCANE_RESTRICT Int32* idx) const
61 {
62 base[idx[0]] = v0;
63 base[idx[1]] = v1;
64 }
65
66 void set(ARCANE_RESTRICT Int32* base) const
67 {
68 base[0] = v0;
69 base[1] = v1;
70 }
71
72 static EMULSimdX2Int32 fromScalar(Int32 a0,Int32 a1)
73 {
74 return EMULSimdX2Int32(a1,a0);
75 }
76
77 private:
78 void operator=(Int32 _v);
79};
80
81/*---------------------------------------------------------------------------*/
82/*---------------------------------------------------------------------------*/
88{
89 public:
90 static const int BLOCK_SIZE = 4;
91 enum
92 {
93 Length = 4,
94 Alignment = 4
95 };
96 public:
97 Int32 v0;
98 Int32 v1;
99 Int32 v2;
100 Int32 v3;
102 explicit EMULSimdX4Int32(Int32 a)
103 : v0(a), v1(a), v2(a), v3(a){}
104 private:
105 EMULSimdX4Int32(Int32 a3,Int32 a2,Int32 a1,Int32 a0)
106 : v0(a0), v1(a1), v2(a2), v3(a3){}
107 public:
108 EMULSimdX4Int32(const Int32* base,const Int32* idx)
109 : v0(base[idx[0]]), v1(base[idx[1]]), v2(base[idx[2]]), v3(base[idx[3]]){}
110 explicit EMULSimdX4Int32(const Int32* base)
111 : v0(base[0]), v1(base[1]), v2(base[2]), v3(base[3]){}
112 explicit EMULSimdX4Int32(const EMULSimdX4Int32* base)
113 : v0(base->v0), v1(base->v1), v2(base->v2), v3(base->v3){}
114
115 Int32 operator[](Integer i) const { return (&v0)[i]; }
116 Int32& operator[](Integer i) { return (&v0)[i]; }
117
118 void set(ARCANE_RESTRICT Int32* base,const ARCANE_RESTRICT Int32* idx) const
119 {
120 base[idx[0]] = v0;
121 base[idx[1]] = v1;
122 base[idx[2]] = v2;
123 base[idx[3]] = v3;
124 }
125
126 void set(ARCANE_RESTRICT Int32* base) const
127 {
128 base[0] = v0;
129 base[1] = v1;
130 base[2] = v2;
131 base[3] = v3;
132 }
133
134 static EMULSimdX4Int32 fromScalar(Int32 a0,Int32 a1,Int32 a2,Int32 a3)
135 {
136 return EMULSimdX4Int32(a3,a2,a1,a0);
137 }
138
139 private:
140 void operator=(Int32 _v);
141};
142
143/*---------------------------------------------------------------------------*/
144/*---------------------------------------------------------------------------*/
155{
156 public:
157 static const int BLOCK_SIZE = 2;
158 enum : Int32
159 {
160 Length = 2
161 };
163 Real v0;
164 Real v1;
165 //NOTE: il est normal que ce constructeur ne fasse pas d'initialisation.
166 EMULSimdReal(){}
167 explicit EMULSimdReal(Real a)
168 : v0(a), v1(a){}
169 private:
170 EMULSimdReal(Real a0,Real a1)
171 : v0(a0), v1(a1){}
172 public:
173 EMULSimdReal(const Real* base)
174 : v0(base[0]), v1(base[1]) {}
175 EMULSimdReal(const Real* base,const Int32* idx)
176 : v0(base[idx[0]]), v1(base[idx[1]]) {}
177 EMULSimdReal(const Real* base,const Int32IndexType* idx)
178 : v0(base[idx->v0]), v1(base[idx->v1]) {}
179 EMULSimdReal(const Real* base,const Int32IndexType& idx)
180 : v0(base[idx.v0]), v1(base[idx.v1]) {}
181 const Real& operator[](Integer i) const { return ((Real*)this)[i]; }
182 Real& operator[](Integer i) { return ((Real*)this)[i]; }
183 void set(ARCANE_RESTRICT Real* base) const
184 {
185 base[0] = v0;
186 base[1] = v1;
187 }
188 void set(ARCANE_RESTRICT Real* base,const Int32* idx) const
189 {
190 base[idx[0]] = v0;
191 base[idx[1]] = v1;
192 }
193 void set(ARCANE_RESTRICT Real* base,const Int32IndexType* idx) const
194 {
195 base[idx->v0] = v0;
196 base[idx->v1] = v1;
197 }
198 void set(ARCANE_RESTRICT Real* base,const Int32IndexType& idx) const
199 {
200 base[idx.v0] = v0;
201 base[idx.v1] = v1;
202 }
203 static EMULSimdReal fromScalar(Real a0,Real a1)
204 {
205 return EMULSimdReal(a0,a1);
206 }
207 private:
208 void operator=(Real _v);
209};
210
211/*---------------------------------------------------------------------------*/
212/*---------------------------------------------------------------------------*/
213
215{
216 public:
217 static const char* name() { return "EMUL"; }
218 enum : Int32
219 {
220 Int32IndexSize = 2
221 };
222 typedef EMULSimdReal SimdReal;
224};
225
226/*---------------------------------------------------------------------------*/
227/*---------------------------------------------------------------------------*/
228
229ARCANE_UTILS_EXPORT std::ostream&
230operator<<(std::ostream& o,const EMULSimdReal& s);
231
232// Unary operation operator-
234{
235 Real* za = (Real*)(&a);
236 return EMULSimdReal::fromScalar(-(za[0]),-(za[1]));
237}
238
239/*---------------------------------------------------------------------------*/
240/*---------------------------------------------------------------------------*/
241
242ARCANE_END_NAMESPACE
243
244/*---------------------------------------------------------------------------*/
245/*---------------------------------------------------------------------------*/
246
247#endif
Vectorisation des réels par émulation.
Definition SimdEMUL.h:155
Vectorisation des entiers en utilisant une émulation.
Definition SimdEMUL.h:35
Vectorisation des entiers en utilisant une émulation.
Definition SimdEMUL.h:88
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120