Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
ax_helm_svv_factorized_kernel.h
Go to the documentation of this file.
1#ifndef __MATH_AX_HELM_SVV_FACTORIZED_KERNEL_H__
2#define __MATH_AX_HELM_SVV_FACTORIZED_KERNEL_H__
3/*
4 Copyright (c) 2026, 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
53template< typename T, const int LX, const bool PAD >
54__global__ void __launch_bounds__(LX*LX)
55ax_helm_svv_factorized_kernel(T * __restrict__ w,
56 const T * __restrict__ u,
57 const T * __restrict__ dx,
58 const T * __restrict__ dy,
59 const T * __restrict__ dz,
60 const T * __restrict__ h1,
61 const T * __restrict__ br,
62 const T * __restrict__ bs,
63 const T * __restrict__ bt,
64 const T * __restrict__ h1_svv,
65 const T * __restrict__ g11,
66 const T * __restrict__ g22,
67 const T * __restrict__ g33,
68 const T * __restrict__ g12,
69 const T * __restrict__ g13,
70 const T * __restrict__ g23) {
71
72 constexpr int P = PAD ? LX + 1 : LX;
73
74 __shared__ T shdx[LX * P];
75 __shared__ T shdy[LX * P];
76 __shared__ T shdz[LX * P];
77 __shared__ T shbr[LX * P];
78 __shared__ T shbs[LX * P];
79 __shared__ T shbt[LX * P];
80
81 __shared__ T shu[LX * P];
82 __shared__ T shur[LX * LX]; // only accessed along fastest dimension
83 __shared__ T shus[LX * P];
84 __shared__ T shur_svv[LX * LX]; // only accessed along fastest dimension
85 __shared__ T shus_svv[LX * P];
86
87 T ru[LX];
88 T rw[LX];
89 T rut;
91
92 const int e = blockIdx.x;
93 const int j = threadIdx.y;
94 const int i = threadIdx.x;
95 const int ij = i + j*LX;
96 const int ij_p = i + j*P;
97 const int ele = e*LX*LX*LX;
98
99 shdx[ij_p] = dx[ij];
100 shdy[ij_p] = dy[ij];
101 shdz[ij_p] = dz[ij];
102 shbr[ij_p] = br[ij];
103 shbs[ij_p] = bs[ij];
104 shbt[ij_p] = bt[ij];
105
106#pragma unroll
107 for (int k = 0; k < LX; ++k) {
108 ru[k] = u[ij + k*LX*LX + ele];
109 rw[k] = 0.0;
110 }
111
113#pragma unroll
114 for (int k = 0; k < LX; ++k) {
115 const int ijk = ij + k*LX*LX;
116 const T G00 = g11[ijk+ele];
117 const T G11 = g22[ijk+ele];
118 const T G22 = g33[ijk+ele];
119 const T G01 = g12[ijk+ele];
120 const T G02 = g13[ijk+ele];
121 const T G12 = g23[ijk+ele];
122
123 T ttmp = 0.0;
124 T ttmp_svv = 0.0;
125 shu[ij_p] = ru[k];
126#pragma unroll
127 for (int l = 0; l < LX; l++) {
128 ttmp += shdz[k+l*P] * ru[l];
129 ttmp_svv += shbt[k+l*P] * ru[l];
130 }
132
133 T rtmp = 0.0;
134 T stmp = 0.0;
135 T rtmp_svv = 0.0;
136 T stmp_svv = 0.0;
137#pragma unroll
138 for (int l = 0; l < LX; l++) {
139 const T ul_r = shu[l+j*P];
140 const T ul_s = shu[i+l*P];
141 rtmp += shdx[i+l*P] * ul_r;
142 stmp += shdy[j+l*P] * ul_s;
143 rtmp_svv += shbr[i+l*P] * ul_r;
144 stmp_svv += shbs[j+l*P] * ul_s;
145 }
146
147 const T H1 = h1[ijk+ele];
148 shur[ij] = H1 * (G00 * rtmp + G01 * stmp + G02 * ttmp);
149 shus[ij_p] = H1 * (G01 * rtmp + G11 * stmp + G12 * ttmp);
150 rut = H1 * (G02 * rtmp + G12 * stmp + G22 * ttmp);
151
152 const T H1_SVV = h1_svv[ijk+ele];
153 shur_svv[ij] = H1_SVV
154 * (G00 * rtmp_svv + G01 * stmp_svv + G02 * ttmp_svv);
155 shus_svv[ij_p] = H1_SVV
156 * (G01 * rtmp_svv + G11 * stmp_svv + G12 * ttmp_svv);
157 rut_svv = H1_SVV
158 * (G02 * rtmp_svv + G12 * stmp_svv + G22 * ttmp_svv);
159
161
162 T wijke = 0.0;
163#pragma unroll
164 for (int l = 0; l < LX; l++) {
165 wijke += shur[l+j*LX] * shdx[l+i*P]
166 + shur_svv[l+j*LX] * shbr[l+i*P];
167 wijke += shus[i+l*P] * shdy[l+j*P]
168 + shus_svv[i+l*P] * shbs[l+j*P];
169 rw[l] += rut * shdz[k+l*P] + rut_svv * shbt[k+l*P];
170 }
171 rw[k] += wijke;
172 }
173
174#pragma unroll
175 for (int k = 0; k < LX; ++k) {
176 w[ij + k*LX*LX + ele] = rw[k];
177 }
178}
179
180#endif // __MATH_AX_HELM_SVV_FACTORIZED_KERNEL_H__
const int ij_p
__shared__ T shdy[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
__shared__ T shu[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__ g22
__shared__ T shdz[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 T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
const int i
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
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void const T *__restrict__ const T *__restrict__ dx
__global__ void const T *__restrict__ u
__shared__ T shus[EB *LX *LX]
const int e
__shared__ T shur[EB *LX *LX]
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
T ru[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
const int ele
T rw[LX]
const int j
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ g11
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ h1
shdx[ij]
__shared__ T shbt[LX *P]
__global__ void T *__restrict__ 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 T *__restrict__ h1_svv
__shared__ T shbr[LX *P]
__global__ void T *__restrict__ 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__ bt
__shared__ T shur_svv[LX *LX]
__global__ void T *__restrict__ 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__ br
__global__ void T *__restrict__ 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__ bs
__shared__ T shus_svv[LX *P]
__shared__ T shbs[LX *P]
__global__ void __launch_bounds__(LX *LX) ax_helm_svv_factorized_kernel(T *__restrict__ w
__syncthreads()