<s> '<STR_LIT>' <EOL> import numpy as np <EOL> from videocore . assembler import qpu <EOL> from videocore . driver import Driver <EOL> @ qpu <EOL> def horizontal_32bit_read ( asm ) : <EOL> mov ( ra0 , uniform ) <EOL> ldi ( rb0 , <NUM_LIT:4> * <NUM_LIT:16> * <NUM_LIT:16> ) <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> setup_dma_load ( Y = <NUM_LIT:16> * i , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_load ( ra0 ) <EOL> iadd ( ra0 , ra0 , rb0 ) <EOL> wait_dma_load ( ) <EOL> setup_vpm_read ( Y = <NUM_LIT:16> , nrows = <NUM_LIT:16> ) <EOL> setup_vpm_write ( Y = <NUM_LIT:0> ) <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> mov ( r0 , vpm ) <EOL> mov ( vpm , r0 ) <EOL> setup_dma_store ( mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_store ( uniform ) <EOL> wait_dma_store ( ) <EOL> exit ( ) <EOL> def test_horizontal_32bit_read ( ) : <EOL> with Driver ( ) as drv : <EOL> X = drv . alloc ( ( <NUM_LIT:64> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> X [ : ] = np . arange ( <NUM_LIT:64> * <NUM_LIT:16> ) . reshape ( <NUM_LIT:64> , <NUM_LIT:16> ) . astype ( '<STR_LIT>' ) <EOL> Y = drv . alloc ( ( <NUM_LIT:16> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> drv . execute ( <EOL> n_threads = <NUM_LIT:1> , <EOL> program = drv . program ( horizontal_32bit_read ) , <EOL> uniforms = [ X . address , Y . address ] <EOL> ) <EOL> assert np . all ( X [ <NUM_LIT:16> : <NUM_LIT:32> ] == Y ) <EOL> @ qpu <EOL> def horizontal_32bit_write ( asm ) : <EOL> mov ( ra0 , uniform ) <EOL> ldi ( rb0 , <NUM_LIT:4> * <NUM_LIT:16> * <NUM_LIT:16> ) <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> setup_dma_load ( Y = <NUM_LIT:16> * i , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_load ( ra0 ) <EOL> iadd ( ra0 , ra0 , rb0 ) <EOL> wait_dma_load ( ) <EOL> setup_vpm_read ( Y = <NUM_LIT:0> , nrows = <NUM_LIT:16> ) <EOL> setup_vpm_write ( Y = <NUM_LIT:16> ) <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> mov ( r0 , vpm ) <EOL> mov ( vpm , r0 ) <EOL> setup_dma_store ( Y = <NUM_LIT:16> , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_store ( uniform ) <EOL> wait_dma_store ( ) <EOL> exit ( ) <EOL> def test_horizontal_32bit_write ( ) : <EOL> with Driver ( ) as drv : <EOL> X = drv . alloc ( ( <NUM_LIT:64> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> X [ : ] = np . arange ( <NUM_LIT:64> * <NUM_LIT:16> ) . reshape ( <NUM_LIT:64> , <NUM_LIT:16> ) . astype ( '<STR_LIT>' ) <EOL> Y = drv . alloc ( ( <NUM_LIT:16> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> drv . execute ( <EOL> n_threads = <NUM_LIT:1> , <EOL> program = drv . program ( horizontal_32bit_write ) , <EOL> uniforms = [ X . address , Y . address ] <EOL> ) <EOL> assert np . all ( X [ : <NUM_LIT:16> ] == Y ) <EOL> @ qpu <EOL> def vertical_32bit_read ( asm ) : <EOL> mov ( ra0 , uniform ) <EOL> ldi ( rb0 , <NUM_LIT:4> * <NUM_LIT:16> * <NUM_LIT:16> ) <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> setup_dma_load ( Y = <NUM_LIT:16> * i , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_load ( ra0 ) <EOL> iadd ( ra0 , ra0 , rb0 ) <EOL> wait_dma_load ( ) <EOL> setup_vpm_read ( nrows = <NUM_LIT:16> , Y = <NUM_LIT:16> , X = <NUM_LIT:0> , mode = '<STR_LIT>' ) <EOL> setup_vpm_write ( Y = <NUM_LIT:0> , X = <NUM_LIT:0> , mode = '<STR_LIT>' ) <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> mov ( r0 , vpm ) <EOL> mov ( vpm , r0 ) <EOL> setup_dma_store ( mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_store ( uniform ) <EOL> wait_dma_store ( ) <EOL> exit ( ) <EOL> def test_vertical_32bit_read ( ) : <EOL> with Driver ( ) as drv : <EOL> X = drv . alloc ( ( <NUM_LIT:64> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> X [ : ] = np . arange ( <NUM_LIT:64> * <NUM_LIT:16> ) . reshape ( <NUM_LIT:64> , <NUM_LIT:16> ) . astype ( '<STR_LIT>' ) <EOL> Y = drv . alloc ( ( <NUM_LIT:16> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> drv . execute ( <EOL> n_threads = <NUM_LIT:1> , <EOL> program = drv . program ( vertical_32bit_read ) , <EOL> uniforms = [ X . address , Y . address ] <EOL> ) <EOL> assert np . all ( X [ <NUM_LIT:16> : <NUM_LIT:32> ] == Y ) <EOL> @ qpu <EOL> def vertical_32bit_write ( asm ) : <EOL> mov ( ra0 , uniform ) <EOL> ldi ( rb0 , <NUM_LIT:4> * <NUM_LIT:16> * <NUM_LIT:16> ) <EOL> for i in range ( <NUM_LIT:4> ) : <EOL> setup_dma_load ( Y = <NUM_LIT:16> * i , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_load ( ra0 ) <EOL> iadd ( ra0 , ra0 , rb0 ) <EOL> wait_dma_load ( ) <EOL> setup_vpm_read ( nrows = <NUM_LIT:16> , Y = <NUM_LIT:0> , X = <NUM_LIT:0> , mode = '<STR_LIT>' ) <EOL> setup_vpm_write ( Y = <NUM_LIT:16> , X = <NUM_LIT:0> , mode = '<STR_LIT>' ) <EOL> for i in range ( <NUM_LIT:16> ) : <EOL> mov ( r0 , vpm ) <EOL> mov ( vpm , r0 ) <EOL> setup_dma_store ( Y = <NUM_LIT:16> , mode = '<STR_LIT>' , nrows = <NUM_LIT:16> ) <EOL> start_dma_store ( uniform ) <EOL> wait_dma_store ( ) <EOL> exit ( ) <EOL> def test_vertical_32bit_write ( ) : <EOL> with Driver ( ) as drv : <EOL> X = drv . alloc ( ( <NUM_LIT:64> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> X [ : ] = np . arange ( <NUM_LIT:64> * <NUM_LIT:16> ) . reshape ( <NUM_LIT:64> , <NUM_LIT:16> ) . astype ( '<STR_LIT>' ) <EOL> Y = drv . alloc ( ( <NUM_LIT:16> , <NUM_LIT:16> ) , dtype = '<STR_LIT>' ) <EOL> drv . execute ( <EOL> n_threads = <NUM_LIT:1> , <EOL> program = drv . program ( vertical_32bit_write ) , <EOL> uniforms = [ X . address , Y . address ] <EOL> ) <EOL> assert np . all ( X [ : <NUM_LIT:16> ] == Y ) </s>
