34 use,
intrinsic :: iso_c_binding, only: c_ptr, c_int
35 use num_types,
only: rp, c_rp
36 use utils,
only: neko_error
37 use comm,
only: neko_comm, pe_size, mpi_real_precision
38 use mpi_f08,
only: mpi_sum, mpi_in_place, mpi_allreduce
58 public :: device_mma_gensub1, device_mma_gensub2, device_mma_gensub3, &
59 device_mma_gensub4, device_mma_max, device_max2, device_rex, &
60 device_lcsc2, device_relambda, device_sub2cons2, device_maxval, &
61 device_norm, device_delx, device_add2inv2, device_gg, device_diagx, &
62 device_bb, device_updatebb, device_aa, device_updateaa, device_dx, &
63 device_dy, device_deta, device_dxsi, device_maxval2, device_maxval3, &
64 device_kkt_rex, device_mattrans_v_mul, device_mma_dipsolvesub1, &
65 device_mma_ljjxinv, device_hess
69 subroutine device_hess(Hess_d, hijx_d, Ljjxinv_d, n, m)
70 type(c_ptr):: Hess_d, hijx_d, Ljjxinv_d
71 integer(c_int) :: n, m
73 call hip_hess(hess_d, hijx_d, ljjxinv_d, n, m)
75 call cuda_hess(hess_d, hijx_d, ljjxinv_d, n, m)
77 call neko_error(
'no device backend configured')
79 call neko_error(
'no device backend configured')
81 end subroutine device_hess
83 subroutine device_mma_ljjxinv(Ljjxinv_d,pjlambda_d, qjlambda_d, x_d, &
84 low_d, upp_d, alpha_d, beta_d, n)
95 type(c_ptr) :: Ljjxinv_d, pjlambda_d, qjlambda_d, x_d, &
96 low_d, upp_d, alpha_d, beta_d
100 low_d, upp_d, alpha_d, beta_d, n)
103 low_d, upp_d, alpha_d, beta_d, n)
105 call neko_error(
'no device backend configured')
107 call neko_error(
'no device backend configured')
109 end subroutine device_mma_ljjxinv
112 subroutine device_mma_dipsolvesub1(x_d, pjlambda_d, qjlambda_d, &
113 low_d, upp_d, alpha_d, beta_d, n)
120 type(c_ptr) :: x_d, pjlambda_d, qjlambda_d, &
121 low_d, upp_d, alpha_d, beta_d
125 low_d, upp_d, alpha_d, beta_d, n)
128 low_d, upp_d, alpha_d, beta_d, n)
130 call neko_error(
'no device backend configured')
132 call neko_error(
'no device backend configured')
134 end subroutine device_mma_dipsolvesub1
137 subroutine device_mattrans_v_mul(output_d, pij_d, lambda_d, m, n)
144 type(c_ptr) :: output_d, pij_d, lambda_d
151 call neko_error(
'no device backend configured')
153 call neko_error(
'no device backend configured')
155 end subroutine device_mattrans_v_mul
159 subroutine device_mma_gensub1(low_d, upp_d, x_d, xmin_d, xmax_d, asyinit, n)
160 type(c_ptr) :: low_d, upp_d, x_d, xmin_d, xmax_d
161 real(c_rp) :: asyinit
168 call neko_error(
'no device backend configured')
170 call neko_error(
'no device backend configured')
172 end subroutine device_mma_gensub1
175 subroutine device_mma_gensub2(low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d, &
177 type(c_ptr) :: low_d, upp_d, x_d, xold1_d, xold2_d, xdiff_d
178 real(c_rp) :: asydecr, asyincr
187 call neko_error(
'no device backend configured')
189 call neko_error(
'no device backend configured')
191 end subroutine device_mma_gensub2
193 subroutine device_mma_gensub3(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, &
194 max_d, alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
195 type(c_ptr) :: x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
196 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d
199 call mma_gensub3_hip(x_d, df0dx_d, dfdx_d, low_d, upp_d, min_d, max_d, &
200 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
203 alpha_d, beta_d, p0j_d, q0j_d, pij_d, qij_d, n, m)
205 call neko_error(
'no device backend configured2')
207 call neko_error(
'no device backend configured3')
209 end subroutine device_mma_gensub3
211 subroutine device_mma_gensub4(x_d, low_d, upp_d, pij_d, qij_d, n, m, bi_d)
212 type(c_ptr) :: x_d, low_d, upp_d, pij_d, qij_d, bi_d
219 call neko_error(
'no device backend configured')
221 call neko_error(
'no device backend configured')
223 end subroutine device_mma_gensub4
225 subroutine device_mma_max(xsi_d, x_d, alpha_d, n)
226 type(c_ptr) :: xsi_d, x_d, alpha_d
233 call neko_error(
'no device backend configured')
235 call neko_error(
'no device backend configured')
237 end subroutine device_mma_max
239 subroutine device_max2(a_d, b, c_d, d, n)
240 type(c_ptr) :: a_d, c_d
248 call neko_error(
'no device backend configured')
250 call neko_error(
'no device backend configured')
252 end subroutine device_max2
256 subroutine device_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, &
257 q0j_d, lambda_d, xsi_d, eta_d, n, m)
258 type(c_ptr) :: rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
259 lambda_d, xsi_d, eta_d
260 integer(c_int) :: n, m
262 call hip_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
263 lambda_d, xsi_d, eta_d, n, m)
265 call cuda_rex(rex_d, x_d, low_d, upp_d, pij_d, p0j_d, qij_d, q0j_d, &
266 lambda_d, xsi_d, eta_d, n, m)
268 call neko_error(
'no device backend configured')
270 call neko_error(
'no device backend configured')
272 end subroutine device_rex
274 function device_lcsc2(a_d, b_d, n)
result(res)
275 type(c_ptr) :: a_d, b_d
285 call neko_error(
'no device backend configured')
287 call neko_error(
'no device backend configured')
289 end function device_lcsc2
291 subroutine device_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
292 type(c_ptr) :: relambda_d, x_d, upp_d, low_d, pij_d, qij_d
293 integer(c_int) :: n, m
295 call hip_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
297 call cuda_relambda(relambda_d, x_d, upp_d, low_d, pij_d, qij_d, n, m)
299 call neko_error(
'no device backend configured')
301 call neko_error(
'no device backend configured')
303 end subroutine device_relambda
305 subroutine device_sub2cons2(rexsi_d, xsi_d, x_d, alpha_d, epsi, n)
306 type(c_ptr):: rexsi_d, xsi_d, x_d, alpha_d
307 real(kind=rp) :: epsi
314 call neko_error(
'no device backend configured')
316 call neko_error(
'no device backend configured')
318 end subroutine device_sub2cons2
320 function device_maxval(rex_d, n)
result(res)
331 call neko_error(
'no device backend configured')
333 call neko_error(
'no device backend configured')
335 end function device_maxval
337 function device_norm(rex_d, n)
result(res)
348 call neko_error(
'no device backend configured')
350 call neko_error(
'no device backend configured')
352 end function device_norm
354 subroutine device_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, &
355 q0j_d, alpha_d, beta_d, lambda_d, epsi, n, m)
356 type(c_ptr):: delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
357 alpha_d, beta_d, lambda_d
358 real(kind=rp) :: epsi
359 integer(c_int) :: n, m
361 call hip_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
362 alpha_d, beta_d, lambda_d, epsi, n, m)
364 call cuda_delx(delx_d, x_d, low_d, upp_d, pij_d, qij_d, p0j_d, q0j_d, &
365 alpha_d, beta_d, lambda_d, epsi, n, m)
367 call neko_error(
'no device backend configured')
369 call neko_error(
'no device backend configured')
371 end subroutine device_delx
373 subroutine device_add2inv2(a_d, b_d, c, n)
374 type(c_ptr):: a_d, b_d
382 call neko_error(
'no device backend configured')
384 call neko_error(
'no device backend configured')
386 end subroutine device_add2inv2
389 subroutine device_gg(GG_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
390 type(c_ptr):: GG_d, x_d, low_d, upp_d, pij_d, qij_d
391 integer(c_int) :: n, m
393 call hip_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
395 call cuda_gg(gg_d, x_d, low_d, upp_d, pij_d, qij_d, n, m)
397 call neko_error(
'no device backend configured')
399 call neko_error(
'no device backend configured')
401 end subroutine device_gg
403 subroutine device_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, &
404 pij_d, qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
405 type(c_ptr):: diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
407 beta_d, eta_d, lambda_d
408 integer(c_int) :: n, m
410 call hip_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
411 qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
413 call cuda_diagx(diagx_d, x_d, xsi_d, low_d, upp_d, p0j_d, q0j_d, pij_d, &
414 qij_d, alpha_d, beta_d, eta_d, lambda_d, n, m)
416 call neko_error(
'no device backend configured')
418 call neko_error(
'no device backend configured')
420 end subroutine device_diagx
423 subroutine device_bb(bb_d, GG_d, delx_d, diagx_d, n, m)
424 type(c_ptr):: bb_d, GG_d, delx_d, diagx_d
425 integer(c_int) :: n, m
427 call hip_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
429 call cuda_bb(bb_d, gg_d, delx_d, diagx_d, n, m)
431 call neko_error(
'no device backend configured')
433 call neko_error(
'no device backend configured')
435 end subroutine device_bb
437 subroutine device_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
438 type(c_ptr):: bb_d, dellambda_d, dely_d, d_d, mu_d, y_d
442 call hip_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
444 call cuda_updatebb(bb_d, dellambda_d, dely_d, d_d, mu_d, y_d, delz, m)
446 call neko_error(
'no device backend configured')
448 call neko_error(
'no device backend configured')
450 end subroutine device_updatebb
452 subroutine device_aa(AA_d, GG_d, diagx_d, n, m)
453 type(c_ptr):: AA_d, GG_d, diagx_d
454 integer(c_int) :: n, m
456 call hip_aa(aa_d, gg_d, diagx_d, n, m)
458 call cuda_aa(aa_d, gg_d, diagx_d, n, m)
460 call neko_error(
'no device backend configured')
462 call neko_error(
'no device backend configured')
464 end subroutine device_aa
466 subroutine device_updateaa(AA_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, &
467 y_d, a_d, zeta, z, m)
468 type(c_ptr):: AA_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, a_d
470 real(c_rp) :: zeta, z
472 call hip_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
475 call cuda_updateaa(aa_d, globaltmp_mm_d, s_d, lambda_d, d_d, mu_d, y_d, &
478 call neko_error(
'no device backend configured')
480 call neko_error(
'no device backend configured')
482 end subroutine device_updateaa
484 subroutine device_dx(dx_d, delx_d, diagx_d, GG_d, dlambda_d, n, m)
485 type(c_ptr):: dx_d, delx_d, diagx_d, GG_d, dlambda_d
486 integer(c_int) :: n, m
488 call hip_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
490 call cuda_dx(dx_d, delx_d, diagx_d, gg_d, dlambda_d, n, m)
492 call neko_error(
'no device backend configured')
494 call neko_error(
'no device backend configured')
496 end subroutine device_dx
498 subroutine device_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
499 type(c_ptr):: dy_d, dely_d, dlambda_d, d_d, mu_d, y_d
502 call hip_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
504 call cuda_dy(dy_d, dely_d, dlambda_d, d_d, mu_d, y_d, n)
506 call neko_error(
'no device backend configured')
508 call neko_error(
'no device backend configured')
510 end subroutine device_dy
512 subroutine device_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
513 type(c_ptr):: dxsi_d, xsi_d, dx_d, x_d, alpha_d
517 call hip_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
519 call cuda_dxsi(dxsi_d, xsi_d, dx_d, x_d, alpha_d, epsi, n)
521 call neko_error(
'no device backend configured')
523 call neko_error(
'no device backend configured')
525 end subroutine device_dxsi
527 subroutine device_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
528 type(c_ptr):: deta_d, eta_d, dx_d, x_d, beta_d
532 call hip_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
534 call cuda_deta(deta_d, eta_d, dx_d, x_d, beta_d, epsi, n)
536 call neko_error(
'no device backend configured')
538 call neko_error(
'no device backend configured')
540 end subroutine device_deta
542 function device_maxval2(dxx_d, xx_d, cons, n)
result(res)
543 type(c_ptr):: dxx_d, xx_d
545 real(kind=rp),
intent(in) :: cons
554 call neko_error(
'no device backend configured')
556 call neko_error(
'no device backend configured')
558 end function device_maxval2
561 function device_maxval3(dx_d, x_d, alpha_d, cons, n)
result(res)
562 type(c_ptr):: dx_d, x_d, alpha_d
563 real(kind=rp),
intent(in) :: cons
573 call neko_error(
'no device backend configured')
575 call neko_error(
'no device backend configured')
577 end function device_maxval3
581 subroutine device_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, &
583 type(c_ptr):: rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d
584 integer(c_int) :: n, m
586 call hip_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
588 call cuda_kkt_rex(rex_d, df0dx_d, dfdx_d, xsi_d, eta_d, lambda_d, n, m)
590 call neko_error(
'no device backend configured')
592 call neko_error(
'no device backend configured')
594 end subroutine device_kkt_rex
598end module device_mma_math