Neko  0.9.0
A portable framework for high-order spectral element flow simulations
sumab_kernel.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2022, The Neko Authors
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions
7  are met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  * Redistributions in binary form must reproduce the above
13  copyright notice, this list of conditions and the following
14  disclaimer in the documentation and/or other materials provided
15  with the distribution.
16 
17  * Neither the name of the authors nor the names of its
18  contributors may be used to endorse or promote products derived
19  from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  POSSIBILITY OF SUCH DAMAGE.
33 */
34 
35 #ifndef __COMMON_SUMAB_KERNEL__
36 #define __COMMON_SUMAB_KERNEL__
37 
38 template< typename T >
39 __global__ void sumab_kernel(T * __restrict__ u,
40  T * __restrict__ v,
41  T * __restrict__ w,
42  const T * __restrict__ uu,
43  const T * __restrict__ vv,
44  const T * __restrict__ ww,
45  const T * __restrict__ ulag1,
46  const T * __restrict__ ulag2,
47  const T * __restrict__ vlag1,
48  const T * __restrict__ vlag2,
49  const T * __restrict__ wlag1,
50  const T * __restrict__ wlag2,
51  const T ab1,
52  const T ab2,
53  const T ab3,
54  const int nab,
55  const int n) {
56 
57  const int idx = blockIdx.x * blockDim.x + threadIdx.x;
58  const int str = blockDim.x * gridDim.x;
59 
60  for (int i = idx; i < n; i += str) {
61  u[i] = ab1 * uu[i] + ab2 * ulag1[i];
62  v[i] = ab1 * vv[i] + ab2 * vlag1[i];
63  w[i] = ab1 * ww[i] + ab2 * wlag1[i];
64  }
65 
66  if (nab == 3) {
67  for (int i = idx; i < n; i += str) {
68  u[i] = u[i] + ab3 * ulag2[i];
69  v[i] = v[i] + ab3 * vlag2[i];
70  w[i] = w[i] + ab3 * wlag2[i];
71  }
72  }
73 
74 }
75 
76 #endif // __COMMON_SUMAB_KERNEL__
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
const int i
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ u
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ v
__global__ void sumab_kernel(T *__restrict__ u, T *__restrict__ v, T *__restrict__ w, const T *__restrict__ uu, const T *__restrict__ vv, const T *__restrict__ ww, const T *__restrict__ ulag1, const T *__restrict__ ulag2, const T *__restrict__ vlag1, const T *__restrict__ vlag2, const T *__restrict__ wlag1, const T *__restrict__ wlag2, const T ab1, const T ab2, const T ab3, const int nab, const int n)
Definition: sumab_kernel.h:39