Skip to content

Commit a1bf1e2

Browse files
committed
Use FlattenMapper before codegen
- Smaller expressions to crunch through - Throws off flop counts
1 parent 0fd7598 commit a1bf1e2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

sumpy/codegen.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import pymbolic.primitives as prim
3737
from loopy.kernel.instruction import Assignment, CallInstruction, make_assignment
3838
from pymbolic.mapper import CSECachingMapperMixin, IdentityMapper, P
39+
from pymbolic.mapper.flattener import FlattenMapper
3940
from pymbolic.typing import ArithmeticExpression, Expression
4041
from pytools import memoize_method
4142

@@ -753,6 +754,7 @@ def to_loopy_insns(
753754
sympy_conv = SympyToPymbolicMapper()
754755
pymbolic_assignments = [(name, sympy_conv(expr)) for name, expr in assignments]
755756

757+
flat = FlattenMapper()
756758
bdr = BesselDerivativeReplacer()
757759
btog = BesselTopOrderGatherer()
758760
vcr = VectorComponentRewriter(vector_names)
@@ -762,6 +764,7 @@ def to_loopy_insns(
762764
cmr = ComplexRewriter(complex_dtype)
763765

764766
def cmb_mapper(expr: Expression, /) -> Expression:
767+
expr = flat(expr)
765768
expr = bdr(expr)
766769
expr = vcr(expr)
767770
expr = pwr(expr)

sumpy/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@ def _parse_version(version: str) -> tuple[tuple[int, ...], str]:
4141
VERSION, VERSION_STATUS = _parse_version(VERSION_TEXT)
4242

4343
_GIT_REVISION = find_module_git_revision(__file__, n_levels_up=1)
44-
KERNEL_VERSION = (*VERSION, _GIT_REVISION, 1)
44+
KERNEL_VERSION = (*VERSION, _GIT_REVISION, 2)

0 commit comments

Comments
 (0)