CMPS 5433 Programming Models ENIAC – Circa 1945
Programming Models – Overview Section 1.5.8 - Appendices CILK Plus (Appendix B) Thread Building Blocks (TBB) (Appendix C) Open MP Array Building Blocks (ArBB)
CILK Plus (Appendix B) Integrated with a C & C++ compiler; extends language with key words & array selection notation Parallel Cilk program is serial with keyword “annotations” designating allowable parallelism – not mandatory Strong guarantee of serial equivalence
CILK Plus (Appendix B) Integrated with a C & C++ compiler; extends language with key words & array selection notation Fork-Join: supports PP patterns & nesting Parallel Loops: regular PP Explicit Vectorization Hyperobjects: to support reduction Serial Semantics: if key words ignored AKA serial elision Efficient Load Balancing: via work-stealing
CILK Basics Original 2 Key words Asynchronous function call cilk_for cilk_spawn cilk_sync Asynchronous function call Using cilk_spawn cilk_for Programmer must determine independence Manages granularity appropriately
Example cilk_spawn - Fibonacci int fib (int n) { if (n<2) return n; else {int x,y; { x=fib(n-1); y=fin(n-2); return x+y; }} int fib (int n) { if (n<2) return n; else {int x,y; { x=cilk_spawn fib(n-1); y=fin(n-2); cilk_sync; return x+y; }} Parallel execution of 2 recursive calls