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_add4s3(a_d, b_d, c_d, d_d, c1, c2, c3, n, strm) &
234 bind(c, name = 'opencl_add4s3')
235 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
236 import c_rp
237 implicit none
238 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
239 real(c_rp) :: c1, c2, c3
240 integer(c_int) :: n
241 end subroutine opencl_add4s3
242
243 subroutine opencl_add5s4(a_d, b_d, c_d, d_d, e_d, &
244 c1, c2, c3, c4, n, strm) &
245 bind(c, name = 'opencl_add5s4')
246 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
247 import c_rp
248 implicit none
249 type(c_ptr), value :: a_d, b_d, c_d, d_d, e_d, strm
250 real(c_rp) :: c1, c2, c3, c4
251 integer(c_int) :: n
252 end subroutine opencl_add5s4
253
254 subroutine opencl_invcol1(a_d, n, strm) &
255 bind(c, name = 'opencl_invcol1')
256 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
257 implicit none
258 type(c_ptr), value :: a_d, strm
259 integer(c_int) :: n
260 end subroutine opencl_invcol1
261
262 subroutine opencl_invcol2(a_d, b_d, n, strm) &
263 bind(c, name = 'opencl_invcol2')
264 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
265 implicit none
266 type(c_ptr), value :: a_d, b_d, strm
267 integer(c_int) :: n
268 end subroutine opencl_invcol2
269
270 subroutine opencl_col2(a_d, b_d, n, strm) &
271 bind(c, name = 'opencl_col2')
272 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
273 implicit none
274 type(c_ptr), value :: a_d, b_d, strm
275 integer(c_int) :: n
276 end subroutine opencl_col2
277
278 subroutine opencl_col3(a_d, b_d, c_d, n, strm) &
279 bind(c, name = 'opencl_col3')
280 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
281 implicit none
282 type(c_ptr), value :: a_d, b_d, c_d, strm
283 integer(c_int) :: n
284 end subroutine opencl_col3
285
286 subroutine opencl_subcol3(a_d, b_d, c_d, n, strm) &
287 bind(c, name = 'opencl_subcol3')
288 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
289 implicit none
290 type(c_ptr), value :: a_d, b_d, c_d, strm
291 integer(c_int) :: n
292 end subroutine opencl_subcol3
293
294 subroutine opencl_sub2(a_d, b_d, n, strm) &
295 bind(c, name = 'opencl_sub2')
296 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
297 implicit none
298 type(c_ptr), value :: a_d, b_d, strm
299 integer(c_int) :: n
300 end subroutine opencl_sub2
301
302 subroutine opencl_sub3(a_d, b_d, c_d, n, strm) &
303 bind(c, name = 'opencl_sub3')
304 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
305 implicit none
306 type(c_ptr), value :: a_d, b_d, c_d, strm
307 integer(c_int) :: n
308 end subroutine opencl_sub3
309
310 subroutine opencl_add3(a_d, b_d, c_d, n, strm) &
311 bind(c, name = 'opencl_add3')
312 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
313 implicit none
314 type(c_ptr), value :: a_d, b_d, c_d, strm
315 integer(c_int) :: n
316 end subroutine opencl_add3
317
318 subroutine opencl_addcol3(a_d, b_d, c_d, n, strm) &
319 bind(c, name = 'opencl_addcol3')
320 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
321 implicit none
322 type(c_ptr), value :: a_d, b_d, c_d, strm
323 integer(c_int) :: n
324 end subroutine opencl_addcol3
325
326 subroutine opencl_addcol4(a_d, b_d, c_d, d_d, n, strm) &
327 bind(c, name = 'opencl_addcol4')
328 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
329 implicit none
330 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
331 integer(c_int) :: n
332 end subroutine opencl_addcol4
333
334 subroutine opencl_addcol3s2(a_d, b_d, c_d, s, n, strm) &
335 bind(c, name = 'opencl_addcol3s2')
336 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
337 import c_rp
338 type(c_ptr), value :: a_d, b_d, c_d, strm
339 real(c_rp) :: s
340 integer(c_int) :: n
341 end subroutine opencl_addcol3s2
342
343 subroutine opencl_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
344 n, strm) &
345 bind(c, name = 'opencl_vdot3')
346 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
347 implicit none
348 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d
349 type(c_ptr), value :: strm
350 integer(c_int) :: n
351 end subroutine opencl_vdot3
352
353 subroutine opencl_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
354 w1_d, w2_d, w3_d, n, strm) &
355 bind(c, name = 'opencl_vcross')
356 use, intrinsic :: iso_c_binding, only: c_int, c_ptr
357 type(c_ptr), value :: u1_d, u2_d, u3_d
358 type(c_ptr), value :: v1_d, v2_d, v3_d
359 type(c_ptr), value :: w1_d, w2_d, w3_d
360 type(c_ptr), value :: strm
361 integer(c_int) :: n
362 end subroutine opencl_vcross
363
364 real(c_rp) function opencl_glsc3(a_d, b_d, c_d, n, strm) &
365 bind(c, name = 'opencl_glsc3')
366 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
367 import c_rp
368 implicit none
369 type(c_ptr), value :: a_d, b_d, c_d, strm
370 integer(c_int) :: n
371 end function opencl_glsc3
372
373 subroutine opencl_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
374 bind(c, name = 'opencl_glsc3_many')
375 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
376 import c_rp
377 implicit none
378 integer(c_int) :: j, n
379 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
380 real(c_rp) :: h(j)
381 end subroutine opencl_glsc3_many
382
383 real(c_rp) function opencl_glsc2(a_d, b_d, n, strm) &
384 bind(c, name = 'opencl_glsc2')
385 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
386 import c_rp
387 implicit none
388 type(c_ptr), value :: a_d, b_d, strm
389 integer(c_int) :: n
390 end function opencl_glsc2
391
392 real(c_rp) function opencl_glsubnorm2(a_d, b_d, n, strm) &
393 bind(c, name = 'opencl_glsubnorm2')
394 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
395 import c_rp
396 implicit none
397 type(c_ptr), value :: a_d, b_d, strm
398 integer(c_int) :: n
399 end function opencl_glsubnorm2
400
401 real(c_rp) function opencl_glsum(a_d, n, strm) &
402 bind(c, name = 'opencl_glsum')
403 use, intrinsic :: iso_c_binding, only: c_ptr, c_int
404 import c_rp
405 implicit none
406 type(c_ptr), value :: a_d, strm
407 integer(c_int) :: n
408 end function opencl_glsum
409 end interface
410
411end 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