The interchange of two loops can be obtained with a scattering function as follows:

# language: C
c

# parameters: {n | n >= 0} and {m | m >= 0}
2 4
#  n  m  1
1  1  0  0
1  0  1  0
1
n m

1 # Number of statements:

1
# {i | 0 <= i <= n}
# {j | 0 <= j <= m}
4 6
#  i  j  n  m  1
1  1  0  0  0  0
1 -1  0  1  0  0
1  0  1  0  0  0
1  0 -1  0  1  0

0  0  0
1
i j

1 # Scattering functions

2 8
# s0 s1  i  j  n  m  1
0  0  1 -1  0  0  0  0
0  1  0  0 -1  0  0  0

1
s0 s1

The output of CLooG is like this:

for (s0=0;s0<=m;s0++) {
  for (s1=0;s1<=n;s1++) {
    S1(i = s1,j = s0) ;
  }
}

None: Graphite/Interchange (last edited 2009-02-17 23:43:48 by 163)