Neko 1.99.5
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, rho, &
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) :: rho, 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, 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
134 reaL(c_rp) :: rho, 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, 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
157 type(c_ptr), value :: phi_s_d
158 reaL(c_rp) :: rho, dt
159 integer(c_int) :: n
160 end subroutine scalar_rhs_maker_oifs_hip
161 end interface
162#elif HAVE_CUDA
163 interface
164 subroutine rhs_maker_sumab_cuda(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
165 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
166 bind(c, name = 'rhs_maker_sumab_cuda')
167 use, intrinsic :: iso_c_binding
168 import c_rp
169 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
170 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
171 real(c_rp) :: ab1, ab2, ab3
172 integer(c_int) :: nab, n
173 end subroutine rhs_maker_sumab_cuda
174 end interface
175
176 interface
177 subroutine rhs_maker_ext_cuda(abx1_d, aby1_d, abz1_d, &
178 abx2_d, aby2_d, abz2_d, &
179 bfx_d, bfy_d, bfz_d, &
180 rho, ab1, ab2, ab3, n) &
181 bind(c, name = 'rhs_maker_ext_cuda')
182 use, intrinsic :: iso_c_binding
183 import c_rp
184 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
185 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
186 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
187 real(c_rp) :: rho, ab1, ab2, ab3
188 integer(c_int) :: n
189 end subroutine rhs_maker_ext_cuda
190 end interface
191
192 interface
193 subroutine scalar_rhs_maker_ext_cuda(fs_lag_d, fs_laglag_d, fs_d, rho, &
194 ext1, ext2, ext3, n) &
195 bind(c, name = 'scalar_rhs_maker_ext_cuda')
196 use, intrinsic :: iso_c_binding
197 import c_rp
198 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
199 real(c_rp) :: rho, ext1, ext2, ext3
200 integer(c_int) :: n
201 end subroutine scalar_rhs_maker_ext_cuda
202 end interface
203
204 interface
205 subroutine rhs_maker_bdf_cuda(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
206 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
207 Blag_d, Blaglag_d, rho, dt, bd2, bd3, bd4, nbd, n) &
208 bind(c, name = 'rhs_maker_bdf_cuda')
209 use, intrinsic :: iso_c_binding
210 import c_rp
211 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
212 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
213 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
214 type(c_ptr), value :: Blag_d, Blaglag_d
215 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
216 integer(c_int) :: nbd, n
217 end subroutine rhs_maker_bdf_cuda
218 end interface
219
220 interface
221 subroutine scalar_rhs_maker_bdf_cuda(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
222 rho, dt, bd2, bd3, bd4, nbd, n) &
223 bind(c, name = 'scalar_rhs_maker_bdf_cuda')
224 use, intrinsic :: iso_c_binding
225 import c_rp
226 type(c_ptr), value :: s_lag_d, s_laglag_d
227 type(c_ptr), value :: fs_d, s_d, B_d
228 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
229 integer(c_int) :: nbd, n
230 end subroutine scalar_rhs_maker_bdf_cuda
231 end interface
232
233 interface
234 subroutine rhs_maker_oifs_cuda(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
235 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_cuda')
236 use, intrinsic :: iso_c_binding
237 import c_rp
238 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
239 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
240 reaL(c_rp) :: rho, dt
241 integer(c_int) :: n
242 end subroutine rhs_maker_oifs_cuda
243 end interface
244
245 interface
246 subroutine scalar_rhs_maker_oifs_cuda(phi_s_d, bf_s_d, rho, dt, n) &
247 bind(c, name = 'scalar_rhs_maker_oifs_cuda')
248 use, intrinsic :: iso_c_binding
249 import c_rp
250 type(c_ptr), value :: bf_s_d
251 type(c_ptr), value :: phi_s_d
252 reaL(c_rp) :: rho, dt
253 integer(c_int) :: n
254 end subroutine scalar_rhs_maker_oifs_cuda
255 end interface
256#elif HAVE_OPENCL
257 interface
258 subroutine rhs_maker_sumab_opencl(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
259 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
260 bind(c, name = 'rhs_maker_sumab_opencl')
261 use, intrinsic :: iso_c_binding
262 import c_rp
263 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
264 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
265 real(c_rp) :: ab1, ab2, ab3
266 integer(c_int) :: nab, n
267 end subroutine rhs_maker_sumab_opencl
268 end interface
269
270 interface
271 subroutine rhs_maker_ext_opencl(abx1_d, aby1_d, abz1_d, &
272 abx2_d, aby2_d, abz2_d, &
273 bfx_d, bfy_d, bfz_d, &
274 rho, ab1, ab2, ab3, n) &
275 bind(c, name = 'rhs_maker_ext_opencl')
276 use, intrinsic :: iso_c_binding
277 import c_rp
278 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
279 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
280 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
281 real(c_rp) :: rho, ab1, ab2, ab3
282 integer(c_int) :: n
283 end subroutine rhs_maker_ext_opencl
284 end interface
285
286 interface
287 subroutine scalar_rhs_maker_ext_opencl(fs_lag_d, fs_laglag_d, fs_d, rho, &
288 ext1, ext2, ext3, n) &
289 bind(c, name = 'scalar_rhs_maker_ext_opencl')
290 use, intrinsic :: iso_c_binding
291 import c_rp
292 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
293 real(c_rp) :: rho, ext1, ext2, ext3
294 integer(c_int) :: n
295 end subroutine scalar_rhs_maker_ext_opencl
296 end interface
297
298 interface
299 subroutine rhs_maker_bdf_opencl(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
300 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
301 rho, dt, bd2, bd3, bd4, nbd, n) bind(c, name = 'rhs_maker_bdf_opencl')
302 use, intrinsic :: iso_c_binding
303 import c_rp
304 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
305 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
306 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
307 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
308 integer(c_int) :: nbd, n
309 end subroutine rhs_maker_bdf_opencl
310 end interface
311
312 interface
313 subroutine scalar_rhs_maker_bdf_opencl(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
314 rho, dt, bd2, bd3, bd4, nbd, n) &
315 bind(c, name = 'scalar_rhs_maker_bdf_opencl')
316 use, intrinsic :: iso_c_binding
317 import c_rp
318 type(c_ptr), value :: s_lag_d, s_laglag_d
319 type(c_ptr), value :: fs_d, s_d, B_d
320 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
321 integer(c_int) :: nbd, n
322 end subroutine scalar_rhs_maker_bdf_opencl
323 end interface
324
325 interface
326 subroutine rhs_maker_oifs_opencl(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
327 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_opencl')
328 use, intrinsic :: iso_c_binding
329 import c_rp
330 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
331 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
332 reaL(c_rp) :: rho, dt
333 integer(c_int) :: n
334 end subroutine rhs_maker_oifs_opencl
335 end interface
336
337 interface
338 subroutine scalar_rhs_maker_oifs_opencl(phi_s_d, bf_s_d, rho, dt, n) &
339 bind(c, name = 'scalar_rhs_maker_oifs_opencl')
340 use, intrinsic :: iso_c_binding
341 import c_rp
342 type(c_ptr), value :: bf_s_d
343 type(c_ptr), value :: phi_s_d
344 reaL(c_rp) :: rho, dt
345 integer(c_int) :: n
346 end subroutine scalar_rhs_maker_oifs_opencl
347 end interface
348#elif HAVE_METAL
349 interface
350 subroutine rhs_maker_sumab_metal(u_d, v_d, w_d, uu_d, vv_d, ww_d, &
351 uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2, ab1, ab2, ab3, nab, n)&
352 bind(c, name = 'rhs_maker_sumab_metal')
353 use, intrinsic :: iso_c_binding
354 import c_rp
355 type(c_ptr), value :: u_d, v_d, w_d, uu_d, vv_d, ww_d
356 type(c_ptr), value :: uulag1, uulag2, vvlag1, vvlag2, wwlag1, wwlag2
357 real(c_rp) :: ab1, ab2, ab3
358 integer(c_int) :: nab, n
359 end subroutine rhs_maker_sumab_metal
360 end interface
361
362 interface
363 subroutine rhs_maker_ext_metal(abx1_d, aby1_d, abz1_d, &
364 abx2_d, aby2_d, abz2_d, &
365 bfx_d, bfy_d, bfz_d, &
366 rho, ab1, ab2, ab3, n) &
367 bind(c, name = 'rhs_maker_ext_metal')
368 use, intrinsic :: iso_c_binding
369 import c_rp
370 type(c_ptr), value :: abx1_d, aby1_d, abz1_d
371 type(c_ptr), value :: abx2_d, aby2_d, abz2_d
372 type(c_ptr), value :: bfx_d, bfy_d, bfz_d
373 real(c_rp) :: rho, ab1, ab2, ab3
374 integer(c_int) :: n
375 end subroutine rhs_maker_ext_metal
376 end interface
377
378 interface
379 subroutine scalar_rhs_maker_ext_metal(fs_lag_d, fs_laglag_d, fs_d, rho, &
380 ext1, ext2, ext3, n) &
381 bind(c, name = 'scalar_rhs_maker_ext_metal')
382 use, intrinsic :: iso_c_binding
383 import c_rp
384 type(c_ptr), value :: fs_lag_d, fs_laglag_d, fs_d
385 real(c_rp) :: rho, ext1, ext2, ext3
386 integer(c_int) :: n
387 end subroutine scalar_rhs_maker_ext_metal
388 end interface
389
390 interface
391 subroutine rhs_maker_bdf_metal(ulag1_d, ulag2_d, vlag1_d, vlag2_d, &
392 wlag1_d, wlag2_d, bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d, &
393 rho, dt, bd2, bd3, bd4, nbd, n) bind(c, name = 'rhs_maker_bdf_metal')
394 use, intrinsic :: iso_c_binding
395 import c_rp
396 type(c_ptr), value :: ulag1_d, ulag2_d, vlag1_d
397 type(c_ptr), value :: vlag2_d, wlag1_d, wlag2_d
398 type(c_ptr), value :: bfx_d, bfy_d, bfz_d, u_d, v_d, w_d, B_d
399 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
400 integer(c_int) :: nbd, n
401 end subroutine rhs_maker_bdf_metal
402 end interface
403
404 interface
405 subroutine scalar_rhs_maker_bdf_metal(s_lag_d, s_laglag_d, fs_d, s_d, B_d, &
406 rho, dt, bd2, bd3, bd4, nbd, n) &
407 bind(c, name = 'scalar_rhs_maker_bdf_metal')
408 use, intrinsic :: iso_c_binding
409 import c_rp
410 type(c_ptr), value :: s_lag_d, s_laglag_d
411 type(c_ptr), value :: fs_d, s_d, B_d
412 reaL(c_rp) :: rho, dt, bd2, bd3, bd4
413 integer(c_int) :: nbd, n
414 end subroutine scalar_rhs_maker_bdf_metal
415 end interface
416
417 interface
418 subroutine rhs_maker_oifs_metal(phi_x_d, phi_y_d, phi_z_d, bf_x_d, &
419 bf_y_d, bf_z_d, rho, dt, n) bind(c, name = 'rhs_maker_oifs_metal')
420 use, intrinsic :: iso_c_binding
421 import c_rp
422 type(c_ptr), value :: bf_x_d, bf_y_d, bf_z_d
423 type(c_ptr), value :: phi_x_d, phi_y_d, phi_z_d
424 reaL(c_rp) :: rho, dt
425 integer(c_int) :: n
426 end subroutine rhs_maker_oifs_metal
427 end interface
428
429 interface
430 subroutine scalar_rhs_maker_oifs_metal(phi_s_d, bf_s_d, rho, dt, n) &
431 bind(c, name = 'scalar_rhs_maker_oifs_metal')
432 use, intrinsic :: iso_c_binding
433 import c_rp
434 type(c_ptr), value :: bf_s_d
435 type(c_ptr), value :: phi_s_d
436 reaL(c_rp) :: rho, dt
437 integer(c_int) :: n
438 end subroutine scalar_rhs_maker_oifs_metal
439 end interface
440#endif
441
442contains
443
444 subroutine rhs_maker_sumab_device(u, v, w, uu, vv, ww, uulag, vvlag, wwlag, ab, nab)
445 type(field_t), intent(inout) :: u,v, w
446 type(field_t), intent(inout) :: uu, vv, ww
447 type(field_series_t), intent(inout) :: uulag, vvlag, wwlag
448 real(kind=rp), dimension(3), intent(in) :: ab
449 integer, intent(in) :: nab
450
451#ifdef HAVE_HIP
452 call rhs_maker_sumab_hip(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
453 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
454 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
455 uu%dof%size())
456#elif HAVE_CUDA
457 call rhs_maker_sumab_cuda(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
458 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
459 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
460 uu%dof%size())
461#elif HAVE_OPENCL
462 call rhs_maker_sumab_opencl(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
463 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
464 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
465 uu%dof%size())
466#elif HAVE_METAL
467 call rhs_maker_sumab_metal(u%x_d, v%x_d, w%x_d, uu%x_d, vv%x_d, ww%x_d, &
468 uulag%lf(1)%x_d, uulag%lf(2)%x_d, vvlag%lf(1)%x_d, vvlag%lf(2)%x_d, &
469 wwlag%lf(1)%x_d, wwlag%lf(2)%x_d, ab(1), ab(2), ab(3), nab, &
470 uu%dof%size())
471#endif
472
473 end subroutine rhs_maker_sumab_device
474
475 subroutine rhs_maker_ext_device(fx_lag, fy_lag, fz_lag, &
476 fx_laglag, fy_laglag, fz_laglag, fx, fy, fz, &
477 rho, ext_coeffs, n)
478 type(field_t), intent(inout) :: fx_lag, fy_lag, fz_lag
479 type(field_t), intent(inout) :: fx_laglag, fy_laglag, fz_laglag
480 real(kind=rp), intent(in) :: rho, ext_coeffs(4)
481 integer, intent(in) :: n
482 real(kind=rp), intent(inout) :: fx(n), fy(n), fz(n)
483 type(c_ptr) :: fx_d, fy_d, fz_d
484
485 fx_d = device_get_ptr(fx)
486 fy_d = device_get_ptr(fy)
487 fz_d = device_get_ptr(fz)
488
489#ifdef HAVE_HIP
490 call rhs_maker_ext_hip(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
491 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
492 fx_d, fy_d, fz_d, rho, &
493 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
494#elif HAVE_CUDA
495 call rhs_maker_ext_cuda(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
496 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
497 fx_d, fy_d, fz_d, rho, &
498 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
499#elif HAVE_OPENCL
500 call rhs_maker_ext_opencl(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
501 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
502 fx_d, fy_d, fz_d, rho, &
503 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
504#elif HAVE_METAL
505 call rhs_maker_ext_metal(fx_lag%x_d, fy_lag%x_d, fz_lag%x_d, &
506 fx_laglag%x_d, fy_laglag%x_d, fz_laglag%x_d, &
507 fx_d, fy_d, fz_d, rho, &
508 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
509#endif
510
511 end subroutine rhs_maker_ext_device
512
513 subroutine scalar_rhs_maker_ext_device(fs_lag, fs_laglag, fs, &
514 rho, ext_coeffs, n)
515 type(field_t), intent(inout) :: fs_lag
516 type(field_t), intent(inout) :: fs_laglag
517 real(kind=rp), intent(in) :: rho, ext_coeffs(4)
518 integer, intent(in) :: n
519 real(kind=rp), intent(inout) :: fs(n)
520 type(c_ptr) :: fs_d
521
522 fs_d = device_get_ptr(fs)
523
524#ifdef HAVE_HIP
525 call scalar_rhs_maker_ext_hip(fs_lag%x_d, fs_laglag%x_d, fs_d, rho, &
526 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
527#elif HAVE_CUDA
528 call scalar_rhs_maker_ext_cuda(fs_lag%x_d, fs_laglag%x_d, fs_d, rho, &
529 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
530#elif HAVE_OPENCL
531 call scalar_rhs_maker_ext_opencl(fs_lag%x_d, fs_laglag%x_d, fs_d, rho, &
532 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
533#elif HAVE_METAL
534 call scalar_rhs_maker_ext_metal(fs_lag%x_d, fs_laglag%x_d, fs_d, rho, &
535 ext_coeffs(1), ext_coeffs(2), ext_coeffs(3), n)
536#endif
537
538 end subroutine scalar_rhs_maker_ext_device
539
540 subroutine rhs_maker_bdf_device(ulag, vlag, wlag, bfx, bfy, bfz, &
541 u, v, w, B, Blag, Blaglag, rho, dt, bd, nbd, n)
542 integer, intent(in) :: n, nbd
543 type(field_t), intent(in) :: u, v, w
544 type(field_series_t), intent(in) :: ulag, vlag, wlag
545 real(kind=rp), intent(inout) :: bfx(n), bfy(n), bfz(n)
546 real(kind=rp), intent(in) :: b(n), blag(n), blaglag(n)
547 real(kind=rp), intent(in) :: dt, rho, bd(4)
548 type(c_ptr) :: bfx_d, bfy_d, bfz_d, b_d, blag_d, blaglag_d
549
550 bfx_d = device_get_ptr(bfx)
551 bfy_d = device_get_ptr(bfy)
552 bfz_d = device_get_ptr(bfz)
553 b_d = device_get_ptr(b)
554 blag_d = device_get_ptr(blag)
555 blaglag_d = device_get_ptr(blaglag)
556#ifdef HAVE_HIP
557 call rhs_maker_bdf_hip(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
558 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
559 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
560 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
561 b_d, blag_d, blaglag_d, &
562 rho, dt, bd(2), bd(3), bd(4), nbd, n)
563#elif HAVE_CUDA
564 call rhs_maker_bdf_cuda(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
565 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
566 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
567 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
568 b_d, blag_d, blaglag_d, &
569 rho, dt, bd(2), bd(3), bd(4), nbd, n)
570#elif HAVE_OPENCL
571 call rhs_maker_bdf_opencl(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
572 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
573 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
574 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
575 b_d, rho, dt, bd(2), bd(3), bd(4), nbd, n)
576#elif HAVE_METAL
577 call rhs_maker_bdf_metal(ulag%lf(1)%x_d, ulag%lf(2)%x_d, &
578 vlag%lf(1)%x_d, vlag%lf(2)%x_d, &
579 wlag%lf(1)%x_d, wlag%lf(2)%x_d, &
580 bfx_d, bfy_d, bfz_d, u%x_d, v%x_d, w%x_d, &
581 b_d, rho, dt, bd(2), bd(3), bd(4), nbd, n)
582#endif
583
584 end subroutine rhs_maker_bdf_device
585
586 subroutine scalar_rhs_maker_bdf_device(s_lag, fs, s, B, rho, dt, &
587 bd, nbd, n)
588 integer, intent(in) :: n, nbd
589 type(field_t), intent(in) :: s
590 type(field_series_t), intent(in) :: s_lag
591 real(kind=rp), intent(inout) :: fs(n)
592 real(kind=rp), intent(in) :: b(n)
593 real(kind=rp), intent(in) :: dt, rho, bd(4)
594 type(c_ptr) :: fs_d, b_d
595
596 fs_d = device_get_ptr(fs)
597 b_d = device_get_ptr(b)
598
599#ifdef HAVE_HIP
600 call scalar_rhs_maker_bdf_hip(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
601 fs_d, s%x_d, b_d, rho, dt, bd(2), bd(3), bd(4), &
602 nbd, n)
603#elif HAVE_CUDA
604 call scalar_rhs_maker_bdf_cuda(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
605 fs_d, s%x_d, b_d, rho, dt, bd(2), bd(3), bd(4), &
606 nbd, n)
607#elif HAVE_OPENCL
608 call scalar_rhs_maker_bdf_opencl(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
609 fs_d, s%x_d, b_d, rho, dt, bd(2), bd(3), bd(4), &
610 nbd, n)
611#elif HAVE_METAL
612 call scalar_rhs_maker_bdf_metal(s_lag%lf(1)%x_d, s_lag%lf(2)%x_d, &
613 fs_d, s%x_d, b_d, rho, dt, bd(2), bd(3), bd(4), &
614 nbd, n)
615#endif
616
617 end subroutine scalar_rhs_maker_bdf_device
618
619 subroutine rhs_maker_oifs_device(phi_x, phi_y, phi_z, bf_x, bf_y, bf_z, &
620 rho, dt, n)
621 real(kind=rp), intent(in) :: rho, dt
622 integer, intent(in) :: n
623 real(kind=rp), intent(inout) :: bf_x(n), bf_y(n), bf_z(n)
624 real(kind=rp), intent(inout) :: phi_x(n), phi_y(n), phi_z(n)
625
626 type(c_ptr) :: phi_x_d, phi_y_d, phi_z_d, bf_x_d, bf_y_d, bf_z_d
627
628 phi_x_d = device_get_ptr(phi_x)
629 phi_y_d = device_get_ptr(phi_y)
630 phi_z_d = device_get_ptr(phi_z)
631 bf_x_d = device_get_ptr(bf_x)
632 bf_y_d = device_get_ptr(bf_y)
633 bf_z_d = device_get_ptr(bf_z)
634
635#ifdef HAVE_HIP
636 call rhs_maker_oifs_hip(phi_x_d, phi_y_d, phi_z_d, &
637 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
638#elif HAVE_CUDA
639 call rhs_maker_oifs_cuda(phi_x_d, phi_y_d, phi_z_d, &
640 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
641#elif HAVE_OPENCL
642 call rhs_maker_oifs_opencl(phi_x_d, phi_y_d, phi_z_d, &
643 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
644#elif HAVE_METAL
645 call rhs_maker_oifs_metal(phi_x_d, phi_y_d, phi_z_d, &
646 bf_x_d, bf_y_d, bf_z_d, rho, dt, n)
647#endif
648
649 end subroutine rhs_maker_oifs_device
650
651 subroutine scalar_rhs_maker_oifs_device(phi_s,bf_s, rho, dt, n)
652 real(kind=rp), intent(in) :: rho, dt
653 integer, intent(in) :: n
654 real(kind=rp), intent(inout) :: bf_s(n)
655 real(kind=rp), intent(inout) :: phi_s(n)
656 type(c_ptr) :: phi_s_d, bf_s_d
657
658 phi_s_d = device_get_ptr(phi_s)
659 bf_s_d = device_get_ptr(bf_s)
660
661#ifdef HAVE_HIP
662 call scalar_rhs_maker_oifs_hip(phi_s_d, bf_s_d, rho, dt, n)
663#elif HAVE_CUDA
664 call scalar_rhs_maker_oifs_cuda(phi_s_d, bf_s_d, rho, dt, n)
665#elif HAVE_OPENCL
666 call scalar_rhs_maker_oifs_opencl(phi_s_d, bf_s_d, rho, dt, n)
667#elif HAVE_METAL
668 call scalar_rhs_maker_oifs_metal(phi_s_d, bf_s_d, rho, dt, n)
669#endif
670
671 end subroutine scalar_rhs_maker_oifs_device
672
673end module rhs_maker_device
Return the device pointer for an associated Fortran array.
Definition device.F90:108
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, dt, bd, nbd, 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 scalar_rhs_maker_ext_device(fs_lag, fs_laglag, fs, rho, ext_coeffs, n)
subroutine rhs_maker_bdf_device(ulag, vlag, wlag, bfx, bfy, bfz, u, v, w, b, blag, blaglag, rho, dt, bd, nbd, 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)
subroutine scalar_rhs_maker_oifs_device(phi_s, bf_s, rho, dt, n)
Routines to generate the right-hand sides for the convection-diffusion equation. Employs the EXT/BDF ...
Definition rhs_maker.f90:38
void scalar_rhs_maker_bdf_opencl(void *s_lag, void *s_laglag, void *fs, void *s, void *B, real *rho, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition rhs_maker.c:205
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_oifs_opencl(void *phi_s, void *bf_s, real *rho, real *dt, int *n)
Definition rhs_maker.c:273
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:241
void scalar_rhs_maker_ext_opencl(void *fs_lag, void *fs_laglag, void *fs, real *rho, real *ext1, real *ext2, real *ext3, int *n)
Definition rhs_maker.c:128
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:159
void scalar_rhs_maker_oifs_cuda(void *phi_s, void *bf_s, real *rho, real *dt, int *n)
Definition rhs_maker.cu:158
void scalar_rhs_maker_bdf_cuda(void *s_lag, void *s_laglag, void *fs, void *s, void *B, real *rho, real *dt, real *bd2, real *bd3, real *bd4, int *nbd, int *n)
Definition rhs_maker.cu:121
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 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 scalar_rhs_maker_ext_cuda(void *fs_lag, void *fs_laglag, void *fs, real *rho, real *ext1, real *ext2, real *ext3, int *n)
Definition rhs_maker.cu:82
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 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:98
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