SlideShare uma empresa Scribd logo
1 de 31
Baixar para ler offline
Cilk: An Efficient Multithreaded
Runtime System
Mohanadarshan - 148241N
Shareek Ahamed - 148201T
Authors: Robert D. Blumofe, Christopher F. Joerg, Bradley C. Kuszmaul,
Charles E. Leiserson, Keith H. Randall and Yuli Zhou
MIT Laboratory for Computer Science, Cambridge
Agenda
● What is Cilk ?
● Why Cilk ?
● Introduction
● Scheduling & Work Stealing
● How it Works ?
● Fibonacci Calculation
● Performance in Cilk Applications
● Current Usage
● Related Works
● Cilk Plus
● Conclusion
What is Cilk ?
● Cilk is a C-based runtime system for multi-threaded parallel programming.
● Cilk guarantees efficient and predictable performance
● Lightweight fork and join
○ Own scheduler (Work Stealing Scheduler)
● Proofs for Performance and Space
● World Class chess programs like StarTech, *Socrates, and Cilkchess are
developed by Cilk.
Why Cilk ?
Multithreading requires to implement dynamic, asynchronous, concurrent programs.
● A multithreaded system provides the programmer with a means to create,
synchronize, and schedule threads.
● Cilk reduces the complexity of implementing multithreaded programs.
● Programmer don’t have to worry about the complexity, only need to identify
region for parallelism.
● Cilk optimizes:
➔ Total work
➔ Critical path
Introduction
Introduction (contd..)
● Cilk program is a set of procedures
● A procedure is a sequence of threads
● Cilk threads are:
○ Represented by nodes in the dag
○ Non-blocking: run to completion: no waiting or suspension: atomic units
of execution
● Threads can spawn child threads
○ downward edges connect a parent to its children
Introduction (contd..)
● A child & parent can run concurrently.
○ Non-blocking threads --> a child cannot return a value to its parent.
○ The parent spawns a successor that receives values from its children
● A thread & its successor are parts of the same Cilk procedure.
○ connected by horizontal arcs
● Children’s returned values are received before their successor begins:
○ They constitute data dependencies.
○ Connected by curved arcs
How it Works ?
● spawn T (k, ?x)
- spawn a child thread
● spawn_next T(k, ?x)
- A successor thread is spawned the same way as a child, except the keyword spawn_next is used
● send_argument( k, value )
- sends value to the argument slot of a waiting closure specified by continuation k.
spawn_next
send_argumentspawn
Parent
Child
Successor
Scheduling
Every Processor has own
- Scheduler
- Ready-Queue
Invoked when thread ends
- Schedules or steals another thread
Work Stealing
● Cilk uses run time scheduling called work stealing.
● Works well on dynamic, asynchronous, MIMD-style programs.
● Work-stealing:
○ a process with no work selects a victim from which to get work.
○ it gets the shallowest thread in the victim’s spawn tree.
● In Cilk, thieves choose the victims randomly.
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
Work Stealing (contd..)
void func f( )
{
work;
spawn g( );
work;
work;
work;
….
work;
}
thread void func g( )
{
work;
work;
work;
}
Worker1 Worker2
How it Works ? (Example :Fibonacci)
thread int fib ( cont int k, int n ) {
if ( n < 2 ) send_argument( k, n );
else { cont int x, y;
spawn_next sum ( k, ?x, ?y );
spawn fib ( x, n - 1 );
spawn fib ( y, n - 2 );
}
}
thread sum ( cont int k, int x, int y ) {
send_argument ( k, x + y );
}
Fibonacci Calculation
Ready Queue
if ( ! readyDeque .isEmpty() )
take deepest thread
else
steal shallowest thread from
readyDeque of randomly selected
victim
Performance in Cilk Application
Experiments were ran on a CM5 supercomputer to document the efficiency of
the work-stealing scheduler.
Tested Applications
1. fib (fibonacci)
2. queens (placing N queens on a N x N chessboard)
3. pfold (protein-folding)
4. ray (ray-tracing algorithm for graphics rendering)
5. Knary (at each node runs an empty “for” loop )
6. Socrates (parallel chess program, uses the Jamboree search algorithm)
Performance in Cilk Application (contd..)
Tserial
⇒ Time taken to run C program (gcc)
T1
⇒ Time taken to run 1-processor Cilk program
T ∞
⇒ Cilk computation timestamping each thread
Tp
⇒ Processor execution time of the Cilk program
Tserial
⇒ Efficiency of the Cilk program
T1
⇒ Efficiency is close to 1 for programs with moderately long threads
Cilk overhead is small.
Performance of Cilk on various applications
Performance in Cilk Application
Finding 33rd
Fibonacci Number
Example applications
Virus shell assembly
Graphics rendering
n-body simulation
Heuristic search
Dense and sparse matrix computations
Friction-stir welding simulation
Artificial evolution
Related Works
EARTH (An Efficient Architecture for Running THreads)
EARTH supports an adaptive event Driven multithreaded execution model,
containing two thread levels:
● threaded procedures
● fibers
A threaded procedure is invoked asynchronously forking a parallel thread of
execution.
A threaded procedure is statically divided into fibers fine grain threads
communicating through dataflow-like synchronization operations.
EARTH vs. CILK
EARTH Model CILK Model
Note: - EARTH has it origin in static dataflow model
- In comparison features of CILK Model is similar to the EARTH model
Cilk Plus
● Maintained by Intel ©
● Only 3 keywords
– Cilk_spawn
– Cilk_sync
– Cilk_for
● Available in Intel Compilers & in gcc branch.
More info - http://www.cilkplus.org/
https://www.youtube.com/watch?v=mv5i3MEvX98
Cilk Plus
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);
}
}
- Easier to implement than Cilk!
- Less complex than Cilk!
Conclusion
● Pros
➔ Guaranteed runtime & space usage
➔ Good performance
➔ Critical Path is short compared to total work
➔ Low Overhead
➔ Very Simple to Use
● Cons
➔ Only suitable for tree like computations
➔ Continuations are confusing
➔ No shared memory
Thank You ...

