Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
compressible_ops_update.hip
Go to the documentation of this file.
1/*
2 Copyright (c) 2025, 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 <stdio.h>
36#include <stdlib.h>
37#include <hip/hip_runtime.h>
39#include <device/hip/check.h>
41
42extern "C" {
43
44void hip_update_uvw(void *u, void *v, void *w,
45 void *m_x, void *m_y, void *m_z,
46 void *rho, int *n) {
47
48 const dim3 nthrds(1024, 1, 1);
49 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
50 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
51
52 hipLaunchKernelGGL(HIP_KERNEL_NAME(update_uvw_kernel<real>),
53 nblcks, nthrds, 0, stream,
54 (real *) u, (real *) v, (real *) w,
55 (real *) m_x, (real *) m_y, (real *) m_z,
56 (real *) rho, *n);
57
58 HIP_CHECK(hipGetLastError());
59
60}
61
62void hip_update_mxyz_p_ruvw(void *m_x, void *m_y, void *m_z,
63 void *p, void *ruvw,
64 void *u, void *v, void *w, void *E,
65 void *rho, real *gamma, int *n) {
66
67 const dim3 nthrds(1024, 1, 1);
68 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
69 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
70
71 hipLaunchKernelGGL(HIP_KERNEL_NAME(update_mxyz_p_ruvw_kernel<real>),
72 nblcks, nthrds, 0, stream,
73 (real *) m_x, (real *) m_y, (real *) m_z,
74 (real *) p, (real *) ruvw,
75 (real *) u, (real *) v, (real *) w,
76 (real *) E, (real *) rho, *gamma, *n);
77
78 HIP_CHECK(hipGetLastError());
79
80}
81
82void hip_update_e(void *E, void *p, void *ruvw,
83 real *gamma, int *n) {
84
85 const dim3 nthrds(1024, 1, 1);
86 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
87 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
88
89 hipLaunchKernelGGL(HIP_KERNEL_NAME(update_e_kernel<real>),
90 nblcks, nthrds, 0, stream,
91 (real *) E, (real *) p, (real *) ruvw,
92 *gamma, *n);
93
94 HIP_CHECK(hipGetLastError());
95
96}
97
98void hip_update_temperature(void *T, void *p, void *rho,
99 real *gamma, int *n) {
100
101 const dim3 nthrds(1024, 1, 1);
102 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
103 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
104
105 hipLaunchKernelGGL(HIP_KERNEL_NAME(update_temperature_kernel<real>),
106 nblcks, nthrds, 0, stream,
107 (real *) T, (real *) p, (real *) rho, *gamma, *n);
108
109 HIP_CHECK(hipGetLastError());
110
111}
112
113void hip_ns_flux_prepare(void *div_flux, void *dissipation, void *h1,
114 void *dudx, void *dudy, void *dudz,
115 void *dvdx, void *dvdy, void *dvdz,
116 void *dwdx, void *dwdy, void *dwdz,
117 void *mu, int *n) {
118
119 const dim3 nthrds(1024, 1, 1);
120 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
121 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
122
123 hipLaunchKernelGGL(HIP_KERNEL_NAME(ns_flux_prepare_kernel<real>),
124 nblcks, nthrds, 0, stream,
125 (real *) div_flux, (real *) dissipation, (real *) h1,
126 (real *) dudx, (real *) dudy, (real *) dudz,
127 (real *) dvdx, (real *) dvdy, (real *) dvdz,
128 (real *) dwdx, (real *) dwdy, (real *) dwdz,
129 (real *) mu, *n);
130
131 HIP_CHECK(hipGetLastError());
132
133}
134
135void hip_ns_flux_finalize(void *visc_m_x, void *visc_m_y, void *visc_m_z,
136 void *visc_E, void *f_x, void *f_y, void *f_z,
137 void *opgrad_x, void *opgrad_y, void *opgrad_z,
138 void *u, void *v, void *w, void *B,
139 void *dissipation, int *n) {
140
141 const dim3 nthrds(1024, 1, 1);
142 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
143 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
144
145 hipLaunchKernelGGL(HIP_KERNEL_NAME(ns_flux_finalize_kernel<real>),
146 nblcks, nthrds, 0, stream,
147 (real *) visc_m_x, (real *) visc_m_y, (real *) visc_m_z,
148 (real *) visc_E, (real *) f_x, (real *) f_y,
149 (real *) f_z, (real *) opgrad_x, (real *) opgrad_y,
150 (real *) opgrad_z, (real *) u, (real *) v, (real *) w,
151 (real *) B, (real *) dissipation, *n);
152
153 HIP_CHECK(hipGetLastError());
154
155}
156
157void hip_ns_flux_temperature(void *div_flux, void *h1, void *p, void *rho,
158 void *kappa, real *gamma, int *n) {
159
160 const dim3 nthrds(1024, 1, 1);
161 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
162 const hipStream_t stream = (hipStream_t) glb_cmd_queue;
163
164 hipLaunchKernelGGL(HIP_KERNEL_NAME(ns_flux_temperature_kernel<real>),
165 nblcks, nthrds, 0, stream,
166 (real *) div_flux, (real *) h1, (real *) p,
167 (real *) rho, (real *) kappa, *gamma, *n);
168
169 HIP_CHECK(hipGetLastError());
170
171}
172
173}
void hip_ns_flux_finalize(void *visc_m_x, void *visc_m_y, void *visc_m_z, void *visc_E, void *f_x, void *f_y, void *f_z, void *opgrad_x, void *opgrad_y, void *opgrad_z, void *u, void *v, void *w, void *B, void *dissipation, int *n)
void hip_update_temperature(void *T, void *p, void *rho, real *gamma, int *n)
void hip_ns_flux_prepare(void *div_flux, void *dissipation, void *h1, void *dudx, void *dudy, void *dudz, void *dvdx, void *dvdy, void *dvdz, void *dwdx, void *dwdy, void *dwdz, void *mu, int *n)
void hip_update_e(void *E, void *p, void *ruvw, real *gamma, int *n)
void hip_ns_flux_temperature(void *div_flux, void *h1, void *p, void *rho, void *kappa, real *gamma, int *n)
void hip_update_uvw(void *u, void *v, void *w, void *m_x, void *m_y, void *m_z, void *rho, int *n)
void hip_update_mxyz_p_ruvw(void *m_x, void *m_y, void *m_z, void *p, void *ruvw, void *u, void *v, void *w, void *E, void *rho, real *gamma, int *n)
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w
__global__ void 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__ const T *__restrict__ h1
__global__ void ns_flux_temperature_kernel(T *__restrict__ div_flux, T *__restrict__ h1, const T *__restrict__ p, const T *__restrict__ rho, const T *__restrict__ kappa, const T gamma, const int n)
__global__ void update_mxyz_p_ruvw_kernel(T *__restrict__ m_x, T *__restrict__ m_y, T *__restrict__ m_z, T *__restrict__ p, T *__restrict__ ruvw, const T *__restrict__ u, const T *__restrict__ v, const T *__restrict__ w, const T *__restrict__ E, const T *__restrict__ rho, const T gamma, const int n)
__global__ void update_temperature_kernel(T *__restrict__ T_field, const T *__restrict__ p, const T *__restrict__ rho, const T gamma, const int n)
__global__ void update_e_kernel(T *__restrict__ E, T *__restrict__ p, const T *__restrict__ ruvw, const T gamma, const int n)
__global__ void update_uvw_kernel(T *__restrict__ u, T *__restrict__ v, T *__restrict__ w, const T *__restrict__ m_x, const T *__restrict__ m_y, const T *__restrict__ m_z, const T *__restrict__ rho, const int n)
__global__ void ns_flux_prepare_kernel(T *__restrict__ div_flux, T *__restrict__ dissipation, T *__restrict__ h1, const T *__restrict__ dudx, const T *__restrict__ dudy, const T *__restrict__ dudz, const T *__restrict__ dvdx, const T *__restrict__ dvdy, const T *__restrict__ dvdz, const T *__restrict__ dwdx, const T *__restrict__ dwdy, const T *__restrict__ dwdz, const T *__restrict__ mu, const int n)
__global__ void ns_flux_finalize_kernel(T *__restrict__ visc_m_x, T *__restrict__ visc_m_y, T *__restrict__ visc_m_z, T *__restrict__ visc_E, T *__restrict__ f_x, T *__restrict__ f_y, T *__restrict__ f_z, const T *__restrict__ opgrad_x, const T *__restrict__ opgrad_y, const T *__restrict__ opgrad_z, const T *__restrict__ u, const T *__restrict__ v, const T *__restrict__ w, const T *__restrict__ B, const T *__restrict__ dissipation, const int n)
double real
void * glb_cmd_queue
#define HIP_CHECK(err)
Definition check.h:8