Skip to content

Commit

Permalink
Use mapper optimizer in traversal benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Sep 25, 2022
1 parent 5b64cd4 commit 472862e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions experiments/traversal-benchmark.py
@@ -1,8 +1,12 @@
# See https://github.com/inducer/pymbolic/pull/110 for context

import sys

from pymbolic import parse
from pymbolic.primitives import Variable
from pymbolic.mapper import CachedIdentityMapper
from pymbolic.mapper import CachedIdentityMapper, IdentityMapper
from pymbolic.mapper.optimize import optimize_mapper


code = ("(-1)*((cse_577[_pt_data_48[((iface_ensm15*1075540 + iel_ensm15*10 + idof_ensm15) % 4302160) // 10, 0],"
"_pt_data_49[(iface_ensm15*1075540 + iel_ensm15*10 + idof_ensm15) % 10]]"
Expand Down Expand Up @@ -91,6 +95,11 @@
"iel_ensm15": Variable("_1"),
"idof_ensm15": Variable("_2"),
}


@optimize_mapper(drop_args=True, drop_kwargs=True,
#inline_cache=True, inline_rec=True,
print_modified_code_file=sys.stdout)
class Renamer(CachedIdentityMapper):
def map_variable(self, expr):
return replacements.get(expr.name, expr)
Expand Down Expand Up @@ -118,5 +127,3 @@ def main():
for _ in range(10_000):
main()
vmprof.disable()


0 comments on commit 472862e

Please sign in to comment.