Commit 081445aa authored by Dominic Kempf's avatar Dominic Kempf

[!361] Update loopy submodule

Merge branch 'feature/update-loopy' into 'master'

ref:extensions/dune-codegen Update the loopy submodule to latest master. This
includes switching to the latest version of the loopy language.

See merge request [!361]

  [!361]: gitlab.dune-project.org/extensions/dune-codegen/merge_requests/361
parents 9b06067d 8ca9a089
Pipeline #21085 passed with stage
in 42 minutes and 55 seconds
Subproject commit f411383630b272a3a5d3e28b82acaaa530a64723
Subproject commit ae1da38a47dd1f0cc256ffc8949d2b8bd51f1f1b
......@@ -7,6 +7,7 @@ from dune.codegen.pdelab.localoperator import determine_accumulation_space, Gene
from dune.codegen.pdelab.argument import name_accumulation_variable
from dune.codegen.pdelab.localoperator import boundary_predicates
from dune.codegen.generation.loopy import function_mangler, temporary_variable
from dune.codegen.tools import get_pymbolic_basename
import loopy as lp
import pymbolic.primitives as prim
......@@ -84,11 +85,15 @@ def generate_accumulation_instruction(expr, visitor):
if visitor.trial_info:
lfs_inames = lfs_inames.union(visitor.trial_info.inames)
deps = lp.symbolic.DependencyMapper()(accexpr)
deps = frozenset({Writes(get_pymbolic_basename(d)) for d in deps})
instruction(assignees=(),
expression=accexpr,
forced_iname_deps=lfs_inames.union(frozenset(quad_inames)),
forced_iname_deps_is_final=True,
predicates=predicates
predicates=predicates,
depends_on=deps,
)
......@@ -114,12 +119,15 @@ def generate_accumulation_instruction_vectorized(expr, visitor):
tuple(prim.Variable(i) for i in sub_element_inames() + lfs_inames))
expr_with_weight = prim.Product((expr, prim.Call(prim.Variable(accumvar + '.weight'), ())))
accum_expr = prim.Sum((expr_with_weight, assignee))
deps = lp.symbolic.DependencyMapper()(accum_expr)
deps = frozenset({Writes(get_pymbolic_basename(d)) for d in deps})
instruction(assignee=assignee,
expression=prim.Sum((expr_with_weight, assignee)),
expression=accum_expr,
forced_iname_deps=frozenset(lfs_inames).union(frozenset(quad_inames)),
forced_iname_deps_is_final=True,
predicates=predicates,
tags=frozenset({'accum'}),
depends_on=frozenset({Writes(accumvar_alias)})
depends_on=deps
)
......@@ -40,7 +40,7 @@ def add_vcl_temporaries(knl, vcl_size):
from loopy.kernel.data import VectorizeTag
return knl.copy(instructions=knl.instructions + new_insns, domains=knl.domains + [init_domain],
temporary_variables=dict(**knl.temporary_variables, **new_vec_temporaries),
iname_to_tag=dict(**knl.iname_to_tag, **{init_iname: VectorizeTag()}),
iname_to_tags=dict(**knl.iname_to_tags, **{init_iname: frozenset({VectorizeTag()})}),
silenced_warnings=knl.silenced_warnings + silenced_warnings)
......
......@@ -17,8 +17,8 @@ silenced_warning = generator_factory(item_tags=("silenced_warning",), no_deco=Tr
kernel_cached = generator_factory(item_tags=("default_cached",), context_tags="kernel")
class DuneGlobalArg(lp.GlobalArg):
allowed_extra_kwargs = lp.GlobalArg.allowed_extra_kwargs + ["managed"]
class DuneGlobalArg(lp.ArrayArg):
allowed_extra_kwargs = lp.ArrayArg.allowed_extra_kwargs + ["managed"]
@generator_factory(item_tags=("argument", "globalarg"),
......@@ -29,7 +29,12 @@ def globalarg(name, shape=lp.auto, managed=True, **kw):
shape = (shape,)
from dune.codegen.loopy.target import dtype_floatingpoint
dtype = kw.pop("dtype", dtype_floatingpoint())
return DuneGlobalArg(name, dtype=dtype, shape=shape, managed=managed, **kw)
return DuneGlobalArg(name,
dtype=dtype,
shape=shape,
managed=managed,
address_space=lp.AddressSpace.GLOBAL,
**kw)
@generator_factory(item_tags=("argument", "constantarg"),
......
......@@ -29,8 +29,8 @@ class FusedMultiplyAdd(prim.Expression):
def __getinitargs__(self):
return (self.mul_op1, self.mul_op2, self.add_op)
def stringifier(self):
return lp.symbolic.StringifyMapper
def make_stringifier(self, originating_stringifier=None):
return lp.symbolic.StringifyMapper()
mapper_method = intern("map_fused_multiply_add")
......
......@@ -206,7 +206,6 @@ def _vectorize_quadrature_loop(knl, inames, suffix):
tuple(prim.Subscript(prim.Variable(get_vector_view_name(quantity)),
(vector_indices.get(horizontal) + i, prim.Variable(vec_iname)))
for i in range(horizontal))),
depends_on=frozenset({'continue_stmt{}'.format(suffix)}),
within_inames=common_inames.union(frozenset({outer_iname, vec_iname})),
within_inames_is_final=True,
id="{}_rotate{}".format(quantity, suffix),
......@@ -268,12 +267,13 @@ def _vectorize_quadrature_loop(knl, inames, suffix):
(vector_indices.get(horizontal) + last_index, prim.Variable(vec_iname)),
),
substitute(insn.expression, replacemap),
depends_on=frozenset({"continue_stmt{}".format(suffix), lp.match.Tagged("sumfact_stage1")}),
depends_on=frozenset({lp.match.Tagged("sumfact_stage1")}),
depends_on_is_final=True,
within_inames=common_inames.union(frozenset({outer_iname, vec_iname})),
within_inames_is_final=True,
id=insn.id,
tags=frozenset({"vec_write{}".format(suffix), "sumfact_stage2"})
tags=frozenset({"vec_write{}".format(suffix), "sumfact_stage2"}),
no_sync_with=frozenset({(lp.match.Tagged("sumfact_stage2"), "any")}),
)
)
......
......@@ -84,14 +84,16 @@ def initialize_options():
# Validate global options
scheme_global = _load_scheme()
validator_global = CodegenOptionsValidator(scheme_global, require_all=True)
if not validator_global.validate(_global_options.__dict__):
opt_dict = _global_options.__dict__
if not validator_global.validate({k: v for k, v in opt_dict.items() if not k.startswith("_")}):
raise RuntimeError("Global options validation failed: {}".format(validator_global.errors))
# Validate form options
scheme_form = _load_scheme(form=True)
validator_form = CodegenOptionsValidator(scheme_form, require_all=True)
for form in [i.strip() for i in _global_options.operators.split(",")]:
if not validator_form.validate(_form_options[form].__dict__):
opt_dict = _form_options[form].__dict__
if not validator_form.validate({k: v for k, v in opt_dict.items() if not k.startswith("_")}):
raise RuntimeError("Form options validation failed: {}".format(validator_form.errors))
......
......@@ -595,7 +595,7 @@ def extract_kernel_from_cache(tag, name, signature, wrap_in_cgen=True, add_timin
from loopy import Options
opt = Options(ignore_boostable_into=True,
check_dep_resolution=False,
enforce_variable_access_ordered="no_check",
enforce_variable_access_ordered=True,
)
# Create the kernel
......@@ -608,7 +608,7 @@ def extract_kernel_from_cache(tag, name, signature, wrap_in_cgen=True, add_timin
options=opt,
silenced_warnings=silenced,
name=name,
lang_version=(2017, 2, 1),
lang_version=(2018, 2),
)
from loopy import make_reduction_inames_unique
kernel = make_reduction_inames_unique(kernel)
......
......@@ -97,7 +97,10 @@ def define_matrix_inverse(name, name_inv, shape, visitor):
instruction(expression=exprs[i][j],
assignee=assignee[i][j],
within_inames=frozenset(visitor.quadrature_inames()),
depends_on=frozenset({Writes(name), Writes(det_inv)}))
depends_on=frozenset({Writes(name), Writes(det_inv)}),
tags=frozenset({"inversion_{}".format(name)}),
no_sync_with=frozenset({(lp.match.Tagged("inversion_{}".format(name)), "any")}),
)
def name_determinant(matrix, shape, visitor):
......
......@@ -673,6 +673,7 @@ def generate_accumulation_instruction(expr, visitor):
forced_iname_deps_is_final=True,
tags=frozenset({"quadvec", "sumfact_stage2"}).union(vectag),
depends_on=frozenset({deps}).union(frozenset({lp.match.Tagged("sumfact_stage1")})),
no_sync_with=frozenset({(lp.match.Tagged("sumfact_stage2"), "any")}),
)
if insn_dep is None:
......
......@@ -106,7 +106,9 @@ class SumfactMultiLinearGeometryMixin(SumfactGeometryMixinBase):
instruction(assignee=assignee,
expression=expression,
within_inames=frozenset(inames),
depends_on=frozenset({lp.match.Tagged("sumfact_stage1")})
depends_on=frozenset({lp.match.Tagged("sumfact_stage1")}),
tags=frozenset({"sumfact_stage2"}),
no_sync_with=frozenset({(lp.match.Tagged("sumfact_stage2"), "any")})
)
names_jacobian.append(name_jacobian)
......@@ -134,6 +136,8 @@ class SumfactMultiLinearGeometryMixin(SumfactGeometryMixinBase):
assignees=frozenset([name, name_detjac]),
read_variables=frozenset(names_jacobian),
inames=frozenset(inames),
tags=frozenset({"sumfact_stage2"}),
no_sync_with=frozenset({(lp.match.Tagged("sumfact_stage2"), "any")})
)
def facet_jacobian_determinant(self, o):
......@@ -453,7 +457,8 @@ class GeoCornersInput(SumfactKernelInterfaceBase, ImmutableCuttingRecord):
insn = instruction(code=code,
within_inames=frozenset(inames_cost_permuted),
assignees=(name,),
tags=frozenset({"sumfact_stage{}".format(sf.stage)}),
tags=frozenset({"sumfact_setup", "sumfact_stage{}".format(sf.stage)}),
no_sync_with=frozenset({(lp.match.Tagged("sumfact_setup"), "any")})
)
return insn_dep.union(frozenset({insn}))
......
loopy @ 00489d72
Subproject commit dedb956bd72a204a685e7aeb7788d1fa55969899
Subproject commit 00489d72917e17b9f1a2585617b019bba1f03242
Subproject commit ffecfaebf21dc8799cd5d007a969e659b255a1e3
Subproject commit cc4d752cffc34042f55a16e589a60a9326b1b884
Subproject commit 747a1c1fac3fb4f2067f00c1a670f5a7b963b396
Subproject commit c8321a19f2b2aa046a8af4f9f342252103558613
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment