From e92a0697aedd148ff8f1a86ccfcdc8877f51ad75 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 22 Jan 2025 14:05:20 +0100 Subject: [PATCH 1/7] 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 0000000000000..9364d6ea369ea --- /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@v4 + - uses: astral-sh/ruff-action@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 Date: Wed, 22 Jan 2025 14:33:29 +0100 Subject: [PATCH 2/7] 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 7daed2e1cd5cc..a933ea557a98b 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 fbb325e1da916..0971c862f987e 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 29383974f2678..1d8a31047d116 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 42f4cc180f1fb..2ab27538d8632 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 Date: Thu, 23 Jan 2025 18:00:55 +0100 Subject: [PATCH 3/7] 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 9364d6ea369ea..0000000000000 --- 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@v4 - - uses: astral-sh/ruff-action@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 Date: Sat, 25 Jan 2025 20:32:06 +0100 Subject: [PATCH 4/7] 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 0971c862f987e..fbb325e1da916 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 1d8a31047d116..29383974f2678 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 2ab27538d8632..42f4cc180f1fb 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__() From e238ce8f2ed868a322c87d575f24c745f6b29674 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 26 Jan 2025 10:09:31 +0100 Subject: [PATCH 5/7] from __future__ import print_function --- openmp/runtime/tools/summarizeStats.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/openmp/runtime/tools/summarizeStats.py b/openmp/runtime/tools/summarizeStats.py index a933ea557a98b..062c16bb9fdc5 100644 --- a/openmp/runtime/tools/summarizeStats.py +++ b/openmp/runtime/tools/summarizeStats.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function + import pandas as pd import numpy as np import re From 14ffcfd5f5199903a5682621f2e60a147e8e56d7 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 27 Jan 2025 23:22:35 +0100 Subject: [PATCH 6/7] Update openmp/runtime/tools/summarizeStats.py --- openmp/runtime/tools/summarizeStats.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openmp/runtime/tools/summarizeStats.py b/openmp/runtime/tools/summarizeStats.py index 062c16bb9fdc5..eea287e0da94f 100644 --- a/openmp/runtime/tools/summarizeStats.py +++ b/openmp/runtime/tools/summarizeStats.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function import pandas as pd import numpy as np From fa96cd4251d5aaaf93312373dd72d4c4436d5ddd Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Mon, 27 Jan 2025 23:41:04 +0100 Subject: [PATCH 7/7] Darker prefers double quotes and spaces. --- openmp/runtime/tools/summarizeStats.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openmp/runtime/tools/summarizeStats.py b/openmp/runtime/tools/summarizeStats.py index eea287e0da94f..c1a59288fae7f 100644 --- a/openmp/runtime/tools/summarizeStats.py +++ b/openmp/runtime/tools/summarizeStats.py @@ -38,7 +38,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): """ @@ -300,10 +300,10 @@ def main(): chartType = "radar" drawRadarChart(data, s, filebase, params, colors[n]) """radar Charts finish here""" - plt.savefig(filebase+"_"+s+"_"+chartType, bbox_inches='tight') - elif s == 'timers': - print("overheads in "+filebase) - numThreads = tmp[s]['SampleCount']['Total_OMP_parallel'] + plt.savefig(filebase + "_" + s + "_" + chartType, bbox_inches="tight") + elif s == "timers": + print("overheads in " + filebase) + numThreads = tmp[s]["SampleCount"]["Total_OMP_parallel"] for key in data.keys(): if key[0:5] == 'Total': del data[key]