Debian Codegraph @

loki/tests/sources/data_dependency_detection/loop_carried_dependencies.f90

raw symbols SCIP
1 subroutine SimpleDependency(data, n)
2 implicit none
3 integer, intent(in) :: n
4 real(8), dimension(n) :: data
5 integer :: i
6
7 ! Loop with a simple loop-carried dependency
8 do i = 1, n
9 data(i) = data(i) + data(i-1)
10 end do
11
12 end subroutine SimpleDependency
13
14
15 subroutine NestedDependency(data, n)
16 implicit none
17 integer, intent(in) :: n
18 real(8), dimension(n) :: data
19 integer :: i, j
20
21 ! Nested loop with a loop-carried dependency
22 do i = 2, n
23 do j = 1, i-1
24 data(i) = data(i) + data(j)
25 end do
26 end do
27
28 end subroutine NestedDependency
29
30
31 subroutine ConditionalDependency(data, n)
32 implicit none
33 integer, intent(in) :: n
34 real(8), dimension(n) :: data
35 integer :: i
36
37 ! Loop with a conditional loop-carried dependency
38 do i = 2, n
39 if (data(i-1) > 0.0) then
40 data(i) = data(i) + data(i-1)
41 endif
42 end do
43
44 end subroutine ConditionalDependency
45
46 subroutine NoDependency(data)
47 implicit none
48 real(8), dimension(20) :: data
49 integer :: i
50
51 do i = 1, 10, 1
52 data(2*i) = 10;
53 end do
54
55 do i = 1, 5, 1
56 data(2*i + 1) = 20;
57 end do
58 end subroutine NoDependency