forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_SIMD.6.f90
More file actions
54 lines (47 loc) · 978 Bytes
/
Example_SIMD.6.f90
File metadata and controls
54 lines (47 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
! @@name: SIMD.6f
! @@type: F-free
! @@compilable: yes
! @@linkable: no
! @@expect: success
function foo(p) result(r)
!$omp declare simd(foo) notinbranch
implicit none
integer :: p, r
p = p + 10
r = p
end function foo
function myaddint(a, b, n) result(r)
implicit none
integer :: a(*), b(*), n, r
integer :: i
integer, external :: foo
!$omp simd
do i=1, n
a(i) = foo(b(i)) ! foo is not called under a condition
end do
r = a(n)
end function myaddint
function goo(p) result(r)
!$omp declare simd(goo) inbranch
implicit none
real :: p, r
p = p + 18.5
r = p
end function goo
function myaddfloat(x, y, n) result(r)
implicit none
real :: x(*), y(*), r
integer :: n
integer :: i
real, external :: goo
!$omp simd
do i=1, n
if (x(i) > y(i)) then
x(i) = goo(y(i))
! goo is called under the condition (or within a branch)
else
x(i) = y(i)
endif
end do
r = x(n)
end function myaddfloat