Skip to content

Commit 5bb5b23

Browse files
committed
ruff format
1 parent 53e8159 commit 5bb5b23

File tree

2 files changed

+67
-66
lines changed

2 files changed

+67
-66
lines changed

polly/utils/jscop2cloog.py

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,34 @@
22
import argparse, os
33
import json
44

5+
56
def getDomains(scop):
6-
statements = scop['statements'];
7-
numStatements = len(statements)
7+
statements = scop["statements"]
8+
numStatements = len(statements)
89

9-
output = "%s\n\n" % str(numStatements)
10+
output = "%s\n\n" % str(numStatements)
1011

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

16+
return output
1517

16-
return output
1718

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

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

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

27-
return output
2830

2931
def writeCloog(scop):
30-
template = """
32+
template = """
3133
# ---------------------- CONTEXT ----------------------
3234
c # language is C
3335
@@ -47,22 +49,22 @@ def writeCloog(scop):
4749
0 # We do not want to set manually the schedule dimension names
4850
"""
4951

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

5558
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')
59+
description = "Translate JSCoP into iscc input"
60+
parser = argparse.ArgumentParser(description)
61+
parser.add_argument("inputFile", metavar="N", type=file, help="The JSCoP file")
6062

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

65-
writeCloog(scop)
67+
writeCloog(scop)
6668

67-
__main__()
6869

70+
__main__()

polly/utils/pyscop/jscop2iscc.py

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,66 @@
44
import argparse, isl, os
55
import json
66

7+
78
def printDomain(scop):
9+
domain = isl.USet("{}")
810

9-
domain = isl.USet('{}')
11+
for statement in scop["statements"]:
12+
domain = domain.union(isl.USet(statement["domain"]))
1013

11-
for statement in scop['statements']:
12-
domain = domain.union(isl.USet(statement['domain']))
14+
print("D :=", end=" ")
15+
print(str(domain) + ";")
1316

14-
print("D :=", end=" ")
15-
print(str(domain) + ";")
1617

1718
def printAccesses(scop):
19+
read = isl.UMap("{}")
1820

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

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

26-
print("R :=", end=" ")
27-
print(str(read) + ";")
29+
write = isl.UMap("{}")
2830

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

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

36-
print("W :=", end=" ")
37-
print(str(write) + ";")
3839

3940
def printSchedule(scop):
41+
schedule = isl.UMap("{}")
4042

41-
schedule = isl.UMap('{}')
43+
for statement in scop["statements"]:
44+
schedule = schedule.union(isl.UMap(statement["schedule"]))
4245

43-
for statement in scop['statements']:
44-
schedule = schedule.union(isl.UMap(statement['schedule']))
46+
print("S :=", end=" ")
47+
print(str(schedule) + ";")
4548

46-
print("S :=", end=" ")
47-
print(str(schedule) + ";")
4849

4950
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")
5454

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

59-
printDomain(scop)
60-
printAccesses(scop)
61-
printSchedule(scop)
59+
printDomain(scop)
60+
printAccesses(scop)
61+
printSchedule(scop)
6262

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

6868

6969
__main__()
70-

0 commit comments

Comments
 (0)