[llvm] [openmp] [polly] Fix four Python files that contain SyntaxErrors (PR #123940)

Christian Clauss via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 25 11:32:44 PST 2025


https://github.com/cclauss updated https://github.com/llvm/llvm-project/pull/123940

>From e92a0697aedd148ff8f1a86ccfcdc8877f51ad75 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Wed, 22 Jan 2025 14:05:20 +0100
Subject: [PATCH 1/4] GitHub Actions: Lint Python code for just for
 SyntaxErrors

---
 .github/workflows/lint.yml | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
 create mode 100644 .github/workflows/lint.yml

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
new file mode 100644
index 00000000000000..9364d6ea369ea0
--- /dev/null
+++ b/.github/workflows/lint.yml
@@ -0,0 +1,15 @@
+name: lint
+
+on: [push, pull_request]
+
+permissions:
+  contents: read
+
+jobs:
+  lint_python:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout at v4
+      - uses: astral-sh/ruff-action at v3
+        with:  # Ignore all ruff rules except Python Syntax Errors
+          args: "check --ignore=ALL"

>From 377269d356077caf25dc44860884faf9b65af50b Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Wed, 22 Jan 2025 14:33:29 +0100
Subject: [PATCH 2/4] print() is a function in Python 3

---
 openmp/runtime/tools/summarizeStats.py        |  8 +++----
 .../External/isl/imath/tools/findthreshold.py |  6 ++---
 polly/utils/jscop2cloog.py                    |  2 +-
 polly/utils/pyscop/jscop2iscc.py              | 24 +++++++++----------
 4 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/openmp/runtime/tools/summarizeStats.py b/openmp/runtime/tools/summarizeStats.py
index 7daed2e1cd5cc0..a933ea557a98bb 100644
--- a/openmp/runtime/tools/summarizeStats.py
+++ b/openmp/runtime/tools/summarizeStats.py
@@ -37,7 +37,7 @@ def draw_circle_frame(self, x0, y0, r):
 
     frame_dict = {'polygon': draw_poly_frame, 'circle': draw_circle_frame}
     if frame not in frame_dict:
-        raise ValueError, 'unknown value for `frame`: %s' % frame
+        raise ValueError('unknown value for `frame`: %s' % frame)
 
     class RadarAxes(PolarAxes):
         """
@@ -143,7 +143,7 @@ def readFile(fname):
             res["counters"] = readCounters(f)
             return res
     except (OSError, IOError):
-        print "Cannot open " + fname
+        print("Cannot open " + fname)
         return None
 
 def usefulValues(l):
@@ -235,7 +235,7 @@ def compPie(data):
             compKeys[key] = data[key]
         else:
             nonCompKeys[key] = data[key]
-    print "comp keys:", compKeys, "\n\n non comp keys:", nonCompKeys
+    print("comp keys:", compKeys, "\n\n non comp keys:", nonCompKeys)
     return [compKeys, nonCompKeys]
 
 def drawMainPie(data, filebase, colors):
@@ -301,7 +301,7 @@ def main():
                 """radar Charts finish here"""
                 plt.savefig(filebase+"_"+s+"_"+chartType, bbox_inches='tight')
             elif s == 'timers':
-                print "overheads in "+filebase
+                print("overheads in "+filebase)
                 numThreads = tmp[s]['SampleCount']['Total_OMP_parallel']
                 for key in data.keys():
                     if key[0:5] == 'Total':
diff --git a/polly/lib/External/isl/imath/tools/findthreshold.py b/polly/lib/External/isl/imath/tools/findthreshold.py
index fbb325e1da916a..0971c862f987e5 100644
--- a/polly/lib/External/isl/imath/tools/findthreshold.py
+++ b/polly/lib/External/isl/imath/tools/findthreshold.py
@@ -86,9 +86,9 @@ def compute_stats():
     stats = compute_stats()
     stats.sort(key=lambda s: s[3] / s[2])
     for prec, thresh, trec, tnorm in stats:
-        print "%d\t%d\t%.3f\t%.3f\t%.4f" % (prec, thresh, trec, tnorm,
-                                            tnorm / trec)
+        print("%d\t%d\t%.3f\t%.3f\t%.4f" % (prec, thresh, trec, tnorm,
+                                            tnorm / trec))
 
-    print
+    print()
 
 # Here there be dragons
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..2ab27538d8632b 100755
--- a/polly/utils/pyscop/jscop2iscc.py
+++ b/polly/utils/pyscop/jscop2iscc.py
@@ -9,8 +9,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 +21,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 +31,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 +41,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 +58,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 05bec7f5446b8070fe916d8a22d27d50d695b8e0 Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Thu, 23 Jan 2025 18:00:55 +0100
Subject: [PATCH 3/4] Remove the GitHub Action but leave the Python changes

---
 .github/workflows/lint.yml | 15 ---------------
 1 file changed, 15 deletions(-)
 delete mode 100644 .github/workflows/lint.yml

diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
deleted file mode 100644
index 9364d6ea369ea0..00000000000000
--- a/.github/workflows/lint.yml
+++ /dev/null
@@ -1,15 +0,0 @@
-name: lint
-
-on: [push, pull_request]
-
-permissions:
-  contents: read
-
-jobs:
-  lint_python:
-    runs-on: ubuntu-latest
-    steps:
-      - uses: actions/checkout at v4
-      - uses: astral-sh/ruff-action at v3
-        with:  # Ignore all ruff rules except Python Syntax Errors
-          args: "check --ignore=ALL"

>From 0d7037e131fc92a507b9549008cc0f37b669a94f Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Sat, 25 Jan 2025 20:32:06 +0100
Subject: [PATCH 4/4] Move the polly fixes to a separate pull request

---
 .../External/isl/imath/tools/findthreshold.py |  6 ++---
 polly/utils/jscop2cloog.py                    |  2 +-
 polly/utils/pyscop/jscop2iscc.py              | 24 +++++++++----------
 3 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/polly/lib/External/isl/imath/tools/findthreshold.py b/polly/lib/External/isl/imath/tools/findthreshold.py
index 0971c862f987e5..fbb325e1da916a 100644
--- a/polly/lib/External/isl/imath/tools/findthreshold.py
+++ b/polly/lib/External/isl/imath/tools/findthreshold.py
@@ -86,9 +86,9 @@ def compute_stats():
     stats = compute_stats()
     stats.sort(key=lambda s: s[3] / s[2])
     for prec, thresh, trec, tnorm in stats:
-        print("%d\t%d\t%.3f\t%.3f\t%.4f" % (prec, thresh, trec, tnorm,
-                                            tnorm / trec))
+        print "%d\t%d\t%.3f\t%.3f\t%.4f" % (prec, thresh, trec, tnorm,
+                                            tnorm / trec)
 
-    print()
+    print
 
 # Here there be dragons
diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py
index 1d8a31047d1164..29383974f26780 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 2ab27538d8632b..42f4cc180f1fb9 100755
--- a/polly/utils/pyscop/jscop2iscc.py
+++ b/polly/utils/pyscop/jscop2iscc.py
@@ -9,8 +9,8 @@ def printDomain(scop):
   for statement in scop['statements']:
     domain = domain.union(isl.USet(statement['domain']))
 
-  print("D :=", end=" ")
-  print(str(domain) + ";")
+  print "D :=",
+  print str(domain) + ";"
 
 def printAccesses(scop):
 
@@ -21,8 +21,8 @@ def printAccesses(scop):
       if access['kind'] == 'read':
         read = read.union(isl.UMap(access['relation']))
 
-  print("R :=", end=" ")
-  print(str(read) + ";")
+  print "R :=",
+  print str(read) + ";"
 
   write = isl.UMap('{}')
 
@@ -31,8 +31,8 @@ def printAccesses(scop):
       if access['kind'] == 'write':
         write = write.union(isl.UMap(access['relation']))
 
-  print("W :=", end=" ")
-  print(str(write) + ";")
+  print "W :=",
+  print str(write) + ";"
 
 def printSchedule(scop):
 
@@ -41,8 +41,8 @@ def printSchedule(scop):
   for statement in scop['statements']:
     schedule = schedule.union(isl.UMap(statement['schedule']))
 
-  print("S :=", end=" ")
-  print(str(schedule) + ";")
+  print "S :=",
+  print str(schedule) + ";"
 
 def __main__():
   description = 'Translate JSCoP into iscc input'
@@ -58,10 +58,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__()



More information about the llvm-commits mailing list