Neko 1.99.1
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
opencl_math.f90
Go to the documentation of this file.
1! Copyright (c) 2024-2025, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
34 use num_types, only: rp, c_rp
35 implicit none
36 public
37
38 interface
39 subroutine opencl_copy(a_d, b_d, n, strm) &
40 bind(c, name = 'opencl_copy')
41 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
42 type(c_ptr), value :: a_d, b_d, strm
43 integer(c_int) :: n
44 end subroutine opencl_copy
45
46 subroutine opencl_masked_copy(a_d, b_d, mask_d, n, n_mask, strm) &
47 bind(c, name = 'opencl_masked_copy')
48 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
49 type(c_ptr), value :: a_d, b_d, mask_d, strm
50 integer(c_int) :: n, n_mask
51 end subroutine opencl_masked_copy
52
53 subroutine opencl_masked_gather_copy(a_d, b_d, mask_d, n, n_mask, strm) &
54 bind(c, name = 'opencl_masked_gather_copy')
55 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
56 type(c_ptr), value :: a_d, b_d, mask_d, strm
57 integer(c_int) :: n, n_mask
58 end subroutine opencl_masked_gather_copy
59
60 subroutine opencl_masked_scatter_copy(a_d, b_d, mask_d, n, n_mask, strm) &
61 bind(c, name = 'opencl_masked_scatter_copy')
62 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
63 type(c_ptr), value :: a_d, b_d, mask_d, strm
64 integer(c_int) :: n, n_mask
65 end subroutine opencl_masked_scatter_copy
66
67 subroutine opencl_cfill_mask(a_d, c, n, mask_d, n_mask, strm) &
68 bind(c, name = 'opencl_cfill_mask')
69 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
70 import c_rp
71 type(c_ptr), value :: a_d
72 real(c_rp) :: c
73 integer(c_int) :: n
74 type(c_ptr), value :: mask_d
75 integer(c_int) :: n_mask
76 type(c_ptr), value :: strm
77 end subroutine opencl_cfill_mask
78
79 subroutine opencl_cmult(a_d, c, n, strm) &
80 bind(c, name = 'opencl_cmult')
81 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
82 import c_rp
83 type(c_ptr), value :: a_d, strm
84 real(c_rp) :: c
85 integer(c_int) :: n
86 end subroutine opencl_cmult
87
88 subroutine opencl_cmult2(a_d, b_d, c, n, strm) &
89 bind(c, name = 'opencl_cmult2')
90 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
91 import c_rp
92 type(c_ptr), value :: a_d, b_d, strm
93 real(c_rp) :: c
94 integer(c_int) :: n
95 end subroutine opencl_cmult2
96
97 subroutine opencl_cdiv(a_d, c, n, strm) &
98 bind(c, name = 'opencl_cdiv')
99 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
100 import c_rp
101 type(c_ptr), value :: a_d, strm
102 real(c_rp) :: c
103 integer(c_int) :: n
104 end subroutine opencl_cdiv
105
106 subroutine opencl_cdiv2(a_d, b_d, c, n, strm) &
107 bind(c, name = 'opencl_cdiv2')
108 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
109 import c_rp
110 type(c_ptr), value :: a_d, b_d, strm
111 real(c_rp) :: c
112 integer(c_int) :: n
113 end subroutine opencl_cdiv2
114
115 subroutine opencl_radd(a_d, c, n, strm) &
116 bind(c, name = 'opencl_radd')
117 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
118 import c_rp
119 type(c_ptr), value :: a_d, strm
120 real(c_rp) :: c
121 integer(c_int) :: n
122 end subroutine opencl_radd
123
124 subroutine opencl_iadd(a_d, c, n, strm) &
125 bind(c, name = 'opencl_iadd')
126 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
127 import c_rp
128 type(c_ptr), value :: a_d, strm
129 integer(c_int) :: c
130 integer(c_int) :: n
131 end subroutine opencl_iadd
132
133 subroutine opencl_cadd2(a_d, b_d, c, n, strm) &
134 bind(c, name = 'opencl_cadd2')
135 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
136 import c_rp
137 type(c_ptr), value :: a_d
138 type(c_ptr), value :: b_d
139 type(c_ptr), value :: strm
140 real(c_rp) :: c
141 integer(c_int) :: n
142 end subroutine opencl_cadd2
143
144 subroutine opencl_cfill(a_d, c, n, strm) &
145 bind(c, name = 'opencl_cfill')
146 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
147 import c_rp
148 type(c_ptr), value :: a_d
149 type(c_ptr), value :: strm
150 real(c_rp) :: c
151 integer(c_int) :: n
152 end subroutine opencl_cfill
153
154 subroutine opencl_rzero(a_d, n, strm) &
155 bind(c, name = 'opencl_rzero')
156 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
157 type(c_ptr), value :: a_d, strm
158 integer(c_int) :: n
159 end subroutine opencl_rzero
160
161 subroutine opencl_rone(a_d, n, strm) &
162 bind(c, name = 'opencl_rone')
163 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
164 type(c_ptr), value :: a_d, strm
165 integer(c_int) :: n
166 end subroutine opencl_rone
167
168 subroutine opencl_add2(a_d, b_d, n, strm) &
169 bind(c, name = 'opencl_add2')
170 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
171 implicit none
172 type(c_ptr), value :: a_d, b_d, strm
173 integer(c_int) :: n
174 end subroutine opencl_add2
175
176 subroutine opencl_add4(a_d, b_d, c_d, d_d, n, strm) &
177 bind(c, name = 'opencl_add4')
178 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
179 implicit none
180 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
181 integer(c_int) :: n
182 end subroutine opencl_add4
183
184 subroutine opencl_add2s1(a_d, b_d, c1, n, strm) &
185 bind(c, name = 'opencl_add2s1')
186 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
187 import c_rp
188 implicit none
189 type(c_ptr), value :: a_d, b_d, strm
190 real(c_rp) :: c1
191 integer(c_int) :: n
192 end subroutine opencl_add2s1
193
194 subroutine opencl_add2s2(a_d, b_d, c1, n, strm) &
195 bind(c, name = 'opencl_add2s2')
196 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
197 import c_rp
198 implicit none
199 type(c_ptr), value :: a_d, b_d, strm
200 real(c_rp) :: c1
201 integer(c_int) :: n
202 end subroutine opencl_add2s2
203
204 subroutine opencl_add2s2_many(y_d, x_d_d, a_d, j, n, strm) &
205 bind(c, name = 'opencl_add2s2_many')
206 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
207 import c_rp
208 implicit none
209 type(c_ptr), value :: y_d, x_d_d, a_d, strm
210 integer(c_int) :: j, n
211 end subroutine opencl_add2s2_many
212
213 subroutine opencl_addsqr2s2(a_d, b_d, c1, n, strm) &
214 bind(c, name = 'opencl_addsqr2s2')
215 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
216 import c_rp
217 implicit none
218 type(c_ptr), value :: a_d, b_d, strm
219 real(c_rp) :: c1
220 integer(c_int) :: n
221 end subroutine opencl_addsqr2s2
222
223 subroutine opencl_add3s2(a_d, b_d, c_d, c1, c2, n, strm) &
224 bind(c, name = 'opencl_add3s2')
225 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
226 import c_rp
227 implicit none
228 type(c_ptr), value :: a_d, b_d, c_d, strm
229 real(c_rp) :: c1, c2
230 integer(c_int) :: n
231 end subroutine opencl_add3s2
232
233 subroutine opencl_invcol1(a_d, n, strm) &
234 bind(c, name = 'opencl_invcol1')
235 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
236 implicit none
237 type(c_ptr), value :: a_d, strm
238 integer(c_int) :: n
239 end subroutine opencl_invcol1
240
241 subroutine opencl_invcol2(a_d, b_d, n, strm) &
242 bind(c, name = 'opencl_invcol2')
243 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
244 implicit none
245 type(c_ptr), value :: a_d, b_d, strm
246 integer(c_int) :: n
247 end subroutine opencl_invcol2
248
249 subroutine opencl_col2(a_d, b_d, n, strm) &
250 bind(c, name = 'opencl_col2')
251 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
252 implicit none
253 type(c_ptr), value :: a_d, b_d, strm
254 integer(c_int) :: n
255 end subroutine opencl_col2
256
257 subroutine opencl_col3(a_d, b_d, c_d, n, strm) &
258 bind(c, name = 'opencl_col3')
259 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
260 implicit none
261 type(c_ptr), value :: a_d, b_d, c_d, strm
262 integer(c_int) :: n
263 end subroutine opencl_col3
264
265 subroutine opencl_subcol3(a_d, b_d, c_d, n, strm) &
266 bind(c, name = 'opencl_subcol3')
267 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
268 implicit none
269 type(c_ptr), value :: a_d, b_d, c_d, strm
270 integer(c_int) :: n
271 end subroutine opencl_subcol3
272
273 subroutine opencl_sub2(a_d, b_d, n, strm) &
274 bind(c, name = 'opencl_sub2')
275 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
276 implicit none
277 type(c_ptr), value :: a_d, b_d, strm
278 integer(c_int) :: n
279 end subroutine opencl_sub2
280
281 subroutine opencl_sub3(a_d, b_d, c_d, n, strm) &
282 bind(c, name = 'opencl_sub3')
283 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
284 implicit none
285 type(c_ptr), value :: a_d, b_d, c_d, strm
286 integer(c_int) :: n
287 end subroutine opencl_sub3
288
289 subroutine opencl_add3(a_d, b_d, c_d, n, strm) &
290 bind(c, name = 'opencl_add3')
291 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
292 implicit none
293 type(c_ptr), value :: a_d, b_d, c_d, strm
294 integer(c_int) :: n
295 end subroutine opencl_add3
296
297 subroutine opencl_addcol3(a_d, b_d, c_d, n, strm) &
298 bind(c, name = 'opencl_addcol3')
299 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
300 implicit none
301 type(c_ptr), value :: a_d, b_d, c_d, strm
302 integer(c_int) :: n
303 end subroutine opencl_addcol3
304
305 subroutine opencl_addcol4(a_d, b_d, c_d, d_d, n, strm) &
306 bind(c, name = 'opencl_addcol4')
307 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
308 implicit none
309 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
310 integer(c_int) :: n
311 end subroutine opencl_addcol4
312
313 subroutine opencl_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
314 n, strm) &
315 bind(c, name = 'opencl_vdot3')
316 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
317 implicit none
318 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d
319 type(c_ptr), value :: strm
320 integer(c_int) :: n
321 end subroutine opencl_vdot3
322
323 subroutine opencl_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
324 w1_d, w2_d, w3_d, n, strm) &
325 bind(c, name = 'opencl_vcross')
326 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
327 type(c_ptr), value :: u1_d, u2_d, u3_d
328 type(c_ptr), value :: v1_d, v2_d, v3_d
329 type(c_ptr), value :: w1_d, w2_d, w3_d
330 type(c_ptr), value :: strm
331 integer(c_int) :: n
332 end subroutine opencl_vcross
333
334 real(c_rp) function opencl_glsc3(a_d, b_d, c_d, n, strm) &
335 bind(c, name = 'opencl_glsc3')
336 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
337 import c_rp
338 implicit none
339 type(c_ptr), value :: a_d, b_d, c_d, strm
340 integer(c_int) :: n
341 end function opencl_glsc3
342
343 subroutine opencl_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
344 bind(c, name = 'opencl_glsc3_many')
345 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
346 import c_rp
347 implicit none
348 integer(c_int) :: j, n
349 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
350 real(c_rp) :: h(j)
351 end subroutine opencl_glsc3_many
352
353 real(c_rp) function opencl_glsc2(a_d, b_d, n, strm) &
354 bind(c, name = 'opencl_glsc2')
355 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
356 import c_rp
357 implicit none
358 type(c_ptr), value :: a_d, b_d, strm
359 integer(c_int) :: n
360 end function opencl_glsc2
361
362 real(c_rp) function opencl_glsubnorm2(a_d, b_d, n, strm) &
363 bind(c, name = 'opencl_glsubnorm2')
364 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
365 import c_rp
366 implicit none
367 type(c_ptr), value :: a_d, b_d, strm
368 integer(c_int) :: n
369 end function opencl_glsubnorm2
370
371 real(c_rp) function opencl_glsum(a_d, n, strm) &
372 bind(c, name = 'opencl_glsum')
373 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
374 import c_rp
375 implicit none
376 type(c_ptr), value :: a_d, strm
377 integer(c_int) :: n
378 end function opencl_glsum
379 end interface
380
381end module opencl_math
integer, parameter, public c_rp
Definition num_types.f90:13
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12