Dynamic Multithreading and Matrix Multiplication using Cilk, Slides of Assembly Language Programming

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

2010/2011

Uploaded on 10/11/2011

lovefool
lovefool šŸ‡¬šŸ‡§

4.5

(21)

292 documents

1 / 72

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Dr. Bradley Kuszmaul, MIT. 6.189 IAP 2007 MIT
6.189 IAP 2007
Lecture 15
Cilk
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48

Partial preview of the text

Download Dynamic Multithreading and Matrix Multiplication using Cilk and more Slides Assembly Language Programming in PDF only on Docsity!

Dr. Bradley Kuszmaul, MIT.

6.189 IAP 2007 MIT

6.189 IAP 2007

Lecture 15

Cilk

Design and Analysis of

Dynamic Multithreaded

Algorithms

Bradley C. Kuszmaul MIT Computer Science and Artificial Intelligence Laboratory

A C language for dynamic multithreading with a provably good runtime system.

Cilk

Platforms

  • Sun UltraSPARC Enterprise
  • SGI Origin 2000
  • Compaq/Digital Alphaserver
  • Intel Pentium SMP’s

Applications

  • virus shell assembly
  • graphics rendering
  • n body simulation Socrates and Cilkchess Cilk automatically manages low level aspects of parallel execution, including protocols, load balancing, and scheduling.

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

B

A

C

D E

A A

B

A

C

A

C

D

A

C

E

Views of stack

A B C D E

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

  • Returned values can be incorporated into the parent frame using a delayed internal function called an

inlet:

  • Within an inlet, the other children of the parent frame to be terminated.^ abort^ keyword causes all
  • The sync^ SYNCHED would succeed.^ pseudovariable tests whether a
  • A Cilk library provides^ mutex locks^ for atomicity.

int y;inlet void foo (int x) { } if (x > y) y = x; …spawn foo(bar(z));

Outline

  • Theory and

Practice•A Chess

Lesson•Fun with Algorithms

  • Work Stealing
  • Opinion &

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

• TP ≄^ T 1 /P

• TP ≄^ Tāˆž

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, …

P = 3

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.

P = 3

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.

P = 3