Arcane  v3.15.0.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
DataOperation.h
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/* DataOperation.h (C) 2000-2024 */
9/* */
10/* Opération sur une donnée. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_IMPL_DATAOPERATION_H
13#define ARCANE_IMPL_DATAOPERATION_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arccore/base/ArrayView.h"
18#include "arccore/base/Span.h"
19
20#include "arcane/utils/Real2.h"
21#include "arcane/utils/Real3.h"
22#include "arcane/utils/Real2x2.h"
23#include "arcane/utils/Real3x3.h"
24#include "arcane/utils/Float16.h"
25#include "arcane/utils/BFloat16.h"
26
27#include "arcane/datatype/IDataOperation.h"
28
29#include "arcane/Parallel.h"
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34namespace Arcane
35{
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
40template<typename DataOperator>
42: public IDataOperation
43{
44 public:
45
47 DataOperationT(const DataOperator& op) : m_operator(op) {}
48
49 private:
50
51 template<typename DataType> void
53 {
54 for( Int32 i=0, n=input.size(); i<n; ++i )
55 output[i] = m_operator(output[i],input[i]);
56 }
57
58 public:
59
60 void apply(ByteArrayView output,ByteConstArrayView input) override
61 {
62 _applyView(output,input);
63 }
64 void apply(RealArrayView output,RealConstArrayView input) override
65 {
66 _applyView(output,input);
67 }
68 void apply(Int32ArrayView output,Int32ConstArrayView input) override
69 {
70 _applyView(output,input);
71 }
72 void apply(Int16ArrayView output,Int16ConstArrayView input) override
73 {
74 _applyView(output,input);
75 }
76 void apply(Int64ArrayView output,Int64ConstArrayView input) override
77 {
78 _applyView(output,input);
79 }
80 void apply(Real2ArrayView output,Real2ConstArrayView input) override
81 {
82 _applyView(output,input);
83 }
84 void apply(Real3ArrayView output,Real3ConstArrayView input) override
85 {
86 _applyView(output,input);
87 }
88 void apply(Real2x2ArrayView output,Real2x2ConstArrayView input) override
89 {
90 _applyView(output,input);
91 }
92 void apply(Real3x3ArrayView output,Real3x3ConstArrayView input) override
93 {
94 _applyView(output,input);
95 }
96 void apply(ArrayView<Int8> output,ConstArrayView<Int8> input) override
97 {
98 _applyView(output,input);
99 }
100 void apply(ArrayView<Float16> output,ConstArrayView<Float16> input) override
101 {
102 _applyView(output,input);
103 }
104 void apply(ArrayView<BFloat16> output,ConstArrayView<BFloat16> input) override
105 {
106 _applyView(output,input);
107 }
108 void apply(ArrayView<Float32> output,ConstArrayView<Float32> input) override
109 {
110 _applyView(output,input);
111 }
112
113 private:
114
115 template<typename DataType> void
116 _applySpan(Span<DataType> output,Span<const DataType> input)
117 {
118 for( Int64 i=0, n=input.size(); i<n; ++i )
119 output[i] = m_operator(output[i],input[i]);
120 }
121
122 public:
123
124 void applySpan(Span<Byte> output,Span<const Byte> input) override
125 {
126 _applySpan(output,input);
127 }
128 void applySpan(Span<Real> output,Span<const Real> input) override
129 {
130 _applySpan(output,input);
131 }
132 void applySpan(Span<Int16> output,Span<const Int16> input) override
133 {
134 _applySpan(output,input);
135 }
136 void applySpan(Span<Int32> output,Span<const Int32> input) override
137 {
138 _applySpan(output,input);
139 }
140 void applySpan(Span<Int64> output,Span<const Int64> input) override
141 {
142 _applySpan(output,input);
143 }
144 void applySpan(Span<Real2> output,Span<const Real2> input) override
145 {
146 _applySpan(output,input);
147 }
148 void applySpan(Span<Real3> output,Span<const Real3> input) override
149 {
150 _applySpan(output,input);
151 }
152 void applySpan(Span<Real2x2> output,Span<const Real2x2> input) override
153 {
154 _applySpan(output,input);
155 }
156 void applySpan(Span<Real3x3> output,Span<const Real3x3> input) override
157 {
158 _applySpan(output,input);
159 }
160 void applySpan(Span<Int8> output,Span<const Int8> input) override
161 {
162 _applySpan(output,input);
163 }
164 void applySpan(Span<Float16> output,Span<const Float16> input) override
165 {
166 _applySpan(output,input);
167 }
168 void applySpan(Span<BFloat16> output,Span<const BFloat16> input) override
169 {
170 _applySpan(output,input);
171 }
172 void applySpan(Span<Float32> output,Span<const Float32> input) override
173 {
174 _applySpan(output,input);
175 }
176
177 private:
178
179 DataOperator m_operator;
180};
181
182/*---------------------------------------------------------------------------*/
183/*---------------------------------------------------------------------------*/
184
185extern "C++" ARCANE_IMPL_EXPORT IDataOperation*
186arcaneCreateDataOperation(Parallel::eReduceType rt);
187
188/*---------------------------------------------------------------------------*/
189/*---------------------------------------------------------------------------*/
190
191} // End namespace Arcane
192
193/*---------------------------------------------------------------------------*/
194/*---------------------------------------------------------------------------*/
195#endif
Interface d'une opération sur une donnée.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:149
Vue modifiable d'un tableau d'un type T.
Vue constante d'un tableau de type T.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
eReduceType
Types des réductions supportées.