The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: bozo on April 16, 2010, 03:23:44 AM

Title: Optimizing Sort and Search algorithms
Post by: bozo on April 16, 2010, 03:23:44 AM
ok, so most comp programming students will have at least encountered basic bubble sort (http://en.wikipedia.org/wiki/Bubble_sort) and binary search (http://en.wikipedia.org/wiki/Binary_search_algorithm) algorithms.

i was curious if there were any efforts to optimize any of these search (http://en.wikipedia.org/wiki/Category:Search_algorithms) and sort (http://en.wikipedia.org/wiki/Sorting_algorithm) algorithms..say for example using SSE2 if that were possible.

i've not researched the possibility of using sse2 (yet) to speed up sorting or searching but am curious to find out..anyone here ever try?
Title: Re: Optimizing Sort and Search algorithms
Post by: dedndave on April 16, 2010, 03:42:04 AM
i think it is the favorite pastime of some of these guys - lol
use the forum search tool - advanced search
you can narrow it down by specifying the author
try hutch--, drizz, jj2007, lingo
and a few others - all good programmers that like to do that stuff

EDIT - Hutch used to have a link for some Boyer-Moore stuff - i don't remember if it was SSE2 or not
anyways - the link is gone, now - maybe he can point you in the right direction

EDIT - this may be it...
http://www.movsd.com/bm.htm
Title: Re: Optimizing Sort and Search algorithms
Post by: hutch-- on April 18, 2010, 06:32:48 AM
A BM algo is probably the wrong algo type to try this on as there is little chance of any parallelism in its design. If memory is not a problem sorting can probably be done with some parallelism, particularly if you know what a pidgeonhole sort works like.

Strangely enough a bubble sort is not entirely useless, they perform well on nearly sorted data but from memory an insertion sort will still beat it in that context.
Title: Re: Optimizing Sort and Search algorithms
Post by: Neo on April 18, 2010, 08:25:46 AM
Comb sort is one of the few that actually vectorizes easily and is nlogn.  Unfortunately, some jerk has a patent application filed on vectorized comb sort: http://www.google.com/patents/about?id=dCOiAAAAEBAJ  :(  Hopefully the patent reviewers require them to tie it to the non-x86-based hardware they're describing it for, 'cause it's utterly ridiculous.
Title: Re: Optimizing Sort and Search algorithms
Post by: hutch-- on April 18, 2010, 09:25:16 AM
Just do a double ended comb sort (cocktail shaker bubble sort applied to a comb sort). They are OK in that they are near impossible to lock up with deliberately structured data but quick sorts generally havve the legs on them.
Title: Re: Optimizing Sort and Search algorithms
Post by: Neo on April 18, 2010, 10:42:42 AM
Good thinking!  I don't think that'd qualify as "invoking a comb sort algorithm", so then their patent's claims wouldn't cover it.  :bg