Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
coef.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 <stdio.h>
36#include "coef_kernel.h"
38#include <device/cuda/check.h>
39
40extern "C" {
41
45 void cuda_coef_generate_geo(void *G11, void *G12, void *G13,
46 void *G22, void *G23, void *G33,
47 void *drdx, void *drdy, void *drdz,
48 void *dsdx, void *dsdy, void *dsdz,
49 void *dtdx, void *dtdy, void *dtdz,
50 void *jacinv, void *w3, int *nel,
51 int *lx, int *gdim) {
52
53 const dim3 nthrds(1024, 1, 1);
54 const dim3 nblcks((*nel), 1, 1);
55 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
56
57#define GEO_CASE(LX) \
58 case LX: \
59 coef_generate_geo_kernel<real, LX, 1024> \
60 <<<nblcks, nthrds, 0, stream>>> \
61 ((real *) G11, (real *) G12, (real *) G13, \
62 (real *) G22, (real *) G23, (real *) G33, \
63 (real *) drdx, (real *) drdy, (real *) drdz, \
64 (real *) dsdx, (real *) dsdy, (real *) dsdz, \
65 (real *) dtdx, (real *) dtdy, (real *) dtdz, \
66 (real *) jacinv, (real *) w3, *gdim); \
67 CUDA_CHECK(cudaGetLastError()); \
68 break
69
70 switch(*lx) {
71 GEO_CASE(2);
72 GEO_CASE(3);
73 GEO_CASE(4);
74 GEO_CASE(5);
75 GEO_CASE(6);
76 GEO_CASE(7);
77 GEO_CASE(8);
78 GEO_CASE(9);
79 GEO_CASE(10);
80 GEO_CASE(11);
81 GEO_CASE(12);
82 GEO_CASE(13);
83 GEO_CASE(14);
84 GEO_CASE(15);
85 GEO_CASE(16);
86 default:
87 {
88 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
89 exit(1);
90 }
91 }
92 }
93
97 void cuda_coef_generate_dxyzdrst(void *drdx, void *drdy, void *drdz,
98 void *dsdx, void *dsdy, void *dsdz,
99 void *dtdx, void *dtdy, void *dtdz,
100 void *dxdr, void *dydr, void *dzdr,
101 void *dxds, void *dyds, void *dzds,
102 void *dxdt, void *dydt, void *dzdt,
103 void *dx, void *dy, void *dz,
104 void *x, void *y, void *z,
105 void *jacinv, void *jac,
106 int *lx, int *nel) {
107
108 const int n = (*nel) * (*lx) * (*lx) * (*lx);
109 const dim3 nthrds(1024, 1, 1);
110 const dim3 nblcks_dxyz((*nel), 1, 1);
111 const dim3 nblcks_drst((n + 1024 - 1)/ 1024, 1, 1);
112 const cudaStream_t stream = (cudaStream_t) glb_cmd_queue;
113
114#define DXYZDRST_CASE(LX) \
115 case LX: \
116 coef_generate_dxyz_kernel<real, LX, 1024> \
117 <<<nblcks_dxyz, nthrds, 0, stream>>> \
118 ((real *) dxdr, (real *) dydr, (real *) dzdr, \
119 (real *) dxds, (real *) dyds, (real *) dzds, \
120 (real *) dxdt, (real *) dydt, (real *) dzdt, \
121 (real *) dx, (real *) dy, (real *) dz, \
122 (real *) x, (real *) y, (real *) z); \
123 CUDA_CHECK(cudaGetLastError()); \
124 break
125
126 switch(*lx) {
127 DXYZDRST_CASE(2);
128 DXYZDRST_CASE(3);
129 DXYZDRST_CASE(4);
130 DXYZDRST_CASE(5);
131 DXYZDRST_CASE(6);
132 DXYZDRST_CASE(7);
133 DXYZDRST_CASE(8);
134 DXYZDRST_CASE(9);
135 DXYZDRST_CASE(10);
136 DXYZDRST_CASE(11);
137 DXYZDRST_CASE(12);
138 DXYZDRST_CASE(13);
139 DXYZDRST_CASE(14);
140 DXYZDRST_CASE(15);
141 DXYZDRST_CASE(16);
142 default:
143 {
144 fprintf(stderr, __FILE__ ": size not supported: %d\n", *lx);
145 exit(1);
146 }
147 }
148
150 <<<nblcks_drst, nthrds, 0, stream>>>
151 ((real *) jac, (real *) jacinv,
152 (real *) drdx, (real *) drdy, (real *) drdz,
153 (real *) dsdx, (real *) dsdy, (real *) dsdz,
154 (real *) dtdx, (real *) dtdy, (real *) dtdz,
155 (real *) dxdr, (real *) dydr, (real *) dzdr,
156 (real *) dxds, (real *) dyds, (real *) dzds,
157 (real *) dxdt, (real *) dydt, (real *) dzdt, n);
159
160 }
161}
162
163
164
165
#define GEO_CASE(LX)
void cuda_coef_generate_dxyzdrst(void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *dxdr, void *dydr, void *dzdr, void *dxds, void *dyds, void *dzds, void *dxdt, void *dydt, void *dzdt, void *dx, void *dy, void *dz, void *x, void *y, void *z, void *jacinv, void *jac, int *lx, int *nel)
Definition coef.cu:97
#define DXYZDRST_CASE(LX)
void cuda_coef_generate_geo(void *G11, void *G12, void *G13, void *G22, void *G23, void *G33, void *drdx, void *drdy, void *drdz, void *dsdx, void *dsdy, void *dsdz, void *dtdx, void *dtdy, void *dtdz, void *jacinv, void *w3, int *nel, int *lx, int *gdim)
Definition coef.cu:45
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ drdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dsdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dtdx
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dz
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ dy
__global__ void T *__restrict__ T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ jacinv
__global__ void const T *__restrict__ x
__global__ void const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ const T *__restrict__ w3
#define CUDA_CHECK(err)
Definition check.h:6
__global__ void dirichlet_apply_scalar_kernel(const int *__restrict__ msk, T *__restrict__ x, const T g, const int m)
double real