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): ...@@ -19,13 +19,14 @@ def read_ufl(uflfile):
uflcode = read_ufl_file(uflfile) uflcode = read_ufl_file(uflfile)
namespace = {} namespace = {}
try: 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: except:
import os import os
basename = os.path.splitext(os.path.basename(uflfile))[0] basename = os.path.splitext(os.path.basename(uflfile))[0]
basename = "{}_debug".format(basename) basename = "{}_debug".format(basename)
pyname = "{}.py".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 pycode = "#!/usr/bin/env python\nfrom dune.perftool.ufl.execution import *\nset_level(DEBUG)\n" + uflcode
with file(pyname, "w") as f: with file(pyname, "w") as f:
f.write(pycode) f.write(pycode)
......
...@@ -8,7 +8,8 @@ from loopy.target.c.codegen.expression import ExpressionToCMapper ...@@ -8,7 +8,8 @@ from loopy.target.c.codegen.expression import ExpressionToCMapper
_registry = {'float32': 'float', _registry = {'float32': 'float',
'int32': 'int', 'int32': 'int',
'float64': 'double', 'float64': 'double',
'string': 'std::string'} 'string': 'std::string',
'str': 'std::string'}
class MyMapper(ExpressionToCMapper): class MyMapper(ExpressionToCMapper):
......
...@@ -270,7 +270,7 @@ def generate_kernel(integrals): ...@@ -270,7 +270,7 @@ def generate_kernel(integrals):
iname, within = next(get_iname_duplication_options(kernel)) iname, within = next(get_iname_duplication_options(kernel))
# Do the transformation # 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) kernel = duplicate_inames(kernel, iname, within)
# Loopy might have introduced some temporary variables during preprocessing. As I want to have my own # 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): ...@@ -31,7 +31,7 @@ def split_into_accumulation_terms(expr):
accumulation_terms = [] accumulation_terms = []
# Treat the case of a rank 1 form: # 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: for arg in mod_args:
# Do the replacement on the expression # Do the replacement on the expression
accumulation_terms.append(replace_expression(expr, accumulation_terms.append(replace_expression(expr,
......
...@@ -31,8 +31,7 @@ class IndexedMapper(MultiFunction): ...@@ -31,8 +31,7 @@ class IndexedMapper(MultiFunction):
tensor, idx = o.ufl_operands tensor, idx = o.ufl_operands
# Extract an index mapping # Extract an index mapping
from itertools import izip for inner, outer in zip(idx, self.indexed_expr.ufl_operands[1]):
for inner, outer in izip(idx, self.indexed_expr.ufl_operands[1]):
self.rim.replacement_map[inner] = self.rim.replacement_map.setdefault(outer, outer) self.rim.replacement_map[inner] = self.rim.replacement_map.setdefault(outer, outer)
# And return an expression with the component tensor removed # 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