Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • pystencils pystencils
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 18
    • Issues 18
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 6
    • Merge requests 6
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pycodegen
  • pystencilspystencils
  • Merge requests
  • !34

Address #13: Use sympy.codegen.rewriting.optimize

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Stephan Seitz requested to merge seitz/pystencils:use_codegen.rewriting.optimize into master Aug 18, 2019
  • Overview 2
  • Commits 4
  • Pipelines 9
  • Changes 6

It's really comfortable to write optimizations in terms of sympy.codegen.rewrite.RewriteOptim:

    # Evaluates all constant terms
    evaluate_constant_terms = ReplaceOptim(
        lambda e: hasattr(e, 'is_constant') and e.is_constant,
        lambda p: p.evalf()
    )

This PR adds a parameter sympy_optimizations to the create_*_kernel functions that applies the list of optimizations to the assignments before creating the AST.

sympy.codegen.rewrite already has some optimizations. Some similar to the optimizations of pystencils. For example create_expand_pow_optimization(limit) is really similar to the logic in CustomSympyPrinter._print_Pow.

See #13 (closed)

Problem: old versions of sympy (e.g. from ubuntu CI) don't have sympy.codegen.rewrite. The optimizations are skipped in that case. test_and_coverage applies all optimizations.

We could also try to implement a fma-optimization (fused-multipy add) with that and sympy.Wild.

Edited Aug 18, 2019 by Stephan Seitz
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: use_codegen.rewriting.optimize