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_up_ramp_mapping_apply, &
43 device_convex_up_ramp_mapping_apply_backward, &
44 device_convex_down_ramp_mapping_apply, &
45 device_convex_down_ramp_mapping_apply_backward
46
47#if HAVE_HIP
48
49 interface
50 subroutine hip_convex_down_ramp_mapping_apply(f_min, f_max, q, &
51 X_out_d, X_in_d, n) &
52 bind(c, name = 'hip_convex_down_RAMP_mapping_apply')
53 import c_rp, c_ptr, c_int
54 real(c_rp) :: f_min
55 real(c_rp) :: f_max
56 real(c_rp) :: q
57 type(c_ptr), value :: X_out_d
58 type(c_ptr), value :: X_in_d
59 integer(c_int) :: n
60 end subroutine hip_convex_down_ramp_mapping_apply
61 end interface
62
63 interface
64 subroutine hip_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
65 sense_out_d, sens_in_d, X_in_d, n) &
66 bind(c, name = 'hip_convex_down_RAMP_mapping_apply_backward')
67 import c_rp, c_ptr, c_int
68 real(c_rp) :: f_min
69 real(c_rp) :: f_max
70 real(c_rp) :: q
71 type(c_ptr), value :: sense_out_d
72 type(c_ptr), value :: sens_in_d
73 type(c_ptr), value :: X_in_d
74 integer(c_int) :: n
75 end subroutine hip_convex_down_ramp_mapping_apply_backward
76 end interface
77
78 interface
79 subroutine hip_convex_up_ramp_mapping_apply(f_min, f_max, q, &
80 X_out_d, X_in_d, n) &
81 bind(c, name = 'hip_convex_up_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 hip_convex_up_ramp_mapping_apply
90 end interface
91
92 interface
93 subroutine hip_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
94 sense_out_d, sens_in_d, X_in_d, n) &
95 bind(c, name = 'hip_convex_up_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 hip_convex_up_ramp_mapping_apply_backward
105 end interface
106
107#elif HAVE_CUDA
108
109 interface
110 subroutine cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
111 X_out_d, X_in_d, n) &
112 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply')
113 import c_rp, c_ptr, c_int
114 real(c_rp) :: f_min
115 real(c_rp) :: f_max
116 real(c_rp) :: q
117 type(c_ptr), value :: X_out_d
118 type(c_ptr), value :: X_in_d
119 integer(c_int) :: n
120 end subroutine cuda_convex_down_ramp_mapping_apply
121 end interface
122
123 interface
124 subroutine cuda_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
125 sense_out_d, sens_in_d, X_in_d, n) &
126 bind(c, name = 'cuda_convex_down_RAMP_mapping_apply_backward')
127 import c_rp, c_ptr, c_int
128 real(c_rp) :: f_min
129 real(c_rp) :: f_max
130 real(c_rp) :: q
131 type(c_ptr), value :: sense_out_d
132 type(c_ptr), value :: sens_in_d
133 type(c_ptr), value :: X_in_d
134 integer(c_int) :: n
135 end subroutine cuda_convex_down_ramp_mapping_apply_backward
136 end interface
137
138 interface
139 subroutine cuda_convex_up_ramp_mapping_apply(f_min, f_max, q, &
140 X_out_d, X_in_d, n) &
141 bind(c, name = 'cuda_convex_up_RAMP_mapping_apply')
142 import c_rp, c_ptr, c_int
143 real(c_rp) :: f_min
144 real(c_rp) :: f_max
145 real(c_rp) :: q
146 type(c_ptr), value :: X_out_d
147 type(c_ptr), value :: X_in_d
148 integer(c_int) :: n
149 end subroutine cuda_convex_up_ramp_mapping_apply
150 end interface
151
152 interface
153 subroutine cuda_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
154 sense_out_d, sens_in_d, X_in_d, n) &
155 bind(c, name = 'cuda_convex_up_RAMP_mapping_apply_backward')
156 import c_rp, c_ptr, c_int
157 real(c_rp) :: f_min
158 real(c_rp) :: f_max
159 real(c_rp) :: q
160 type(c_ptr), value :: sense_out_d
161 type(c_ptr), value :: sens_in_d
162 type(c_ptr), value :: X_in_d
163 integer(c_int) :: n
164 end subroutine cuda_convex_up_ramp_mapping_apply_backward
165 end interface
166
167#elif HAVE_OPENCL
168
169#endif
170
171contains
172
173 subroutine device_convex_down_ramp_mapping_apply(f_min, f_max, q, &
174 X_out_d, X_in_d, n)
175 real(kind=rp), intent(in) :: f_min
176 real(kind=rp), intent(in) :: f_max
177 real(kind=rp), intent(in) :: q
178 type(c_ptr) :: X_out_d
179 type(c_ptr) :: X_in_d
180 integer :: n
181#if HAVE_HIP
182 call hip_convex_down_ramp_mapping_apply(f_min, f_max, q, &
183 x_out_d, x_in_d, n)
184#elif HAVE_CUDA
185 call cuda_convex_down_ramp_mapping_apply(f_min, f_max, q, &
186 x_out_d, x_in_d, n)
187#else
188 call neko_error('No device backend configured')
189#endif
190 end subroutine device_convex_down_ramp_mapping_apply
191
192 subroutine device_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
193 sense_out_d, sens_in_d, X_in_d, n)
194 real(kind=rp), intent(in) :: f_min
195 real(kind=rp), intent(in) :: f_max
196 real(kind=rp), intent(in) :: q
197 type(c_ptr) :: sense_out_d
198 type(c_ptr) :: sens_in_d
199 type(c_ptr) :: X_in_d
200 integer :: n
201#if HAVE_HIP
202 call hip_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
203 sense_out_d, sens_in_d, x_in_d, n)
204#elif HAVE_CUDA
205 call cuda_convex_down_ramp_mapping_apply_backward(f_min, f_max, q, &
206 sense_out_d, sens_in_d, x_in_d, n)
207#else
208 call neko_error('No device backend configured')
209#endif
210 end subroutine device_convex_down_ramp_mapping_apply_backward
211
212 subroutine device_convex_up_ramp_mapping_apply(f_min, f_max, q, &
213 X_out_d, X_in_d, n)
214 real(kind=rp), intent(in) :: f_min
215 real(kind=rp), intent(in) :: f_max
216 real(kind=rp), intent(in) :: q
217 type(c_ptr) :: X_out_d
218 type(c_ptr) :: X_in_d
219 integer :: n
220#if HAVE_HIP
221 call hip_convex_up_ramp_mapping_apply(f_min, f_max, q, &
222 x_out_d, x_in_d, n)
223#elif HAVE_CUDA
224 call cuda_convex_up_ramp_mapping_apply(f_min, f_max, q, &
225 x_out_d, x_in_d, n)
226#else
227 call neko_error('No device backend configured')
228#endif
229 end subroutine device_convex_up_ramp_mapping_apply
230
231 subroutine device_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
232 sense_out_d, sens_in_d, X_in_d, n)
233 real(kind=rp), intent(in) :: f_min
234 real(kind=rp), intent(in) :: f_max
235 real(kind=rp), intent(in) :: q
236 type(c_ptr) :: sense_out_d
237 type(c_ptr) :: sens_in_d
238 type(c_ptr) :: X_in_d
239 integer :: n
240#if HAVE_HIP
241 call hip_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
242 sense_out_d, sens_in_d, x_in_d, n)
243#elif HAVE_CUDA
244 call cuda_convex_up_ramp_mapping_apply_backward(f_min, f_max, q, &
245 sense_out_d, sens_in_d, x_in_d, n)
246#else
247 call neko_error('No device backend configured')
248#endif
249 end subroutine device_convex_up_ramp_mapping_apply_backward
250end module device_ramp_mapping