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