Scheduling Parallel Program with Work Stealing

Scheduling Parallel Program with Work Stealing

Scheduling parallel program with Work stealing Vincent Danjean, [email protected] MOAIS project, INRIA Grenoble Rhône-Alpes Seminar at UFRGS, Porto Alegre, Brazil Moais Positioning Grid MPSoC Cluster Multicore KAAPI GPU To mutually adapt application and scheduling ArTeCS / oct 2009 2 jeudi 12 novembre 2009 Moais Positioning Grid MPSoC Cluster Multicore KAAPI GPU To mutually adapt application and scheduling ArTeCS / oct 2009 2 jeudi 12 novembre 2009 MOAIS group • Funded by INRIA, CNRS, UJF, INPG • Part of LIG (Laboratoire d’Informatique de Grenoble) - http://moais.imag.fr • Jean-Louis Roch: project Leader • 10 researchers • 18 PhD students ArTeCS / oct 2009 3 jeudi 12 novembre 2009 Research actions • Scheduling [Denis Trystram] - multi-objectif criteria, malleable and moldable model • Parallel Algorithms [Jean-Louis Roch] - adaptive algorithms • Virtual Reality [Bruno Rafn] - interactive simulation • Runtime for HPC [Thierry Gautier] - grid and cluster, multi-processor ArTeCS / oct 2009 4 jeudi 12 novembre 2009 Outline • Athapascan / Kaapi a software stack • Foundation of work stealing • Controls of the overheads • Experiments with STL algorithms ArTeCS / oct 2009 5 jeudi 12 novembre 2009 Goal • Write once, run anywhere... with guaranteed performance • Problem: heterogeneity - variations of the environment (#cores, speed, failure...) - irregular computation ArTeCS / oct 2009 6 jeudi 12 novembre 2009 KAAPI Overview Application KAAPI middleware parallel architecture ArTeCS / oct 2009 7 jeudi 12 novembre 2009 KAAPI Overview Application Model: abstract representation KAAPI middleware Algorithms: scheduling, fault tolerance protocol, ... parallel architecture ArTeCS / oct 2009 7 jeudi 12 novembre 2009 KAAPI Overview “causal connexions” Application Model: abstract representation KAAPI middleware Algorithms: scheduling, fault tolerance protocol, ... Performance parallel architecture ArTeCS / oct 2009 7 jeudi 12 novembre 2009 KAAPI Overview Application Model: abstract representation KAAPI middleware Algorithms: scheduling, fault tolerance protocol, ... Performance parallel architecture ArTeCS / oct 2009 7 jeudi 12 novembre 2009 API: Athapascan • Global address space - Creation of objects in a global address space with ‘shared’ keyword • Task = function call - Creation with ‘Fork’ keyword (≠ unix fork) ~ Cilk spawn - Tasks only communicate through shared objects - Task declares access mode (read, write, concurrent write, exclusive) to shared objects • Automatic scheduling - Work stealing or graph partitioning ➡‘Sequential’ semantics • C++ library, not a language extension - C language extension + compiler was prototyped ArTeCS / oct 2009 8 jeudi 12 novembre 2009 Fibonacci example struct Fibonacci { void operator()( int n, a1::Shared_w<int> result ) { if (n < 2) result.write( n ); else { a1::Shared<int> subresult1; a1::Shared<int> subresult2; a1::Fork<Fibonacci>()(n-1, subresult1); a1::Fork<Fibonacci>()(n-2, subresult2); a1::Fork<Sum>()(result, subresult1, subresult2); } } }; struct Sum { void operator()( a1::Shared_w<int> result, a1::Shared_r<int> sr1, a1::Shared_r<int> sr2 ) { result.write( sr1.read() + sr2.read() ); } } ArTeCS / oct 2009 9 jeudi 12 novembre 2009 Fibonacci example struct Fibonacci { void operator()( int n, a1::Shared_w<int> result ) { w->r if (n < 2) result.write( n ); else { dependencies a1::Shared<int> subresult1; a1::Shared<int> subresult2; a1::Fork<Fibonacci>()(n-1, subresult1); a1::Fork<Fibonacci>()(n-2, subresult2); a1::Fork<Sum>()(result, subresult1, subresult2); } } }; struct Sum { void operator()( a1::Shared_w<int> result, a1::Shared_r<int> sr1, a1::Shared_r<int> sr2 ) { result.write( sr1.read() + sr2.read() ); } } ArTeCS / oct 2009 9 jeudi 12 novembre 2009 Semantics & C++ Elision struct Fibonacci { void operator()( int n, a1::Shared_w<int> result ) { if (n < 2) result.write( n ); else { a1::Shared<int> subresult1; a1::Shared<int> subresult2; a1::Fork<Fibonacci>()(n-1, subresult1); a1::Fork<Fibonacci>()(n-2, subresult2); a1::Fork<Sum>()(result, subresult1, subresult2); } } }; struct Sum { void operator()( a1::Shared_w<int> result, a1::Shared_r<int> sr1, a1::Shared_r<int> sr2 ) { result.write( sr1.read() + sr2.read() ); } } ArTeCS / oct 2009 10 jeudi 12 novembre 2009 Semantics & C++ Elision struct Fibonacci { void operator()( int n, a1::Shared_w<int& result ) { if (n < 2) result =rite( n ); else { a1::Shared<int> subresult1; a1::Shared<int> subresult2; a1::Fork<Fibonacci>()(n-1, subresult1); a1::Fork<Fibonacci>()(n-2, subresult2); a1::Fork<Sum>()(result, subresult1, subresult2); } } }; struct Sum { void operator()( a1::Shared_w<int& result, a1::Shared_r<int> sr1, a1::Shared_r<int> sr2 ) { result =rite( sr1.read() + sr2.read() ); } } ArTeCS / oct 2009 11 jeudi 12 novembre 2009 Online construction Fibonacci result Time ArTeCS / oct 2009 12 jeudi 12 novembre 2009 Online construction Fibonacci Fibonacci Fibonacci subres2 subres1 result Sum result Time ArTeCS / oct 2009 12 jeudi 12 novembre 2009 Online construction Fibonacci Fibonacci Fibonacci Fibonacci Fibonacci subres2 subres1 subres1.1 subres1.2 result Sum Fibonacci Sum result subres2 subres1 Sum result Time ArTeCS / oct 2009 12 jeudi 12 novembre 2009 Data Flow Graph Interests One abstract representation for •- Scheduling - data flow graph ⇒ precedences graph ⇒ dependences graph • classical numerical kernel ⇒ partitioning the dependences graph - Explicit data transfer - data to be transfered is explicit in the data flow graph • automatic overlapping communication by computation - Original Fault Tolerant Protocols - TIC [IET05, Europar05, TDSC09] • coupling scheduling by work stealing with abstract representation - CCK [TSI07, MCO08] • coordinated checkpointing with partial restart after failure - Sabotage Tolerance [PDP09] - dynamically adapt the execution to sabotage • Drawback: complexity to manage it ArTeCS / oct 2009 13 jeudi 12 novembre 2009 Stack management • Stack based allocation - Tasks and accesses to shared data are pushed in a stack - close to the management of the C function call stack - O(1) allocation time - O(#parameters) initialization time Shared<int> sr1 Shared<int> sr1 a1::Shared<int> subresult1; Fibonacci, sr1 a1::Shared<int> subresult2; a1::Fork<Fibonacci>()(n-1, subresult1); Fibonacci, sr2 a1::Fork<Fibonacci>()(n-2, subresult2); Sum, r, sr1, sr2 a1::Fork<Sum>()(result, subresult1, subresult2); Stack growth ArTeCS / oct 2009 14 jeudi 12 novembre 2009 Execution model • A (dynamic) set of UNIX processes - communication by active message - Each process is multithreaded - The root process forks the main task • Threads inside processes are either - Performing work - excute tasks - idle and participate to scheduling -then it try to steal work (task) from other threads (work-stealing algorithm) ArTeCS / oct 2009 15 jeudi 12 novembre 2009 2 Level Scheduling K-Thread Idle K-Processor process process K-Processor KAAPI Scheduler other process Active Message OS scheduler over TCP/IP, Myrinet OS scheduler and SSH OS CPU CPU CPU CPU CPU ArTeCS / oct 2009 16 jeudi 12 novembre 2009 Outline • Athapascan / Kaapi a software stack • Foundation of work stealing • Controls of the overheads • Experiments with STL algorithms ArTeCS / oct 2009 17 jeudi 12 novembre 2009 Principle of work stealing Working thread Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Steal request Return result Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Steal request Return result Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Steal request Return result Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Principle of work stealing Working thread Steal request Return result Idle thread Idle thread ArTeCS / oct 2009 18 jeudi 12 novembre 2009 Work stealing queue • Task: basic unit of computation • Each thread has its own work queue - push( task ) -> () : push a task used by the - pop() -> task : pop a task owner thread - push / pop: LIFO order • A idle thread can steal task from a victim thread’s workqueue - steal() -> task : steal a task from the queue used by the - push / steal: FIFO order thief thread Random selection of victim threads • ArTeCS / oct 2009 19 jeudi 12 novembre 2009 Assumption/Definitions • Fork/Join recursive parallel program - (formally: strict multithreaded computation) • Notation: - Tseq : “sequential work” - T1 : execution time on 1 core of the parallel program, called “work” - T∞ : time of execution on ∞ cores, called the “critical path” or the depth - Tp : time of execution on P cores - P : the number of processors ArTeCS / oct 2009 20 jeudi 12 novembre 2009 Remarks def • P∞ = T1 / T∞ - available parallelism (maximum speedup) - e.g. Fibonacci(30) = 83040 -2 -7 - T1 = 5.285*10 s, T∞ = 3.08*10 s - P∞ ≈ 171591 •T1 / Tseq - measure the work overhead - the creation of tasks - the work queue management (push/pop) ArTeCS / oct 2009 21 jeudi 12 novembre 2009 Theoretical bound - Using work stealing scheduler with random selection of victim, the expected time on P processors is: Tp = O(Tseq / P + T∞) - The expected number of steal requests per thread Xp is: Xp = O(T∞) - [Blumofe, Leiseron, Focs 94, PPoPP 95], [Arora, Blumofe, Plaxton, SPAA 98], ..

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    120 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us