Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
compressible_ops_update.cu
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 <cuda.h>
38#include <cuda_runtime.h>
39#include <cublas.h>
41#include <device/cuda/check.h>
43
44extern "C" {
45
46void cuda_update_uvw(void *u, void *v, void *w,
47 void *m_x, void *m_y, void *m_z,
48 void *rho, int *n) {
49
50 const dim3 nthrds(1024, 1, 1);
51 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
52 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
53
55 <<<nblcks, nthrds, 0, stream>>>((real *) u, (real *) v, (real *) w,
56 (real *) m_x, (real *) m_y, (real *) m_z,
57 (real *) rho, *n);
58
59 CUDA_CHECK(cudaGetLastError());
60
61}
62
63void cuda_update_mxyz_p_ruvw(void *m_x, void *m_y, void *m_z,
64 void *p, void *ruvw,
65 void *u, void *v, void *w, void *E,
66 void *rho, real *gamma, int *n) {
67
68 const dim3 nthrds(1024, 1, 1);
69 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
70 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
71
73 <<<nblcks, nthrds, 0, stream>>>((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 CUDA_CHECK(cudaGetLastError());
79
80}
81
82void cuda_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 cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
88
90 <<<nblcks, nthrds, 0, stream>>>((real *) E, (real *) p, (real *) ruvw,
91 *gamma, *n);
92
93 CUDA_CHECK(cudaGetLastError());
94
95}
96
97void cuda_update_temperature(void *T, void *p, void *rho,
98 real *gamma, int *n) {
99
100 const dim3 nthrds(1024, 1, 1);
101 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
102 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
103
105 <<<nblcks, nthrds, 0, stream>>>((real *) T, (real *) p, (real *) rho,
106 *gamma, *n);
107
108 CUDA_CHECK(cudaGetLastError());
109
110}
111
112void cuda_ns_flux_prepare(void *div_flux, void *dissipation, void *h1,
113 void *dudx, void *dudy, void *dudz,
114 void *dvdx, void *dvdy, void *dvdz,
115 void *dwdx, void *dwdy, void *dwdz,
116 void *mu, int *n) {
117
118 const dim3 nthrds(1024, 1, 1);
119 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
120 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
121
123 <<<nblcks, nthrds, 0, stream>>>((real *) div_flux,
124 (real *) dissipation, (real *) h1,
125 (real *) dudx, (real *) dudy,
126 (real *) dudz, (real *) dvdx,
127 (real *) dvdy, (real *) dvdz,
128 (real *) dwdx, (real *) dwdy,
129 (real *) dwdz, (real *) mu, *n);
130
131 CUDA_CHECK(cudaGetLastError());
132
133}
134
135void cuda_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 cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
144
146 <<<nblcks, nthrds, 0, stream>>>((real *) visc_m_x,
147 (real *) visc_m_y,
148 (real *) visc_m_z, (real *) visc_E,
149 (real *) f_x, (real *) f_y,
150 (real *) f_z, (real *) opgrad_x,
151 (real *) opgrad_y, (real *) opgrad_z,
152 (real *) u, (real *) v, (real *) w,
153 (real *) B, (real *) dissipation, *n);
154
155 CUDA_CHECK(cudaGetLastError());
156
157}
158
159void cuda_ns_flux_temperature(void *div_flux, void *h1, void *p, void *rho,
160 void *kappa, real *gamma, int *n) {
161
162 const dim3 nthrds(1024, 1, 1);
163 const dim3 nblcks(((*n) + 1024 - 1) / 1024, 1, 1);
164 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
165
167 <<<nblcks, nthrds, 0, stream>>>((real *) div_flux, (real *) h1,
168 (real *) p, (real *) rho,
169 (real *) kappa, *gamma, *n);
170
171 CUDA_CHECK(cudaGetLastError());
172
173}
174
175}
void cuda_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 cuda_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 cuda_update_uvw(void *u, void *v, void *w, void *m_x, void *m_y, void *m_z, void *rho, int *n)
void cuda_update_temperature(void *T, void *p, void *rho, real *gamma, int *n)
void cuda_ns_flux_temperature(void *div_flux, void *h1, void *p, void *rho, void *kappa, real *gamma, int *n)
void cuda_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)
void cuda_update_e(void *E, void *p, void *ruvw, 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
#define CUDA_CHECK(err)
Definition check.h:6
__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