Neko-TOP
A portable framework for high-order spectral element flow toplogy optimization.
Loading...
Searching...
No Matches
device_RAMP_mapping.f90
Go to the documentation of this file.
1
34!
35module device_ramp_mapping
36 use utils, only: neko_error
37 use num_types, only: rp, c_rp
38 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
39 implicit none
40 private
41
42 public :: device_convex_down_ramp_mapping_apply, &
43 device_convex_down_ramp_mapping_apply_backward
44
45#if HAVE_HIP
46
47 interface
48 subroutine hip_convex_down_ramp_mapping_apply(f_min, f_max, q, &
49 X_out_d, X_in_d, n) &
50 bind(c, name = 'hip_convex_down_RAMP_mapping_apply')
51 import c_rp, c_ptr, c_int
52 real(c_rp) :: f_min
53 real(c_rp) :: f_max
54 real(c_rp) :: q
55 type(c_ptr), value :: X_out_d
56 type(c_ptr), value :: X_in_d
57 integer(c_int) :: n
58 end subroutine hip_convex_down_ramp_mapping_apply
59 end interface
60
61 interface
62 subroutine hip_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
63 sense_out_d, sens_in_d, X_in_d, n) &
64 bind(c, name = 'hip_convex_down_RAMP_mapping_apply_backward')
65 import c_rp, c_ptr, c_int
66 real(c_rp) :: f_min
67 real(c_rp) :: f_max
68 real(c_rp) :: q
69 type(c_ptr), value :: sense_out_d
70 type(c_ptr), value :: sens_in_d
71 type(c_ptr), value :: X_in_d
72 integer(c_int) :: n
73 end subroutine hip_convex_down_ramp_mapping_apply_backward
74 end interface
75
76#elif HAVE_CUDA
77
78 interface
79 subroutine cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
80 X_out_d, X_in_d, n) &
81 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply')
82 import c_rp, c_ptr, c_int
83 real(c_rp) :: f_min
84 real(c_rp) :: f_max
85 real(c_rp) :: q
86 type(c_ptr), value :: X_out_d
87 type(c_ptr), value :: X_in_d
88 integer(c_int) :: n
89 end subroutine cuda_convex_down_ramp_mapping_apply
90 end interface
91
92 interface
93 subroutine cuda_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
94 sense_out_d, sens_in_d, X_in_d, n) &
95 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply_backward')
96 import c_rp, c_ptr, c_int
97 real(c_rp) :: f_min
98 real(c_rp) :: f_max
99 real(c_rp) :: q
100 type(c_ptr), value :: sense_out_d
101 type(c_ptr), value :: sens_in_d
102 type(c_ptr), value :: X_in_d
103 integer(c_int) :: n
104 end subroutine cuda_convex_down_ramp_mapping_apply_backward
105 end interface
106
107#elif HAVE_OPENCL
108
109#endif
110
111contains
112
113 subroutine device_convex_down_ramp_mapping_apply(f_min, f_max, q, &
114 X_out_d, X_in_d, n)
115 real(kind=rp), intent(in) :: f_min
116 real(kind=rp), intent(in) :: f_max
117 real(kind=rp), intent(in) :: q
118 type(c_ptr) :: X_out_d
119 type(c_ptr) :: X_in_d
120 integer :: n
121#if HAVE_HIP
122 call hip_convex_down_ramp_mapping_apply(f_min, f_max, q, &
123 x_out_d, x_in_d, n)
124#elif HAVE_CUDA
125 call cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
126 x_out_d, x_in_d, n)
127#else
128 call neko_error('No device backend configured')
129#endif
130 end subroutine device_convex_down_ramp_mapping_apply
131
132 subroutine device_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
133 sense_out_d, sens_in_d, X_in_d, n)
134 real(kind=rp), intent(in) :: f_min
135 real(kind=rp), intent(in) :: f_max
136 real(kind=rp), intent(in) :: q
137 type(c_ptr) :: sense_out_d
138 type(c_ptr) :: sens_in_d
139 type(c_ptr) :: X_in_d
140 integer :: n
141#if HAVE_HIP
142 call hip_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
143 sense_out_d, sens_in_d, x_in_d, n)
144#elif HAVE_CUDA
145 call cuda_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
146 sense_out_d, sens_in_d, x_in_d, n)
147#else
148 call neko_error('No device backend configured')
149#endif
150 end subroutine device_convex_down_ramp_mapping_apply_backward
151end module device_ramp_mapping