[polly] polly: Fix files that contain Python 3 SyntaxErrors (PR #124424)
Christian Clauss via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 14:55:26 PST 2025
https://github.com/cclauss updated https://github.com/llvm/llvm-project/pull/124424
>From 53e8159b97ee0785a1a756bc4d07097fc641e7be Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Sat, 25 Jan 2025 20:27:04 +0100
Subject: [PATCH 1/2] polly: Fix Python 3 SyntaxErrors
---
polly/utils/jscop2cloog.py | 2 +-
polly/utils/pyscop/jscop2iscc.py | 26 ++++++++++++++------------
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py
index 29383974f26780..1d8a31047d1164 100755
--- a/polly/utils/jscop2cloog.py
+++ b/polly/utils/jscop2cloog.py
@@ -50,7 +50,7 @@ def writeCloog(scop):
context = scop['context']
domains = getDomains(scop)
schedules = getSchedules(scop)
- print template % (context, domains, schedules)
+ print(template % (context, domains, schedules))
def __main__():
description = 'Translate JSCoP into iscc input'
diff --git a/polly/utils/pyscop/jscop2iscc.py b/polly/utils/pyscop/jscop2iscc.py
index 42f4cc180f1fb9..7ffccaf2deb1e4 100755
--- a/polly/utils/pyscop/jscop2iscc.py
+++ b/polly/utils/pyscop/jscop2iscc.py
@@ -1,4 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import argparse, isl, os
import json
@@ -9,8 +11,8 @@ def printDomain(scop):
for statement in scop['statements']:
domain = domain.union(isl.USet(statement['domain']))
- print "D :=",
- print str(domain) + ";"
+ print("D :=", end=" ")
+ print(str(domain) + ";")
def printAccesses(scop):
@@ -21,8 +23,8 @@ def printAccesses(scop):
if access['kind'] == 'read':
read = read.union(isl.UMap(access['relation']))
- print "R :=",
- print str(read) + ";"
+ print("R :=", end=" ")
+ print(str(read) + ";")
write = isl.UMap('{}')
@@ -31,8 +33,8 @@ def printAccesses(scop):
if access['kind'] == 'write':
write = write.union(isl.UMap(access['relation']))
- print "W :=",
- print str(write) + ";"
+ print("W :=", end=" ")
+ print(str(write) + ";")
def printSchedule(scop):
@@ -41,8 +43,8 @@ def printSchedule(scop):
for statement in scop['statements']:
schedule = schedule.union(isl.UMap(statement['schedule']))
- print "S :=",
- print str(schedule) + ";"
+ print("S :=", end=" ")
+ print(str(schedule) + ";")
def __main__():
description = 'Translate JSCoP into iscc input'
@@ -58,10 +60,10 @@ def __main__():
printAccesses(scop)
printSchedule(scop)
- print 'R := R * D;'
- print 'W := W * D;'
- print 'Dep := (last W before R under S)[0];'
- print 'schedule D respecting Dep minimizing Dep;'
+ print('R := R * D;')
+ print('W := W * D;')
+ print('Dep := (last W before R under S)[0];')
+ print('schedule D respecting Dep minimizing Dep;')
__main__()
>From 5bb5b23b5ff5447cef9c0e28326f1967db7c502a Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Mon, 27 Jan 2025 23:55:11 +0100
Subject: [PATCH 2/2] ruff format
---
polly/utils/jscop2cloog.py | 56 ++++++++++++-----------
polly/utils/pyscop/jscop2iscc.py | 77 ++++++++++++++++----------------
2 files changed, 67 insertions(+), 66 deletions(-)
diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py
index 1d8a31047d1164..2dfd277fb97196 100755
--- a/polly/utils/jscop2cloog.py
+++ b/polly/utils/jscop2cloog.py
@@ -2,32 +2,34 @@
import argparse, os
import json
+
def getDomains(scop):
- statements = scop['statements'];
- numStatements = len(statements)
+ statements = scop["statements"]
+ numStatements = len(statements)
- output = "%s\n\n" % str(numStatements)
+ output = "%s\n\n" % str(numStatements)
- for statement in scop['statements']:
- output += "%s\n\n" % statement['domain']
- output += "0 0 0 # for future options\n\n"
+ for statement in scop["statements"]:
+ output += "%s\n\n" % statement["domain"]
+ output += "0 0 0 # for future options\n\n"
+ return output
- return output
def getSchedules(scop):
- statements = scop['statements'];
- numStatements = len(statements)
+ statements = scop["statements"]
+ numStatements = len(statements)
+
+ output = "%s\n\n" % str(numStatements)
- output = "%s\n\n" % str(numStatements)
+ for statement in scop["statements"]:
+ output += "%s\n\n" % statement["schedule"]
- for statement in scop['statements']:
- output += "%s\n\n" % statement['schedule']
+ return output
- return output
def writeCloog(scop):
- template = """
+ template = """
# ---------------------- CONTEXT ----------------------
c # language is C
@@ -47,22 +49,22 @@ def writeCloog(scop):
0 # We do not want to set manually the schedule dimension names
"""
- context = scop['context']
- domains = getDomains(scop)
- schedules = getSchedules(scop)
- print(template % (context, domains, schedules))
+ context = scop["context"]
+ domains = getDomains(scop)
+ schedules = getSchedules(scop)
+ print(template % (context, domains, schedules))
+
def __main__():
- description = 'Translate JSCoP into iscc input'
- parser = argparse.ArgumentParser(description)
- parser.add_argument('inputFile', metavar='N', type=file,
- help='The JSCoP file')
+ description = "Translate JSCoP into iscc input"
+ parser = argparse.ArgumentParser(description)
+ parser.add_argument("inputFile", metavar="N", type=file, help="The JSCoP file")
- args = parser.parse_args()
- inputFile = args.inputFile
- scop = json.load(inputFile)
+ args = parser.parse_args()
+ inputFile = args.inputFile
+ scop = json.load(inputFile)
- writeCloog(scop)
+ writeCloog(scop)
-__main__()
+__main__()
diff --git a/polly/utils/pyscop/jscop2iscc.py b/polly/utils/pyscop/jscop2iscc.py
index 7ffccaf2deb1e4..02b4abd9cf4b40 100755
--- a/polly/utils/pyscop/jscop2iscc.py
+++ b/polly/utils/pyscop/jscop2iscc.py
@@ -4,67 +4,66 @@
import argparse, isl, os
import json
+
def printDomain(scop):
+ domain = isl.USet("{}")
- domain = isl.USet('{}')
+ for statement in scop["statements"]:
+ domain = domain.union(isl.USet(statement["domain"]))
- for statement in scop['statements']:
- domain = domain.union(isl.USet(statement['domain']))
+ print("D :=", end=" ")
+ print(str(domain) + ";")
- print("D :=", end=" ")
- print(str(domain) + ";")
def printAccesses(scop):
+ read = isl.UMap("{}")
- read = isl.UMap('{}')
+ for statement in scop["statements"]:
+ for access in statement["accesses"]:
+ if access["kind"] == "read":
+ read = read.union(isl.UMap(access["relation"]))
- for statement in scop['statements']:
- for access in statement['accesses']:
- if access['kind'] == 'read':
- read = read.union(isl.UMap(access['relation']))
+ print("R :=", end=" ")
+ print(str(read) + ";")
- print("R :=", end=" ")
- print(str(read) + ";")
+ write = isl.UMap("{}")
- write = isl.UMap('{}')
+ for statement in scop["statements"]:
+ for access in statement["accesses"]:
+ if access["kind"] == "write":
+ write = write.union(isl.UMap(access["relation"]))
- for statement in scop['statements']:
- for access in statement['accesses']:
- if access['kind'] == 'write':
- write = write.union(isl.UMap(access['relation']))
+ print("W :=", end=" ")
+ print(str(write) + ";")
- print("W :=", end=" ")
- print(str(write) + ";")
def printSchedule(scop):
+ schedule = isl.UMap("{}")
- schedule = isl.UMap('{}')
+ for statement in scop["statements"]:
+ schedule = schedule.union(isl.UMap(statement["schedule"]))
- for statement in scop['statements']:
- schedule = schedule.union(isl.UMap(statement['schedule']))
+ print("S :=", end=" ")
+ print(str(schedule) + ";")
- print("S :=", end=" ")
- print(str(schedule) + ";")
def __main__():
- description = 'Translate JSCoP into iscc input'
- parser = argparse.ArgumentParser(description)
- parser.add_argument('inputFile', metavar='N', type=file,
- help='The JSCoP file')
+ description = "Translate JSCoP into iscc input"
+ parser = argparse.ArgumentParser(description)
+ parser.add_argument("inputFile", metavar="N", type=file, help="The JSCoP file")
- args = parser.parse_args()
- inputFile = args.inputFile
- scop = json.load(inputFile)
+ args = parser.parse_args()
+ inputFile = args.inputFile
+ scop = json.load(inputFile)
- printDomain(scop)
- printAccesses(scop)
- printSchedule(scop)
+ printDomain(scop)
+ printAccesses(scop)
+ printSchedule(scop)
- print('R := R * D;')
- print('W := W * D;')
- print('Dep := (last W before R under S)[0];')
- print('schedule D respecting Dep minimizing Dep;')
+ print("R := R * D;")
+ print("W := W * D;")
+ print("Dep := (last W before R under S)[0];")
+ print("schedule D respecting Dep minimizing Dep;")
__main__()
-
More information about the llvm-commits
mailing list