1
CS 240A :
Examples with Cilk++
Thanks to
Charles E. Leiserson for some of these slides
•
Divide & Conquer Paradigm for Cilk++
•
Solving recurrences
•
Sorting: Quicksort and Mergesort
•
Graph traversal: Breadth-First Search

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*
2
T
P
=
execution time on
P
processors
T
1
=
work
T
∞
=
span
*
*
Also called
critical-path length
or
computational depth
.
Speedup on p processors
∙
T
1
/T
p
Parallelism
∙
T
1
/T
∞
Work and Span (Recap)

3
Sorting
∙
Sorting is possibly the most frequently
executed operation in computing!
∙
Quicksort
is the fastest sorting algorithm
in practice with an average running time
of O(N log N),
(but O(N
2
) worst case
performance)
∙
Mergesort
has worst case performance of
O(N log N) for sorting N elements
∙
Both based on the recursive
divide-and-
conquer
paradigm

This
** preview**
has intentionally

**sections.**

*blurred***to view the full version.**

*Sign up*