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