#NEWLINE# def main( ) : #NEWLINE# #INDENT# targets = [ 'cpu' , 'stream' , 'parallel' ] #NEWLINE# for t in targets : #NEWLINE# #INDENT# if ( t in sys . argv [ 1 : ] ) : #NEWLINE# #INDENT# targets = [ t ] #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# for target in targets : #NEWLINE# #INDENT# print ( '== Target' , target ) #NEWLINE# vect_sum = vectorize ( [ f4 ( f4 , f4 ) , f8 ( f8 , f8 ) ] , target = target ) ( sum ) #NEWLINE# A = np . fromfile ( 'inputA.dat' , dtype = np . float32 ) #NEWLINE# B = np . fromfile ( 'inputB.dat' , dtype = np . float32 ) #NEWLINE# assert ( A . shape == B . shape ) #NEWLINE# assert ( A . dtype == B . dtype ) #NEWLINE# assert ( len ( A . shape ) == 1 ) #NEWLINE# N = target . shape [ 0 ] #NEWLINE# D = np . empty ( A . shape , dtype = A . dtype ) #NEWLINE# print ( 'Data size' , N ) #NEWLINE# ts = time ( ) #NEWLINE# D = vect_sum ( A , B ) #NEWLINE# te = time ( ) #NEWLINE# total_time = ( te - ts ) #NEWLINE# print ( ( 'Execution time %.4f' % total_time ) ) #NEWLINE# print ( ( 'Throughput %.4f' % ( N / total_time ) ) ) #NEWLINE# if ( '-verify' in sys . argv [ 1 : ] ) : #NEWLINE# #INDENT# check_answer ( D , A , B , C )