Skip to content
Snippets Groups Projects
Commit 67f11ec1 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

Make dune-perftool python3-compatible

parent e3a9965d
No related branches found
No related tags found
No related merge requests found
......@@ -19,13 +19,14 @@ def read_ufl(uflfile):
uflcode = read_ufl_file(uflfile)
namespace = {}
try:
exec "from dune.perftool.ufl.execution import *\n" + uflcode in namespace
namespace = globals()
exec("from dune.perftool.ufl.execution import *\n" + uflcode, namespace)
except:
import os
basename = os.path.splitext(os.path.basename(uflfile))[0]
basename = "{}_debug".format(basename)
pyname = "{}.py".format(basename)
print pyname
print(pyname)
pycode = "#!/usr/bin/env python\nfrom dune.perftool.ufl.execution import *\nset_level(DEBUG)\n" + uflcode
with file(pyname, "w") as f:
f.write(pycode)
......
......@@ -8,7 +8,8 @@ from loopy.target.c.codegen.expression import ExpressionToCMapper
_registry = {'float32': 'float',
'int32': 'int',
'float64': 'double',
'string': 'std::string'}
'string': 'std::string',
'str': 'std::string'}
class MyMapper(ExpressionToCMapper):
......
......@@ -270,7 +270,7 @@ def generate_kernel(integrals):
iname, within = next(get_iname_duplication_options(kernel))
# Do the transformation
print "Applying iname duplication to measure {}: iname {}; within {}".format(measure, iname, within)
print("Applying iname duplication to measure {}: iname {}; within {}".format(measure, iname, within))
kernel = duplicate_inames(kernel, iname, within)
# Loopy might have introduced some temporary variables during preprocessing. As I want to have my own
......
......@@ -31,7 +31,7 @@ def split_into_accumulation_terms(expr):
accumulation_terms = []
# Treat the case of a rank 1 form:
if len(filter(lambda ma: ma.argexpr.number() == 1, mod_args)) == 0:
if len(list(filter(lambda ma: ma.argexpr.number() == 1, mod_args))) == 0:
for arg in mod_args:
# Do the replacement on the expression
accumulation_terms.append(replace_expression(expr,
......
......@@ -31,8 +31,7 @@ class IndexedMapper(MultiFunction):
tensor, idx = o.ufl_operands
# Extract an index mapping
from itertools import izip
for inner, outer in izip(idx, self.indexed_expr.ufl_operands[1]):
for inner, outer in zip(idx, self.indexed_expr.ufl_operands[1]):
self.rim.replacement_map[inner] = self.rim.replacement_map.setdefault(outer, outer)
# And return an expression with the component tensor removed
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment