Neko  0.9.0
A portable framework for high-order spectral element flow simulations
rhs_maker.cu
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 #include <device/device_config.h>
36 #include <device/cuda/check.h>
37 
38 #include "sumab_kernel.h"
39 #include "makeext_kernel.h"
40 #include "makebdf_kernel.h"
41 
42 extern "C" {
43  void rhs_maker_sumab_cuda(void *u, void *v, void *w,
44  void *uu, void *vv, void *ww,
45  void *ulag1, void *ulag2, void *vlag1,
46  void *vlag2, void *wlag1, void *wlag2,
47  real *ab1, real *ab2, real *ab3, int *nab, int *n) {
48 
49  const dim3 nthrds(1024, 1, 1);
50  const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
51  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
52 
53  sumab_kernel<real>
54  <<<nblcks, nthrds, 0, stream>>>((real *) u, (real *) v, (real *) w,
55  (real *) uu, (real *) vv, (real *) ww,
56  (real *) ulag1, (real *) ulag2, (real *) vlag1,
57  (real *) vlag2, (real *) wlag1, (real *) wlag2,
58  *ab1, *ab2, *ab3, *nab, *n);
59  CUDA_CHECK(cudaGetLastError());
60  }
61 
62  void rhs_maker_ext_cuda(void *abx1, void *aby1, void *abz1,
63  void *abx2, void *aby2, void *abz2,
64  void *bfx, void *bfy, void *bfz,
65  real *rho, real *ab1, real *ab2, real *ab3, int *n) {
66 
67  const dim3 nthrds(1024, 1, 1);
68  const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
69  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
70 
71  makeext_kernel<real>
72  <<<nblcks, nthrds, 0, stream>>>((real *) abx1, (real *) aby1,
73  (real *) abz1, (real *) abx2,
74  (real *) aby2, (real *) abz2,
75  (real *) bfx, (real *) bfy,
76  (real *) bfz, *rho, *ab1,
77  *ab2, *ab3, *n);
78  CUDA_CHECK(cudaGetLastError());
79  }
80 
81  void scalar_rhs_maker_ext_cuda(void *fs_lag, void *fs_laglag, void *fs,
82  real *rho, real *ext1, real *ext2, real *ext3,
83  int *n) {
84 
85  const dim3 nthrds(1024, 1, 1);
86  const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
87  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
88 
89  scalar_makeext_kernel<real>
90  <<<nblcks, nthrds, 0, stream>>>((real *) fs_lag,
91  (real *) fs_laglag,
92  (real *) fs,
93  *rho, *ext1, *ext2, *ext3, *n);
94  CUDA_CHECK(cudaGetLastError());
95  }
96 
97  void rhs_maker_bdf_cuda(void *ulag1, void *ulag2, void *vlag1,
98  void *vlag2, void *wlag1, void *wlag2,
99  void *bfx, void *bfy, void *bfz,
100  void *u, void *v, void *w, void *B,
101  real *rho, real *dt, real *bd2,
102  real *bd3, real *bd4, int *nbd, int *n) {
103 
104  const dim3 nthrds(1024, 1, 1);
105  const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
106  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
107 
108  makebdf_kernel<real>
109  <<<nblcks, nthrds, 0, stream>>>((real *) ulag1, (real *) ulag2,
110  (real *) vlag1, (real *) vlag2,
111  (real *) wlag1, (real *) wlag2,
112  (real *) bfx, (real *) bfy, (real *) bfz,
113  (real *) u, (real *) v, (real *) w,
114  (real *) B, *rho, *dt,
115  *bd2, *bd3, *bd4, *nbd, *n);
116  CUDA_CHECK(cudaGetLastError());
117  }
118 
119  void scalar_rhs_maker_bdf_cuda(void *s_lag, void *s_laglag,
120  void *fs,
121  void *s, void *B,
122  real *rho, real *dt, real *bd2,
123  real *bd3, real *bd4, int *nbd, int *n) {
124 
125  const dim3 nthrds(1024, 1, 1);
126  const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
127  const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
128 
129  scalar_makebdf_kernel<real>
130  <<<nblcks, nthrds, 0, stream>>>((real *) s_lag,
131  (real *) s_laglag,
132  (real *) fs,
133  (real *) s,
134  (real *) B,
135  *rho, *dt, *bd2, *bd3, *bd4, *nbd, *n);
136  CUDA_CHECK(cudaGetLastError());
137  }
138 }
139 
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__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 const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dt
Definition: cdtp_kernel.h:109
#define CUDA_CHECK(err)
Definition: check.h:6
double real
Definition: device_config.h:12
void * glb_cmd_queue
void scalar_rhs_maker_bdf_cuda(void *s_lag, void *s_laglag, void *fs, void *s, void *B, real *rho, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition: rhs_maker.cu:119
void rhs_maker_ext_cuda(void *abx1, void *aby1, void *abz1, void *abx2, void *aby2, void *abz2, void *bfx, void *bfy, void *bfz, real *rho, real *ab1, real *ab2, real *ab3, int *n)
Definition: rhs_maker.cu:62
void rhs_maker_bdf_cuda(void *ulag1, void *ulag2, void *vlag1, void *vlag2, void *wlag1, void *wlag2, void *bfx, void *bfy, void *bfz, void *u, void *v, void *w, void *B, real *rho, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition: rhs_maker.cu:97
void scalar_rhs_maker_ext_cuda(void *fs_lag, void *fs_laglag, void *fs, real *rho, real *ext1, real *ext2, real *ext3, int *n)
Definition: rhs_maker.cu:81
void rhs_maker_sumab_cuda(void *u, void *v, void *w, void *uu, void *vv, void *ww, void *ulag1, void *ulag2, void *vlag1, void *vlag2, void *wlag1, void *wlag2, real *ab1, real *ab2, real *ab3, int *nab, int *n)
Definition: rhs_maker.cu:43