Previous | Next --- Slide 9 of 45
Back to Lecture Thumbnails
landuo

So when do we call cilk_sync in this program?

ekr

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.