1 / 98

Grade School Again: A Parallel Perspective

Grade School Again: A Parallel Perspective. Plus/Minus Binary (Extended Binary). Base 2: Each digit can be -1, 0, 1, Example: 1 -1 -1 = 4 -2 -1 = 1. One weight for each power of 3. Left = “negative”. Right = “positive”. How to add 2 n-bit numbers. * *. * *. * *. * *. * *. * *. * *.

ross
Download Presentation

Grade School Again: A Parallel Perspective

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Grade School Again:A Parallel Perspective

  2. Plus/Minus Binary(Extended Binary) • Base 2: Each digit can be -1, 0, 1, • Example: • 1 -1 -1 = 4 -2 -1 = 1

  3. One weight for each power of 3. Left = “negative”. Right = “positive”

  4. How to add 2 n-bit numbers. ** ** ** ** ** ** ** ** ** ** ** +

  5. How to add 2 n-bit numbers. ** * ** ** ** ** ** ** ** ** ** * ** +

  6. How to add 2 n-bit numbers. ** * ** ** ** ** ** ** ** ** * ** * ** * +

  7. How to add 2 n-bit numbers. ** * ** ** ** ** ** ** ** * ** * ** * * ** * +

  8. How to add 2 n-bit numbers. ** * ** ** ** ** ** ** * ** * ** * * ** * * ** * +

  9. How to add 2 n-bit numbers. ** * * * * ** * * ** * * ** * * ** * * ** * *** * * ** * * ** * * ** * * ** * +

  10. How to add 2 n-bit numbers. ** * * * * ** * * ** * * ** * * ** * * ** * *** * * ** * * ** * * ** * * ** * + Time < kn is proportional to n Let k be the maximum time that it takes you to do

  11. The time grow linearly with input size. time kn # of bits in numbers

  12. If n people agree to help you add two n bit numbers, it is not obvious that they can finish faster than if you had done it yourself.

  13. Is it possible to add two n bit numbers in less than linear parallel-time? Darn those carries.

  14. Fast parallel addition is no obvious in usual binary. But it is amazingly direct in Extended Binary!

  15. Extended binary means base 2 allowing digits to be from {-1, 0, 1}. We can call each digit a “trit”.

  16. n people can add 2, n-trit, plus/minus binary numbers in constant time!

  17. An Addition Party to Add 110-1 to -111-1 -

  18. -1 1 1 1 0 -1 1 -1 1 An Addition Party Invite n people to add two n-trit numbers Assign one person to each trit position

  19. An Addition Party -2 0 1 2 1 0 1 -1 Each person should add the two input trits in their possession. Problem: 2 and -2 are not allowed in the final answer.

  20. Pass Left 1 1 -2 0 1 0 -1 0 -1 If you have a 1 or a 2 subtract 2 from yourself and pass a 1 to the left. (Nobody keeps more than 0) Add in anything that is given to you from the right. (Nobody has more than a 1)

  21. After passing left -2 1 1 1 -1 0 1 There will never again be any 2s as everyone had at most 0 and received at most 1 more

  22. Passing left again -1 -1 1 1 1 1 0 0 1 If you have a -1 or -2 add 2 to yourself and pass a -1 to the left (Nobody keeps less than 0)

  23. After passing left again 0 1 1 0 0 1 -1 No -2s anymore either. Everyone kept at least 0 and received At most -1.

  24. -1 0 1 1 1 0 0 1 1 0 -1 1 1 -1 -1 1 =

  25. Caution: Parties and Algorithms Do not Mix 1 1 1 0 1 1

  26. Is there a fast parallel way to convert an Extended Binary number into a standard binary number?

  27. Not obvious: Sub-linear addition in standard Binary. Sub-linear EB to Binary

  28. Let’s reexamine grade school addition from the view of a computer circuit.

  29. Grade School Addition 1011111100 • 1011111101 • 1000000110 + 10100000011

  30. Grade School Addition c5c4c3c2 c1 • a4a3a2 a1 a0 • b4b3b2 b1 b0 + s1

  31. ai bi ai bi ci+1 ci ci si si an-1 bn-1 a1 b1 a0 b0 … 0 cn … c1 sn-1 s1 s0 Ripple-carry adder

  32. ai bi ci+1 ci si Logical representation of binary: 0 = false, 1 = true • s1 = (a1 XOR b1) XOR c1 • c2 = (a1 AND b1) OR (a1 AND c1) OR (b1 AND c1)

  33. ai bi ci ai bi ci+1 ci si XOR AND AND AND OR XOR OR ci+1 si

  34. 0 Ripple-carry adder How long to add two n bit numbers? Propagation time through the circuit will be q(n)

  35. Circuits compute things in parallel. We can think of the propagation delay as PARALLEL TIME.

  36. Is it possible to add two n bit numbers in less than linear parallel-time?

  37. I suppose the EB addition algorithm could be helpful somehow.

  38. Plus/minus binary means base 2 allowing digits to be from {-1, 0, 1}. We can call each digit a “trit”.

  39. n people can add 2, n-trit, plus/minus binary numbers in constant time!

  40. -1 1 1 1 0 -1 -1 1 1

  41. Can we still do addition quickly in the standard representation?

  42. Yes, but first a neat idea… Instead of adding two numbers to make one number, let’s think about adding 3 numbers to make 2 numbers.

  43. Carry-Save Addition • The sum of three numbers can be converted into the sum of 2 numbers in constant parallel time! 1100111011 1011111101 1000000110 + +

  44. 1111000000 + 10001111110 Carry-Save Addition • The sum of three numbers can be converted into the sum of 2 numbers in constant parallel time! 1100111011 1011111101 1000000110 + + XOR Carries

  45. Cool! So if we if represent x as a+b, and y as c+d, then can add x,y using two of these (this is basically the same as that plus/minus binary thing). (a+b+c)+d=(e+f)+d=g+h

  46. Even in standard representation, this is really useful for multiplication.

  47. * * * * * * * * X 10110111 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Grade School Multiplication

  48. We need to add n 2n-bit numbers:a1, a2, a3,…, an

  49. + + A tree of carry-save adders a1 an + + + + + + + + + + + Add the last two

  50. + + A tree of carry-save adders + + + + + + + + + + + Add the last two T(n)  log3/2(n) + [last step]

More Related