1 / 11

Cilk

Cilk. Chao Huang CS498LVK. Introduction. A multithreaded parallel programming language Effective for exploiting dynamic, asynchronous parallelism (Chess games) Developed by the Supercomputing Technologies Group under Prof. Charles E. Leiserson at MIT. Cilk Keywords.

coby
Download Presentation

Cilk

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cilk Chao Huang CS498LVK

  2. Introduction • A multithreaded parallel programming language • Effective for exploiting dynamic, asynchronous parallelism (Chess games) • Developed by the Supercomputing Technologies Group under Prof. Charles E. Leiserson at MIT

  3. Cilk Keywords • spawn: indicates the procedure can operate in parallel with other code; the scheduler decides whether to execute it on a new thread or not • sync: indicates that the current procedure cannot proceed until all previous spawned procedures have completed and returned • C elision of a Cilk program is a valid C program

  4. Example (1) cilk int fib (int n) { if (n < 2) return n; else { int x, y; x = spawn fib (n-1); y = spawn fib (n-2); sync; return (x+y); } }

  5. Cilk Keywords • inlet: identifies a function inside the procedure as an inlet • An inlet is a C function internal to a Cilk procedure which handles the returned results of a spawned procedure call • Allows more complex way of handling return value in the parent’s frame

  6. Example (2) cilk int fib (int n) { int x = 0; inlet void sum (int result) { x += result; return; } if (n<2) return n; else { sum(spawn fib (n-1)); sum(spawn fib (n-2)); sync; return (x); } }

  7. Example (3) cilk int fib (int n) { int x = 0; if (n<2) return n; else { /* implicit inlets */ x += spawn fib (n-1); x += spawn fib (n-2); sync; return (x); } }

  8. Cilk Keywords • abort: indicates that other procedures that have been spawned off by the parent procedure can be safely aborted • Useful in speculative work such as space searching

  9. Cilk Keywords cilk void baz(int n); cilk void foo(int n) { inlet void bar() { abort; } bar(spawn baz(17)); spawn baz(28); sync; }

  10. Implementation • Scheduling scheme: work-stealing • Ready procedures are put on a double-ended queue • The processor restores suspended procedures from the end of the deque they have been stored • Underloaded processors steal work from other processors’ queues at the other end of the deque

  11. Important Applications • Parallel chess programs • Cilkchess • *Socrates • Parallel gomoku

More Related