
































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lecture note from mit on dynamic multithreading using cilk, a programming language for parallel computing. The notes cover the theory and practice of multithreading, a chess lesson, and the implementation of matrix multiplication using cilk. The document also discusses the concept of work-stealing scheduler and its performance.
Typology: Slides
1 / 72
This page cannot be seen from the preview
Don't miss anything!

































































Dr. Bradley Kuszmaul, MIT.
6.189 IAP 2007 MIT
Lecture 15
Cilk
Bradley C. Kuszmaul MIT Computer Science and Artificial Intelligence Laboratory
A C language for dynamic multithreading with a provably good runtime system.
Cilk
Platforms
Applications
Fibonacci int fib (int n) {if (n<2) return (n); else {int x,y; x = fib(n-1);y = fib(n-2); } return (x+y); } C elision
cilk int fib (int n) { cilkif (n<2) return (n); else {int x,y; x =y = spawn fib(n-1);spawn fib(n-2);spawnspawn sync;return (x+y);sync; } }
Cilk code
Cilk is a faithfulfaithful extension of C. A Cilk programās serial elision serial elision is always a legal implementation of Cilk semantics. Cilk provides nono new data types.
Cactus Stack
Views of stack
Cilk supports Cās rule for pointers: A pointer to stack space can be passed from parent to child, but not from child to parent. (Cilk also supports malloc .)
Cilkās cactus stack supports several views in parallel.
Advanced Features
inlet:
int y;inlet void foo (int x) { } if (x > y) y = x; ā¦spawn foo(bar(z));
Outline
Practiceā¢A Chess
Lessonā¢Fun with Algorithms
Conclusion
Algorithmic Complexity TP = execution time on Measures P processors
Algorithmic Complexity TP = execution time on Measures P processors
T 1 = workwork Tā = critical pathcritical path
Algorithmic Complexity TP = execution time on Measures P processors
Lower Bounds
T 1 = workwork Tā = critical pathcritical path
Greedy Scheduling
Theorem [Graham & Brent]: There exists an execution with TP ⤠T 1 /P + Tā.
Greedy Scheduling
Theorem [Graham & Brent]: There exists an execution with TP ⤠T 1 /P + Tā. Proof. At each time step, ā¦
Greedy Scheduling
Theorem [Graham & Brent]: There exists an execution with TP ⤠T 1 /P + Tā. Proof. At each time step, if at least P tasks are ready, execute P of them.
Greedy Scheduling
Theorem [Graham & Brent]: There exists an execution with TP ⤠T 1 /P + Tā.
If fewer than P tasks are ready, ā¦
Proof. At each time step, if at least P tasks are ready, execute P of them.