[polly] [polly] python futurize --stage1 --write (PR #124580)
Christian Clauss via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 08:18:25 PST 2025
https://github.com/cclauss created https://github.com/llvm/llvm-project/pull/124580
As request at https://github.com/llvm/llvm-project/pull/124424#issuecomment-2616004789 an alternative approach to:
* #124424
% `cd polly`
% `uv tool run --python=3.12 --from=future futurize --stage1 --write .`
* https://python-future.org/automatic_conversion.html#stage-1-safe-fixes
@Meinersbur
>From 026a717ee4b97ab7d0d6cbe45026a963e436d9ca Mon Sep 17 00:00:00 2001
From: Christian Clauss <cclauss at me.com>
Date: Mon, 27 Jan 2025 17:09:58 +0100
Subject: [PATCH] [polly] python futurize --stage1 --write
---
.../imath/tests/gmp-compat-test/gendata.py | 3 ++-
.../External/isl/imath/tools/findthreshold.py | 9 ++++---
polly/lib/External/isl/libisl-gdb.py | 1 +
polly/test/update_check.py | 1 +
polly/utils/jscop2cloog.py | 3 ++-
polly/utils/pyscop/jscop2iscc.py | 25 ++++++++++---------
6 files changed, 24 insertions(+), 18 deletions(-)
diff --git a/polly/lib/External/isl/imath/tests/gmp-compat-test/gendata.py b/polly/lib/External/isl/imath/tests/gmp-compat-test/gendata.py
index 3ca17ff359d912..f2ff6cec380912 100644
--- a/polly/lib/External/isl/imath/tests/gmp-compat-test/gendata.py
+++ b/polly/lib/External/isl/imath/tests/gmp-compat-test/gendata.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import random
import gmpapi
@@ -42,7 +43,7 @@ def apply(fun, lst):
mm_all = mm_slong + mm_ulong + mm_sint + mm_uint + mm_sshort + mm_ushort
zero_one_all = mzero_one + zero_one
-mpz_std_list = zero_one_all + mm_all + apply(plus1, mm_all) + apply(minus1, mm_all)
+mpz_std_list = zero_one_all + mm_all + plus1(*mm_all) + minus1(*mm_all)
si_std_list = (
zero_one + mm_slong + mm_sint + mm_sshort + mm_slong1 + mm_sint1 + mm_sshort1
)
diff --git a/polly/lib/External/isl/imath/tools/findthreshold.py b/polly/lib/External/isl/imath/tools/findthreshold.py
index fbb325e1da916a..8a5b2f22646f13 100644
--- a/polly/lib/External/isl/imath/tools/findthreshold.py
+++ b/polly/lib/External/isl/imath/tools/findthreshold.py
@@ -21,6 +21,7 @@
## call mp_int_multiply_threshold(n) during program initialization, to
## establish a satisfactory result.
##
+from __future__ import print_function
import math, os, random, sys, time
@@ -62,7 +63,7 @@ def compute_stats():
check_binary('imtimer')
seed = int(time.time())
- print >> sys.stderr, "Computing timer statistics (this may take a while)"
+ print("Computing timer statistics (this may take a while)", file=sys.stderr)
stats = {}
for prec in (32, 40, 64, 80, 128, 150, 256, 384, 512, 600, 768, 1024):
sys.stderr.write('%-4d ' % prec)
@@ -86,9 +87,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/lib/External/isl/libisl-gdb.py b/polly/lib/External/isl/libisl-gdb.py
index bf01bc583d15d8..a3e0045364f7e0 100644
--- a/polly/lib/External/isl/libisl-gdb.py
+++ b/polly/lib/External/isl/libisl-gdb.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
import gdb
import re
diff --git a/polly/test/update_check.py b/polly/test/update_check.py
index a973c72ff4e78e..0ee10fd6f04930 100644
--- a/polly/test/update_check.py
+++ b/polly/test/update_check.py
@@ -4,6 +4,7 @@
# Polly/LLVM update_check.py
# Update lit FileCheck files by replacing the 'CHECK:' lines by the actual output of the 'RUN:' command.
+from __future__ import print_function
import argparse
import os
import subprocess
diff --git a/polly/utils/jscop2cloog.py b/polly/utils/jscop2cloog.py
index 29383974f26780..10a27d5f0d2968 100755
--- a/polly/utils/jscop2cloog.py
+++ b/polly/utils/jscop2cloog.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import argparse, os
import json
@@ -50,7 +51,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..efa481b455ce76 100755
--- a/polly/utils/pyscop/jscop2iscc.py
+++ b/polly/utils/pyscop/jscop2iscc.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
+from __future__ import print_function
import argparse, isl, os
import json
@@ -9,8 +10,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 +22,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 +32,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 +42,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 +59,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