pystencils issues https://i10git.cs.fau.de/pycodegen/pystencils/-/issues 2022-03-27T15:17:16+02:00 https://i10git.cs.fau.de/pycodegen/pystencils/-/issues/60 SymPy CSE does not work as good as it used to work 2022-03-27T15:17:16+02:00 Markus Holzer SymPy CSE does not work as good as it used to work https://github.com/sympy/sympy/commit/19c715920e52337d124dda63abdc056f56ec094e has a negative impact on our CSE routine. An example would be `test_simplifications_srt_d2q9_incompressible` in lbmpy The following example should demonstra... https://github.com/sympy/sympy/commit/19c715920e52337d124dda63abdc056f56ec094e has a negative impact on our CSE routine. An example would be `test_simplifications_srt_d2q9_incompressible` in lbmpy The following example should demonstrate the change, before 19c715920e52337d124dda63abdc056f56ec094e: ```python import sympy as sp var = sp.symbols("a b c d") test = -var + var/9 + var**2/2 + var/3, -var + var/9 + var**2/2 - var/3 sp.cse(test) >>> ([(x0, c/3), (x1, c**2/2 + d/9)], [-a + x0 + x1, -b - x0 + x1]) ``` After 19c715920e52337d124dda63abdc056f56ec094e: ```python import sympy as sp var = sp.symbols("a b c d") test = -var + var/9 + var**2/2 + var/3, -var + var/9 + var**2/2 - var/3 sp.cse(test) >>> ([(x0, c/3), (x1, c**2)], [-a + d/9 + x0 + x1/2, -b + d/9 - x0 + x1/2]) ``` The second latest master version does not find the replacements for the divisions. An issue in Sympy was created here: https://github.com/sympy/sympy/issues/23297 Markus Holzer Markus Holzer https://i10git.cs.fau.de/pycodegen/pystencils/-/issues/62 Wrong cast 2022-08-11T15:31:17+02:00 Markus Holzer Wrong cast This code: ```python import sympy as sp import pystencils as ps field_type = &quot;float64&quot; # if ctx.double_accuracy else &quot;float32&quot; # ----- Solving the 2D Poisson equation with rhs -------------------------- dx = sp.Symbol(&quot;dx&quot;) dy = sp.Sym... This code: ```python import sympy as sp import pystencils as ps field_type = "float64" # if ctx.double_accuracy else "float32" # ----- Solving the 2D Poisson equation with rhs -------------------------- dx = sp.Symbol("dx") dy = sp.Symbol("dy") src, dst, rhs = ps.fields(f"src, src_tmp, rhs: {field_type}[2D]", layout='fzyx') up = ps.Assignment(src[0, 0], ((dy**2 * (src[1, 0] + src[-1, 0])) + (dx**2 * (src[0, 1] + src[0, -1])) - (rhs[0, 0] * dx**2 * dy**2)) / (2 * (dx**2 + dy**2))) config = ps.CreateKernelConfig(data_type=field_type, cpu_vectorize_info={'instruction_set': 'avx', 'assume_inner_stride_one': True, 'assume_aligned': True}) ast = ps.create_kernel(up, config=config) ast.compile() ``` leads to `NotImplementedError: Vectorizer cannot cast between different datatypes` Markus Holzer Markus Holzer