Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
device_coef.F90
Go to the documentation of this file.
1! Copyright (c) 2022-2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
34 use num_types, only : rp
35 use utils, only : neko_error
36 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
37 implicit none
38 private
39
41
42#ifdef HAVE_HIP
43 interface
44 subroutine hip_coef_generate_geo(G11, G12, G13, G22, G23, G33, &
45 drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, &
46 jacinv, w3, nel, lx, gdim) &
47 bind(c, name='hip_coef_generate_geo')
48 use, intrinsic :: iso_c_binding
49 implicit none
50 type(c_ptr), value :: G11, G12, G13, G22, G23, G33
51 type(c_ptr), value :: drdx, drdy, drdz
52 type(c_ptr), value :: dsdx, dsdy, dsdz
53 type(c_ptr), value :: dtdx, dtdy, dtdz
54 type(c_ptr), value :: jacinv, w3
55 integer(c_int) :: nel, gdim, lx
56 end subroutine hip_coef_generate_geo
57 end interface
58
59 interface
60 subroutine hip_coef_generate_dxyzdrst(drdx, drdy, drdz, dsdx, dsdy, &
61 dsdz, dtdx, dtdy, dtdz, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, &
62 dydt, dzdt, dx, dy, dz, x, y, z, jacinv, jac, lx, nel) &
63 bind(c, name='hip_coef_generate_dxyzdrst')
64 use, intrinsic :: iso_c_binding
65 implicit none
66 type(c_ptr), value :: drdx, drdy, drdz
67 type(c_ptr), value :: dsdx, dsdy, dsdz
68 type(c_ptr), value :: dtdx, dtdy, dtdz
69 type(c_ptr), value :: dxdr, dydr, dzdr
70 type(c_ptr), value :: dxds, dyds, dzds
71 type(c_ptr), value :: dxdt, dydt, dzdt
72 type(c_ptr), value :: dx, dy, dz, x, y, z
73 type(c_ptr), value :: jacinv, jac
74 integer(c_int) :: lx, nel
75 end subroutine hip_coef_generate_dxyzdrst
76 end interface
77#elif HAVE_CUDA
78 interface
79 subroutine cuda_coef_generate_geo(G11, G12, G13, G22, G23, G33, &
80 drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, &
81 jacinv, w3, nel, lx, gdim) &
82 bind(c, name='cuda_coef_generate_geo')
83 use, intrinsic :: iso_c_binding
84 implicit none
85 type(c_ptr), value :: G11, G12, G13, G22, G23, G33
86 type(c_ptr), value :: drdx, drdy, drdz
87 type(c_ptr), value :: dsdx, dsdy, dsdz
88 type(c_ptr), value :: dtdx, dtdy, dtdz
89 type(c_ptr), value :: jacinv, w3
90 integer(c_int) :: nel, gdim, lx
91 end subroutine cuda_coef_generate_geo
92 end interface
93
94 interface
95 subroutine cuda_coef_generate_dxyzdrst(drdx, drdy, drdz, dsdx, dsdy, &
96 dsdz, dtdx, dtdy, dtdz, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, &
97 dydt, dzdt, dx, dy, dz, x, y, z, jacinv, jac, lx, nel) &
98 bind(c, name='cuda_coef_generate_dxyzdrst')
99 use, intrinsic :: iso_c_binding
100 implicit none
101 type(c_ptr), value :: drdx, drdy, drdz
102 type(c_ptr), value :: dsdx, dsdy, dsdz
103 type(c_ptr), value :: dtdx, dtdy, dtdz
104 type(c_ptr), value :: dxdr, dydr, dzdr
105 type(c_ptr), value :: dxds, dyds, dzds
106 type(c_ptr), value :: dxdt, dydt, dzdt
107 type(c_ptr), value :: dx, dy, dz, x, y, z
108 type(c_ptr), value :: jacinv, jac
109 integer(c_int) :: lx, nel
110 end subroutine cuda_coef_generate_dxyzdrst
111 end interface
112#elif HAVE_OPENCL
113 interface
114 subroutine opencl_coef_generate_geo(G11, G12, G13, G22, G23, G33, &
115 drdx, drdy, drdz, dsdx, dsdy, dsdz, dtdx, dtdy, dtdz, &
116 jacinv, w3, nel, lx, gdim) &
117 bind(c, name='opencl_coef_generate_geo')
118 use, intrinsic :: iso_c_binding
119 implicit none
120 type(c_ptr), value :: G11, G12, G13, G22, G23, G33
121 type(c_ptr), value :: drdx, drdy, drdz
122 type(c_ptr), value :: dsdx, dsdy, dsdz
123 type(c_ptr), value :: dtdx, dtdy, dtdz
124 type(c_ptr), value :: jacinv, w3
125 integer(c_int) :: nel, gdim, lx
126 end subroutine opencl_coef_generate_geo
127 end interface
128
129 interface
130 subroutine opencl_coef_generate_dxyzdrst(drdx, drdy, drdz, dsdx, dsdy, &
131 dsdz, dtdx, dtdy, dtdz, dxdr, dydr, dzdr, dxds, dyds, dzds, dxdt, &
132 dydt, dzdt, dx, dy, dz, x, y, z, jacinv, jac, lx, nel) &
133 bind(c, name='opencl_coef_generate_dxyzdrst')
134 use, intrinsic :: iso_c_binding
135 implicit none
136 type(c_ptr), value :: drdx, drdy, drdz
137 type(c_ptr), value :: dsdx, dsdy, dsdz
138 type(c_ptr), value :: dtdx, dtdy, dtdz
139 type(c_ptr), value :: dxdr, dydr, dzdr
140 type(c_ptr), value :: dxds, dyds, dzds
141 type(c_ptr), value :: dxdt, dydt, dzdt
142 type(c_ptr), value :: dx, dy, dz, x, y, z
143 type(c_ptr), value :: jacinv, jac
144 integer(c_int) :: lx, nel
145 end subroutine opencl_coef_generate_dxyzdrst
146 end interface
147#endif
148
149contains
150
151 subroutine device_coef_generate_geo(G11_d, G12_d, G13_d, G22_d, &
152 G23_d, G33_d, drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, &
153 dsdz_d, dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nel, lx, gdim)
154 type(c_ptr) :: g11_d, g12_d, g13_d, g22_d, g23_d, g33_d
155 type(c_ptr) :: drdx_d, drdy_d, drdz_d
156 type(c_ptr) :: dsdx_d, dsdy_d, dsdz_d
157 type(c_ptr) :: dtdx_d, dtdy_d, dtdz_d
158 type(c_ptr) :: jacinv_d, w3_d
159 integer :: nel, gdim, lx
160
161#ifdef HAVE_HIP
162 call hip_coef_generate_geo(g11_d, g12_d, g13_d, g22_d, g23_d, &
163 g33_d, drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
164 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nel, lx, gdim)
165#elif HAVE_CUDA
166 call cuda_coef_generate_geo(g11_d, g12_d, g13_d, g22_d, g23_d, &
167 g33_d, drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
168 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nel, lx, gdim)
169#elif HAVE_OPENCL
170 call opencl_coef_generate_geo(g11_d, g12_d, g13_d, g22_d, g23_d, &
171 g33_d, drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, &
172 dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nel, lx, gdim)
173#else
174 call neko_error('No device backend configured')
175#endif
176
177 end subroutine device_coef_generate_geo
178
179 subroutine device_coef_generate_dxydrst(drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d,&
180 dsdz_d, dtdx_d, dtdy_d, dtdz_d, dxdr_d, dydr_d, dzdr_d, dxds_d, &
181 dyds_d, dzds_d, dxdt_d, dydt_d, dzdt_d, dx_d, dy_d, dz_d, &
182 x_d, y_d, z_d, jacinv_d, jac_d, lx, nel)
183 type(c_ptr) :: drdx_d, drdy_d, drdz_d
184 type(c_ptr) :: dsdx_d, dsdy_d, dsdz_d
185 type(c_ptr) :: dtdx_d, dtdy_d, dtdz_d
186 type(c_ptr) :: dxdr_d, dydr_d, dzdr_d
187 type(c_ptr) :: dxds_d, dyds_d, dzds_d
188 type(c_ptr) :: dxdt_d, dydt_d, dzdt_d
189 type(c_ptr) :: dx_d, dy_d, dz_d, x_d, y_d, z_d
190 type(c_ptr) :: jacinv_d, jac_d
191 integer :: lx, nel
192
193#ifdef HAVE_HIP
194 call hip_coef_generate_dxyzdrst(drdx_d, drdy_d, drdz_d, dsdx_d, &
195 dsdy_d, dsdz_d, dtdx_d, dtdy_d, dtdz_d, dxdr_d, dydr_d, &
196 dzdr_d, dxds_d, dyds_d, dzds_d, dxdt_d, dydt_d, dzdt_d, &
197 dx_d, dy_d, dz_d, x_d, y_d, z_d, jacinv_d, jac_d, lx, nel)
198#elif HAVE_CUDA
199 call cuda_coef_generate_dxyzdrst(drdx_d, drdy_d, drdz_d, dsdx_d, &
200 dsdy_d, dsdz_d, dtdx_d, dtdy_d, dtdz_d, dxdr_d, dydr_d, &
201 dzdr_d, dxds_d, dyds_d, dzds_d, dxdt_d, dydt_d, dzdt_d, &
202 dx_d, dy_d, dz_d, x_d, y_d, z_d, jacinv_d, jac_d, lx, nel)
203#elif HAVE_OPENCL
204 call opencl_coef_generate_dxyzdrst(drdx_d, drdy_d, drdz_d, dsdx_d, &
205 dsdy_d, dsdz_d, dtdx_d, dtdy_d, dtdz_d, dxdr_d, dydr_d, &
206 dzdr_d, dxds_d, dyds_d, dzds_d, dxdt_d, dydt_d, dzdt_d, &
207 dx_d, dy_d, dz_d, x_d, y_d, z_d, jacinv_d, jac_d, lx, nel)
208#else
209 call neko_error('No device backend configured')
210#endif
211 end subroutine device_coef_generate_dxydrst
212
213end module device_coef
void opencl_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.c:54
void opencl_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.c:125
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
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
subroutine, public device_coef_generate_dxydrst(drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, dtdx_d, dtdy_d, dtdz_d, dxdr_d, dydr_d, dzdr_d, dxds_d, dyds_d, dzds_d, dxdt_d, dydt_d, dzdt_d, dx_d, dy_d, dz_d, x_d, y_d, z_d, jacinv_d, jac_d, lx, nel)
subroutine, public device_coef_generate_geo(g11_d, g12_d, g13_d, g22_d, g23_d, g33_d, drdx_d, drdy_d, drdz_d, dsdx_d, dsdy_d, dsdz_d, dtdx_d, dtdy_d, dtdz_d, jacinv_d, w3_d, nel, lx, gdim)
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Utilities.
Definition utils.f90:35