forked from OpenMP/Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample_SIMD.8.f90
More file actions
54 lines (44 loc) · 873 Bytes
/
Example_SIMD.8.f90
File metadata and controls
54 lines (44 loc) · 873 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.8f
! @@type: F-free
! @@compilable: yes
! @@linkable: yes
! @@expect: success
module work
integer :: P(1000)
real :: A(1000)
contains
function do_work(arr) result(pri)
implicit none
real, dimension(*) :: arr
real :: pri
integer :: i, j
!$omp simd private(j) lastprivate(pri)
do i = 1, 999
j = P(i)
pri = 0.5
if (mod(j-1, 2) == 0) then
pri = A(j+1) + arr(i)
endif
A(j) = pri * 1.5
pri = pri + A(j)
end do
end function do_work
end module work
program simd_8f
use work
implicit none
real :: pri, arr(1000)
integer :: i
do i = 1, 1000
P(i) = i
A(i) = (i-1) * 1.5
arr(i) = (i-1) * 1.8
end do
pri = do_work(arr)
if (pri == 8237.25) then
print 2, "passed", pri
else
print 2, "failed", pri
endif
2 format(a, ": result pri = ", f7.2, " (8237.25)")
end program