#NEWLINE# def test_pycuda_only( ) : #NEWLINE# #INDENT# 'Run pycuda only example to test that pycuda works.' #NEWLINE# from pycuda.compiler import SourceModule #NEWLINE# mod = SourceModule ( '\n__global__ void multiply_them(float *dest, float *a, float *b)\n{\n  const int i = threadIdx.x;\n  dest[i] = a[i] * b[i];\n}\n' ) #NEWLINE# multiply_them = mod . get_function ( 'multiply_them' ) #NEWLINE# a = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) #NEWLINE# b = numpy . random . randn ( 100 ) . astype ( numpy . float32 ) #NEWLINE# dest = numpy . zeros_like ( b ) #NEWLINE# multiply_them ( drv . Out ( dest ) , drv . In ( a ) , drv . In ( b ) , block = ( 400 , 1 , 1 ) , grid = ( 1 , 1 ) ) #NEWLINE# assert ( dest == ( a * b ) ) . all ( )