Neko 1.99.7
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
rhs_maker_device.F90
Go to the documentation of this file.
1! Copyright (c) 2022, 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!
36 use device, only : device_get_ptr
37 use device_math, only : device_copy
39 use field, only : field_t
40 use num_types, only : rp, c_rp
41 use, intrinsic :: iso_c_binding, only : c_ptr
42 implicit none
43 private
44
46 contains
47 procedure, nopass :: compute_fluid => rhs_maker_sumab_device
49
50 type, public, extends(rhs_maker_ext_t) :: rhs_maker_ext_device_t
51 contains
52 procedure, nopass :: compute_fluid => rhs_maker_ext_device
53 procedure, nopass :: compute_scalar => scalar_rhs_maker_ext_device
55
56 type, public, extends(rhs_maker_bdf_t) :: rhs_maker_bdf_device_t
57 contains
58 procedure, nopass :: compute_fluid => rhs_maker_bdf_device
59 procedure, nopass :: compute_scalar => scalar_rhs_maker_bdf_device
61
62 type, public, extends(rhs_maker_oifs_t) :: rhs_maker_oifs_device_t
63 contains
64 procedure, nopass :: compute_fluid => rhs_maker_oifs_device
65 procedure, nopass :: compute_scalar => scalar_rhs_maker_oifs_device
67
68#ifdef HAVE_HIP
69 interface
70 subroutine rhs_maker_sumab_hip(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
71 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
72 bind(c, name = 'rhs_maker_sumab_hip')
73 use, intrinsic :: iso_c_binding
74 import c_rp
75 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
76 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
77 real(c_rp) :: ab1, ab2, ab3
78 integer(c_int) :: nab, n
79 end subroutine rhs_maker_sumab_hip
80 end interface
81
82 interface
83 subroutine rhs_maker_ext_hip(abx1_d, aby1_d, abz1_d, &
84 abx2_d, aby2_d, abz2_d, &
85 bfx_d, bfy_d, bfz_d, &
86 rho, ab1, ab2, ab3, n) &
87 bind(c, name = 'rhs_maker_ext_hip')
88 use, intrinsic :: iso_c_binding
89 import c_rp
90 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
91 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
92 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
93 real(c_rp) :: rho, ab1, ab2, ab3
94 integer(c_int) :: n
95 end subroutine rhs_maker_ext_hip
96 end interface
97
98 interface
99 subroutine scalar_rhs_maker_ext_hip(fs_lag_d, fs_laglag_d, fs_d, &
100 ext1, ext2, ext3, n) &
101 bind(c, name = 'scalar_rhs_maker_ext_hip')
102 use, intrinsic :: iso_c_binding
103 import c_rp
104 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
105 real(c_rp) :: ext1, ext2, ext3
106 integer(c_int) :: n
107 end subroutine scalar_rhs_maker_ext_hip
108 end interface
109
110 interface
111 subroutine rhs_maker_bdf_hip(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
112 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
113 Blag_d, Blaglag_d, rho, dt, bd2, bd3, bd4, nbd, n) &
114 bind(c, name = 'rhs_maker_bdf_hip')
115 use, intrinsic :: iso_c_binding
116 import c_rp
117 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
118 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
119 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
120 type(c_ptr), value :: Blag_d, Blaglag_d
121 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
122 integer(c_int) :: nbd, n
123 end subroutine rhs_maker_bdf_hip
124 end interface
125
126 interface
127 subroutine scalar_rhs_maker_bdf_hip(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
128 rho_cp_d, dt, bd2, bd3, bd4, nbd, n) &
129 bind(c, name = 'scalar_rhs_maker_bdf_hip')
130 use, intrinsic :: iso_c_binding
131 import c_rp
132 type(c_ptr), value :: s_lag_d, s_laglag_d
133 type(c_ptr), value :: fs_d, s_d, B_d, rho_cp_d
134 reaL(c_rp) :: dt, bd2, bd3, bd4
135 integer(c_int) :: nbd, n
136 end subroutine scalar_rhs_maker_bdf_hip
137 end interface
138
139 interface
140 subroutine rhs_maker_oifs_hip(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
141 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_hip')
142 use, intrinsic :: iso_c_binding
143 import c_rp
144 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
145 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
146 reaL(c_rp) :: rho, dt
147 integer(c_int) :: n
148 end subroutine rhs_maker_oifs_hip
149 end interface
150
151 interface
152 subroutine scalar_rhs_maker_oifs_hip(phi_s_d, bf_s_d, rho_cp_d, dt, n) &
153 bind(c, name = 'scalar_rhs_maker_oifs_hip')
154 use, intrinsic :: iso_c_binding
155 import c_rp
156 type(c_ptr), value :: bf_s_d, phi_s_d, rho_cp_d
157 reaL(c_rp) :: dt
158 integer(c_int) :: n
159 end subroutine scalar_rhs_maker_oifs_hip
160 end interface
161#elif HAVE_CUDA
162 interface
163 subroutine rhs_maker_sumab_cuda(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
164 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
165 bind(c, name = 'rhs_maker_sumab_cuda')
166 use, intrinsic :: iso_c_binding
167 import c_rp
168 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
169 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
170 real(c_rp) :: ab1, ab2, ab3
171 integer(c_int) :: nab, n
172 end subroutine rhs_maker_sumab_cuda
173 end interface
174
175 interface
176 subroutine rhs_maker_ext_cuda(abx1_d, aby1_d, abz1_d, &
177 abx2_d, aby2_d, abz2_d, &
178 bfx_d, bfy_d, bfz_d, &
179 rho, ab1, ab2, ab3, n) &
180 bind(c, name = 'rhs_maker_ext_cuda')
181 use, intrinsic :: iso_c_binding
182 import c_rp
183 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
184 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
185 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
186 real(c_rp) :: rho, ab1, ab2, ab3
187 integer(c_int) :: n
188 end subroutine rhs_maker_ext_cuda
189 end interface
190
191 interface
192 subroutine scalar_rhs_maker_ext_cuda(fs_lag_d, fs_laglag_d, fs_d, &
193 ext1, ext2, ext3, n) &
194 bind(c, name = 'scalar_rhs_maker_ext_cuda')
195 use, intrinsic :: iso_c_binding
196 import c_rp
197 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
198 real(c_rp) :: ext1, ext2, ext3
199 integer(c_int) :: n
200 end subroutine scalar_rhs_maker_ext_cuda
201 end interface
202
203 interface
204 subroutine rhs_maker_bdf_cuda(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
205 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
206 Blag_d, Blaglag_d, rho, dt, bd2, bd3, bd4, nbd, n) &
207 bind(c, name = 'rhs_maker_bdf_cuda')
208 use, intrinsic :: iso_c_binding
209 import c_rp
210 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
211 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
212 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
213 type(c_ptr), value :: Blag_d, Blaglag_d
214 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
215 integer(c_int) :: nbd, n
216 end subroutine rhs_maker_bdf_cuda
217 end interface
218
219 interface
220 subroutine scalar_rhs_maker_bdf_cuda(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
221 rho_cp_d, dt, bd2, bd3, bd4, nbd, n) &
222 bind(c, name = 'scalar_rhs_maker_bdf_cuda')
223 use, intrinsic :: iso_c_binding
224 import c_rp
225 type(c_ptr), value :: s_lag_d, s_laglag_d
226 type(c_ptr), value :: fs_d, s_d, B_d, rho_cp_d
227 reaL(c_rp) :: dt, bd2, bd3, bd4
228 integer(c_int) :: nbd, n
229 end subroutine scalar_rhs_maker_bdf_cuda
230 end interface
231
232 interface
233 subroutine rhs_maker_oifs_cuda(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
234 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_cuda')
235 use, intrinsic :: iso_c_binding
236 import c_rp
237 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
238 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
239 reaL(c_rp) :: rho, dt
240 integer(c_int) :: n
241 end subroutine rhs_maker_oifs_cuda
242 end interface
243
244 interface
245 subroutine scalar_rhs_maker_oifs_cuda(phi_s_d, bf_s_d, rho_cp_d, dt, n) &
246 bind(c, name = 'scalar_rhs_maker_oifs_cuda')
247 use, intrinsic :: iso_c_binding
248 import c_rp
249 type(c_ptr), value :: bf_s_d, phi_s_d, rho_cp_d
250 reaL(c_rp) :: dt
251 integer(c_int) :: n
252 end subroutine scalar_rhs_maker_oifs_cuda
253 end interface
254#elif HAVE_OPENCL
255 interface
256 subroutine rhs_maker_sumab_opencl(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
257 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
258 bind(c, name = 'rhs_maker_sumab_opencl')
259 use, intrinsic :: iso_c_binding
260 import c_rp
261 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
262 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
263 real(c_rp) :: ab1, ab2, ab3
264 integer(c_int) :: nab, n
265 end subroutine rhs_maker_sumab_opencl
266 end interface
267
268 interface
269 subroutine rhs_maker_ext_opencl(abx1_d, aby1_d, abz1_d, &
270 abx2_d, aby2_d, abz2_d, &
271 bfx_d, bfy_d, bfz_d, &
272 rho, ab1, ab2, ab3, n) &
273 bind(c, name = 'rhs_maker_ext_opencl')
274 use, intrinsic :: iso_c_binding
275 import c_rp
276 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
277 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
278 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
279 real(c_rp) :: rho, ab1, ab2, ab3
280 integer(c_int) :: n
281 end subroutine rhs_maker_ext_opencl
282 end interface
283
284 interface
285 subroutine scalar_rhs_maker_ext_opencl(fs_lag_d, fs_laglag_d, fs_d, &
286 ext1, ext2, ext3, n) &
287 bind(c, name = 'scalar_rhs_maker_ext_opencl')
288 use, intrinsic :: iso_c_binding
289 import c_rp
290 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
291 real(c_rp) :: ext1, ext2, ext3
292 integer(c_int) :: n
293 end subroutine scalar_rhs_maker_ext_opencl
294 end interface
295
296 interface
297 subroutine rhs_maker_bdf_opencl(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
298 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
299 rho, dt, bd2, bd3, bd4, nbd, n) bind(c, name = 'rhs_maker_bdf_opencl')
300 use, intrinsic :: iso_c_binding
301 import c_rp
302 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
303 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
304 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
305 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
306 integer(c_int) :: nbd, n
307 end subroutine rhs_maker_bdf_opencl
308 end interface
309
310 interface
311 subroutine scalar_rhs_maker_bdf_opencl(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
312 rho_cp_d, dt, bd2, bd3, bd4, nbd, n) &
313 bind(c, name = 'scalar_rhs_maker_bdf_opencl')
314 use, intrinsic :: iso_c_binding
315 import c_rp
316 type(c_ptr), value :: s_lag_d, s_laglag_d
317 type(c_ptr), value :: fs_d, s_d, B_d, rho_cp_d
318 reaL(c_rp) :: dt, bd2, bd3, bd4
319 integer(c_int) :: nbd, n
320 end subroutine scalar_rhs_maker_bdf_opencl
321 end interface
322
323 interface
324 subroutine rhs_maker_oifs_opencl(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
325 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_opencl')
326 use, intrinsic :: iso_c_binding
327 import c_rp
328 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
329 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
330 reaL(c_rp) :: rho, dt
331 integer(c_int) :: n
332 end subroutine rhs_maker_oifs_opencl
333 end interface
334
335 interface
336 subroutine scalar_rhs_maker_oifs_opencl(phi_s_d, bf_s_d, rho_cp_d, dt, n) &
337 bind(c, name = 'scalar_rhs_maker_oifs_opencl')
338 use, intrinsic :: iso_c_binding
339 import c_rp
340 type(c_ptr), value :: bf_s_d, phi_s_d, rho_cp_d
341 reaL(c_rp) :: dt
342 integer(c_int) :: n
343 end subroutine scalar_rhs_maker_oifs_opencl
344 end interface
345#elif HAVE_METAL
346 interface
347 subroutine rhs_maker_sumab_metal(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
348 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
349 bind(c, name = 'rhs_maker_sumab_metal')
350 use, intrinsic :: iso_c_binding
351 import c_rp
352 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
353 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
354 real(c_rp) :: ab1, ab2, ab3
355 integer(c_int) :: nab, n
356 end subroutine rhs_maker_sumab_metal
357 end interface
358
359 interface
360 subroutine rhs_maker_ext_metal(abx1_d, aby1_d, abz1_d, &
361 abx2_d, aby2_d, abz2_d, &
362 bfx_d, bfy_d, bfz_d, &
363 rho, ab1, ab2, ab3, n) &
364 bind(c, name = 'rhs_maker_ext_metal')
365 use, intrinsic :: iso_c_binding
366 import c_rp
367 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
368 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
369 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
370 real(c_rp) :: rho, ab1, ab2, ab3
371 integer(c_int) :: n
372 end subroutine rhs_maker_ext_metal
373 end interface
374
375 interface
376 subroutine scalar_rhs_maker_ext_metal(fs_lag_d, fs_laglag_d, fs_d, &
377 ext1, ext2, ext3, n) &
378 bind(c, name = 'scalar_rhs_maker_ext_metal')
379 use, intrinsic :: iso_c_binding
380 import c_rp
381 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
382 real(c_rp) :: ext1, ext2, ext3
383 integer(c_int) :: n
384 end subroutine scalar_rhs_maker_ext_metal
385 end interface
386
387 interface
388 subroutine rhs_maker_bdf_metal(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
389 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
390 rho, dt, bd2, bd3, bd4, nbd, n) bind(c, name = 'rhs_maker_bdf_metal')
391 use, intrinsic :: iso_c_binding
392 import c_rp
393 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
394 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
395 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
396 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
397 integer(c_int) :: nbd, n
398 end subroutine rhs_maker_bdf_metal
399 end interface
400
401 interface
402 subroutine scalar_rhs_maker_bdf_metal(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
403 rho_cp_d, dt, bd2, bd3, bd4, nbd, n) &
404 bind(c, name = 'scalar_rhs_maker_bdf_metal')
405 use, intrinsic :: iso_c_binding
406 import c_rp
407 type(c_ptr), value :: s_lag_d, s_laglag_d
408 type(c_ptr), value :: fs_d, s_d, B_d, rho_cp_d
409 reaL(c_rp) :: dt, bd2, bd3, bd4
410 integer(c_int) :: nbd, n
411 end subroutine scalar_rhs_maker_bdf_metal
412 end interface
413
414 interface
415 subroutine rhs_maker_oifs_metal(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
416 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_metal')
417 use, intrinsic :: iso_c_binding
418 import c_rp
419 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
420 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
421 reaL(c_rp) :: rho, dt
422 integer(c_int) :: n
423 end subroutine rhs_maker_oifs_metal
424 end interface
425
426 interface
427 subroutine scalar_rhs_maker_oifs_metal(phi_s_d, bf_s_d, rho_cp_d, dt, n) &
428 bind(c, name = 'scalar_rhs_maker_oifs_metal')
429 use, intrinsic :: iso_c_binding
430 import c_rp
431 type(c_ptr), value :: bf_s_d, phi_s_d, rho_cp_d
432 reaL(c_rp) :: dt
433 integer(c_int) :: n
434 end subroutine scalar_rhs_maker_oifs_metal
435 end interface
436#endif
437
438contains
439
440 subroutine rhs_maker_sumab_device(u, v, w, uu, vv, ww, uulag, vvlag, wwlag, ab, nab)
441 type(field_t), intent(inout) :: u,v, w
442 type(field_t), intent(inout) :: uu, vv, ww
443 type(field_series_t), intent(inout) :: uulag, vvlag, wwlag
444 real(kind=rp), dimension(3), intent(in) :: ab
445 integer, intent(in) :: nab
446
447#ifdef HAVE_HIP
448 call rhs_maker_sumab_hip(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
449 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
450 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
451 uu%dof%size())
452#elif HAVE_CUDA
453 call rhs_maker_sumab_cuda(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
454 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
455 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
456 uu%dof%size())
457#elif HAVE_OPENCL
458 call rhs_maker_sumab_opencl(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
459 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
460 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
461 uu%dof%size())
462#elif HAVE_METAL
463 call rhs_maker_sumab_metal(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
464 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
465 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
466 uu%dof%size())
467#endif
468
469 end subroutine rhs_maker_sumab_device
470
471 subroutine rhs_maker_ext_device(fx_lag, fy_lag, fz_lag, &
472 fx_laglag, fy_laglag, fz_laglag, fx, fy, fz, &
473 rho, ext_coeffs, n)
474 type(field_t), intent(inout) :: fx_lag, fy_lag, fz_lag
475 type(field_t), intent(inout) :: fx_laglag, fy_laglag, fz_laglag
476 real(kind=rp), intent(in) :: rho, ext_coeffs(4)
477 integer, intent(in) :: n
478 real(kind=rp), intent(inout) :: fx(n), fy(n), fz(n)
479 type(c_ptr) :: fx_d, fy_d, fz_d
480
481 fx_d = device_get_ptr(fx)
482 fy_d = device_get_ptr(fy)
483 fz_d = device_get_ptr(fz)
484
485#ifdef HAVE_HIP
486 call rhs_maker_ext_hip(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
487 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
488 fx_d, fy_d, fz_d, rho, &
489 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
490#elif HAVE_CUDA
491 call rhs_maker_ext_cuda(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
492 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
493 fx_d, fy_d, fz_d, rho, &
494 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
495#elif HAVE_OPENCL
496 call rhs_maker_ext_opencl(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
497 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
498 fx_d, fy_d, fz_d, rho, &
499 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
500#elif HAVE_METAL
501 call rhs_maker_ext_metal(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
502 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
503 fx_d, fy_d, fz_d, rho, &
504 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
505#endif
506
507 end subroutine rhs_maker_ext_device
508
509 subroutine scalar_rhs_maker_ext_device(fs_lag, fs_laglag, fs, ext_coeffs, n)
510 type(field_t), intent(inout) :: fs_lag
511 type(field_t), intent(inout) :: fs_laglag
512 real(kind=rp), intent(in) :: ext_coeffs(4)
513 integer, intent(in) :: n
514 real(kind=rp), intent(inout) :: fs(n)
515 type(c_ptr) :: fs_d
516
517 fs_d = device_get_ptr(fs)
518
519#ifdef HAVE_HIP
520 call scalar_rhs_maker_ext_hip(fs_lag%x_d, fs_laglag%x_d, fs_d, &
521 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
522#elif HAVE_CUDA
523 call scalar_rhs_maker_ext_cuda(fs_lag%x_d, fs_laglag%x_d, fs_d, &
524 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
525#elif HAVE_OPENCL
526 call scalar_rhs_maker_ext_opencl(fs_lag%x_d, fs_laglag%x_d, fs_d, &
527 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
528#elif HAVE_METAL
529 call scalar_rhs_maker_ext_metal(fs_lag%x_d, fs_laglag%x_d, fs_d, &
530 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
531#endif
532
533 end subroutine scalar_rhs_maker_ext_device
534
535 subroutine rhs_maker_bdf_device(ulag, vlag, wlag, bfx, bfy, bfz, &
536 u, v, w, B, Blag, Blaglag, rho, dt, bd, nbd, n)
537 integer, intent(in) :: n, nbd
538 type(field_t), intent(in) :: u, v, w
539 type(field_series_t), intent(in) :: ulag, vlag, wlag
540 real(kind=rp), intent(inout) :: bfx(n), bfy(n), bfz(n)
541 real(kind=rp), intent(in) :: b(n), blag(n), blaglag(n)
542 real(kind=rp), intent(in) :: dt, rho, bd(4)
543 type(c_ptr) :: bfx_d, bfy_d, bfz_d, b_d, blag_d, blaglag_d
544
545 bfx_d = device_get_ptr(bfx)
546 bfy_d = device_get_ptr(bfy)
547 bfz_d = device_get_ptr(bfz)
548 b_d = device_get_ptr(b)
549 blag_d = device_get_ptr(blag)
550 blaglag_d = device_get_ptr(blaglag)
551#ifdef HAVE_HIP
552 call rhs_maker_bdf_hip(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
553 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
554 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
555 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
556 b_d, blag_d, blaglag_d, &
557 rho, dt, bd(2), bd(3), bd(4), nbd, n)
558#elif HAVE_CUDA
559 call rhs_maker_bdf_cuda(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
560 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
561 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
562 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
563 b_d, blag_d, blaglag_d, &
564 rho, dt, bd(2), bd(3), bd(4), nbd, n)
565#elif HAVE_OPENCL
566 call rhs_maker_bdf_opencl(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
567 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
568 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
569 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
570 b_d, rho, dt, bd(2), bd(3), bd(4), nbd, n)
571#elif HAVE_METAL
572 call rhs_maker_bdf_metal(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
573 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
574 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
575 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
576 b_d, rho, dt, bd(2), bd(3), bd(4), nbd, n)
577#endif
578
579 end subroutine rhs_maker_bdf_device
580
581 subroutine scalar_rhs_maker_bdf_device(s_lag, fs, s, B, rho_cp, dt, &
582 bd, nbd, n)
583 integer, intent(in) :: n, nbd
584 type(field_t), intent(in) :: s, rho_cp
585 type(field_series_t), intent(in) :: s_lag
586 real(kind=rp), intent(inout) :: fs(n)
587 real(kind=rp), intent(in) :: b(n)
588 real(kind=rp), intent(in) :: dt, bd(4)
589 type(c_ptr) :: fs_d, b_d
590
591 fs_d = device_get_ptr(fs)
592 b_d = device_get_ptr(b)
593
594#ifdef HAVE_HIP
595 call scalar_rhs_maker_bdf_hip(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
596 fs_d, s%x_d, b_d, rho_cp%x_d, dt, bd(2), bd(3), bd(4), &
597 nbd, n)
598#elif HAVE_CUDA
599 call scalar_rhs_maker_bdf_cuda(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
600 fs_d, s%x_d, b_d, rho_cp%x_d, dt, bd(2), bd(3), bd(4), &
601 nbd, n)
602#elif HAVE_OPENCL
603 call scalar_rhs_maker_bdf_opencl(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
604 fs_d, s%x_d, b_d, rho_cp%x_d, dt, bd(2), bd(3), bd(4), &
605 nbd, n)
606#elif HAVE_METAL
607 call scalar_rhs_maker_bdf_metal(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
608 fs_d, s%x_d, b_d, rho_cp%x_d, dt, bd(2), bd(3), bd(4), &
609 nbd, n)
610#endif
611
612 end subroutine scalar_rhs_maker_bdf_device
613
614 subroutine rhs_maker_oifs_device(phi_x, phi_y, phi_z, bf_x, bf_y, bf_z, &
615 rho, dt, n)
616 real(kind=rp), intent(in) :: rho, dt
617 integer, intent(in) :: n
618 real(kind=rp), intent(inout) :: bf_x(n), bf_y(n), bf_z(n)
619 real(kind=rp), intent(inout) :: phi_x(n), phi_y(n), phi_z(n)
620
621 type(c_ptr) :: phi_x_d, phi_y_d, phi_z_d, bf_x_d, bf_y_d, bf_z_d
622
623 phi_x_d = device_get_ptr(phi_x)
624 phi_y_d = device_get_ptr(phi_y)
625 phi_z_d = device_get_ptr(phi_z)
626 bf_x_d = device_get_ptr(bf_x)
627 bf_y_d = device_get_ptr(bf_y)
628 bf_z_d = device_get_ptr(bf_z)
629
630#ifdef HAVE_HIP
631 call rhs_maker_oifs_hip(phi_x_d, phi_y_d, phi_z_d, &
632 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
633#elif HAVE_CUDA
634 call rhs_maker_oifs_cuda(phi_x_d, phi_y_d, phi_z_d, &
635 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
636#elif HAVE_OPENCL
637 call rhs_maker_oifs_opencl(phi_x_d, phi_y_d, phi_z_d, &
638 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
639#elif HAVE_METAL
640 call rhs_maker_oifs_metal(phi_x_d, phi_y_d, phi_z_d, &
641 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
642#endif
643
644 end subroutine rhs_maker_oifs_device
645
646 subroutine scalar_rhs_maker_oifs_device(phi_s, bf_s, rho_cp, dt, n)
647 type(field_t), intent(in) :: rho_cp
648 real(kind=rp), intent(in) :: dt
649 integer, intent(in) :: n
650 real(kind=rp), intent(inout) :: bf_s(n)
651 real(kind=rp), intent(inout) :: phi_s(n)
652 type(c_ptr) :: phi_s_d, bf_s_d
653
654 phi_s_d = device_get_ptr(phi_s)
655 bf_s_d = device_get_ptr(bf_s)
656
657#ifdef HAVE_HIP
658 call scalar_rhs_maker_oifs_hip(phi_s_d, bf_s_d, rho_cp%x_d, dt, n)
659#elif HAVE_CUDA
660 call scalar_rhs_maker_oifs_cuda(phi_s_d, bf_s_d, rho_cp%x_d, dt, n)
661#elif HAVE_OPENCL
662 call scalar_rhs_maker_oifs_opencl(phi_s_d, bf_s_d, rho_cp%x_d, dt, n)
663#elif HAVE_METAL
664 call scalar_rhs_maker_oifs_metal(phi_s_d, bf_s_d, rho_cp%x_d, dt, n)
665#endif
666
667 end subroutine scalar_rhs_maker_oifs_device
668
669end module rhs_maker_device
Return the device pointer for an associated Fortran array.
Definition device.F90:113
subroutine, public device_copy(a_d, b_d, n, strm)
Copy a vector .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Contains the field_serties_t type.
Defines a field.
Definition field.f90:34
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
subroutine scalar_rhs_maker_bdf_device(s_lag, fs, s, b, rho_cp, dt, bd, nbd, n)
subroutine scalar_rhs_maker_ext_device(fs_lag, fs_laglag, fs, ext_coeffs, n)
subroutine rhs_maker_sumab_device(u, v, w, uu, vv, ww, uulag, vvlag, wwlag, ab, nab)
subroutine rhs_maker_oifs_device(phi_x, phi_y, phi_z, bf_x, bf_y, bf_z, rho, dt, n)
subroutine rhs_maker_bdf_device(ulag, vlag, wlag, bfx, bfy, bfz, u, v, w, b, blag, blaglag, rho, dt, bd, nbd, n)
subroutine scalar_rhs_maker_oifs_device(phi_s, bf_s, rho_cp, dt, n)
subroutine rhs_maker_ext_device(fx_lag, fy_lag, fz_lag, fx_laglag, fy_laglag, fz_laglag, fx, fy, fz, rho, ext_coeffs, n)
Routines to generate the right-hand sides for the convection-diffusion equation. Employs the EXT/BDF ...
Definition rhs_maker.f90:38
void rhs_maker_sumab_opencl(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 *ext1, real *ext2, real *ext3, int *nab, int *n)
Definition rhs_maker.c:49
void scalar_rhs_maker_bdf_opencl(void *s_lag, void *s_laglag, void *fs, void *s, void *B, void *rho_cp, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition rhs_maker.c:203
void scalar_rhs_maker_ext_opencl(void *fs_lag, void *fs_laglag, void *fs, real *ext1, real *ext2, real *ext3, int *n)
Definition rhs_maker.c:128
void rhs_maker_ext_opencl(void *abx1, void *aby1, void *abz1, void *abx2, void *aby2, void *abz2, void *bfx, void *bfy, void *bfz, real *rho, real *ext1, real *ext2, real *ext3, int *n)
Definition rhs_maker.c:90
void rhs_maker_oifs_opencl(void *phi_x, void *phi_y, void *phi_z, void *bf_x, void *bf_y, void *bf_z, real *rho, real *dt, int *n)
Definition rhs_maker.c:239
void scalar_rhs_maker_oifs_opencl(void *phi_s, void *bf_s, void *rho_cp, real *dt, int *n)
Definition rhs_maker.c:271
void rhs_maker_bdf_opencl(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.c:157
void scalar_rhs_maker_oifs_cuda(void *phi_s, void *bf_s, void *rho_cp, real *dt, int *n)
Definition rhs_maker.cu:158
void rhs_maker_oifs_cuda(void *phi_x, void *phi_y, void *phi_z, void *bf_x, void *bf_y, void *bf_z, real *rho, real *dt, int *n)
Definition rhs_maker.cu:141
void scalar_rhs_maker_bdf_cuda(void *s_lag, void *s_laglag, void *fs, void *s, void *B, void *rho_cp, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition rhs_maker.cu:120
void rhs_maker_ext_cuda(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.cu:63
void rhs_maker_sumab_cuda(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.cu:44
void scalar_rhs_maker_ext_cuda(void *fs_lag, void *fs_laglag, void *fs, real *ext1, real *ext2, real *ext3, int *n)
Definition rhs_maker.cu:82
void rhs_maker_bdf_cuda(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, void *Blag, void *Blaglag, real *rho, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition rhs_maker.cu:97
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
Abstract type to add contributions to F from lagged BD terms.
Definition rhs_maker.f90:59
Abstract type to sum up contributions to kth order extrapolation scheme.
Definition rhs_maker.f90:52
Abstract type to add contributions of kth order OIFS scheme.
Definition rhs_maker.f90:66
Abstract type to compute extrapolated velocity field for the pressure equation.
Definition rhs_maker.f90:46