Neko 1.99.3
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
hip_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 hip_copy(a_d, b_d, n, strm) &
40 bind(c, name = 'hip_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 hip_copy
45
46 subroutine hip_masked_copy(a_d, b_d, mask_d, n, n_mask, strm) &
47 bind(c, name = 'hip_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 hip_masked_copy
52
53 subroutine hip_masked_gather_copy(a_d, b_d, mask_d, n, n_mask, strm) &
54 bind(c, name = 'hip_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 hip_masked_gather_copy
59
60 subroutine hip_masked_gather_copy_aligned(a_d, b_d, mask_d, n, n_mask, &
61 strm) bind(c, name = 'hip_masked_gather_copy_aligned')
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
66
67 subroutine hip_masked_scatter_copy(a_d, b_d, mask_d, n, n_mask, strm) &
68 bind(c, name = 'hip_masked_scatter_copy')
69 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
70 type(c_ptr), value :: a_d, b_d, mask_d, strm
71 integer(c_int) :: n, n_mask
72 end subroutine hip_masked_scatter_copy
73
74 subroutine hip_masked_atomic_reduction(a_d, b_d, mask_d, n, m, strm) &
75 bind(c, name = 'hip_masked_atomic_reduction')
76 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
77 type(c_ptr), value :: a_d, b_d, mask_d, strm
78 integer(c_int) :: n, m
79 end subroutine hip_masked_atomic_reduction
80
81 subroutine hip_cfill_mask(a_d, c, n, mask_d, n_mask, strm) &
82 bind(c, name = 'hip_cfill_mask')
83 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
84 import c_rp
85 type(c_ptr), value :: a_d
86 real(c_rp) :: c
87 integer(c_int) :: n
88 type(c_ptr), value :: mask_d
89 integer(c_int) :: n_mask
90 type(c_ptr), value :: strm
91 end subroutine hip_cfill_mask
92
93 subroutine hip_cmult(a_d, c, n, strm) &
94 bind(c, name = 'hip_cmult')
95 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
96 import c_rp
97 type(c_ptr), value :: a_d, strm
98 real(c_rp) :: c
99 integer(c_int) :: n
100 end subroutine hip_cmult
101
102 subroutine hip_cmult2(a_d, b_d, c, n, strm) &
103 bind(c, name = 'hip_cmult2')
104 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
105 import c_rp
106 type(c_ptr), value :: a_d, b_d, strm
107 real(c_rp) :: c
108 integer(c_int) :: n
109 end subroutine hip_cmult2
110
111 subroutine hip_cdiv(a_d, c, n, strm) &
112 bind(c, name = 'hip_cdiv')
113 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
114 import c_rp
115 type(c_ptr), value :: a_d, strm
116 real(c_rp) :: c
117 integer(c_int) :: n
118 end subroutine hip_cdiv
119
120 subroutine hip_cdiv2(a_d, b_d, c, n, strm) &
121 bind(c, name = 'hip_cdiv2')
122 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
123 import c_rp
124 type(c_ptr), value :: a_d, b_d, strm
125 real(c_rp) :: c
126 integer(c_int) :: n
127 end subroutine hip_cdiv2
128
129 subroutine hip_radd(a_d, c, n, strm) &
130 bind(c, name = 'hip_radd')
131 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
132 import c_rp
133 type(c_ptr), value :: a_d, strm
134 real(c_rp) :: c
135 integer(c_int) :: n
136 end subroutine hip_radd
137
138 subroutine hip_cadd2(a_d, b_d, c, n, strm) &
139 bind(c, name = 'hip_cadd2')
140 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
141 import c_rp
142 type(c_ptr), value :: a_d
143 type(c_ptr), value :: b_d
144 type(c_ptr), value :: strm
145 real(c_rp) :: c
146 integer(c_int) :: n
147 end subroutine hip_cadd2
148
149 subroutine hip_cfill(a_d, c, n, strm) &
150 bind(c, name = 'hip_cfill')
151 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
152 import c_rp
153 type(c_ptr), value :: a_d, strm
154 real(c_rp) :: c
155 integer(c_int) :: n
156 end subroutine hip_cfill
157
158 subroutine hip_rzero(a_d, n, strm) &
159 bind(c, name = 'hip_rzero')
160 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
161 type(c_ptr), value :: a_d, strm
162 integer(c_int) :: n
163 end subroutine hip_rzero
164
165 subroutine hip_add2(a_d, b_d, n, strm) &
166 bind(c, name = 'hip_add2')
167 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
168 import c_rp
169 type(c_ptr), value :: a_d, b_d, strm
170 integer(c_int) :: n
171 end subroutine hip_add2
172
173 subroutine hip_add4(a_d, b_d, c_d, d_d, n, strm) &
174 bind(c, name = 'hip_add4')
175 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
176 import c_rp
177 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
178 integer(c_int) :: n
179 end subroutine hip_add4
180
181 subroutine hip_add2s1(a_d, b_d, c1, n, strm) &
182 bind(c, name = 'hip_add2s1')
183 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
184 import c_rp
185 type(c_ptr), value :: a_d, b_d, strm
186 real(c_rp) :: c1
187 integer(c_int) :: n
188 end subroutine hip_add2s1
189
190 subroutine hip_add2s2(a_d, b_d, c1, n, strm) &
191 bind(c, name = 'hip_add2s2')
192 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
193 import c_rp
194 type(c_ptr), value :: a_d, b_d, strm
195 real(c_rp) :: c1
196 integer(c_int) :: n
197 end subroutine hip_add2s2
198
199 subroutine hip_addsqr2s2(a_d, b_d, c1, n, strm) &
200 bind(c, name = 'hip_addsqr2s2')
201 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
202 import c_rp
203 type(c_ptr), value :: a_d, b_d, strm
204 real(c_rp) :: c1
205 integer(c_int) :: n
206 end subroutine hip_addsqr2s2
207
208 subroutine hip_add3s2(a_d, b_d, c_d, c1, c2, n, strm) &
209 bind(c, name = 'hip_add3s2')
210 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
211 import c_rp
212 type(c_ptr), value :: a_d, b_d, c_d, strm
213 real(c_rp) :: c1, c2
214 integer(c_int) :: n
215 end subroutine hip_add3s2
216
217 subroutine hip_add4s3(a_d, b_d, c_d, d_d, c1, c2, c3, n, strm) &
218 bind(c, name = 'hip_add4s3')
219 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
220 import c_rp
221 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
222 real(c_rp) :: c1, c2, c3
223 integer(c_int) :: n
224 end subroutine hip_add4s3
225
226 subroutine hip_add5s4(a_d, b_d, c_d, d_d, e_d, c1, c2, c3, c4, n, strm) &
227 bind(c, name = 'hip_add5s4')
228 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
229 import c_rp
230 type(c_ptr), value :: a_d, b_d, c_d, d_d, e_d, strm
231 real(c_rp) :: c1, c2, c3, c4
232 integer(c_int) :: n
233 end subroutine hip_add5s4
234
235 subroutine hip_invcol1(a_d, n, strm) &
236 bind(c, name = 'hip_invcol1')
237 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
238 type(c_ptr), value :: a_d, strm
239 integer(c_int) :: n
240 end subroutine hip_invcol1
241
242 subroutine hip_invcol2(a_d, b_d, n, strm) &
243 bind(c, name = 'hip_invcol2')
244 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
245 type(c_ptr), value :: a_d, b_d, strm
246 integer(c_int) :: n
247 end subroutine hip_invcol2
248
249 subroutine hip_invcol3(a_d, b_d, c_d, n, strm) &
250 bind(c, name = 'hip_invcol3')
251 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
252 type(c_ptr), value :: a_d, b_d, c_d, strm
253 integer(c_int) :: n
254 end subroutine hip_invcol3
255
256 subroutine hip_col2(a_d, b_d, n, strm) &
257 bind(c, name = 'hip_col2')
258 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
259 type(c_ptr), value :: a_d, b_d, strm
260 integer(c_int) :: n
261 end subroutine hip_col2
262
263 subroutine hip_col3(a_d, b_d, c_d, n, strm) &
264 bind(c, name = 'hip_col3')
265 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
266 type(c_ptr), value :: a_d, b_d, c_d, strm
267 integer(c_int) :: n
268 end subroutine hip_col3
269
270 subroutine hip_subcol3(a_d, b_d, c_d, n, strm) &
271 bind(c, name = 'hip_subcol3')
272 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
273 type(c_ptr), value :: a_d, b_d, c_d, strm
274 integer(c_int) :: n
275 end subroutine hip_subcol3
276
277 subroutine hip_sub2(a_d, b_d, n, strm) &
278 bind(c, name = 'hip_sub2')
279 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
280 type(c_ptr), value :: a_d, b_d, strm
281 integer(c_int) :: n
282 end subroutine hip_sub2
283
284 subroutine hip_sub3(a_d, b_d, c_d, n, strm) &
285 bind(c, name = 'hip_sub3')
286 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
287 type(c_ptr), value :: a_d, b_d, c_d, strm
288 integer(c_int) :: n
289 end subroutine hip_sub3
290
291 subroutine hip_add3(a_d, b_d, c_d, n, strm) &
292 bind(c, name = 'hip_add3')
293 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
294 type(c_ptr), value :: a_d, b_d, c_d, strm
295 integer(c_int) :: n
296 end subroutine hip_add3
297
298 subroutine hip_addcol3(a_d, b_d, c_d, n, strm) &
299 bind(c, name = 'hip_addcol3')
300 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
301 type(c_ptr), value :: a_d, b_d, c_d, strm
302 integer(c_int) :: n
303 end subroutine hip_addcol3
304
305 subroutine hip_addcol4(a_d, b_d, c_d, d_d, n, strm) &
306 bind(c, name = 'hip_addcol4')
307 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
308 type(c_ptr), value :: a_d, b_d, c_d, d_d, strm
309 integer(c_int) :: n
310 end subroutine hip_addcol4
311
312 subroutine hip_addcol3s2(a_d, b_d, c_d, s, n, strm) &
313 bind(c, name = 'hip_addcol3s2')
314 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
315 import c_rp
316 type(c_ptr), value :: a_d, b_d, c_d, strm
317 real(c_rp) :: s
318 integer(c_int) :: n
319 end subroutine hip_addcol3s2
320
321 subroutine hip_vdot3(dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, n, strm) &
322 bind(c, name = 'hip_vdot3')
323 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
324 type(c_ptr), value :: dot_d, u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, strm
325 integer(c_int) :: n
326 end subroutine hip_vdot3
327
328 subroutine hip_vcross(u1_d, u2_d, u3_d, v1_d, v2_d, v3_d, &
329 w1_d, w2_d, w3_d, n, strm) &
330 bind(c, name = 'hip_vcross')
331 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
332
333 type(c_ptr), value :: u1_d, u2_d, u3_d
334 type(c_ptr), value :: v1_d, v2_d, v3_d
335 type(c_ptr), value :: w1_d, w2_d, w3_d
336 type(c_ptr), value :: strm
337 integer(c_int) :: n
338 end subroutine hip_vcross
339
340 real(c_rp) function hip_vlsc3(u_d, v_d, w_d, n, strm) &
341 bind(c, name = 'hip_vlsc3')
342 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
343 import c_rp
344 type(c_ptr), value :: u_d, v_d, w_d, strm
345 integer(c_int) :: n
346 end function hip_vlsc3
347
348 subroutine hip_add2s2_many(y_d, x_d_d, a_d, j, n, strm) &
349 bind(c, name = 'hip_add2s2_many')
350 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
351 import c_rp
352 type(c_ptr), value :: y_d, x_d_d, a_d, strm
353 integer(c_int) :: j, n
354 end subroutine hip_add2s2_many
355
356 real(c_rp) function hip_glsc3(a_d, b_d, c_d, n, strm) &
357 bind(c, name = 'hip_glsc3')
358 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
359 import c_rp
360 type(c_ptr), value :: a_d, b_d, c_d, strm
361 integer(c_int) :: n
362 end function hip_glsc3
363
364 subroutine hip_glsc3_many(h, w_d, v_d_d, mult_d, j, n, strm) &
365 bind(c, name = 'hip_glsc3_many')
366 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
367 import c_rp
368 type(c_ptr), value :: w_d, v_d_d, mult_d, strm
369 integer(c_int) :: j, n
370 real(c_rp) :: h(j)
371 end subroutine hip_glsc3_many
372
373 real(c_rp) function hip_glsc2(a_d, b_d, n, strm) &
374 bind(c, name = 'hip_glsc2')
375 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
376 import c_rp
377 type(c_ptr), value :: a_d, b_d, strm
378 integer(c_int) :: n
379 end function hip_glsc2
380
381 real(c_rp) function hip_glsubnorm2(a_d, b_d, n, strm) &
382 bind(c, name = 'hip_glsubnorm2')
383 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
384 import c_rp
385 type(c_ptr), value :: a_d, b_d, strm
386 integer(c_int) :: n
387 end function hip_glsubnorm2
388
389 real(c_rp) function hip_glsum(a_d, n, strm) &
390 bind(c, name = 'hip_glsum')
391 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
392 import c_rp
393 type(c_ptr), value :: a_d, strm
394 integer(c_int) :: n
395 end function hip_glsum
396
397 subroutine hip_absval(a_d, n, strm) &
398 bind(c, name = 'hip_absval')
399 use, intrinsic :: iso_c_binding, only : c_ptr, c_int
400 import c_rp
401 type(c_ptr), value :: a_d, strm
402 integer(c_int) :: n
403 end subroutine hip_absval
404 end interface
405
406 ! ========================================================================== !
407 ! Interfaces for the pointwise operations.
408
409 interface
410 subroutine hip_pwmax_vec2(a_d, b_d, n, strm) &
411 bind(c, name = 'hip_pwmax_vec2')
412 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
413 type(c_ptr), value :: a_d, b_d, strm
414 integer(c_int) :: n
415 end subroutine hip_pwmax_vec2
416
417 subroutine hip_pwmax_vec3(a_d, b_d, c_d, n, strm) &
418 bind(c, name = 'hip_pwmax_vec3')
419 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
420 type(c_ptr), value :: a_d, b_d, c_d, strm
421 integer(c_int) :: n
422 end subroutine hip_pwmax_vec3
423
424 subroutine hip_pwmax_sca2(a_d, c_d, n, strm) &
425 bind(c, name = 'hip_pwmax_sca2')
426 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
427 import c_rp
428 type(c_ptr), value :: a_d, strm
429 real(c_rp) :: c_d
430 integer(c_int) :: n
431 end subroutine hip_pwmax_sca2
432
433 subroutine hip_pwmax_sca3(a_d, b_d, c_d, n, strm) &
434 bind(c, name = 'hip_pwmax_sca3')
435 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
436 import c_rp
437 type(c_ptr), value :: a_d, b_d, strm
438 real(c_rp) :: c_d
439 integer(c_int) :: n
440 end subroutine hip_pwmax_sca3
441
442 subroutine hip_pwmin_vec2(a_d, b_d, n, strm) &
443 bind(c, name = 'hip_pwmin_vec2')
444 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
445 type(c_ptr), value :: a_d, b_d, strm
446 integer(c_int) :: n
447 end subroutine hip_pwmin_vec2
448
449 subroutine hip_pwmin_vec3(a_d, b_d, c_d, n, strm) &
450 bind(c, name = 'hip_pwmin_vec3')
451 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
452 type(c_ptr), value :: a_d, b_d, c_d, strm
453 integer(c_int) :: n
454 end subroutine hip_pwmin_vec3
455
456 subroutine hip_pwmin_sca2(a_d, c_d, n, strm) &
457 bind(c, name = 'hip_pwmin_sca2')
458 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
459 import c_rp
460 type(c_ptr), value :: a_d, strm
461 real(c_rp) :: c_d
462 integer(c_int) :: n
463 end subroutine hip_pwmin_sca2
464
465 subroutine hip_pwmin_sca3(a_d, b_d, c_d, n, strm) &
466 bind(c, name = 'hip_pwmin_sca3')
467 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
468 import c_rp
469 type(c_ptr), value :: a_d, b_d, strm
470 real(c_rp) :: c_d
471 integer(c_int) :: n
472 end subroutine hip_pwmin_sca3
473
474 end interface
475
476 ! ========================================================================== !
477 ! Interfaces for integer operations.
478
479 interface
480
481 subroutine hip_iadd(a_d, c, n, strm) &
482 bind(c, name = 'hip_iadd')
483 use, intrinsic :: iso_c_binding, only : c_int, c_ptr
484 import c_rp
485 type(c_ptr), value :: a_d, strm
486 integer(c_int) :: c
487 integer(c_int) :: n
488 end subroutine hip_iadd
489
490 end interface
491end module hip_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