Skip to content
Snippets Groups Projects
Commit f678a2fa authored by Richard Angersbach's avatar Richard Angersbach
Browse files

Add unit test for checking border cases of freezing illegal usages of ReductionAssignments

parent eb6e8c0f
No related branches found
No related tags found
1 merge request!438Reduction Support
......@@ -66,6 +66,7 @@ from pystencils.sympyextensions.integer_functions import (
ceil_to_multiple,
div_ceil,
)
from pystencils.sympyextensions.reduction import AddReductionAssignment
def test_freeze_simple():
......@@ -494,6 +495,36 @@ def test_invalid_arrays():
_ = freeze(symb_arr)
def test_invalid_reduction_assignments():
x = fields(f"x: float64[1d]")
w = TypedSymbol("w", "float64")
ctx = KernelCreationContext()
freeze = FreezeExpressions(ctx)
one = PsExpression.make(PsConstant(1, ctx.index_dtype))
counter = ctx.get_symbol("ctr", ctx.index_dtype)
ispace = FullIterationSpace(
ctx, [FullIterationSpace.Dimension(one, one, one, counter)]
)
ctx.set_iteration_space(ispace)
invalid_assignment = Assignment(w, -1 * x.center())
reduction_assignment = AddReductionAssignment(w, 3 * x.center())
# reduction symbol is used before ReductionAssignment
with pytest.raises(FreezeError):
_ = [freeze(asm) for asm in [invalid_assignment, reduction_assignment]]
# reduction symbol is used after ReductionAssignment
with pytest.raises(FreezeError):
_ = [freeze(asm) for asm in [reduction_assignment, invalid_assignment]]
# duplicate ReductionAssignment
with pytest.raises(FreezeError):
_ = [freeze(asm) for asm in [reduction_assignment, reduction_assignment]]
def test_memory_access():
ctx = KernelCreationContext()
freeze = FreezeExpressions(ctx)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment