Nektar++
Loading...
Searching...
No Matches
Functions
PhysDerivSumFacStdKernels.hpp File Reference

Go to the source code of this file.

Functions

template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor1DKernel (const unsigned int nq0, const simd_type *in, const simd_type *D0, simd_type *out_d0)
 
template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor2DKernel (const unsigned int nq0, const unsigned int nq1, const simd_type *in, const simd_type *D0, const simd_type *D1, simd_type *out_d0, simd_type *out_d1, bool Deriv0=true, bool Deriv1=true)
 
template<typename simd_type >
static NEK_FORCE_INLINE void SumDerivTensor2DKernel (const unsigned int nq0, const unsigned int nq1, const simd_type *in0, const simd_type *in1, const simd_type *D0, const simd_type *D1, simd_type *out, const typename simd_type::scalarType scale=0.0, bool Deriv0=true, bool Deriv1=true)
 
template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor3DKernel (const unsigned int nq0, const unsigned int nq1, const unsigned int nq2, const simd_type *in, const simd_type *D0, const simd_type *D1, const simd_type *D2, simd_type *out_d0, simd_type *out_d1, simd_type *out_d2, bool Deriv0=true, bool Deriv1=true, bool Deriv2=true)
 
template<typename simd_type >
static NEK_FORCE_INLINE void SumDerivTensor3DKernel (const unsigned int nq0, const unsigned int nq1, const unsigned int nq2, const simd_type *in0, const simd_type *in1, const simd_type *in2, const simd_type *D0, const simd_type *D1, const simd_type *D2, simd_type *out, const typename simd_type::scalarType scale=0.0, bool Deriv0=true, bool Deriv1=true, bool Deriv2=true)
 

Function Documentation

◆ PhysDerivTensor1DKernel()

template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor1DKernel ( const unsigned int  nq0,
const simd_type *  in,
const simd_type *  D0,
simd_type *  out_d0 
)
static

Definition at line 37 of file PhysDerivSumFacStdKernels.hpp.

41{
42 // All matricies are column major ordered since operators used to
43 // be computed via BLAS.
44
45 // D0 * in
46 for (unsigned int i = 0; i < nq0; ++i)
47 { // Row index of D0 matrix
48
49 simd_type prod_sum = 0.0;
50 for (unsigned int k = 0; k < nq0; ++k)
51 { // Col index of D0, row index of IN
52 simd_type v1 = D0[k * nq0 + i]; // Load 1x
53 simd_type v2 = simd_type(in[k]); // Load 1x
54
55 prod_sum.fma(v1, v2);
56 }
57
58 out_d0[i] = prod_sum; // Store 1x
59 }
60}

Referenced by Nektar::StdRegions::StdExpansion1D::PhysTensorDeriv().

◆ PhysDerivTensor2DKernel()

template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor2DKernel ( const unsigned int  nq0,
const unsigned int  nq1,
const simd_type *  in,
const simd_type *  D0,
const simd_type *  D1,
simd_type *  out_d0,
simd_type *  out_d1,
bool  Deriv0 = true,
bool  Deriv1 = true 
)
static

Definition at line 63 of file PhysDerivSumFacStdKernels.hpp.

67{
68 // All matricies are column major ordered since operators used to
69 // be computed via BLAS.
70
71 // D0 * in
72 if (Deriv0) // backwards compatibility with StdRegsion PhyTensorDeriv
73 {
74 for (unsigned int i = 0; i < nq0; ++i)
75 { // Row index of D0 matrix
76 for (unsigned int j = 0; j < nq1; ++j)
77 { // Col index of IN matrix
78
79 simd_type prod_sum = 0.0;
80 for (unsigned int k = 0; k < nq0; ++k)
81 { // Col index of D0, row index of IN
82 simd_type v1 = D0[k * nq0 + i]; // Load 1x
83 simd_type v2 = in[j * nq0 + k]; // Load 1x
84
85 prod_sum.fma(v1, v2);
86 }
87
88 out_d0[j * nq0 + i] = prod_sum; // Store 1x
89 }
90 }
91 }
92
93 // D1 * in
94 if (Deriv1)
95 {
96 // in * D1^T
97 for (unsigned int i = 0; i < nq0; ++i)
98 { // row index for grid
99 for (unsigned int j = 0; j < nq1; ++j)
100 { // Column index for D1^T (row idx for D1)
101
102 simd_type prod_sum = 0.0;
103 for (unsigned int k = 0; k < nq1; ++k)
104 {
105 simd_type v1 = in[k * nq0 + i]; // Load 1x
106 simd_type v2 = D1[k * nq1 + j]; // Load 1x
107
108 prod_sum.fma(v1, v2);
109 }
110
111 out_d1[j * nq0 + i] = prod_sum; // Store 1x
112 }
113 }
114 }
115}

