Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
SpanViews.h
Aller à la documentation de ce fichier.
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* SpanViews.h (C) 2000-2024 */
9/* */
10/* Gestion des vues pour les 'Span' pour les accélérateurs. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_ACCELERATOR_SPANVIEW_H
13#define ARCANE_ACCELERATOR_SPANVIEW_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/NumArray.h"
19
20/*---------------------------------------------------------------------------*/
21/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30/*---------------------------------------------------------------------------*/
31
32namespace Arcane::Accelerator
33{
34
35/*---------------------------------------------------------------------------*/
36/*---------------------------------------------------------------------------*/
37
38template <typename DataType, typename Extents, typename LayoutPolicy>
40
41/*---------------------------------------------------------------------------*/
42/*---------------------------------------------------------------------------*/
47{
48 protected:
49
50 // Pour l'instant n'utilise pas encore \a command
51 // mais il ne faut pas le supprimer
52 explicit SpanViewBase(const ViewBuildInfo&)
53 {
54 }
55
56 private:
57};
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
64template <typename Accessor>
66: public SpanViewBase
67{
68 public:
69
70 using DataType = typename Accessor::ValueType;
71 using AccessorReturnType = typename Accessor::AccessorReturnType;
73 using size_type = typename SpanType::size_type;
74
75 public:
76
77 SpanView(const ViewBuildInfo& command, SpanType v)
78 : SpanViewBase(command)
79 , m_values(v)
80 {}
81
82 constexpr ARCCORE_HOST_DEVICE AccessorReturnType operator()(size_type i) const
83 {
84 return Accessor::build(m_values.ptrAt(i));
85 }
86
87 constexpr ARCCORE_HOST_DEVICE AccessorReturnType operator[](size_type i) const
88 {
89 return Accessor::build(m_values.ptrAt(i));
90 }
91 constexpr ARCCORE_HOST_DEVICE size_type size() const { return m_values.size(); }
92
93 private:
94
95 SpanType m_values;
96};
97
98/*---------------------------------------------------------------------------*/
99/*---------------------------------------------------------------------------*/
103template <typename Accessor>
105: public SpanViewBase
106{
107 public:
108
109 using DataType = typename Accessor::ValueType;
110 using AccessorReturnType = typename Accessor::AccessorReturnType;
112 using size_type = typename SpanType::size_type;
113
114 public:
115
116 SmallSpanView(const ViewBuildInfo& command, SpanType v)
117 : SpanViewBase(command)
118 , m_values(v)
119 {}
120
121 constexpr ARCCORE_HOST_DEVICE AccessorReturnType operator()(size_type i) const
122 {
123 return Accessor::build(m_values.ptrAt(i));
124 }
125
126 constexpr ARCCORE_HOST_DEVICE AccessorReturnType operator[](size_type i) const
127 {
128 return Accessor::build(m_values.ptrAt(i));
129 }
130 constexpr ARCCORE_HOST_DEVICE size_type size() const { return m_values.size(); }
131
132 private:
133
134 SpanType m_values;
135};
136
137/*---------------------------------------------------------------------------*/
138/*---------------------------------------------------------------------------*/
142template <typename DataType> auto
144{
145 using Accessor = DataViewSetter<DataType>;
146 return SpanView<Accessor>(command, var);
147}
148
149/*---------------------------------------------------------------------------*/
150/*---------------------------------------------------------------------------*/
154template <typename DataType> auto
156{
157 return viewOut(command, var.span());
158}
159
160/*---------------------------------------------------------------------------*/
161/*---------------------------------------------------------------------------*/
165template <typename DataType> auto
167{
168 using Accessor = DataViewSetter<DataType>;
169 return SmallSpanView<Accessor>(command, var);
170}
171/*---------------------------------------------------------------------------*/
172/*---------------------------------------------------------------------------*/
176template <typename DataType> auto
178{
179 return viewOut(command, SmallSpan<DataType>(var));
180}
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
187template <typename DataType> auto
189{
190 using Accessor = DataViewGetterSetter<DataType>;
191 return SpanView<Accessor>(command, var);
192}
193
194/*---------------------------------------------------------------------------*/
195/*---------------------------------------------------------------------------*/
199template <typename DataType> auto
201{
202 return viewInOut(command, var.span());
203}
204
205/*---------------------------------------------------------------------------*/
206/*---------------------------------------------------------------------------*/
210template <typename DataType> auto
212{
213 using Accessor = DataViewGetterSetter<DataType>;
214 return SmallSpanView<Accessor>(command, var);
215}
216
217/*---------------------------------------------------------------------------*/
218/*---------------------------------------------------------------------------*/
222template <typename DataType> auto
224{
225 return viewInOut(command, SmallSpan<DataType>(var));
226}
227
228/*----------------------------------------------1-----------------------------*/
229/*---------------------------------------------------------------------------*/
233template <typename DataType> auto
235{
236 using Accessor = DataViewGetter<DataType>;
237 return SpanView<Accessor>(command, var);
238}
239
240/*----------------------------------------------1-----------------------------*/
241/*---------------------------------------------------------------------------*/
245template <typename DataType> auto
247{
248 return viewIn(command, var.span());
249}
250
251/*----------------------------------------------1-----------------------------*/
252/*---------------------------------------------------------------------------*/
256template <typename DataType> auto
258{
259 using Accessor = DataViewGetter<DataType>;
260 return SmallSpanView<Accessor>(command, var);
261}
262
263/*---------------------------------------------------------------------------*/
264/*---------------------------------------------------------------------------*/
265
267template <typename DataType> auto
269{
270 return viewIn(command, SmallSpan<const DataType>(var));
271}
272
273/*---------------------------------------------------------------------------*/
274/*---------------------------------------------------------------------------*/
275
276} // End namespace Arcane::Accelerator
277
278/*---------------------------------------------------------------------------*/
279/*---------------------------------------------------------------------------*/
280
281#endif
Vue en lecture, écriture ou lecture/écriture sur un 'SmallSpan'.
Definition SpanViews.h:106
Classe de base des vues sur les 'NumArray'.
Definition SpanViews.h:47
Vue en lecture, écriture ou lecture/écriture sur un 'Span'.
Definition SpanViews.h:67
Informations pour construire une vue pour les données sur accélérateur.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Vue d'un tableau d'éléments de type T.
Definition Span.h:670
constexpr ARCCORE_HOST_DEVICE pointer ptrAt(SizeType index) const
Addresse du index-ème élément.
Definition Span.h:240
constexpr ARCCORE_HOST_DEVICE SizeType size() const noexcept
Retourne la taille du tableau.
Definition Span.h:209
Vue d'un tableau d'éléments de type T.
Definition Span.h:510
Espace de nom pour l'utilisation des accélérateurs.
auto viewInOut(RunCommand &cmd, CellMaterialVariableScalarRef< DataType > &var)
Vue en lecture/écriture pour les variables materiaux scalaire.
auto viewIn(RunCommand &cmd, const CellMaterialVariableScalarRef< DataType > &var)
Vue en lecture pour les variables materiaux scalaire.
auto viewOut(RunCommand &cmd, CellMaterialVariableScalarRef< DataType > &var)
Vue en écriture pour les variables materiaux scalaire.