Martian 07



CPU vs GPU

If you could remember my last post about a self-driving car where I did a basic operation of multiply and sum of two arrays weights(W) and example(X):

1-314-26-350-10-1201-7


00001211001513050700000012001014

[w1*x1 + w2*x2...... + w15*x15 + w16*x16]

[ 1*00 + -3*00 +...1*10 + -7*14 ] = 68



If we breakdown this equation, we have to do 16 multiplications and 15 addition, in total 30 CPU operations to complete this one, whereas in GPU it needed only 3 steps, let's see:


1-314-26-350-10-1201-7


00001211001513050700000012001014

W × XT

[ 1 , 16 ] × [ 16 , 1 ]

[ 1 , 1 ]

68



Nifty right! just in 3 steps, Let's do this for 6 examples, stacked into rows of a single table:



  • 00000504001014030212110204040100
  • 00010404021112020314100004050000
  • 00080800001212000010100000080800
  • 00000614000612100015201106110500
  • 00101000001111000012120000111100
  • 10081000122012000015100600080600




























1-314-26-350-10-1201-7
00000504001014030212110204040100
00010404021112020314100004050000
00080800001212000010100000080800
00000614000612100015201106110500
00101000001111000012120000111100
10081000122012000015100600080600


×












=

394550915269

W × XT

[ 1 , 16 ] × [ 16 , 6 ]

[ 1 , 6 ]

Still, in 3 steps, whetever be the number of examples. if you do the same thing with CPU it 180 steps as one example takes 30 steps and there are 6 of them so.