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