Attachment:Avxbench.ijs

From J Wiki
Jump to navigation Jump to search

require 'jfiles'

make_data=:3 : 0 jcreate 'data_avx'

'C c'=: 10000000 1000 b=: (<.-:#a)+ c ?. c [ a=: C ?. C NB. intsr (<'intsr';a;b;c) jappend 'data_avx' b=: (c?.#a){a [ a=: C ?@$ <:2^63 NB. intbr (<'intbr';a;b;c) jappend 'data_avx' b=: (c?.#a){a [ a=: >,.~":each <"0 [C ?@$ <:2^63 NB. char (<'char';a;b;c) jappend 'data_avx' b=: 0.1+(c?.#a){a [ a=: 0.1+C ?@$ <:2^63 NB. float (<'float';a;b;c) jappend 'data_avx'

'C c'=: 100000 1000 b=: (<.-:#a)+ c ?. c [ a=: C ?. C NB. intsr (<'intsr';a;b;c) jappend 'data_avx' b=: (c?.#a){a [ a=: C ?@$ <:2^63 NB. intbr (<'intbr';a;b;c) jappend 'data_avx' b=: (c?.#a){a [ a=: >,.~":each <"0 [C ?@$ <:2^63 NB. char (<'char';a;b;c) jappend 'data_avx' b=: 0.1+(c?.#a){a [ a=: 0.1+C ?@$ <:2^63 NB. float (<'float';a;b;c) jappend 'data_avx'

im=: %. rm=: 1000 1000 ?.@$0 (<'inv';im;rm) jappend 'data_avx' )

timespacex =: 6!:2 , 7!:2@]

tests=: 0 : 0 a i. a a i. b b i. a a e. b b e. a a (+/@:e.) b a (e. i. 1:) b ~.a ~:a /:a /:~a ) tests=: LF cut tests

testsf=: 0 : 0 a i.!.0 a a i.!.0 b b i.!.0 a a e.!.0 b b e.!.0 a a (+/@:(e.!.0)) b a (e.!.0 i.!.0 1:) b ~.a ~:a /:a /:~a ) testsf=: LF cut testsf

run_tests=: 3 : 0 jcreate 'test_avx_',y for_i. i.4 do. 'name a b c'=: >jread 'data_avx';i r=. (10 timespacex ])&.>tests (<(<name),<r) jappend 'test_avx_',y end. r=. (10 timespacex ])&.>testsf (<(<name,'0'),<r) jappend 'test_avx_',y

for_i. 4+i.4 do. 'name a b c'=: >jread 'data_avx';i r=. (10 timespacex ])&.>tests (<(<name),<r) jappend 'test_avx_',y end. r=. (10 timespacex ])&.>testsf (<(<name,'0'),<r) jappend 'test_avx_',y

'name im rm'=: >jread 'data_avx';8 (<(<name),<10 timespacex 'im +/ . * rm') jappend 'test_avx_',y )

tit=: 'intsr';'intbr';'char';'float';'float0';'test'

show_tests=: 4 :0 r=. ((#tests),0)$0 for_i. i.5 do. j=.;(0{])&.>>1{ >jread x;i k=.;(0{])&.>>1{ >jread y;i r=.r,.k%j end. s=. ((#tests),0)$0 for_i. 5+i.5 do. j=.;(0{])&.>>1{ >jread x;i k=.;(0{])&.>>1{ >jread y;i s=.s,.k%j end. j=.0{;>1{ >jread x;10 k=.0{;>1{ >jread y;10 t=.k%j

r0=.((6 j. 2)":])&.><"0 r r1=.tit,r0,.tests s0=.((6 j. 2)":])&.><"0 s s1=.tit,s0,.tests t1=.(<'matrix multiply'),.<(6 j. 2)":t

r1;s1;t1 )


NB. make_data NB. run_tests '_j64avx_qt_' NB. Run on AVX J NB. run_tests '_j64_805_qt_' NB. Run on J805 NB. 'test_avx_j64avx_qt_' show_tests 'test_avx_j64_805_qt_'