Neko 1.99.7
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_kernel.h
Go to the documentation of this file.
1#ifndef __MATH_AX_HELM_KERNEL_H__
2#define __MATH_AX_HELM_KERNEL_H__
3/*
4 Copyright (c) 2021-2024, The Neko Authors
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions
9 are met:
10
11 * Redistributions of source code must retain the above copyright
12 notice, this list of conditions and the following disclaimer.
13
14 * Redistributions in binary form must reproduce the above
15 copyright notice, this list of conditions and the following
16 disclaimer in the documentation and/or other materials provided
17 with the distribution.
18
19 * Neither the name of the authors nor the names of its
20 contributors may be used to endorse or promote products derived
21 from this software without specific prior written permission.
22
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35*/
36
37#include "elem_block.h"
38
39/*
40 * Elements per block for the vector kstep kernels, pinned rather than swept.
41 *
42 * These hold three times the register blocked state of the scalar ones -- six
43 * T[LX] arrays rather than two -- and measure at 254-255 registers on sm_90
44 * for every lx from 8 up, spilling at 10, 12, 14 and 16. There is no headroom
45 * for a wider block, so they keep one element per block. Override with
46 * -DNEKO_AX_HELM_VECTOR_EB_C=<0|1|2> if that ever changes.
47 */
48#ifndef NEKO_AX_HELM_VECTOR_EB_C
49#define NEKO_AX_HELM_VECTOR_EB_C 0
50#endif
51
56template< typename T, const int LX, const int CHUNKS >
58 const T * __restrict__ u,
59 const T * __restrict__ dx,
60 const T * __restrict__ dy,
61 const T * __restrict__ dz,
62 const T * __restrict__ dxt,
63 const T * __restrict__ dyt,
64 const T * __restrict__ dzt,
65 const T * __restrict__ h1,
66 const T * __restrict__ g11,
67 const T * __restrict__ g22,
68 const T * __restrict__ g33,
69 const T * __restrict__ g12,
70 const T * __restrict__ g13,
71 const T * __restrict__ g23) {
72
76
80
85
86 const int e = blockIdx.x;
87 const int iii = threadIdx.x;
88 const int nchunks = (LX * LX * LX - 1)/CHUNKS + 1;
89
90 if (iii<LX*LX) {
91 shdx[iii] = dx[iii];
92 shdy[iii] = dy[iii];
93 shdz[iii] = dz[iii];
94 }
95
96 {
97 int i = iii;
98 while (i < LX * LX * LX){
99 shu[i] = u[i+e*LX*LX*LX];
100 i = i + CHUNKS;
101 }
102 }
103
105
106 if (iii<LX*LX){
107 shdxt[iii] = dxt[iii];
108 shdyt[iii] = dyt[iii];
109 shdzt[iii] = dzt[iii];
110 }
111
112 for (int n=0; n<nchunks; n++){
113 const int ijk = iii+n*CHUNKS;
114 const int jk = ijk/LX;
115 const int i = ijk-jk*LX;
116 const int k = jk/LX;
117 const int j = jk-k*LX;
118 if (i<LX && j<LX && k<LX && ijk < LX*LX*LX){
119 const T G00 = g11[ijk+e*LX*LX*LX];
120 const T G11 = g22[ijk+e*LX*LX*LX];
121 const T G22 = g33[ijk+e*LX*LX*LX];
122 const T G01 = g12[ijk+e*LX*LX*LX];
123 const T G02 = g13[ijk+e*LX*LX*LX];
124 const T G12 = g23[ijk+e*LX*LX*LX];
125 const T H1 = h1[ijk+e*LX*LX*LX];
126 T rtmp = 0.0;
127 T stmp = 0.0;
128 T ttmp = 0.0;
129#pragma unroll
130 for (int l = 0; l<LX; l++){
131 rtmp = rtmp + shdx[i+l*LX] * shu[l+j*LX+k*LX*LX];
132 stmp = stmp + shdy[j+l*LX] * shu[i+l*LX+k*LX*LX];
133 ttmp = ttmp + shdz[k+l*LX] * shu[i+j*LX+l*LX*LX];
134 }
135 shur[ijk] = H1 * (G00 * rtmp + G01 * stmp + G02 * ttmp);
136 shus[ijk] = H1 * (G01 * rtmp + G11 * stmp + G12 * ttmp);
137 shut[ijk] = H1 * (G02 * rtmp + G12 * stmp + G22 * ttmp);
138 }
139 }
140
142
143 for (int n=0; n<nchunks; n++){
144 const int ijk = iii+n*CHUNKS;
145 const int jk = ijk/LX;
146 const int k = jk/LX;
147 const int j = jk-k*LX;
148 const int i = ijk-jk*LX;
149 if (i<LX && j<LX && k<LX && ijk <LX*LX*LX){
150 T wijke = 0.0;
151#pragma unroll
152 for (int l = 0; l<LX; l++){
153 wijke = wijke
154 + shdxt[i+l*LX] * shur[l+j*LX+k*LX*LX]
155 + shdyt[j+l*LX] * shus[i+l*LX+k*LX*LX]
156 + shdzt[k+l*LX] * shut[i+j*LX+l*LX*LX];
157 }
158 w[ijk+e*LX*LX*LX] = wijke;
159 }
160 }
161}
162
163template< typename T, const int LX, const int EB >
166 const T * __restrict__ u,
177 const int nelv) {
178
179 /* Element independent, one copy per block */
180 __shared__ T shdx[LX * LX];
183
184 /* One slice per element in the block */
188
189 static_assert(sizeof(shdx) +
190 sizeof(shdy) +
191 sizeof(shdz) +
192 sizeof(shu) +
193 sizeof(shur) +
194 sizeof(shus)
196 "kstep block exceeds the shared memory budget");
197
201
202 /* Threads past the last element still have to reach the block wide
203 barriers below, so clamp their reads and drop their stores rather
204 than returning early. At EB == 1 the grid covers nelv exactly, so all
205 of this bookkeeping is constant folded and the kernel is exactly what
206 it was before blocking */
207 const int eb = (EB == 1) ? 0 : threadIdx.z;
208 const int e_blk = blockIdx.x * EB + eb;
209 const bool active = (EB == 1) ? true : (e_blk < nelv);
210 const int e = active ? e_blk : (nelv - 1);
211 const int j = threadIdx.y;
212 const int i = threadIdx.x;
213 const int ij = i + j*LX;
214 const int sh = eb*LX*LX;
215 const int ele = e*LX*LX*LX;
216
217 if (eb == 0) {
218 shdx[ij] = dx[ij];
219 shdy[ij] = dy[ij];
220 shdz[ij] = dz[ij];
221 }
222
223#pragma unroll
224 for(int k = 0; k < LX; ++k){
225 ru[k] = u[ij + k*LX*LX + ele];
226 rw[k] = 0.0;
227 }
228
229
231#pragma unroll
232 for (int k = 0; k < LX; ++k){
233 const int ijk = ij + k*LX*LX;
234 const T G00 = g11[ijk+ele];
235 const T G11 = g22[ijk+ele];
236 const T G22 = g33[ijk+ele];
237 const T G01 = g12[ijk+ele];
238 const T G02 = g13[ijk+ele];
239 const T G12 = g23[ijk+ele];
240 const T H1 = h1[ijk+ele];
241 T ttmp = 0.0;
242 shu[sh + ij] = ru[k];
243#pragma unroll
244 for (int l = 0; l < LX; l++){
245 ttmp += shdz[k+l*LX] * ru[l];
246 }
248
249 T rtmp = 0.0;
250 T stmp = 0.0;
251#pragma unroll
252 for (int l = 0; l < LX; l++){
253 rtmp += shdx[i+l*LX] * shu[sh + l+j*LX];
254 stmp += shdy[j+l*LX] * shu[sh + i+l*LX];
255 }
256 shur[sh + ij] = H1
257 * (G00 * rtmp
258 + G01 * stmp
259 + G02 * ttmp);
260 shus[sh + ij] = H1
261 * (G01 * rtmp
262 + G11 * stmp
263 + G12 * ttmp);
264 rut = H1
265 * (G02 * rtmp
266 + G12 * stmp
267 + G22 * ttmp);
268
270
271 T wijke = 0.0;
272#pragma unroll
273 for (int l = 0; l < LX; l++){
274 wijke += shur[sh + l+j*LX] * shdx[l+i*LX];
275 rw[l] += rut * shdz[k+l*LX];
276 wijke += shus[sh + i+l*LX] * shdy[l + j*LX];
277 }
278 rw[k] += wijke;
279 }
280 if (active) {
281#pragma unroll
282 for (int k = 0; k < LX; ++k){
283 w[ij + k*LX*LX + ele] = rw[k];
284 }
285 }
286}
287
293template< typename T, const int LX, const int EB >
296 const T * __restrict__ u,
297 const T * __restrict__ dx,
298 const T * __restrict__ dy,
299 const T * __restrict__ dz,
300 const T * __restrict__ h1,
301 const T * __restrict__ g11,
302 const T * __restrict__ g22,
303 const T * __restrict__ g33,
304 const T * __restrict__ g12,
305 const T * __restrict__ g13,
306 const T * __restrict__ g23,
307 const int nelv) {
308
309 /* Element independent, one copy per block */
310 __shared__ T shdx[LX * (LX+1)];
311 __shared__ T shdy[LX * (LX+1)];
312 __shared__ T shdz[LX * (LX+1)];
313
314 /* One slice per element in the block */
315 __shared__ T shu[EB * LX * (LX+1)];
316 __shared__ T shur[EB * LX * LX]; // only accessed using fastest dimension
317 __shared__ T shus[EB * LX * (LX+1)];
318
319 static_assert(sizeof(shdx) +
320 sizeof(shdy) +
321 sizeof(shdz) +
322 sizeof(shu) +
323 sizeof(shur) +
324 sizeof(shus)
326 "kstep block exceeds the shared memory budget");
327
328 T ru[LX];
329 T rw[LX];
330 T rut;
331
332 /* At EB == 1 the grid covers nelv exactly, so the blocking bookkeeping is
333 constant folded away and the kernel is exactly what it was before */
334 const int eb = (EB == 1) ? 0 : threadIdx.z;
335 const int e_blk = blockIdx.x * EB + eb;
336 const bool active = (EB == 1) ? true : (e_blk < nelv);
337 const int e = active ? e_blk : (nelv - 1);
338 const int j = threadIdx.y;
339 const int i = threadIdx.x;
340 const int ij = i + j*LX;
341 const int ij_p = i + j*(LX+1);
342 const int sh = eb*LX*LX;
343 const int sh_p = eb*LX*(LX+1);
344 const int ele = e*LX*LX*LX;
345
346 if (eb == 0) {
347 shdx[ij_p] = dx[ij];
348 shdy[ij_p] = dy[ij];
349 shdz[ij_p] = dz[ij];
350 }
351
352#pragma unroll
353 for(int k = 0; k < LX; ++k){
354 ru[k] = u[ij + k*LX*LX + ele];
355 rw[k] = 0.0;
356 }
357
358
360#pragma unroll
361 for (int k = 0; k < LX; ++k){
362 const int ijk = ij + k*LX*LX;
363 const T G00 = g11[ijk+ele];
364 const T G11 = g22[ijk+ele];
365 const T G22 = g33[ijk+ele];
366 const T G01 = g12[ijk+ele];
367 const T G02 = g13[ijk+ele];
368 const T G12 = g23[ijk+ele];
369 const T H1 = h1[ijk+ele];
370 T ttmp = 0.0;
371 shu[sh_p + ij_p] = ru[k];
372#pragma unroll
373 for (int l = 0; l < LX; l++){
374 ttmp += shdz[k+l*(LX+1)] * ru[l];
375 }
377
378 T rtmp = 0.0;
379 T stmp = 0.0;
380#pragma unroll
381 for (int l = 0; l < LX; l++){
382 rtmp += shdx[i+l*(LX+1)] * shu[sh_p + l+j*(LX+1)];
383 stmp += shdy[j+l*(LX+1)] * shu[sh_p + i+l*(LX+1)];
384 }
385 shur[sh + ij] = H1
386 * (G00 * rtmp
387 + G01 * stmp
388 + G02 * ttmp);
389 shus[sh_p + ij_p] = H1
390 * (G01 * rtmp
391 + G11 * stmp
392 + G12 * ttmp);
393 rut = H1
394 * (G02 * rtmp
395 + G12 * stmp
396 + G22 * ttmp);
397
399
400 T wijke = 0.0;
401#pragma unroll
402 for (int l = 0; l < LX; l++){
403 wijke += shur[sh + l+j*LX] * shdx[l+i*(LX+1)];
404 rw[l] += rut * shdz[k+l*(LX+1)];
405 wijke += shus[sh_p + i+l*(LX+1)] * shdy[l + j*(LX+1)];
406 }
407 rw[k] += wijke;
408 }
409 if (active) {
410#pragma unroll
411 for (int k = 0; k < LX; ++k){
412 w[ij + k*LX*LX + ele] = rw[k];
413 }
414 }
415}
416
417/*
418 * Vector versions
419 */
420
421template< typename T, const int LX, const int EB >
426 const T * __restrict__ u,
427 const T * __restrict__ v,
428 const T * __restrict__ w,
429 const T * __restrict__ dx,
430 const T * __restrict__ dy,
431 const T * __restrict__ dz,
432 const T * __restrict__ h1,
433 const T * __restrict__ g11,
434 const T * __restrict__ g22,
435 const T * __restrict__ g33,
436 const T * __restrict__ g12,
437 const T * __restrict__ g13,
438 const T * __restrict__ g23,
439 const int nelv) {
440
441 /* Element independent, one copy per block */
442 __shared__ T shdx[LX * LX];
443 __shared__ T shdy[LX * LX];
444 __shared__ T shdz[LX * LX];
445
446 /* One slice per element in the block */
447 __shared__ T shu[EB * LX * LX];
448 __shared__ T shur[EB * LX * LX];
449 __shared__ T shus[EB * LX * LX];
450
454
458
459 static_assert(sizeof(shdx) +
460 sizeof(shdy) +
461 sizeof(shdz) +
462 sizeof(shu) +
463 sizeof(shur) +
464 sizeof(shus) +
465 sizeof(shv) +
466 sizeof(shvr) +
467 sizeof(shvs) +
468 sizeof(shw) +
469 sizeof(shwr) +
470 sizeof(shws)
472 "kstep block exceeds the shared memory budget");
473
474 T ru[LX];
476 T rw[LX];
477
481
482 T rut;
485
486 /* At EB == 1 the grid covers nelv exactly, so the blocking bookkeeping is
487 constant folded away and the kernel is exactly what it was before */
488 const int eb = (EB == 1) ? 0 : threadIdx.z;
489 const int e_blk = blockIdx.x * EB + eb;
490 const bool active = (EB == 1) ? true : (e_blk < nelv);
491 const int e = active ? e_blk : (nelv - 1);
492 const int j = threadIdx.y;
493 const int i = threadIdx.x;
494 const int ij = i + j*LX;
495 const int sh = eb*LX*LX;
496 const int ele = e*LX*LX*LX;
497
498 if (eb == 0) {
499 shdx[ij] = dx[ij];
500 shdy[ij] = dy[ij];
501 shdz[ij] = dz[ij];
502 }
503
504#pragma unroll
505 for(int k = 0; k < LX; ++k){
506 ru[k] = u[ij + k*LX*LX + ele];
507 ruw[k] = 0.0;
508
509 rv[k] = v[ij + k*LX*LX + ele];
510 rvw[k] = 0.0;
511
512 rw[k] = w[ij + k*LX*LX + ele];
513 rww[k] = 0.0;
514 }
515
516
518#pragma unroll
519 for (int k = 0; k < LX; ++k){
520 const int ijk = ij + k*LX*LX;
521 const T G00 = g11[ijk+ele];
522 const T G11 = g22[ijk+ele];
523 const T G22 = g33[ijk+ele];
524 const T G01 = g12[ijk+ele];
525 const T G02 = g13[ijk+ele];
526 const T G12 = g23[ijk+ele];
527 const T H1 = h1[ijk+ele];
528 T uttmp = 0.0;
529 T vttmp = 0.0;
530 T wttmp = 0.0;
531 shu[sh + ij] = ru[k];
532 shv[sh + ij] = rv[k];
533 shw[sh + ij] = rw[k];
534#pragma unroll
535 for (int l = 0; l < LX; l++){
536 uttmp += shdz[k+l*LX] * ru[l];
537 vttmp += shdz[k+l*LX] * rv[l];
538 wttmp += shdz[k+l*LX] * rw[l];
539 }
541
542 T urtmp = 0.0;
543 T ustmp = 0.0;
544
545 T vrtmp = 0.0;
546 T vstmp = 0.0;
547
548 T wrtmp = 0.0;
549 T wstmp = 0.0;
550#pragma unroll
551 for (int l = 0; l < LX; l++){
552 urtmp += shdx[i+l*LX] * shu[sh + l+j*LX];
553 ustmp += shdy[j+l*LX] * shu[sh + i+l*LX];
554
555 vrtmp += shdx[i+l*LX] * shv[sh + l+j*LX];
556 vstmp += shdy[j+l*LX] * shv[sh + i+l*LX];
557
558 wrtmp += shdx[i+l*LX] * shw[sh + l+j*LX];
559 wstmp += shdy[j+l*LX] * shw[sh + i+l*LX];
560 }
561
562 shur[sh + ij] = H1
563 * (G00 * urtmp
564 + G01 * ustmp
565 + G02 * uttmp);
566 shus[sh + ij] = H1
567 * (G01 * urtmp
568 + G11 * ustmp
569 + G12 * uttmp);
570 rut = H1
571 * (G02 * urtmp
572 + G12 * ustmp
573 + G22 * uttmp);
574
575 shvr[sh + ij] = H1
576 * (G00 * vrtmp
577 + G01 * vstmp
578 + G02 * vttmp);
579 shvs[sh + ij] = H1
580 * (G01 * vrtmp
581 + G11 * vstmp
582 + G12 * vttmp);
583 rvt = H1
584 * (G02 * vrtmp
585 + G12 * vstmp
586 + G22 * vttmp);
587
588 shwr[sh + ij] = H1
589 * (G00 * wrtmp
590 + G01 * wstmp
591 + G02 * wttmp);
592 shws[sh + ij] = H1
593 * (G01 * wrtmp
594 + G11 * wstmp
595 + G12 * wttmp);
596 rwt = H1
597 * (G02 * wrtmp
598 + G12 * wstmp
599 + G22 * wttmp);
600
602
603 T uwijke = 0.0;
604 T vwijke = 0.0;
605 T wwijke = 0.0;
606#pragma unroll
607 for (int l = 0; l < LX; l++){
608 uwijke += shur[sh + l+j*LX] * shdx[l+i*LX];
609 ruw[l] += rut * shdz[k+l*LX];
610 uwijke += shus[sh + i+l*LX] * shdy[l + j*LX];
611
612 vwijke += shvr[sh + l+j*LX] * shdx[l+i*LX];
613 rvw[l] += rvt * shdz[k+l*LX];
614 vwijke += shvs[sh + i+l*LX] * shdy[l + j*LX];
615
616 wwijke += shwr[sh + l+j*LX] * shdx[l+i*LX];
617 rww[l] += rwt * shdz[k+l*LX];
618 wwijke += shws[sh + i+l*LX] * shdy[l + j*LX];
619 }
620 ruw[k] += uwijke;
621 rvw[k] += vwijke;
622 rww[k] += wwijke;
623 }
624 if (active) {
625#pragma unroll
626 for (int k = 0; k < LX; ++k){
627 au[ij + k*LX*LX + ele] = ruw[k];
628 av[ij + k*LX*LX + ele] = rvw[k];
629 aw[ij + k*LX*LX + ele] = rww[k];
630 }
631 }
632}
633
634template< typename T, const int LX, const int EB >
637 T * __restrict__ av,
638 T * __restrict__ aw,
639 const T * __restrict__ u,
640 const T * __restrict__ v,
641 const T * __restrict__ w,
642 const T * __restrict__ dx,
643 const T * __restrict__ dy,
644 const T * __restrict__ dz,
645 const T * __restrict__ h1,
646 const T * __restrict__ g11,
647 const T * __restrict__ g22,
648 const T * __restrict__ g33,
649 const T * __restrict__ g12,
650 const T * __restrict__ g13,
651 const T * __restrict__ g23,
652 const int nelv) {
653
654 /* Element independent, one copy per block */
655 __shared__ T shdx[LX * (LX+1)];
656 __shared__ T shdy[LX * (LX+1)];
657 __shared__ T shdz[LX * (LX+1)];
658
659 /* One slice per element in the block */
660 __shared__ T shu[EB * LX * (LX+1)];
661 __shared__ T shur[EB * LX * LX];
662 __shared__ T shus[EB * LX * (LX+1)];
663
664 __shared__ T shv[EB * LX * (LX+1)];
665 __shared__ T shvr[EB * LX * LX];
666 __shared__ T shvs[EB * LX * (LX+1)];
667
668 __shared__ T shw[EB * LX * (LX+1)];
669 __shared__ T shwr[EB * LX * LX];
670 __shared__ T shws[EB * LX * (LX+1)];
671
672 static_assert(sizeof(shdx) +
673 sizeof(shdy) +
674 sizeof(shdz) +
675 sizeof(shu) +
676 sizeof(shur) +
677 sizeof(shus) +
678 sizeof(shv) +
679 sizeof(shvr) +
680 sizeof(shvs) +
681 sizeof(shw) +
682 sizeof(shwr) +
683 sizeof(shws)
685 "kstep block exceeds the shared memory budget");
686
687 T ru[LX];
688 T rv[LX];
689 T rw[LX];
690
691 T ruw[LX];
692 T rvw[LX];
693 T rww[LX];
694
695 T rut;
696 T rvt;
697 T rwt;
698
699 /* At EB == 1 the grid covers nelv exactly, so the blocking bookkeeping is
700 constant folded away and the kernel is exactly what it was before */
701 const int eb = (EB == 1) ? 0 : threadIdx.z;
702 const int e_blk = blockIdx.x * EB + eb;
703 const bool active = (EB == 1) ? true : (e_blk < nelv);
704 const int e = active ? e_blk : (nelv - 1);
705 const int j = threadIdx.y;
706 const int i = threadIdx.x;
707 const int ij = i + j*LX;
708 const int ij_p = i + j*(LX+1);
709 const int sh = eb*LX*LX;
710 const int sh_p = eb*LX*(LX+1);
711 const int ele = e*LX*LX*LX;
712
713 if (eb == 0) {
714 shdx[ij_p] = dx[ij];
715 shdy[ij_p] = dy[ij];
716 shdz[ij_p] = dz[ij];
717 }
718
719#pragma unroll
720 for(int k = 0; k < LX; ++k){
721 ru[k] = u[ij + k*LX*LX + ele];
722 ruw[k] = 0.0;
723
724 rv[k] = v[ij + k*LX*LX + ele];
725 rvw[k] = 0.0;
726
727 rw[k] = w[ij + k*LX*LX + ele];
728 rww[k] = 0.0;
729 }
730
731
733#pragma unroll
734 for (int k = 0; k < LX; ++k){
735 const int ijk = ij + k*LX*LX;
736 const T G00 = g11[ijk+ele];
737 const T G11 = g22[ijk+ele];
738 const T G22 = g33[ijk+ele];
739 const T G01 = g12[ijk+ele];
740 const T G02 = g13[ijk+ele];
741 const T G12 = g23[ijk+ele];
742 const T H1 = h1[ijk+ele];
743 T uttmp = 0.0;
744 T vttmp = 0.0;
745 T wttmp = 0.0;
746 shu[sh_p + ij_p] = ru[k];
747 shv[sh_p + ij_p] = rv[k];
748 shw[sh_p + ij_p] = rw[k];
749#pragma unroll
750 for (int l = 0; l < LX; l++){
751 uttmp += shdz[k+l*(LX+1)] * ru[l];
752 vttmp += shdz[k+l*(LX+1)] * rv[l];
753 wttmp += shdz[k+l*(LX+1)] * rw[l];
754 }
756
757 T urtmp = 0.0;
758 T ustmp = 0.0;
759
760 T vrtmp = 0.0;
761 T vstmp = 0.0;
762
763 T wrtmp = 0.0;
764 T wstmp = 0.0;
765#pragma unroll
766 for (int l = 0; l < LX; l++){
767 urtmp += shdx[i+l*(LX+1)] * shu[sh_p + l+j*(LX+1)];
768 ustmp += shdy[j+l*(LX+1)] * shu[sh_p + i+l*(LX+1)];
769
770 vrtmp += shdx[i+l*(LX+1)] * shv[sh_p + l+j*(LX+1)];
771 vstmp += shdy[j+l*(LX+1)] * shv[sh_p + i+l*(LX+1)];
772
773 wrtmp += shdx[i+l*(LX+1)] * shw[sh_p + l+j*(LX+1)];
774 wstmp += shdy[j+l*(LX+1)] * shw[sh_p + i+l*(LX+1)];
775 }
776
777 shur[sh + ij] = H1
778 * (G00 * urtmp
779 + G01 * ustmp
780 + G02 * uttmp);
781 shus[sh_p + ij_p] = H1
782 * (G01 * urtmp
783 + G11 * ustmp
784 + G12 * uttmp);
785 rut = H1
786 * (G02 * urtmp
787 + G12 * ustmp
788 + G22 * uttmp);
789
790 shvr[sh + ij] = H1
791 * (G00 * vrtmp
792 + G01 * vstmp
793 + G02 * vttmp);
794 shvs[sh_p + ij_p] = H1
795 * (G01 * vrtmp
796 + G11 * vstmp
797 + G12 * vttmp);
798 rvt = H1
799 * (G02 * vrtmp
800 + G12 * vstmp
801 + G22 * vttmp);
802
803 shwr[sh + ij] = H1
804 * (G00 * wrtmp
805 + G01 * wstmp
806 + G02 * wttmp);
807 shws[sh_p + ij_p] = H1
808 * (G01 * wrtmp
809 + G11 * wstmp
810 + G12 * wttmp);
811 rwt = H1
812 * (G02 * wrtmp
813 + G12 * wstmp
814 + G22 * wttmp);
815
817
818 T uwijke = 0.0;
819 T vwijke = 0.0;
820 T wwijke = 0.0;
821#pragma unroll
822 for (int l = 0; l < LX; l++){
823 uwijke += shur[sh + l+j*LX] * shdx[l+i*(LX+1)];
824 ruw[l] += rut * shdz[k+l*(LX+1)];
825 uwijke += shus[sh_p + i+l*(LX+1)] * shdy[l + j*(LX+1)];
826
827 vwijke += shvr[sh + l+j*LX] * shdx[l+i*(LX+1)];
828 rvw[l] += rvt * shdz[k+l*(LX+1)];
829 vwijke += shvs[sh_p + i+l*(LX+1)] * shdy[l + j*(LX+1)];
830
831 wwijke += shwr[sh + l+j*LX] * shdx[l+i*(LX+1)];
832 rww[l] += rwt * shdz[k+l*(LX+1)];
833 wwijke += shws[sh_p + i+l*(LX+1)] * shdy[l + j*(LX+1)];
834 }
835 ruw[k] += uwijke;
836 rvw[k] += vwijke;
837 rww[k] += wwijke;
838 }
839 if (active) {
840#pragma unroll
841 for (int k = 0; k < LX; ++k){
842 au[ij + k*LX*LX + ele] = ruw[k];
843 av[ij + k*LX*LX + ele] = rvw[k];
844 aw[ij + k*LX*LX + ele] = rww[k];
845 }
846 }
847}
848
849template< typename T >
851 T * __restrict__ av,
852 T * __restrict__ aw,
853 const T * __restrict__ u,
854 const T * __restrict__ v,
855 const T * __restrict__ w,
856 const T * __restrict__ h2,
857 const T * __restrict__ B,
858 const int n) {
859
860 const int idx = blockIdx.x * blockDim.x + threadIdx.x;
861 const int str = blockDim.x * gridDim.x;
862
863 for (int i = idx; i < n; i += str) {
864 au[i] = au[i] + h2[i] * B[i] * u[i];
865 av[i] = av[i] + h2[i] * B[i] * v[i];
866 aw[i] = aw[i] + h2[i] * B[i] * w[i];
867 }
868
869}
870#endif // __MATH_AX_HELM_KERNEL_H__
__global__ void ale_add_kinematics_kernel(const int n, T *__restrict__ wx, T *__restrict__ wy, T *__restrict__ wz, const T *__restrict__ x_ref, const T *__restrict__ y_ref, const T *__restrict__ z_ref, const T *__restrict__ phi, const T *__restrict__ x, const T *__restrict__ y, const T *__restrict__ z, const kinematics_params_t kin_params)
shdx[ij]
const bool active
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const int nelv
const int ij_p
__shared__ T shus[EB *LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g23
T rww[LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g22
__global__ void T *__restrict__ av
const int sh
T ru[LX]
const int eb
__shared__ T shv[EB *LX *LX]
T rv[LX]
__shared__ T shwr[EB *LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g13
__global__ void ax_helm_kernel_1d(T *__restrict__ w, const T *__restrict__ u, const T *__restrict__ dx, const T *__restrict__ dy, const T *__restrict__ dz, const T *__restrict__ dxt, const T *__restrict__ dyt, const T *__restrict__ dzt, const T *__restrict__ h1, const T *__restrict__ g11, const T *__restrict__ g22, const T *__restrict__ g33, const T *__restrict__ g12, const T *__restrict__ g13, const T *__restrict__ g23)
const int sh_p
__shared__ T shur[EB *LX *LX]
const int i
__shared__ T shvs[EB *LX *LX]
const int ij
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g12
T rwt
T rw[LX]
__shared__ T shw[EB *LX *LX]
__shared__ T shws[EB *LX *LX]
__shared__ T shu[EB *LX *LX]
T rut
T ruw[LX]
const int e
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
const int e_blk
T rvt
T rvw[LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g33
__global__ void T *__restrict__ T *__restrict__ aw
__shared__ T shvr[EB *LX *LX]
__global__ void const T *__restrict__ u
const int ele
__global__ void const T *__restrict__ const T *__restrict__ dx
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
const int j
__shared__ T shdz[LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ h1
__syncthreads()
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g11
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void ax_helm_kernel_vector_part2(T *__restrict__ au, T *__restrict__ av, T *__restrict__ aw, const T *__restrict__ u, const T *__restrict__ v, const T *__restrict__ w, const T *__restrict__ h2, const T *__restrict__ B, const int n)
__shared__ T shdy[LX *LX]
__shared__ T shdzt[LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dzt
__shared__ T shdyt[LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dyt
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dxt
#define NEKO_EB_MAX_SMEM
Definition elem_block.h:60
#define NEKO_EB_BOUNDS(NT)
Definition elem_block.h:95