sortingsorting-network

Sorting networks costs and delay


From what I read I could not figure out how the cost and delay are calculated.

I have posted my example bellow Example


Solution

  • From what I can see, your answer is correct.

    Cost is the total number compare exchanges done in the sorting network. I believe here it's 28.

    Delay is the number of stages that must be done in sequence, i.e. have data dependencies. In the example there is a delay of 13.

    Why do we care about the difference? Cost represents the amount of work we have to do in a serial implementation however the benefit of using a sorting network is that many of the compare-exchanges can be done in parallel. When you have as much parallelism available as there are compare-exchanges in a single stage, you can calculate that stage concurrently.

    In a perfectly parallel system, the latency of the algorithm is going to be related to the delay rather than the cost. In a completely serial system, the latency is going to be related to the cost rather than the delay.