I believe cilk_sync would be called just after the if-else block, to indicate that the entire sublist is sorted and can be returned.
Olorin
slide 6 says that cilk_sync is implicitly called at the end of functions with cilk_spawn calls
kayvonf
@olorin is correct.
sanchuah
The code seems not correct. It only sorts the segmented chunks, but the whole array is not sorted.
kayvonf
@sanchuah: You should assume that partition operates by placing all elements less than the pivot (middle) in array indices below middle (and all elements greater than the pivot in indices greater than middle. This is a common quicksort implementation.
So when do we call
cilk_sync
in this program?I believe cilk_sync would be called just after the if-else block, to indicate that the entire sublist is sorted and can be returned.
slide 6 says that
cilk_sync
is implicitly called at the end of functions withcilk_spawn
calls@olorin is correct.
The code seems not correct. It only sorts the segmented chunks, but the whole array is not sorted.
@sanchuah: You should assume that
partition
operates by placing all elements less than the pivot (middle
) in array indices belowmiddle
(and all elements greater than the pivot in indices greater thanmiddle
. This is a common quicksort implementation.