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

Implement a printing facility for vectorization strategies

parent 9087f6c9
No related branches found
No related tags found
No related merge requests found
......@@ -49,7 +49,7 @@ def walk_map_sumfact_kernel(self, expr, *args):
def stringify_map_sumfact_kernel(self, expr, *args):
return "SUMFACT"
return str(expr)
def dependency_map_sumfact_kernel(self, expr):
......
......@@ -92,6 +92,9 @@ class AlreadyAssembledInput(SumfactKernelInputBase):
def __hash__(self):
return hash(self.index)
def __str__(self):
return "Input{}".format(self.index[0])
class SumfactAccumulationInfo(ImmutableRecord):
def __init__(self,
......
......@@ -64,6 +64,9 @@ class LFSSumfactKernelInput(SumfactKernelInputBase, ImmutableRecord):
restriction=restriction,
)
def __str__(self):
return "{}".format(self.coeff_func(self.restriction))
def realize(self, sf, index, insn_dep):
lfs = name_lfs(self.element, self.restriction, self.element_index)
basisiname = sumfact_iname(name_lfs_bound(lfs), "basis")
......
......@@ -146,6 +146,12 @@ class SumfactKernel(SumfactKernelBase, ImmutableRecord, prim.Variable):
def stringifier(self):
return lp.symbolic.StringifyMapper
def __str__(self):
# Above stringifier just calls back into this
return "SF{}:[{}]->[{}]".format(self.stage,
str(self.input),
", ".join(str(m) for m in self.matrix_sequence))
mapper_method = "map_sumfact_kernel"
#
......@@ -385,6 +391,12 @@ class VectorizedSumfactKernel(SumfactKernelBase, ImmutableRecord, prim.Variable)
def stringifier(self):
return lp.symbolic.StringifyMapper
def __str__(self):
# Above stringifier just calls back into this
return "VSF{}:[{}]->[{}]".format(self.stage,
", ".join(str(k.input) for k in self.kernels),
", ".join(str(mat) for mat in self.matrix_sequence))
mapper_method = "map_vectorized_sumfact_kernel"
init_arg_names = ("kernels", "horizontal_width", "vertical_width", "buffer", "insn_dep")
......
......@@ -63,6 +63,15 @@ class BasisTabulationMatrix(BasisTabulationMatrixBase, ImmutableRecord):
slice_index=slice_index,
)
def __str__(self):
return "{}{}A{}{}{}" \
.format("face{}_".format(self.face) if self.face is not None else "",
"d" if self.derivative else "",
self.basis_size,
"T" if self.transpose else "",
"_slice{}".format(self.slice_index) if self.slice_size is not None else "",
)
@property
def rows(self):
if self.transpose:
......@@ -131,6 +140,13 @@ class BasisTabulationMatrixArray(BasisTabulationMatrixBase):
width = len(tabs)
self.width = width
def __str__(self):
abbrevs = tuple("{}A{}{}".format("d" if t.derivative else "",
self.basis_size,
"s{}".format(t.slice_index) if t.slice_size is not None else "")
for t in self.tabs)
return "_".join(abbrevs)
@property
def quadrature_size(self):
return self.tabs[0].quadrature_size
......
......@@ -203,6 +203,26 @@ def greedy_vectorization_strategy(sumfacts, width):
return result
def print_vectorization_strategy(strategy):
qp, strategy = strategy
print "\nPrinting potential vectorization strategy:"
print "Quadrature point tuple: {}".format(qp)
# Look for all realizations in the strategy and iterate over them
cache_keys = frozenset(v.cache_key for v in strategy.values())
for ck in cache_keys:
# Filter all the kernels that are realized by this and print
for key in strategy:
if strategy[key].cache_key == ck:
print "{}:".format(key)
# Find one representative to print
for val in strategy.values():
if val.cache_key == ck:
print " {}".format(val)
break
def decide_vectorization_strategy():
""" Decide how to vectorize!
Note that the vectorization of the quadrature loop is independent of this,
......
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