<s> from __future__ import print_function , absolute_import <EOL> import numpy as np <EOL> import numba . unittest_support as unittest <EOL> from numba import hsa <EOL> def copy_kernel ( out , inp ) : <EOL> i = hsa . get_global_id ( <NUM_LIT:0> ) <EOL> if i < out . size : <EOL> out [ i ] = inp [ i ] <EOL> class TestAutoJit ( unittest . TestCase ) : <EOL> def test_autojit_kernel ( self ) : <EOL> kernel = hsa . jit ( copy_kernel ) <EOL> inp = np . arange ( <NUM_LIT:10> ) <EOL> out = np . zeros_like ( inp ) <EOL> kernel . forall ( out . size ) ( out , inp ) <EOL> np . testing . assert_equal ( inp , out ) <EOL> def test_autojit_device ( self ) : <EOL> @ hsa . jit ( device = True ) <EOL> def inner ( a , b ) : <EOL> return a + b <EOL> @ hsa . jit <EOL> def outer ( A , B ) : <EOL> i = hsa . get_global_id ( <NUM_LIT:0> ) <EOL> if i < A . size : <EOL> A [ i ] = inner ( A [ i ] , B [ i ] ) <EOL> A = np . arange ( <NUM_LIT:10> ) <EOL> Aorig = A . copy ( ) <EOL> B = np . arange ( <NUM_LIT:10> ) <EOL> outer . forall ( A . size ) ( A , B ) <EOL> self . assertFalse ( np . all ( Aorig == A ) ) <EOL> np . testing . assert_equal ( Aorig + B , A ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> unittest . main ( ) </s>
