<s> """<STR_LIT>""" <EOL> from __future__ import print_function <EOL> import pycuda . autoinit <EOL> import pycuda . gpuarray as gpuarray <EOL> import pycuda . driver as drv <EOL> import numpy as np <EOL> import skcuda . linalg as culinalg <EOL> import skcuda . misc as cumisc <EOL> culinalg . init ( ) <EOL> import string <EOL> demo_types = [ np . float32 , np . complex64 ] <EOL> if cumisc . get_compute_capability ( pycuda . autoinit . device ) >= <NUM_LIT> : <EOL> demo_types . extend ( [ np . float64 , np . complex128 ] ) <EOL> for t in demo_types : <EOL> print ( '<STR_LIT>' + str ( np . dtype ( t ) ) ) <EOL> if np . iscomplexobj ( t ( ) ) : <EOL> a = np . asarray ( np . random . rand ( <NUM_LIT:10> , <NUM_LIT:5> ) + <NUM_LIT> * np . random . rand ( <NUM_LIT:10> , <NUM_LIT:5> ) , t ) <EOL> b = np . asarray ( np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) + <NUM_LIT> * np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) , t ) <EOL> c = np . asarray ( np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) + <NUM_LIT> * np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) , t ) <EOL> else : <EOL> a = np . asarray ( np . random . rand ( <NUM_LIT:10> , <NUM_LIT:5> ) , t ) <EOL> b = np . asarray ( np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) , t ) <EOL> c = np . asarray ( np . random . rand ( <NUM_LIT:5> , <NUM_LIT:5> ) , t ) <EOL> a_gpu = gpuarray . to_gpu ( a ) <EOL> b_gpu = gpuarray . to_gpu ( b ) <EOL> c_gpu = gpuarray . to_gpu ( c ) <EOL> temp_gpu = culinalg . dot ( a_gpu , b_gpu ) <EOL> d_gpu = culinalg . dot ( temp_gpu , c_gpu ) <EOL> temp_gpu . gpudata . free ( ) <EOL> del ( temp_gpu ) <EOL> print ( '<STR_LIT>' , np . allclose ( np . dot ( np . dot ( a , b ) , c ) , d_gpu . get ( ) ) ) <EOL> print ( '<STR_LIT>' + str ( np . dtype ( t ) ) ) <EOL> if np . iscomplexobj ( t ( ) ) : <EOL> d = np . asarray ( np . random . rand ( <NUM_LIT:5> ) + <NUM_LIT> * np . random . rand ( <NUM_LIT:5> ) , t ) <EOL> e = np . asarray ( np . random . rand ( <NUM_LIT:5> ) + <NUM_LIT> * np . random . rand ( <NUM_LIT:5> ) , t ) <EOL> else : <EOL> d = np . asarray ( np . random . rand ( <NUM_LIT:5> ) , t ) <EOL> e = np . asarray ( np . random . rand ( <NUM_LIT:5> ) , t ) <EOL> d_gpu = gpuarray . to_gpu ( d ) <EOL> e_gpu = gpuarray . to_gpu ( e ) <EOL> temp = culinalg . dot ( d_gpu , e_gpu ) <EOL> print ( '<STR_LIT>' , np . allclose ( np . dot ( d , e ) , temp ) ) </s>