Mais conteúdo relacionado

Mais procurados

Objectivec vs swift
Objectivec vs swiftObjectivec vs swift
Objectivec vs swift
Nisr Mohamed
 

Mais procurados (20)

Solving Nonograms In Parallel
Solving Nonograms In ParallelSolving Nonograms In Parallel
Solving Nonograms In Parallel
 
Reactive cocoa 101
Reactive cocoa 101Reactive cocoa 101
Reactive cocoa 101
 
Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)Optimizing with persistent data structures (LLVM Cauldron 2016)
Optimizing with persistent data structures (LLVM Cauldron 2016)
 
Swift vs Objective-C
Swift vs Objective-CSwift vs Objective-C
Swift vs Objective-C
 
Objectivec vs swift
Objectivec vs swiftObjectivec vs swift
Objectivec vs swift
 
(chapter 8) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 8) A Concise and Practical Introduction to Programming Algorithms in...(chapter 8) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 8) A Concise and Practical Introduction to Programming Algorithms in...
 
Algorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O AnalysisAlgorithm Complexity & Big-O Analysis
Algorithm Complexity & Big-O Analysis
 
Using Akka Futures
Using Akka FuturesUsing Akka Futures
Using Akka Futures
 
OCL 2.4. (... 2.5)
OCL 2.4. (... 2.5)OCL 2.4. (... 2.5)
OCL 2.4. (... 2.5)
 
Safe navigation in OCL
Safe navigation in OCLSafe navigation in OCL
Safe navigation in OCL
 
Ijcet 06 08_003
Ijcet 06 08_003Ijcet 06 08_003
Ijcet 06 08_003
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Re-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for XtextRe-engineering Eclipse MDT/OCL for Xtext
Re-engineering Eclipse MDT/OCL for Xtext
 
IIUG 2016 Gathering Informix data into R
IIUG 2016 Gathering Informix data into RIIUG 2016 Gathering Informix data into R
IIUG 2016 Gathering Informix data into R
 
A Journey From Objective C to Swift - Chromeinfotech
A Journey From Objective C to Swift - ChromeinfotechA Journey From Objective C to Swift - Chromeinfotech
A Journey From Objective C to Swift - Chromeinfotech
 
Evaluation of prefix expression with example
Evaluation of prefix expression with exampleEvaluation of prefix expression with example
Evaluation of prefix expression with example
 
[Question Paper] Advanced Java (60:40 Pattern) [October / 2013]
[Question Paper] Advanced Java (60:40 Pattern) [October / 2013][Question Paper] Advanced Java (60:40 Pattern) [October / 2013]
[Question Paper] Advanced Java (60:40 Pattern) [October / 2013]
 
Transparent Latent GAN
Transparent Latent GANTransparent Latent GAN
Transparent Latent GAN
 
