Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
device_mma_math.f90
Go to the documentation of this file.
1
34!
35module device_mma_math
36 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
37 use num_types, only: rp, c_rp
38 use utils, only: neko_error
39 use comm, only: neko_comm, pe_size, mpi_real_precision
40 use mpi_f08, only: mpi_sum, mpi_in_place, mpi_allreduce
41 use cuda_mma_math, only: cuda_mma_max, cuda_max2, cuda_rex, cuda_lcsc2, &
51 use hip_mma_math, only: hip_mma_max, hip_max2, hip_rex, hip_lcsc2, &
61
62 implicit none
63 private
64
65
66 public :: device_mma_gensub1, device_mma_gensub2, device_mma_gensub3, &
67 device_mma_gensub4, device_mma_max, device_max2, device_rex, &
68 device_lcsc2, device_relambda, device_sub2cons2, device_maxval, &
69 device_norm, device_delx, device_add2inv2, device_gg, device_diagx, &
70 device_bb, device_updatebb, device_aa, device_updateaa, device_dx, &
71 device_dy, device_deta, device_dxsi, device_maxval2, device_maxval3, &
72 device_kkt_rex, device_mattrans_v_mul, device_mma_dipsolvesub1, &
73 device_mma_ljjxinv, device_hess, device_delta_1dbeam, &
74 device_solve_linear_system, device_prepare_hessian, &
75 device_prepare_aa_matrix, device_update_hessian_z, &
76 device_mma_gensub3_dip, device_mma_dip_kkt
77
78contains
81 subroutine device_update_hessian_z(Hess_d, a_d, m)
82 use iso_c_binding
83 type(c_ptr), intent(in) :: hess_d
84 type(c_ptr), intent(in) :: a_d
85 integer, value :: m
86#if HAVE_HIP
87 call mma_update_hessian_z_hip(hess_d, a_d, m)
88#elif HAVE_CUDA
89 call mma_update_hessian_z_cuda(hess_d, a_d, m)
90#elif HAVE_OPENCL
91 call neko_error('Z-term Hessian update not implemented for OpenCL')
92#else
93 call neko_error('No device backend configured for Z-term Hessian update')
94#endif
95 end subroutine device_update_hessian_z
96
97
99 subroutine device_prepare_aa_matrix(AA_d, s_d, lambda_d, d_d, mu_d, y_d, &
100 a_d, zeta, z, m)
101 type(c_ptr) :: aa_d, s_d, lambda_d, d_d, mu_d, y_d, a_d
102 real(c_rp) :: zeta, z
103 integer, value :: m
104#if HAVE_HIP
105 call mma_prepare_aa_matrix_hip(aa_d, s_d, lambda_d, d_d, mu_d, y_d, a_d, &
106 zeta, z, m)
107#elif HAVE_CUDA
108 call mma_prepare_aa_matrix_cuda(aa_d, s_d, lambda_d, d_d, mu_d, y_d, a_d, &
109 zeta, z, m)
110#elif HAVE_OPENCL
111 call neko_error('AA matrix preparation not implemented for OpenCL')
112#else
113 call neko_error('No device backend configured for AA matrix preparation')
114#endif
115 end subroutine device_prepare_aa_matrix
116
118 subroutine device_prepare_hessian(Hess_d, y_d, mu_d, lambda_d, m)
119 type(c_ptr) :: hess_d, y_d, mu_d, lambda_d
120 integer, value :: m
121#if HAVE_HIP
122 call mma_prepare_hessian_hip(hess_d, y_d, mu_d, lambda_d, m)
123#elif HAVE_CUDA
124 call mma_prepare_hessian_cuda(hess_d, y_d, mu_d, lambda_d, m)
125#elif HAVE_OPENCL
126 call neko_error('no device backend configured')
127#else
128 call neko_error('no device backend configured')
129#endif
130 end subroutine device_prepare_hessian
131
132 subroutine device_solve_linear_system(A_d, b_d, n, info)
133 type(c_ptr) :: a_d, b_d
134 integer(c_int), value :: n
135 integer(c_int) :: info
136#if HAVE_HIP
137 call hipsolver_wrapper(a_d, b_d, n, info)
138 ! call hip_custom_solver(A_d, b_d, n, info)
139#elif HAVE_CUDA
140 call cusolver_wrapper(a_d, b_d, n, info)
141 ! call cuda_custom_solver(A_d, b_d, n, info)
142#elif HAVE_OPENCL
143 call neko_error('no device backend configured')
144#else
145 call neko_error('no device backend configured')
146#endif
147 end subroutine device_solve_linear_system
148
149
154 subroutine device_delta_1dbeam(Delta_d, L_total, Le, offset, n)
155 type(c_ptr) :: delta_d
156 real(c_rp) :: l_total, le
157 integer(c_int), value :: offset, n
158#if HAVE_HIP
159 call delta_1dbeam_hip(delta_d, l_total, le, offset, n)
160#elif HAVE_CUDA
161 call delta_1dbeam_cuda(delta_d, l_total, le, offset, n)
162#elif HAVE_OPENCL
163 call neko_error('no device backend configured')
164#else
165 call neko_error('no device backend configured')
166#endif
167 end subroutine device_delta_1dbeam
168
169
170 subroutine device_hess(Hess_d, hijx_d, Ljjxinv_d, n, m)
171 type(c_ptr):: hess_d, hijx_d, ljjxinv_d
172 integer(c_int) :: n, m
173#if HAVE_HIP
174 call hip_hess(hess_d, hijx_d, ljjxinv_d, n, m)
175#elif HAVE_CUDA
176 call cuda_hess(hess_d, hijx_d, ljjxinv_d, n, m)
177#elif HAVE_OPENCL
178 call neko_error('no device backend configured')
179#else
180 call neko_error('no device backend configured')
181#endif
182 end subroutine device_hess
183
184
193 subroutine device_mma_ljjxinv(Ljjxinv_d,pjlambda_d, qjlambda_d, x_d, &
194 low_d, upp_d, alpha_d, beta_d, n)
195 type(c_ptr) :: ljjxinv_d, pjlambda_d, qjlambda_d, x_d, &
196 low_d, upp_d, alpha_d, beta_d
197 integer(c_int) :: n
198#if HAVE_HIP
199 call mma_ljjxinv_hip(ljjxinv_d, pjlambda_d, qjlambda_d, x_d, &
200 low_d, upp_d, alpha_d, beta_d, n)
201#elif HAVE_CUDA
202 call mma_ljjxinv_cuda(ljjxinv_d, pjlambda_d, qjlambda_d, x_d, &
203 low_d, upp_d, alpha_d, beta_d, n)
204#elif HAVE_OPENCL
205 call neko_error('no device backend configured')
206#else
207 call neko_error('no device backend configured')
208#endif
209 end subroutine device_mma_ljjxinv
210
211
216 subroutine device_mma_dipsolvesub1(x_d, pjlambda_d, qjlambda_d, &
217 low_d, upp_d, alpha_d, beta_d, n)
218 type(c_ptr) :: x_d, pjlambda_d, qjlambda_d, &
219 low_d, upp_d, alpha_d, beta_d
220 integer(c_int) :: n
221#if HAVE_HIP
222 call mma_dipsolvesub1_hip(x_d, pjlambda_d, qjlambda_d, &
223 low_d, upp_d, alpha_d, beta_d, n)
224#elif HAVE_CUDA
225 call mma_dipsolvesub1_cuda(x_d, pjlambda_d, qjlambda_d, &
226 low_d, upp_d, alpha_d, beta_d, n)
227#elif HAVE_OPENCL
228 call neko_error('no device backend configured')
229#else
230 call neko_error('no device backend configured')
231#endif
232 end subroutine device_mma_dipsolvesub1
233
234
239 subroutine device_mattrans_v_mul(output_d, pij_d, lambda_d, m, n)
240 type(c_ptr) :: output_d, pij_d, lambda_d
241 integer :: m, n
242#if HAVE_HIP
243 call mattrans_v_mul_hip(output_d, pij_d, lambda_d, m, n)
244#elif HAVE_CUDA
245 call mattrans_v_mul_cuda(output_d, pij_d, lambda_d, m, n)
246#elif HAVE_OPENCL
247 call neko_error('no device backend configured')
248#else
249 call neko_error('no device backend configured')
250#endif
251 end subroutine device_mattrans_v_mul
252
253
254
255 subroutine device_mma_gensub1(low_d, upp_d, x_d, xmin_d, xmax_d, asyinit, n)
256 type(c_ptr) :: low_d, upp_d, x_d, xmin_d, xmax_d
257 real(c_rp) :: asyinit
258 integer :: n
259#if HAVE_HIP
260 call mma_gensub1_hip(low_d, upp_d, x_d, xmin_d, xmax_d, asyinit, n)
261#elif HAVE_CUDA
262 call mma_gensub1_cuda(low_d, upp_d, x_d, xmin_d, xmax_d, asyinit, n)
263#elif HAVE_OPENCL
264 call neko_error('no device backend configured')
265#else
266 call neko_error('no device backend configured')
267#endif
268 end subroutine device_mma_gensub1
269
270
271 subroutine device_mma_gensub2(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
272 asydecr, asyincr, n)
273 type(c_ptr) :: low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d
274 real(c_rp) :: asydecr, asyincr
275 integer :: n
276#if HAVE_HIP
277 call mma_gensub2_hip(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
278 asydecr, asyincr, n)
279#elif HAVE_CUDA
280 call mma_gensub2_cuda(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
281 asydecr, asyincr, n)
282#elif HAVE_OPENCL
283 call neko_error('no device backend configured')
284#else
285 call neko_error('no device backend configured')
286#endif
287 end subroutine device_mma_gensub2
288
289 subroutine device_mma_gensub3(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, &
290 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
291 type(c_ptr) :: x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
292 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d
293 integer :: n, m
294#if HAVE_HIP
295 call mma_gensub3_hip(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
296 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
297#elif HAVE_CUDA
298 call mma_gensub3_cuda(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
299 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
300#elif HAVE_OPENCL
301 call neko_error('no device backend configured2')
302#else
303 call neko_error('no device backend configured3')
304#endif
305 end subroutine device_mma_gensub3
306
325 subroutine device_mma_gensub3_dip(x_d, df0dx_d, dfdx_d, low_d, upp_d, &
326 min_d, max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
327 type(c_ptr) :: x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
328 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d
329 integer(c_int) :: n, m
330#if HAVE_HIP
331 call mma_gensub3_dip_hip(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, &
332 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
333#elif HAVE_CUDA
334 call mma_gensub3_dip_cuda(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, &
335 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
336#elif HAVE_OPENCL
337 call neko_error('no device backend configured')
338#else
339 call neko_error('no device backend configured')
340#endif
341 end subroutine device_mma_gensub3_dip
342
343 subroutine device_mma_gensub4(x_d, low_d, upp_d, pij_d, qij_d, n, m, bi_d)
344 type(c_ptr) :: x_d, low_d, upp_d, pij_d, qij_d, bi_d
345 integer :: n, m
346#if HAVE_HIP
347 call mma_gensub4_hip(x_d, low_d, upp_d, pij_d, qij_d, n, m, bi_d)
348#elif HAVE_CUDA
349 call mma_gensub4_cuda(x_d, low_d, upp_d, pij_d, qij_d, n, m, bi_d)
350#elif HAVE_OPENCL
351 call neko_error('no device backend configured')
352#else
353 call neko_error('no device backend configured')
354#endif
355 end subroutine device_mma_gensub4
356
357 subroutine device_mma_max(xsi_d, x_d, alpha_d, n)
358 type(c_ptr) :: xsi_d, x_d, alpha_d
359 integer :: n
360#if HAVE_HIP
361 call hip_mma_max(xsi_d, x_d, alpha_d, n)
362#elif HAVE_CUDA
363 call cuda_mma_max(xsi_d, x_d, alpha_d, n)
364#elif HAVE_OPENCL
365 call neko_error('no device backend configured')
366#else
367 call neko_error('no device backend configured')
368#endif
369 end subroutine device_mma_max
370
371 subroutine device_max2(a_d, b, c_d, d, n)
372 type(c_ptr) :: a_d, c_d
373 real(c_rp) :: b, d
374 integer :: n
375#if HAVE_HIP
376 call hip_max2(a_d, b, c_d, d, n)
377#elif HAVE_CUDA
378 call cuda_max2(a_d, b, c_d, d, n)
379#elif HAVE_OPENCL
380 call neko_error('no device backend configured')
381#else
382 call neko_error('no device backend configured')
383#endif
384 end subroutine device_max2
385
386
387
388 subroutine device_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, &
389 q0j_d, lambda_d, xsi_d, eta_d, n, m)
390 type(c_ptr) :: rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
391 lambda_d, xsi_d, eta_d
392 integer(c_int) :: n, m
393#if HAVE_HIP
394 call hip_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
395 lambda_d, xsi_d, eta_d, n, m)
396#elif HAVE_CUDA
397 call cuda_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
398 lambda_d, xsi_d, eta_d, n, m)
399#elif HAVE_OPENCL
400 call neko_error('no device backend configured')
401#else
402 call neko_error('no device backend configured')
403#endif
404 end subroutine device_rex
405
406 function device_lcsc2(a_d, b_d, n) result(res)
407 type(c_ptr) :: a_d, b_d
408 integer(c_int) :: n
409 real(kind=rp) :: res
410 ! Default value in case of no valid backend (resolve compiler warning)
411 res = 0.0_rp
412#if HAVE_HIP
413 res = hip_lcsc2(a_d, b_d, n)
414#elif HAVE_CUDA
415 res = cuda_lcsc2(a_d, b_d, n)
416#elif HAVE_OPENCL
417 call neko_error('no device backend configured')
418#else
419 call neko_error('no device backend configured')
420#endif
421 end function device_lcsc2
422
423 subroutine device_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
424 type(c_ptr) :: relambda_d, x_d, upp_d, low_d, pij_d, qij_d
425 integer(c_int) :: n, m
426#if HAVE_HIP
427 call hip_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
428#elif HAVE_CUDA
429 call cuda_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
430#elif HAVE_OPENCL
431 call neko_error('no device backend configured')
432#else
433 call neko_error('no device backend configured')
434#endif
435 end subroutine device_relambda
436
437 subroutine device_sub2cons2(rexsi_d, xsi_d, x_d, alpha_d, epsi, n)
438 type(c_ptr):: rexsi_d, xsi_d, x_d, alpha_d
439 real(kind=rp) :: epsi
440 integer(c_int) :: n
441#if HAVE_HIP
442 call hip_sub2cons2(rexsi_d, xsi_d, x_d, alpha_d, epsi, n)
443#elif HAVE_CUDA
444 call cuda_sub2cons2(rexsi_d, xsi_d, x_d, alpha_d, epsi, n)
445#elif HAVE_OPENCL
446 call neko_error('no device backend configured')
447#else
448 call neko_error('no device backend configured')
449#endif
450 end subroutine device_sub2cons2
451
452 function device_maxval(rex_d, n) result(res)
453 type(c_ptr):: rex_d
454 real(kind=rp) :: res
455 integer(c_int) :: n
456 ! Default value in case of no valid backend (resolve compiler warning)
457 res = 0.0_rp
458#if HAVE_HIP
459 res = hip_maxval(rex_d, n)
460#elif HAVE_CUDA
461 res = cuda_maxval(rex_d, n)
462#elif HAVE_OPENCL
463 call neko_error('no device backend configured')
464#else
465 call neko_error('no device backend configured')
466#endif
467 end function device_maxval
468
469 function device_norm(rex_d, n) result(res)
470 type(c_ptr):: rex_d
471 real(kind=rp) :: res
472 integer(c_int) :: n
473 ! Default value in case of no valid backend (resolve compiler warning)
474 res = 0.0_rp
475#if HAVE_HIP
476 res = hip_norm(rex_d, n)
477#elif HAVE_CUDA
478 res = cuda_norm(rex_d, n)
479#elif HAVE_OPENCL
480 call neko_error('no device backend configured')
481#else
482 call neko_error('no device backend configured')
483#endif
484 end function device_norm
485
486 subroutine device_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, &
487 q0j_d, alpha_d, beta_d, lambda_d, epsi, n, m)
488 type(c_ptr):: delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
489 alpha_d, beta_d, lambda_d
490 real(kind=rp) :: epsi
491 integer(c_int) :: n, m
492#if HAVE_HIP
493 call hip_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
494 alpha_d, beta_d, lambda_d, epsi, n, m)
495#elif HAVE_CUDA
496 call cuda_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
497 alpha_d, beta_d, lambda_d, epsi, n, m)
498#elif HAVE_OPENCL
499 call neko_error('no device backend configured')
500#else
501 call neko_error('no device backend configured')
502#endif
503 end subroutine device_delx
504
505 subroutine device_add2inv2(a_d, b_d, c, n)
506 type(c_ptr):: a_d, b_d
507 real(kind=rp) :: c
508 integer(c_int) :: n
509#if HAVE_HIP
510 call hip_add2inv2(a_d, b_d, c, n)
511#elif HAVE_CUDA
512 call cuda_add2inv2(a_d, b_d, c, n)
513#elif HAVE_OPENCL
514 call neko_error('no device backend configured')
515#else
516 call neko_error('no device backend configured')
517#endif
518 end subroutine device_add2inv2
519
520
521 subroutine device_gg(GG_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
522 type(c_ptr):: gg_d, x_d, low_d, upp_d, pij_d, qij_d
523 integer(c_int) :: n, m
524#if HAVE_HIP
525 call hip_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
526#elif HAVE_CUDA
527 call cuda_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
528#elif HAVE_OPENCL
529 call neko_error('no device backend configured')
530#else
531 call neko_error('no device backend configured')
532#endif
533 end subroutine device_gg
534
535 subroutine device_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, &
536 pij_d, qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
537 type(c_ptr):: diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
538 qij_d, alpha_d, &
539 beta_d, eta_d, lambda_d
540 integer(c_int) :: n, m
541#if HAVE_HIP
542 call hip_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
543 qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
544#elif HAVE_CUDA
545 call cuda_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
546 qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
547#elif HAVE_OPENCL
548 call neko_error('no device backend configured')
549#else
550 call neko_error('no device backend configured')
551#endif
552 end subroutine device_diagx
553
554
555 subroutine device_bb(bb_d, GG_d, delx_d, diagx_d, n, m)
556 type(c_ptr):: bb_d, gg_d, delx_d, diagx_d
557 integer(c_int) :: n, m
558#if HAVE_HIP
559 call hip_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
560#elif HAVE_CUDA
561 call cuda_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
562#elif HAVE_OPENCL
563 call neko_error('no device backend configured')
564#else
565 call neko_error('no device backend configured')
566#endif
567 end subroutine device_bb
568
569 subroutine device_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
570 type(c_ptr):: bb_d, dellambda_d, dely_d, d_d, mu_d, y_d
571 integer(c_int) :: m
572 real(c_rp) :: delz
573#if HAVE_HIP
574 call hip_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
575#elif HAVE_CUDA
576 call cuda_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
577#elif HAVE_OPENCL
578 call neko_error('no device backend configured')
579#else
580 call neko_error('no device backend configured')
581#endif
582 end subroutine device_updatebb
583
584 subroutine device_aa(AA_d, GG_d, diagx_d, n, m)
585 type(c_ptr):: aa_d, gg_d, diagx_d
586 integer(c_int) :: n, m
587#if HAVE_HIP
588 call hip_aa(aa_d, gg_d, diagx_d, n, m)
589#elif HAVE_CUDA
590 call cuda_aa(aa_d, gg_d, diagx_d, n, m)
591#elif HAVE_OPENCL
592 call neko_error('no device backend configured')
593#else
594 call neko_error('no device backend configured')
595#endif
596 end subroutine device_aa
597
598 subroutine device_updateaa(AA_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, &
599 y_d, a_d, zeta, z, m)
600 type(c_ptr):: aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, a_d
601 integer(c_int) :: m
602 real(c_rp) :: zeta, z
603#if HAVE_HIP
604 call hip_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
605 a_d, zeta, z, m)
606#elif HAVE_CUDA
607 call cuda_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
608 a_d, zeta, z, m)
609#elif HAVE_OPENCL
610 call neko_error('no device backend configured')
611#else
612 call neko_error('no device backend configured')
613#endif
614 end subroutine device_updateaa
615
616 subroutine device_dx(dx_d, delx_d, diagx_d, GG_d, dlambda_d, n, m)
617 type(c_ptr):: dx_d, delx_d, diagx_d, gg_d, dlambda_d
618 integer(c_int) :: n, m
619#if HAVE_HIP
620 call hip_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
621#elif HAVE_CUDA
622 call cuda_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
623#elif HAVE_OPENCL
624 call neko_error('no device backend configured')
625#else
626 call neko_error('no device backend configured')
627#endif
628 end subroutine device_dx
629
630 subroutine device_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
631 type(c_ptr):: dy_d, dely_d, dlambda_d, d_d, mu_d, y_d
632 integer(c_int) :: n
633#if HAVE_HIP
634 call hip_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
635#elif HAVE_CUDA
636 call cuda_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
637#elif HAVE_OPENCL
638 call neko_error('no device backend configured')
639#else
640 call neko_error('no device backend configured')
641#endif
642 end subroutine device_dy
643
644 subroutine device_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
645 type(c_ptr):: dxsi_d, xsi_d, dx_d, x_d, alpha_d
646 integer(c_int) :: n
647 real(c_rp) :: epsi
648#if HAVE_HIP
649 call hip_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
650#elif HAVE_CUDA
651 call cuda_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
652#elif HAVE_OPENCL
653 call neko_error('no device backend configured')
654#else
655 call neko_error('no device backend configured')
656#endif
657 end subroutine device_dxsi
658
659 subroutine device_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
660 type(c_ptr):: deta_d, eta_d, dx_d, x_d, beta_d
661 integer(c_int) :: n
662 real(c_rp) :: epsi
663#if HAVE_HIP
664 call hip_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
665#elif HAVE_CUDA
666 call cuda_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
667#elif HAVE_OPENCL
668 call neko_error('no device backend configured')
669#else
670 call neko_error('no device backend configured')
671#endif
672 end subroutine device_deta
673
674 function device_maxval2(dxx_d, xx_d, cons, n) result(res)
675 type(c_ptr):: dxx_d, xx_d
676 integer :: n
677 real(kind=rp), intent(in) :: cons
678 real(kind=rp) :: res
679 ! Default value in case of no valid backend (resolve compiler warning)
680 res = 0.0_rp
681#if HAVE_HIP
682 res = hip_maxval2(dxx_d, xx_d, cons, n)
683#elif HAVE_CUDA
684 res = cuda_maxval2(dxx_d, xx_d, cons, n)
685#elif HAVE_OPENCL
686 call neko_error('no device backend configured')
687#else
688 call neko_error('no device backend configured')
689#endif
690 end function device_maxval2
691
692
693 function device_maxval3(dx_d, x_d, alpha_d, cons, n) result(res)
694 type(c_ptr):: dx_d, x_d, alpha_d
695 real(kind=rp), intent(in) :: cons
696 real(kind=rp) :: res
697 integer(c_int) :: n
698 ! Default value in case of no valid backend (resolve compiler warning)
699 res = 0.0_rp
700#if HAVE_HIP
701 res = hip_maxval3(dx_d, x_d, alpha_d, cons, n)
702#elif HAVE_CUDA
703 res = cuda_maxval3(dx_d, x_d, alpha_d, cons, n)
704#elif HAVE_OPENCL
705 call neko_error('no device backend configured')
706#else
707 call neko_error('no device backend configured')
708#endif
709 end function device_maxval3
710
711
712
713 subroutine device_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, &
714 n, m)
715 type(c_ptr):: rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d
716 integer(c_int) :: n, m
717#if HAVE_HIP
718 call hip_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
719#elif HAVE_CUDA
720 call cuda_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
721#elif HAVE_OPENCL
722 call neko_error('no device backend configured')
723#else
724 call neko_error('no device backend configured')
725#endif
726 end subroutine device_kkt_rex
727
742 subroutine device_mma_dip_kkt(res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, &
743 lambda_d, n, m)
744 type(c_ptr) :: res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, lambda_d
745 integer(c_int) :: n, m
746#if HAVE_HIP
747 call mma_dip_kkt_hip(res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, &
748 lambda_d, n, m)
749#elif HAVE_CUDA
750 call mma_dip_kkt_cuda(res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, &
751 lambda_d, n, m)
752#elif HAVE_OPENCL
753 call neko_error('no device backend configured')
754#else
755 call neko_error('no device backend configured')
756#endif
757 end subroutine device_mma_dip_kkt
758
759! #endif
760
761end module device_mma_math
Binding of mma_dip_kkt_cuda, see device_mma_dip_kkt.
Binding of mma_gensub3_dip_cuda, see device_mma_gensub3_dip.
Binding of mma_dip_kkt_hip, see device_mma_dip_kkt.
Binding of mma_gensub3_dip_hip, see device_mma_gensub3_dip.