Talk:Optimized Merge Sort For DSP With Index Ordering

Comments on Optimized Merge Sort For DSP With Index Ordering -

Niall said ...
I have started trying to adapt this code for my purpose but there appear to be serious flaws with it. I am getting memory corruption somewhere around the scratch buffer when attempting to sort an array of around 200 elements. A quick look at the code reveals some more serious issues when attempting to sort larger arrays. For example the comments would suggest that it supports sorting of up to 4K elements, however since the static inputs and indexes arrays are only 128 elements each, there will be memory issues when attempting to sort any array of more than 512 elements.

--Niall 03:58, 4 January 2013 (CST)

Laurent gauthier said ...
Hi Niall,

I am the author of this code. As the code stands the 4K comment is misleading, the real limit is 4*128 = 512 elements.

You could sort 4K elements by bumping this 128 up to 1024.

The corruption you are seeing is probably due to the fact that your scratch buffer, used for SortIndex_merge32, is not quite large enough.

The scratch buffer for a 512 elements array should be of size 1536 (1.5K).

I have since worked on another sort function (combination of bitonic sort and merge sort) which appears to be faster but the code is not quite ready yet.

I would be interested in understanding what size of data-types and arrays are you targeting?

Feel free to contact me at l-gauthier@ti.com.

--Laurent gauthier 04:25, 4 January 2013 (CST)