Distributed Graph Algorithms
Distributed Graph AlgorithmsDistributed Graph Algorithms
Distributed Graph Algorithms
 
D422 7-2 string hadeling
D422 7-2  string hadelingD422 7-2  string hadeling
D422 7-2 string hadeling
 

Semelhante a Cilk - An Efficient Multithreaded Runtime System

Semelhante a Cilk - An Efficient Multithreaded Runtime System (20)

Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using AutomataModeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
Modeling the Behavior of Threads in the PREEMPT_RT Linux Kernel Using Automata
 
Threads
ThreadsThreads
Threads
 
Async fun
Async funAsync fun
Async fun
 
Open cl programming using python syntax
Open cl programming using python syntaxOpen cl programming using python syntax
Open cl programming using python syntax
 
OpenCL programming using Python syntax
OpenCL programming using Python syntax OpenCL programming using Python syntax
OpenCL programming using Python syntax
 
Giorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrencyGiorgio zoppi cpp11concurrency
Giorgio zoppi cpp11concurrency
 
Effective java item 80 and 81
Effective java   item 80 and 81Effective java   item 80 and 81
Effective java item 80 and 81
 
cb streams - gavin pickin
cb streams - gavin pickincb streams - gavin pickin
cb streams - gavin pickin
 
Go and Uber’s time series database m3
Go and Uber’s time series database m3Go and Uber’s time series database m3
Go and Uber’s time series database m3
 
Twins: OOP and FP
Twins: OOP and FPTwins: OOP and FP
Twins: OOP and FP
 
Mit cilk
Mit cilkMit cilk
Mit cilk
 
Distributed implementation of a lstm on spark and tensorflow
Distributed implementation of a lstm on spark and tensorflowDistributed implementation of a lstm on spark and tensorflow
Distributed implementation of a lstm on spark and tensorflow
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrency
 
Scikit-Learn: Machine Learning in Python
Scikit-Learn: Machine Learning in PythonScikit-Learn: Machine Learning in Python
Scikit-Learn: Machine Learning in Python
 
Exciting JavaScript - Part I
Exciting JavaScript - Part IExciting JavaScript - Part I
Exciting JavaScript - Part I
 
Return of c++
Return of c++Return of c++
Return of c++
 
(3) cpp procedural programming
(3) cpp procedural programming(3) cpp procedural programming
(3) cpp procedural programming
 
GCF
GCFGCF
GCF
 
Async Web Frameworks in Python
Async Web Frameworks in PythonAsync Web Frameworks in Python
Async Web Frameworks in Python
 
Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017Thinking Functionally - John Stevenson - Codemotion Rome 2017
Thinking Functionally - John Stevenson - Codemotion Rome 2017
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Último (20)

tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - KeynoteWSO2Con204 - Hard Rock Presentation - Keynote
WSO2Con204 - Hard Rock Presentation - Keynote
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

