Skip to content

Commit 5c00c6f

Browse files
committed
[polly] python futurize --stage1 --write
1 parent 5d1c596 commit 5c00c6f

File tree

2 files changed

+69
-66
lines changed

2 files changed

+69
-66
lines changed

polly/utils/jscop2cloog.py

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import argparse, os
34
import json
45

6+
57
def getDomains(scop):
6-
statements = scop['statements'];
7-
numStatements = len(statements)
8+
statements = scop["statements"]
9+
numStatements = len(statements)
810

9-
output = "%s\n\n" % str(numStatements)
11+
output = "%s\n\n" % str(numStatements)
1012

11-
for statement in scop['statements']:
12-
output += "%s\n\n" % statement['domain']
13-
output += "0 0 0 # for future options\n\n"
13+
for statement in scop["statements"]:
14+
output += "%s\n\n" % statement["domain"]
15+
output += "0 0 0 # for future options\n\n"
1416

17+
return output
1518

16-
return output
1719

1820
def getSchedules(scop):
19-
statements = scop['statements'];
20-
numStatements = len(statements)
21+
statements = scop["statements"]
22+
numStatements = len(statements)
23+
24+
output = "%s\n\n" % str(numStatements)
2125

22-
output = "%s\n\n" % str(numStatements)
26+
for statement in scop["statements"]:
27+
output += "%s\n\n" % statement["schedule"]
2328

24-
for statement in scop['statements']:
25-
output += "%s\n\n" % statement['schedule']
29+
return output
2630

27-
return output
2831

2932
def writeCloog(scop):
30-
template = """
33+
template = """
3134
# ---------------------- CONTEXT ----------------------
3235
c # language is C
3336
@@ -47,22 +50,22 @@ def writeCloog(scop):
4750
0 # We do not want to set manually the schedule dimension names
4851
"""
4952

50-
context = scop['context']
51-
domains = getDomains(scop)
52-
schedules = getSchedules(scop)
53-
print template % (context, domains, schedules)
53+
context = scop["context"]
54+
domains = getDomains(scop)
55+
schedules = getSchedules(scop)
56+
print(template % (context, domains, schedules))
57+
5458

5559
def __main__():
56-
description = 'Translate JSCoP into iscc input'
57-
parser = argparse.ArgumentParser(description)
58-
parser.add_argument('inputFile', metavar='N', type=file,
59-
help='The JSCoP file')
60+
description = "Translate JSCoP into iscc input"
61+
parser = argparse.ArgumentParser(description)
62+
parser.add_argument("inputFile", metavar="N", type=file, help="The JSCoP file")
6063

61-
args = parser.parse_args()
62-
inputFile = args.inputFile
63-
scop = json.load(inputFile)
64+
args = parser.parse_args()
65+
inputFile = args.inputFile
66+
scop = json.load(inputFile)
6467

65-
writeCloog(scop)
68+
writeCloog(scop)
6669

67-
__main__()
6870

71+
__main__()

polly/utils/pyscop/jscop2iscc.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,68 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import argparse, isl, os
34
import json
45

6+
57
def printDomain(scop):
8+
domain = isl.USet("{}")
69

7-
domain = isl.USet('{}')
10+
for statement in scop["statements"]:
11+
domain = domain.union(isl.USet(statement["domain"]))
812

9-
for statement in scop['statements']:
10-
domain = domain.union(isl.USet(statement['domain']))
13+
print("D :=", end=" ")
14+
print(str(domain) + ";")
1115

12-
print "D :=",
13-
print str(domain) + ";"
1416

1517
def printAccesses(scop):
18+
read = isl.UMap("{}")
1619

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"]))
1824

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) + ";")
2327

24-
print "R :=",
25-
print str(read) + ";"
28+
write = isl.UMap("{}")
2629

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"]))
2834

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) + ";")
3337

34-
print "W :=",
35-
print str(write) + ";"
3638

3739
def printSchedule(scop):
40+
schedule = isl.UMap("{}")
3841

39-
schedule = isl.UMap('{}')
42+
for statement in scop["statements"]:
43+
schedule = schedule.union(isl.UMap(statement["schedule"]))
4044

41-
for statement in scop['statements']:
42-
schedule = schedule.union(isl.UMap(statement['schedule']))
45+
print("S :=", end=" ")
46+
print(str(schedule) + ";")
4347

44-
print "S :=",
45-
print str(schedule) + ";"
4648

4749
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")
5253

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)
5657

57-
printDomain(scop)
58-
printAccesses(scop)
59-
printSchedule(scop)
58+
printDomain(scop)
59+
printAccesses(scop)
60+
printSchedule(scop)
6061

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;")
6566

6667

6768
__main__()
68-

0 commit comments

Comments
 (0)