summaryrefslogtreecommitdiff
path: root/omegalib/examples/hpf.out
blob: 3ee21e7aeaa66b9aa33c69f7d0dfa2b014a375f5 (plain)
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
55
56
57
58
59
>>> # Example taken from
>>> # @INPROCEEDINGS{delft,
>>> # author = {Corinne Ancourt and Fabien Coelho and Fran\c{c}ois Irigoin 
>>> #           and Ronan Keryell},
>>> # title = {A Linear Algebra Framework for Static HPF Code Distribution},
>>> #          booktitle = {Proceedings of the Fourth International Workshop
>>> #          on Compilers for Parallel Computers},
>>> # year = 1993,
>>> # month = dec,
>>> # pages = {117-132},
>>> # publisher = {Delft University of Technology}
>>> # }
>>> # 
>>> # Generate local code for this HPF code fragment
>>> # !HPF$ template T(0:150,0:150)
>>> # !HPF$ align Y(I,J) with T(3*I,3*J)
>>> A := { [i,j] -> [3i,3j] };
>>> # !HPF$ processors P(0:3, 0:3)
>>> # !HPF$ distribute
>>> # !HPF$  T(cyclic(4), cyclic(4)) onto P
>>> D := { [t1,t2] -> [p1,p2,c1,c2,o1,o2] :
>>>      t1 = 16c1+4p1+o1 
>>>      && t2 = 16c2+4p2+o2 
>>>      && 0 <= p1,p2 <= 3
>>>      && 0 <= o1,o2 <= 3 };
>>> #
>>> #      do I = 0, 14
>>> #         Y(I,I) = 1.0
>>> #      enddo
>>> #
>>> I := { [i] : 0 <= i <= 14 };
>>> Y := { [i] -> [i,i] };
>>> R := D(A(Y(I)));
>>> R;
{[p1,p1,c1,c1,o1,o1]: exists ( alpha : p1+o1+c1 = 3alpha && 0 <= p1 <= 3, -c1+4 && 0 <= o1 <= 3 && 0 <= c1 <= 2)}
>>> 
>>> symbolic P1,P2;
>>> selectLocal := {[P1,P2,c1,c2,o1,o2] -> [c1,c2,o1,o2]};
>>> # We want to iteration the chunk and offset values
>>> # of Y touched by this statement.
>>> # the code given in the above paper is:
>>> # do u3 = 0, 2
>>> #   do u4 = 0, 2
>>> #    do u5 = max(max(0,intDiv(2+4*p1+16*u3,3)),intDiv(2+4*p2+16*u4),3),
>>> #            min(min(14,intDiv(3+4*p1+16*u3,3)),intDiv(3+4*p2+16*u4,3))
>>> #      u6 = intDiv(3*u5-4*p1-16*u3,3)
>>> #        s1[u3,u4,u5,u6]
>>> #
>>> # We generate:
>>> codegen selectLocal(R);
if (P1 == P2 && P1 >= 0 && P1 <= 3) {
  for(t1 = 0; t1 <= min(-P1+4,2); t1++) {
    for(t3 = intMod(-P1-t1,3); t3 <= 3; t3 += 3) {
      s0(t1,t1,t3,t3);
    }
  }
}

>>>