◆ PhysDerivTensor3DKernel()

template<typename simd_type >
static NEK_FORCE_INLINE void PhysDerivTensor3DKernel ( const unsigned int  nq0,
const unsigned int  nq1,
const unsigned int  nq2,
const simd_type *  in,
const simd_type *  D0,
const simd_type *  D1,
const simd_type *  D2,
simd_type *  out_d0,
simd_type *  out_d1,
simd_type *  out_d2,
bool  Deriv0 = true,
bool  Deriv1 = true,
bool  Deriv2 = true 
)
static

Definition at line 175 of file PhysDerivSumFacStdKernels.hpp.

181{
182 // All matricies are column major ordered since operators used to
183 // be computed via BLAS.
184
185 // Direction 0
186 if (Deriv0)
187 {
188 for (unsigned int i = 0; i < nq0; ++i)
189 {
190 for (unsigned int j = 0; j < nq1 * nq2; ++j)
191 {
192 simd_type prod_sum = 0.0;
193 for (unsigned int k = 0; k < nq0; ++k)
194 {
195 simd_type v1 = D0[k * nq0 + i]; // Load 1x
196 simd_type v2 = in[j * nq0 + k]; // Load 1x
197
198 prod_sum.fma(v1, v2);
199 }
200
201 out_d0[j * nq0 + i] = prod_sum; // Store 1x
202 }
203 }
204 }
205
206 // Direction 1
207 if (Deriv1)
208 {
209 for (unsigned int block = 0; block < nq2; ++block)
210 {
211 unsigned int start = block * nq0 * nq1;
212
213 for (unsigned int i = 0; i < nq0; ++i)
214 {
215 for (unsigned int j = 0; j < nq1; ++j)
216 {
217 simd_type prod_sum = 0.0;
218 for (unsigned int k = 0; k < nq1; ++k)
219 {
220 simd_type v1 = in[start + k * nq0 + i]; // Load 1x
221 simd_type v2 = D1[k * nq1 + j]; // Load 1x
222
223 prod_sum.fma(v1, v2);
224 }
225
226 out_d1[start + j * nq0 + i] = prod_sum; // Store 1x
227 }
228 }
229 }
230 }
231
232 // Direction 2
233 if (Deriv2)
234 {
235 for (unsigned int i = 0; i < nq0 * nq1; ++i)
236 {
237 for (unsigned int j = 0; j < nq2; ++j)
238 {
239 simd_type prod_sum = 0.0;
240 for (unsigned int k = 0; k < nq2; ++k)
241 {
242 simd_type v1 = simd_type(in[k * nq0 * nq1 + i]); // Load 1x
243 simd_type v2 = D2[k * nq2 + j]; // Load 1x
244
245 prod_sum.fma(v1, v2);
246 }
247
248 out_d2[j * nq0 * nq1 + i] = prod_sum; // Store 1x
249 }
250 }
251 }
252}

◆ SumDerivTensor2DKernel()

template<typename simd_type >
static NEK_FORCE_INLINE void SumDerivTensor2DKernel ( const unsigned int  nq0,
const unsigned int  nq1,
const simd_type *  in0,
const simd_type *  in1,
const simd_type *  D0,
const simd_type *  D1,
simd_type *  out,
const typename simd_type::scalarType  scale = 0.0,
bool  Deriv0 = true,
bool  Deriv1 = true 
)
static

Definition at line 118 of file PhysDerivSumFacStdKernels.hpp.

