Skip to content
Snippets Groups Projects
Select Git revision
  • 68777af399806d58b6b56a05b757c9b88e7595a6
  • master default protected
  • v2.0-dev protected
  • zikeliml/Task-96-dotExporterForAST
  • zikeliml/124-rework-tutorials
  • fma
  • fhennig/v2.0-deprecations
  • holzer-master-patch-46757
  • 66-absolute-access-is-probably-not-copied-correctly-after-_eval_subs
  • gpu_bufferfield_fix
  • hyteg
  • vectorization_sqrt_fix
  • target_dh_refactoring
  • const_fix
  • improved_comm
  • gpu_liveness_opts
  • release/1.3.7 protected
  • release/1.3.6 protected
  • release/2.0.dev0 protected
  • release/1.3.5 protected
  • release/1.3.4 protected
  • release/1.3.3 protected
  • release/1.3.2 protected
  • release/1.3.1 protected
  • release/1.3 protected
  • release/1.2 protected
  • release/1.1.1 protected
  • release/1.1 protected
  • release/1.0.1 protected
  • release/1.0 protected
  • release/0.4.4 protected
  • last/Kerncraft
  • last/OpenCL
  • last/LLVM
  • release/0.4.3 protected
  • release/0.4.2 protected
36 results

test_interpolation.py

Blame
  • 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)