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