|
1 | 1 | #!/usr/bin/env python |
| 2 | +from __future__ import print_function |
2 | 3 | import argparse, isl, os |
3 | 4 | import json |
4 | 5 |
|
| 6 | + |
5 | 7 | def printDomain(scop): |
| 8 | + domain = isl.USet("{}") |
6 | 9 |
|
7 | | - domain = isl.USet('{}') |
| 10 | + for statement in scop["statements"]: |
| 11 | + domain = domain.union(isl.USet(statement["domain"])) |
8 | 12 |
|
9 | | - for statement in scop['statements']: |
10 | | - domain = domain.union(isl.USet(statement['domain'])) |
| 13 | + print("D :=", end=" ") |
| 14 | + print(str(domain) + ";") |
11 | 15 |
|
12 | | - print "D :=", |
13 | | - print str(domain) + ";" |
14 | 16 |
|
15 | 17 | def printAccesses(scop): |
| 18 | + read = isl.UMap("{}") |
16 | 19 |
|
17 | | - read = isl.UMap('{}') |
| 20 | + for statement in scop["statements"]: |
| 21 | + for access in statement["accesses"]: |
| 22 | + if access["kind"] == "read": |
| 23 | + read = read.union(isl.UMap(access["relation"])) |
18 | 24 |
|
19 | | - for statement in scop['statements']: |
20 | | - for access in statement['accesses']: |
21 | | - if access['kind'] == 'read': |
22 | | - read = read.union(isl.UMap(access['relation'])) |
| 25 | + print("R :=", end=" ") |
| 26 | + print(str(read) + ";") |
23 | 27 |
|
24 | | - print "R :=", |
25 | | - print str(read) + ";" |
| 28 | + write = isl.UMap("{}") |
26 | 29 |
|
27 | | - write = isl.UMap('{}') |
| 30 | + for statement in scop["statements"]: |
| 31 | + for access in statement["accesses"]: |
| 32 | + if access["kind"] == "write": |
| 33 | + write = write.union(isl.UMap(access["relation"])) |
28 | 34 |
|
29 | | - for statement in scop['statements']: |
30 | | - for access in statement['accesses']: |
31 | | - if access['kind'] == 'write': |
32 | | - write = write.union(isl.UMap(access['relation'])) |
| 35 | + print("W :=", end=" ") |
| 36 | + print(str(write) + ";") |
33 | 37 |
|
34 | | - print "W :=", |
35 | | - print str(write) + ";" |
36 | 38 |
|
37 | 39 | def printSchedule(scop): |
| 40 | + schedule = isl.UMap("{}") |
38 | 41 |
|
39 | | - schedule = isl.UMap('{}') |
| 42 | + for statement in scop["statements"]: |
| 43 | + schedule = schedule.union(isl.UMap(statement["schedule"])) |
40 | 44 |
|
41 | | - for statement in scop['statements']: |
42 | | - schedule = schedule.union(isl.UMap(statement['schedule'])) |
| 45 | + print("S :=", end=" ") |
| 46 | + print(str(schedule) + ";") |
43 | 47 |
|
44 | | - print "S :=", |
45 | | - print str(schedule) + ";" |
46 | 48 |
|
47 | 49 | def __main__(): |
48 | | - description = 'Translate JSCoP into iscc input' |
49 | | - parser = argparse.ArgumentParser(description) |
50 | | - parser.add_argument('inputFile', metavar='N', type=file, |
51 | | - help='The JSCoP file') |
| 50 | + description = "Translate JSCoP into iscc input" |
| 51 | + parser = argparse.ArgumentParser(description) |
| 52 | + parser.add_argument("inputFile", metavar="N", type=file, help="The JSCoP file") |
52 | 53 |
|
53 | | - args = parser.parse_args() |
54 | | - inputFile = args.inputFile |
55 | | - scop = json.load(inputFile) |
| 54 | + args = parser.parse_args() |
| 55 | + inputFile = args.inputFile |
| 56 | + scop = json.load(inputFile) |
56 | 57 |
|
57 | | - printDomain(scop) |
58 | | - printAccesses(scop) |
59 | | - printSchedule(scop) |
| 58 | + printDomain(scop) |
| 59 | + printAccesses(scop) |
| 60 | + printSchedule(scop) |
60 | 61 |
|
61 | | - print 'R := R * D;' |
62 | | - print 'W := W * D;' |
63 | | - print 'Dep := (last W before R under S)[0];' |
64 | | - print 'schedule D respecting Dep minimizing Dep;' |
| 62 | + print("R := R * D;") |
| 63 | + print("W := W * D;") |
| 64 | + print("Dep := (last W before R under S)[0];") |
| 65 | + print("schedule D respecting Dep minimizing Dep;") |
65 | 66 |
|
66 | 67 |
|
67 | 68 | __main__() |
68 | | - |
0 commit comments