Skip to content
Snippets Groups Projects
Select Git revision
  • improved_comm
  • master default protected
  • Bindgen-master-patch-10312
  • central_moments
  • mr_bugfix_momentum_density_calculation
  • test_martin
  • csebug
  • release/0.2.14
  • release/0.2.13
  • release/0.2.12
  • release/0.2.11
  • release/0.2.10
  • release/0.2.9
  • release/0.2.8
  • release/0.2.7
  • release/0.2.6
  • release/0.2.5
  • release/0.2.4
  • release/0.2.3
  • release/0.2.2
  • release/0.2.1
21 results

MANIFEST.in

Blame
  • Forked from pycodegen / lbmpy
    Source project has a limited visibility.
    test_address_of.py 1.40 KiB
    """
    Test of pystencils.data_types.address_of
    """
    
    import pystencils
    from pystencils.data_types import PointerType, address_of, cast_func, create_type
    from pystencils.simp.simplifications import sympy_cse
    
    
    def test_address_of():
        x, y = pystencils.fields('x,y: int64[2d]')
        s = pystencils.TypedSymbol('s', PointerType(create_type('int64')))
    
        assignments = pystencils.AssignmentCollection({
            s: address_of(x[0, 0]),
            y[0, 0]: cast_func(s, create_type('int64'))
        }, {})
    
        ast = pystencils.create_kernel(assignments)
        code = pystencils.show_code(ast)
        print(code)
    
        assignments = pystencils.AssignmentCollection({
            y[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64'))
        }, {})
    
        ast = pystencils.create_kernel(assignments)
        code = pystencils.show_code(ast)
        print(code)
    
    
    def test_address_of_with_cse():
        x, y = pystencils.fields('x,y: int64[2d]')
        s = pystencils.TypedSymbol('s', PointerType(create_type('int64')))
    
        assignments = pystencils.AssignmentCollection({
            y[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64')) + s,
            x[0, 0]: cast_func(address_of(x[0, 0]), create_type('int64')) + 1
        }, {})
    
        ast = pystencils.create_kernel(assignments)
        code = pystencils.show_code(ast)
        assignments_cse = sympy_cse(assignments)
    
        ast = pystencils.create_kernel(assignments_cse)
        code = pystencils.show_code(ast)
        print(code)