Click here to Skip to main content
15,899,018 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Root Sorting Pin
Manfred Rudolf Bihy9-Nov-16 3:25
professionalManfred Rudolf Bihy9-Nov-16 3:25 
Questionwhich algorithm dominates f(n) or (g(n)) Pin
Member 127799066-Oct-16 7:11
Member 127799066-Oct-16 7:11 
AnswerRe: which algorithm dominates f(n) or (g(n)) Pin
Afzaal Ahmad Zeeshan6-Oct-16 7:32
professionalAfzaal Ahmad Zeeshan6-Oct-16 7:32 
GeneralRe: which algorithm dominates f(n) or (g(n)) Pin
Member 127799066-Oct-16 8:50
Member 127799066-Oct-16 8:50 
Questionquestion about cycle reduction problem Pin
Member 127782295-Oct-16 10:58
Member 127782295-Oct-16 10:58 
AnswerRe: question about cycle reduction problem Pin
Chris Losinger6-Oct-16 3:59
professionalChris Losinger6-Oct-16 3:59 
Questionbooth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
EZCodeProject27-Sep-16 13:45
EZCodeProject27-Sep-16 13:45 
AnswerRe: booth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
harold aptroot28-Sep-16 3:11
harold aptroot28-Sep-16 3:11 
That is correct (though usually you wouldn't select a random 1 but a particular 1, eg going from low to high or from high to low, you can use some additional tricks that way). Typical hardware implementations don't use this because it takes a lot of steps. They typically don't really use Booth's algorithm either, but some of the ideas are reused.

Yes it may take very few steps, but it can also take many steps (consider -1 * -1). It's bad enough already that it can take many steps, but the variation is really bad as well - throws a wrench into the usual pipelining and forwarding tricks. I suppose you might pipeline it by unrolling that entire loop, not very pleasant in terms of area, and then it has multiple exits which on top of being generally annoying means you can't do the usual thing of dispatching an instruction the cycle before its inputs will be ready and then rely on forwarding because you don't know when the multiplication ends until it does (ok you kind of could but it sucks).. it's horrible.

So other algorithms were invented, such as the Dadda multiplier and the Wallace tree. The idea (for both of them) is to first compute all pairwise single-bit products, then add them up using as many simple adders as possible (not full word adders, but the 3:2 compressor kind). That works out really well, because the first step (the single bit products) are all completely independent, and then you get a ton of product bits that you can reduce to fewer bits with independent full adders. It takes some number of layers of such adders, and the layers are dependent, but within a layer everything is parallel.

And then you still need a multi-bit adders in the end, where you'd use any fast adder design you like. You only need one of them so go crazy, unlike an unrolled russian peasant multiplication (RPM) where you'd need a metric ton of big adders (you could use ripple carry but then it sucks). So it's smaller and faster than unrolled RPM, and pipelinable unlike iterative RPM.

That's not the end though, for example you can use slightly larger modules that add up 5 bits into 3 in a particular way and build the same sort of layered tree out of those, which is a bit faster. And you can shuffle the connections of those modules around a bit so that you connect slow bits (the modules don't calculate their outputs all at the same time) to "fast inputs" (the delay through a module is not the same for every input) and vice versa to compensate the timings.

Now Booth's encoding, specifically the modified Booth encoding of radix-4 (if you go higher the circuits become annoying, not worth it), can be used to improve that even more, because you get fewer partial products .

Anyway, on a typical modern processor, multiplication takes maybe 3 to 5 times as much time as an addition. You can't match that with RPM unless there are very few bits set in the multiplicand, on average it would lose bit a huge margin.
GeneralRe: booth's algorithm vs russian peasant's algorithm for multiplying two binary numbers Pin
EZCodeProject28-Sep-16 7:08
EZCodeProject28-Sep-16 7:08 
QuestionTrying to get additions, deletions and changes between 2 file versions Pin
Christopher Cote26-Sep-16 2:56
Christopher Cote26-Sep-16 2:56 
AnswerRe: Trying to get additions, deletions and changes between 2 file versions Pin
Peter_in_278026-Sep-16 17:41
professionalPeter_in_278026-Sep-16 17:41 
GeneralRe: Trying to get additions, deletions and changes between 2 file versions Pin
Christopher Cote5-Dec-16 3:12
Christopher Cote5-Dec-16 3:12 
QuestionCompress items of size based on width and height Pin
jkirkerx20-Sep-16 13:59
professionaljkirkerx20-Sep-16 13:59 
SuggestionRe: Compress items of size based on width and height Pin
Maciej Los26-Sep-16 4:44
mveMaciej Los26-Sep-16 4:44 
AnswerRe: Compress items of size based on width and height Pin
Maciej Los26-Sep-16 12:01
mveMaciej Los26-Sep-16 12:01 
GeneralRe: Compress items of size based on width and height Pin
jkirkerx27-Sep-16 7:46
professionaljkirkerx27-Sep-16 7:46 
QuestionRe: Compress items of size based on width and height [Modified] Pin
Maciej Los27-Sep-16 8:39
mveMaciej Los27-Sep-16 8:39 
AnswerRe: Compress items of size based on width and height [Modified] Pin
jkirkerx27-Sep-16 10:42
professionaljkirkerx27-Sep-16 10:42 
GeneralRe: Compress items of size based on width and height [Modified] Pin
Maciej Los27-Sep-16 21:41
mveMaciej Los27-Sep-16 21:41 
GeneralRe: Compress items of size based on width and height [Modified] Pin
jkirkerx28-Sep-16 6:36
professionaljkirkerx28-Sep-16 6:36 
GeneralThis is what I released today for production testing Pin
jkirkerx30-Sep-16 7:26
professionaljkirkerx30-Sep-16 7:26 
GeneralRe: This is what I released today for production testing Pin
Maciej Los4-Oct-16 9:22
mveMaciej Los4-Oct-16 9:22 
GeneralRe: This is what I released today for production testing Pin
jkirkerx4-Oct-16 9:30
professionaljkirkerx4-Oct-16 9:30 
GeneralRe: This is what I released today for production testing Pin
Maciej Los4-Oct-16 9:34
mveMaciej Los4-Oct-16 9:34 
GeneralRe: This is what I released today for production testing Pin
jkirkerx4-Oct-16 9:37
professionaljkirkerx4-Oct-16 9:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.