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
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
81 subroutine device_update_hessian_z(Hess_d, a_d, m)
83 type(c_ptr),
intent(in) :: hess_d
84 type(c_ptr),
intent(in) :: a_d
91 call neko_error(
'Z-term Hessian update not implemented for OpenCL')
93 call neko_error(
'No device backend configured for Z-term Hessian update')
95 end subroutine device_update_hessian_z
99 subroutine device_prepare_aa_matrix(AA_d, s_d, lambda_d, d_d, mu_d, y_d, &
101 type(c_ptr) :: aa_d, s_d, lambda_d, d_d, mu_d, y_d, a_d
102 real(c_rp) :: zeta, z
111 call neko_error(
'AA matrix preparation not implemented for OpenCL')
113 call neko_error(
'No device backend configured for AA matrix preparation')
115 end subroutine device_prepare_aa_matrix
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
126 call neko_error(
'no device backend configured')
128 call neko_error(
'no device backend configured')
130 end subroutine device_prepare_hessian
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
143 call neko_error(
'no device backend configured')
145 call neko_error(
'no device backend configured')
147 end subroutine device_solve_linear_system
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
163 call neko_error(
'no device backend configured')
165 call neko_error(
'no device backend configured')
167 end subroutine device_delta_1dbeam
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
174 call hip_hess(hess_d, hijx_d, ljjxinv_d, n, m)
176 call cuda_hess(hess_d, hijx_d, ljjxinv_d, n, m)
178 call neko_error(
'no device backend configured')
180 call neko_error(
'no device backend configured')
182 end subroutine device_hess
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
200 low_d, upp_d, alpha_d, beta_d, n)
203 low_d, upp_d, alpha_d, beta_d, n)
205 call neko_error(
'no device backend configured')
207 call neko_error(
'no device backend configured')
209 end subroutine device_mma_ljjxinv
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
223 low_d, upp_d, alpha_d, beta_d, n)
226 low_d, upp_d, alpha_d, beta_d, n)
228 call neko_error(
'no device backend configured')
230 call neko_error(
'no device backend configured')
232 end subroutine device_mma_dipsolvesub1
239 subroutine device_mattrans_v_mul(output_d, pij_d, lambda_d, m, n)
240 type(c_ptr) :: output_d, pij_d, lambda_d
247 call neko_error(
'no device backend configured')
249 call neko_error(
'no device backend configured')
251 end subroutine device_mattrans_v_mul
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
264 call neko_error(
'no device backend configured')
266 call neko_error(
'no device backend configured')
268 end subroutine device_mma_gensub1
271 subroutine device_mma_gensub2(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
273 type(c_ptr) :: low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d
274 real(c_rp) :: asydecr, asyincr
283 call neko_error(
'no device backend configured')
285 call neko_error(
'no device backend configured')
287 end subroutine device_mma_gensub2
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
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)
299 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
301 call neko_error(
'no device backend configured2')
303 call neko_error(
'no device backend configured3')
305 end subroutine device_mma_gensub3
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
332 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
335 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
337 call neko_error(
'no device backend configured')
339 call neko_error(
'no device backend configured')
341 end subroutine device_mma_gensub3_dip
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
351 call neko_error(
'no device backend configured')
353 call neko_error(
'no device backend configured')
355 end subroutine device_mma_gensub4
357 subroutine device_mma_max(xsi_d, x_d, alpha_d, n)
358 type(c_ptr) :: xsi_d, x_d, alpha_d
365 call neko_error(
'no device backend configured')
367 call neko_error(
'no device backend configured')
369 end subroutine device_mma_max
371 subroutine device_max2(a_d, b, c_d, d, n)
372 type(c_ptr) :: a_d, c_d
380 call neko_error(
'no device backend configured')
382 call neko_error(
'no device backend configured')
384 end subroutine device_max2
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
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)
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)
400 call neko_error(
'no device backend configured')
402 call neko_error(
'no device backend configured')
404 end subroutine device_rex
406 function device_lcsc2(a_d, b_d, n)
result(res)
407 type(c_ptr) :: a_d, b_d
417 call neko_error(
'no device backend configured')
419 call neko_error(
'no device backend configured')
421 end function device_lcsc2
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
427 call hip_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
429 call cuda_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
431 call neko_error(
'no device backend configured')
433 call neko_error(
'no device backend configured')
435 end subroutine device_relambda
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
446 call neko_error(
'no device backend configured')
448 call neko_error(
'no device backend configured')
450 end subroutine device_sub2cons2
452 function device_maxval(rex_d, n)
result(res)
463 call neko_error(
'no device backend configured')
465 call neko_error(
'no device backend configured')
467 end function device_maxval
469 function device_norm(rex_d, n)
result(res)
480 call neko_error(
'no device backend configured')
482 call neko_error(
'no device backend configured')
484 end function device_norm
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
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)
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)
499 call neko_error(
'no device backend configured')
501 call neko_error(
'no device backend configured')
503 end subroutine device_delx
505 subroutine device_add2inv2(a_d, b_d, c, n)
506 type(c_ptr):: a_d, b_d
514 call neko_error(
'no device backend configured')
516 call neko_error(
'no device backend configured')
518 end subroutine device_add2inv2
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
525 call hip_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
527 call cuda_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
529 call neko_error(
'no device backend configured')
531 call neko_error(
'no device backend configured')
533 end subroutine device_gg
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, &
539 beta_d, eta_d, lambda_d
540 integer(c_int) :: n, m
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)
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)
548 call neko_error(
'no device backend configured')
550 call neko_error(
'no device backend configured')
552 end subroutine device_diagx
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
559 call hip_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
561 call cuda_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
563 call neko_error(
'no device backend configured')
565 call neko_error(
'no device backend configured')
567 end subroutine device_bb
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
574 call hip_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
576 call cuda_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
578 call neko_error(
'no device backend configured')
580 call neko_error(
'no device backend configured')
582 end subroutine device_updatebb
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
588 call hip_aa(aa_d, gg_d, diagx_d, n, m)
590 call cuda_aa(aa_d, gg_d, diagx_d, n, m)
592 call neko_error(
'no device backend configured')
594 call neko_error(
'no device backend configured')
596 end subroutine device_aa
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
602 real(c_rp) :: zeta, z
604 call hip_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
607 call cuda_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
610 call neko_error(
'no device backend configured')
612 call neko_error(
'no device backend configured')
614 end subroutine device_updateaa
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
620 call hip_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
622 call cuda_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
624 call neko_error(
'no device backend configured')
626 call neko_error(
'no device backend configured')
628 end subroutine device_dx
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
634 call hip_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
636 call cuda_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
638 call neko_error(
'no device backend configured')
640 call neko_error(
'no device backend configured')
642 end subroutine device_dy
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
649 call hip_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
651 call cuda_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
653 call neko_error(
'no device backend configured')
655 call neko_error(
'no device backend configured')
657 end subroutine device_dxsi
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
664 call hip_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
666 call cuda_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
668 call neko_error(
'no device backend configured')
670 call neko_error(
'no device backend configured')
672 end subroutine device_deta
674 function device_maxval2(dxx_d, xx_d, cons, n)
result(res)
675 type(c_ptr):: dxx_d, xx_d
677 real(kind=rp),
intent(in) :: cons
686 call neko_error(
'no device backend configured')
688 call neko_error(
'no device backend configured')
690 end function device_maxval2
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
705 call neko_error(
'no device backend configured')
707 call neko_error(
'no device backend configured')
709 end function device_maxval3
713 subroutine device_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, &
715 type(c_ptr):: rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d
716 integer(c_int) :: n, m
718 call hip_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
720 call cuda_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
722 call neko_error(
'no device backend configured')
724 call neko_error(
'no device backend configured')
726 end subroutine device_kkt_rex
742 subroutine device_mma_dip_kkt(res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, &
744 type(c_ptr) :: res_d, x_d, df0dx_d, dfdx_d, xmin_d, xmax_d, lambda_d
745 integer(c_int) :: n, m
753 call neko_error(
'no device backend configured')
755 call neko_error(
'no device backend configured')
757 end subroutine device_mma_dip_kkt
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.