[polly] [polly] python futurize --stage1 --write (PR #124580)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 08:22:04 PST 2025


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {darker}-->


:warning: Python code formatter, darker found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
darker --check --diff -r 178f47143a3b3c547df6d1f07e9707792f5d9fd4...026a717ee4b97ab7d0d6cbe45026a963e436d9ca polly/lib/External/isl/imath/tests/gmp-compat-test/gendata.py polly/lib/External/isl/imath/tools/findthreshold.py polly/lib/External/isl/libisl-gdb.py polly/test/update_check.py polly/utils/jscop2cloog.py polly/utils/pyscop/jscop2iscc.py
``````````

</details>

<details>
<summary>
View the diff from darker here.
</summary>

``````````diff
--- lib/External/isl/imath/tools/findthreshold.py	2025-01-27 16:09:58.000000 +0000
+++ lib/External/isl/imath/tools/findthreshold.py	2025-01-27 16:21:33.501707 +0000
@@ -85,11 +85,10 @@
 
 if __name__ == "__main__":
     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()
 
 # Here there be dragons
--- utils/jscop2cloog.py	2025-01-27 16:09:58.000000 +0000
+++ utils/jscop2cloog.py	2025-01-27 16:21:33.754433 +0000
@@ -1,36 +1,38 @@
 #!/usr/bin/env python
 from __future__ import print_function
 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)
 
-def getSchedules(scop):
-  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
 
 # Context (no constraints on two parameters)
 %s
@@ -46,24 +48,24 @@
 %s
 
 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__()
-
--- utils/pyscop/jscop2iscc.py	2025-01-27 16:09:58.000000 +0000
+++ utils/pyscop/jscop2iscc.py	2025-01-27 16:21:33.873732 +0000
@@ -1,69 +1,68 @@
 #!/usr/bin/env python
 from __future__ import print_function
 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__()
-

``````````

</details>


https://github.com/llvm/llvm-project/pull/124580


More information about the llvm-commits mailing list