Cilk - An Efficient Multithreaded Runtime System

  • 1. Cilk: An Efficient Multithreaded Runtime System Mohanadarshan - 148241N Shareek Ahamed - 148201T Authors: Robert D. Blumofe, Christopher F. Joerg, Bradley C. Kuszmaul, Charles E. Leiserson, Keith H. Randall and Yuli Zhou MIT Laboratory for Computer Science, Cambridge
  • 2. Agenda ● What is Cilk ? ● Why Cilk ? ● Introduction ● Scheduling & Work Stealing ● How it Works ? ● Fibonacci Calculation ● Performance in Cilk Applications ● Current Usage ● Related Works ● Cilk Plus ● Conclusion
  • 3. What is Cilk ? ● Cilk is a C-based runtime system for multi-threaded parallel programming. ● Cilk guarantees efficient and predictable performance ● Lightweight fork and join ○ Own scheduler (Work Stealing Scheduler) ● Proofs for Performance and Space ● World Class chess programs like StarTech, *Socrates, and Cilkchess are developed by Cilk.
  • 4. Why Cilk ? Multithreading requires to implement dynamic, asynchronous, concurrent programs. ● A multithreaded system provides the programmer with a means to create, synchronize, and schedule threads. ● Cilk reduces the complexity of implementing multithreaded programs. ● Programmer don’t have to worry about the complexity, only need to identify region for parallelism. ● Cilk optimizes: ➔ Total work ➔ Critical path
  • 6. Introduction (contd..) ● Cilk program is a set of procedures ● A procedure is a sequence of threads ● Cilk threads are: ○ Represented by nodes in the dag ○ Non-blocking: run to completion: no waiting or suspension: atomic units of execution ● Threads can spawn child threads ○ downward edges connect a parent to its children
  • 7. Introduction (contd..) ● A child & parent can run concurrently. ○ Non-blocking threads --> a child cannot return a value to its parent. ○ The parent spawns a successor that receives values from its children ● A thread & its successor are parts of the same Cilk procedure. ○ connected by horizontal arcs ● Children’s returned values are received before their successor begins: ○ They constitute data dependencies. ○ Connected by curved arcs
  • 8. How it Works ? ● spawn T (k, ?x) - spawn a child thread ● spawn_next T(k, ?x) - A successor thread is spawned the same way as a child, except the keyword spawn_next is used ● send_argument( k, value ) - sends value to the argument slot of a waiting closure specified by continuation k. spawn_next send_argumentspawn Parent Child Successor
  • 9. Scheduling Every Processor has own - Scheduler - Ready-Queue Invoked when thread ends - Schedules or steals another thread
  • 10. Work Stealing ● Cilk uses run time scheduling called work stealing. ● Works well on dynamic, asynchronous, MIMD-style programs. ● Work-stealing: ○ a process with no work selects a victim from which to get work. ○ it gets the shallowest thread in the victim’s spawn tree. ● In Cilk, thieves choose the victims randomly.
  • 11. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 12. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 13. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 14. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 15. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 16. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 17. Work Stealing (contd..) void func f( ) { work; spawn g( ); work; work; work; …. work; } thread void func g( ) { work; work; work; } Worker1 Worker2
  • 18. How it Works ? (Example :Fibonacci) thread int fib ( cont int k, int n ) { if ( n < 2 ) send_argument( k, n ); else { cont int x, y; spawn_next sum ( k, ?x, ?y ); spawn fib ( x, n - 1 ); spawn fib ( y, n - 2 ); } } thread sum ( cont int k, int x, int y ) { send_argument ( k, x + y ); }
  • 20. Ready Queue if ( ! readyDeque .isEmpty() ) take deepest thread else steal shallowest thread from readyDeque of randomly selected victim
  • 21. Performance in Cilk Application Experiments were ran on a CM5 supercomputer to document the efficiency of the work-stealing scheduler. Tested Applications 1. fib (fibonacci) 2. queens (placing N queens on a N x N chessboard) 3. pfold (protein-folding) 4. ray (ray-tracing algorithm for graphics rendering) 5. Knary (at each node runs an empty “for” loop ) 6. Socrates (parallel chess program, uses the Jamboree search algorithm)
  • 22. Performance in Cilk Application (contd..) Tserial ⇒ Time taken to run C program (gcc) T1 ⇒ Time taken to run 1-processor Cilk program T ∞ ⇒ Cilk computation timestamping each thread Tp ⇒ Processor execution time of the Cilk program Tserial ⇒ Efficiency of the Cilk program T1 ⇒ Efficiency is close to 1 for programs with moderately long threads Cilk overhead is small.
  • 23. Performance of Cilk on various applications
  • 24. Performance in Cilk Application Finding 33rd Fibonacci Number
  • 25. Example applications Virus shell assembly Graphics rendering n-body simulation Heuristic search Dense and sparse matrix computations Friction-stir welding simulation Artificial evolution
  • 26. Related Works EARTH (An Efficient Architecture for Running THreads) EARTH supports an adaptive event Driven multithreaded execution model, containing two thread levels: ● threaded procedures ● fibers A threaded procedure is invoked asynchronously forking a parallel thread of execution. A threaded procedure is statically divided into fibers fine grain threads communicating through dataflow-like synchronization operations.
  • 27. EARTH vs. CILK EARTH Model CILK Model Note: - EARTH has it origin in static dataflow model - In comparison features of CILK Model is similar to the EARTH model
  • 28. Cilk Plus ● Maintained by Intel © ● Only 3 keywords – Cilk_spawn – Cilk_sync – Cilk_for ● Available in Intel Compilers & in gcc branch. More info - http://www.cilkplus.org/ https://www.youtube.com/watch?v=mv5i3MEvX98
  • 29. Cilk Plus 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); } } - Easier to implement than Cilk! - Less complex than Cilk!
  • 30. Conclusion ● Pros ➔ Guaranteed runtime & space usage ➔ Good performance ➔ Critical Path is short compared to total work ➔ Low Overhead ➔ Very Simple to Use ● Cons ➔ Only suitable for tree like computations ➔ Continuations are confusing ➔ No shared memory