123{
124 // All matricies are column major ordered since operators used to
125 // be computed via BLAS.
126
127 // D0 * in
128 if (Deriv0) // backwards compatibility with StdRegsion PhyTensorDeriv
129 {
130 for (unsigned int i = 0; i < nq0; ++i)
131 { // Row index of D0 matrix
132 for (unsigned int j = 0; j < nq1; ++j)
133 { // Col index of IN matrix
134
135 simd_type prod_sum = 0.0;
136 for (unsigned int k = 0; k < nq0; ++k)
137 { // Col index of D0, row index of IN
138 simd_type v1 = D0[i * nq0 + k]; // Load 1x
139 simd_type v2 = in0[j * nq0 + k]; // Load 1x
140
141 prod_sum.fma(v1, v2);
142 }
143
144 out[j * nq0 + i] *= simd_type(scale);
145 out[j * nq0 + i] += prod_sum; // Store 1x
146 }
147 }
148 }
149
150 // D1 * in
151 if (Deriv1)
152 {
153 // in * D1^T
154 for (unsigned int j = 0; j < nq1; ++j)
155 { // Column index for D1^T (row idx for D1)
156 for (unsigned int i = 0; i < nq0; ++i)
157 { // row index for grid
158
159 simd_type prod_sum = 0.0;
160 for (unsigned int k = 0; k < nq1; ++k)
161 {
162 simd_type v1 = in1[k * nq0 + i]; // Load 1x
163 simd_type v2 = D1[j * nq1 + k]; // Load 1x
164
165 prod_sum.fma(v1, v2);
166 }
167
168 out[j * nq0 + i] += prod_sum; // Store 1x
169 }
170 }
171 }
172}

◆ SumDerivTensor3DKernel()

template<typename simd_type >
static NEK_FORCE_INLINE void SumDerivTensor3DKernel ( const unsigned int  nq0,
const unsigned int  nq1,
const unsigned int  nq2,
const simd_type *  in0,
const simd_type *  in1,
const simd_type *  in2,
const simd_type *  D0,
const simd_type *  D1,
const simd_type *  D2,
simd_type *  out,
const typename simd_type::scalarType  scale = 0.0,
bool  Deriv0 = true,
bool  Deriv1 = true,
bool  Deriv2 = true 
)
static

Definition at line 255 of file PhysDerivSumFacStdKernels.hpp.

261{
262 // All matricies are column major ordered since operators used to
263 // be computed via BLAS.
264
265 // Compared with PhysDerivTensor3DKernel, here we must multiply by the
266 // transpose of D matrix
267
268 // Direction 0
269 if (Deriv0)
270 {
271 for (unsigned int p = 0; p < nq0; ++p)
272 {
273 unsigned int cnt_kji = 0, cnt_kj = 0;
274 for (unsigned int k = 0; k < nq2; ++k)
275 {
276 for (unsigned int j = 0; j < nq1; ++j, ++cnt_kj)
277 {
278 simd_type prod_sum = 0.0;
279 for (unsigned int i = 0; i < nq0; ++i, ++cnt_kji)
280 {
281 simd_type v1 = D0[p * nq0 + i]; // Load 1x
282 simd_type v2 = in0[cnt_kji]; // Load 1x
283
284 prod_sum.fma(v1, v2);
285 }
286 out[cnt_kj * nq0 + p] *= simd_type(scale);
287 out[cnt_kj * nq0 + p] += prod_sum; // Store 1x
288 }
289 }
290 }
291 }
292
293 // Direction 1
294 if (Deriv1)
295 {
296 for (unsigned int block = 0; block < nq2; ++block)
297 {
298 unsigned int start = block * nq0 * nq1;
299
300 for (unsigned int i = 0; i < nq0; ++i)
301 {
302 for (unsigned int j = 0; j < nq1; ++j)
303 {
304 simd_type prod_sum = 0.0;
305 for (unsigned int k = 0; k < nq1; ++k)
306 {
307 simd_type v1 = in1[start + k * nq0 + i]; // Load 1x
308 simd_type v2 = D1[j * nq1 + k]; // Load 1x
309
310 prod_sum.fma(v1, v2);
311 }
312
313 out[start + j * nq0 + i] += prod_sum; // Store 1x
314 }
315 }
316 }
317 }
318
319 // Direction 2
320 if (Deriv2)
321 {
322 unsigned int cnt_hi = 0;
323 for (unsigned int h = 0; h < nq1; ++h)
324 {
325 for (unsigned int i = 0; i < nq0; ++i, ++cnt_hi)
326 {
327 for (unsigned int j = 0; j < nq2; ++j)
328 {
329 simd_type prod_sum = 0.0;
330 for (unsigned int k = 0; k < nq2; ++k)
331 {
332 simd_type v1 = in2[k * nq0 * nq1 + cnt_hi]; // Load 1x
333 simd_type v2 = D2[j * nq2 + k]; // Load 1x
334
335 prod_sum.fma(v1, v2);
336 }
337
338 out[j * nq0 * nq1 + cnt_hi] += prod_sum; // Store 1x
339 }
340 }
341 }
342 }
343}
std::vector< double > p(NPUPPER)