User Tools

Site Tools


projects:matrix_multiplier

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
projects:matrix_multiplier [2013/12/19 21:35]
gredelston [How could someone else do it?]
projects:matrix_multiplier [2013/12/20 08:55] (current)
jlangowitz [How could someone else do it?]
Line 4: Line 4:
 ===== What did we do? ===== ===== What did we do? =====
  
 +Matrix multipliers!! We created a hardware implementation for a matrix multiplier, and also implemented the multiplier in assembly. In this particular case, we limited our multiplier to 4x4 matrices, where each element is a 32-bit unsigned integer; however, one could reasonably abstract to a more extensible multiplier.
 ===== Why did we do it? ===== ===== Why did we do it? =====
 +Comparison of software and hardware:​\\ ​
 +We wanted to look at a hardware and software implementation of matrix multiplication to see if it is worth putting a hardware matrix multiplier into a processor in order to more easily preform linear algebra operations. Based on the size of the dedicated matrix multiplication hardware and its marginally small speed increase compared to a purely software implementation,​ we have determined that it is almost never a good idea to have dedicated matrix multipliers,​ unless that is the only operation you ever need to perform. The hardware implementation takes 16 clock cycles to compute a 4x4 matrix product, plus the amount of time to load the matrix data from memory, which should be constant with either method. The assembly code emits about 1100 instructions for the same math in MIPS, but will load the data equally fast as for the hardware, in about 32 instructions,​ assuming one instruction per load, giving a total of 1132 to 48 instructions. This means we only get about a speed increase of about 23x for matrix multiplication,​ and we are totally monopolizing 4 multiply units and 3 32 bit adders which could either be removed or used to perform other operations that are used more than matrix multiplication more quickly. Additionally,​ the way we are storing our matrices means we either need to use 48 registers to contain all 3 matrices at once, which is totally unfeasible given the size of most register files, or we need to be constantly loading data in and out of memory, just like a straight software implementation. Our matrix multiplier also has the issue of only multiplying 4x4 matrices, so if you have different sized matrices, it is useless, but adjusting software to handle bigger matrices is nowhere near as problematic. In the end, while designing a matrix multiplier was a fun exercise, it should forever remain just an exercise, as this is a case in which well-designed software with flexible hardware trumps large, fast, but extremely specific hardware components.\\ ​
  
 ===== How did we do it? ===== ===== How did we do it? =====
 +{{ :​projects:​matrixmultiplier.png?​800 |}} 
 +{{ :​projects:​matrixregister.png?​800 |}} 
 +{{ :​projects:​dotter.png?​800 |}} 
 +{{ :​projects:​32bitmultiply.png?​800 |}} 
 +{{ :​projects:​incrementor.png?​800 |}}
 ===== How could someone else do it? ===== ===== How could someone else do it? =====
  
Line 92: Line 99:
  li $t1, 4  li $t1, 4
  bne $a1, $t1, nextElement  bne $a1, $t1, nextElement
 +
 +Additional resources:​\\ ​
 +The black boxes in our circuit diagrams do not go all the way down to the gate level. If you are not sure how the following low-level components work and want more information,​ check out their Wikipedia pages here:​\\ ​
 +Latches and Flip Flops: http://​en.wikipedia.org/​wiki/​Flip-flop_(electronics)\\ ​
 +Adders: http://​en.wikipedia.org/​wiki/​Adder_(electronics)\\ ​
 +Muxes and Demuxes: http://​en.wikipedia.org/​wiki/​Multiplexor\\ ​
 +If you have any questions about our project, contact us at jlangowitz@gmail.com ​ or gredelston@gmail.com. Feel  free to use our code or circuit diagrams for your purposes, and if for some reason you feel like actually implementing a matrix multiplier based on our schematics, please let us know how it works out.
  
projects/matrix_multiplier.1387506944.txt.gz · Last modified: 2013/12/19 21:35 by gredelston