I am doing a theoretical exercise for a class about a theoretical study of parallelizing the mergesort algorithm and the speed-up obtained for different amounts of cores.
I am using the following approach:
Using the merge sort tree, each level must be executed after the previous one, so they are sequential. However, tasks (divide or merge) of the same level are independent so they can be executed concurrently. This would make the maximum number of cores for which we can obtain some speed-up compared to the sequential version n/2 (n is the size of the input list).
However, the proposed solution states the following:
We when forming the lists, we spawn a thread for the computation of left in the MergeSort code, and spawn a thread for the computation of the right. If we consider this recursively, for n initial elements in the array, we can utilize 1 + 2 + 4 + 8 + 16 + …. + log2(n) processors to obtain speedup.In this question, log2(n) is the largest value of Y for which we can obtain any speedup without restructuring.
I don’t understand why it is log2(n) and not n/2. Could someone explain it to me?
tiredStudent is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.