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