Скачать презентацию AMPI and Charm L V Kale Sameer Kumar Скачать презентацию AMPI and Charm L V Kale Sameer Kumar

124e639c77cf35e9b1a71dac0a294c8a.ppt

  • Количество слайдов: 155

AMPI and Charm++ L. V. Kale Sameer Kumar Orion Sky Lawlor charm. cs. uiuc. AMPI and Charm++ L. V. Kale Sameer Kumar Orion Sky Lawlor charm. cs. uiuc. edu 2003/10/27 1

Overview n Introduction to Virtualization n What it is, how it helps Charm++ Basics Overview n Introduction to Virtualization n What it is, how it helps Charm++ Basics n AMPI Basics and Features n AMPI and Charm++ Features n 2

Our Mission and Approach n To enhance Performance and Productivity in programming complex parallel Our Mission and Approach n To enhance Performance and Productivity in programming complex parallel applications n n Approach: Application Oriented yet CS centered research n n n Performance: scalable to thousands of processors Productivity: of human programmers Complex: irregular structure, dynamic variations Develop enabling technology, for a wide collection of apps. Develop, use and test it in the context of real applications How? n n Develop novel Parallel programming techniques Embody them into easy to use abstractions So, application scientist can use advanced techniques with ease Enabling technology: reused across many apps 3

What is Virtualization? 4 What is Virtualization? 4

Virtualization n Virtualization is abstracting away things you don’t care about E. g. , Virtualization n Virtualization is abstracting away things you don’t care about E. g. , OS allows you to (largely) ignore the physical memory layout by providing virtual memory n Both easier to use (than overlays) and can provide better performance (copy-on-write) n n Virtualization allows runtime system to optimize beneath the computation 5

Virtualized Parallel Computing n Virtualization means: using many “virtual processors” on each real processor Virtualized Parallel Computing n Virtualization means: using many “virtual processors” on each real processor A virtual processor may be a parallel object, an MPI process, etc. n Also known as “overdecomposition” n n Charm++ and AMPI: Virtualized programming systems Charm++ uses migratable objects n AMPI uses migratable MPI processes n 6

Virtualized Programming Model User writes code in terms of communicating objects n System maps Virtualized Programming Model User writes code in terms of communicating objects n System maps objects System implementation to processors n User View 7

Decomposition for Virtualization n Divide the computation into a large number of pieces n Decomposition for Virtualization n Divide the computation into a large number of pieces n n Larger than number of processors, maybe even independent of number of processors Let the system map objects to processors Automatically schedule objects n Automatically balance load n 8

Benefits of Virtualization 9 Benefits of Virtualization 9

Benefits of Virtualization n Better Software Engineering n n Message Driven Execution n Adaptive Benefits of Virtualization n Better Software Engineering n n Message Driven Execution n Adaptive overlap between computation and communication Predictability of execution Flexible and dynamic mapping to processors n n Logical Units decoupled from “Number of processors” Flexible mapping on clusters Change the set of processors for a given job Automatic Checkpointing Principle of Persistence 10

Why Message-Driven Modules ? SPMD and Message-Driven Modules (From A. Gursoy, Simplified expression of Why Message-Driven Modules ? SPMD and Message-Driven Modules (From A. Gursoy, Simplified expression of message-driven programs and quantification of their impact on performance, Ph. D Thesis, Apr 1994. ) 11

Example: Multiprogramming Two independent modules A and B should trade off the processor while Example: Multiprogramming Two independent modules A and B should trade off the processor while waiting for messages 12

Example: Pipelining Two different processors 1 and 2 should send large messages in pieces, Example: Pipelining Two different processors 1 and 2 should send large messages in pieces, to allow pipelining 13

Cache Benefit from Virtualization FEM Framework application on eight physical processors 14 Cache Benefit from Virtualization FEM Framework application on eight physical processors 14

Principle of Persistence n Once the application is expressed in terms of interacting objects: Principle of Persistence n Once the application is expressed in terms of interacting objects: n n Object communication patterns and computational loads tend to persist over time In spite of dynamic behavior • Abrupt and large, but infrequent changes (e. g. : mesh refinements) • Slow and small changes (e. g. : particle migration) n Parallel analog of principle of locality n n Just a heuristic, but holds for most CSE applications Learning / adaptive algorithms Adaptive Communication libraries Measurement based load balancing 15

Balancing n n Based on Principle of persistence Runtime instrumentation n n Measures communication Balancing n n Based on Principle of persistence Runtime instrumentation n n Measures communication volume and computation time Measurement based load balancers n n Use the instrumented data-base periodically to make new decisions Many alternative strategies can use the database • Centralized vs distributed • Greedy improvements vs complete reassignments • Taking communication into account • Taking dependences into account (More complex) 16

Example: Expanding Charm++ Job This 8 -processor AMPI job expands to 16 processors at Example: Expanding Charm++ Job This 8 -processor AMPI job expands to 16 processors at step 600 by migrating objects. The number of virtual processors stays the same. 17

Virtualization in Charm++ & AMPI n Charm++: Parallel C++ with Data Driven Objects called Virtualization in Charm++ & AMPI n Charm++: Parallel C++ with Data Driven Objects called Chares n Asynchronous method invocation n n AMPI: Adaptive MPI Familiar MPI 1. 1 interface n Many MPI threads per processor n Blocking calls only block thread; not processor n 18

Support for Virtualization Degree of Virtualization Virtual AMPI Charm++ CORBA MPI RPC None TCP/IP Support for Virtualization Degree of Virtualization Virtual AMPI Charm++ CORBA MPI RPC None TCP/IP Message Passing Asynch. Methods Communication and Synchronization Scheme 19

Charm++ Basics (Orion Lawlor) 20 Charm++ Basics (Orion Lawlor) 20

Charm++ Parallel library for Object. Oriented C++ applications n Messaging via remote method calls Charm++ Parallel library for Object. Oriented C++ applications n Messaging via remote method calls (like CORBA) n n n Communication “proxy” objects Methods called by scheduler n System determines who runs next Multiple objects per processor n Object migration fully supported n n Even with broadcasts, reductions 21

Charm++ Remote Method Calls Interface (. ci) file array[1 D] foo { entry void Charm++ Remote Method Calls Interface (. ci) file array[1 D] foo { entry void foo(int problem. No); entry void bar(int x); }; n To call a method on a remote C++ object foo, use the local “proxy” C++ object CProxy_foo generated from the interface file: Generated class In a. C file CProxy_foo some. Foo=. . . ; some. Foo[i]. bar(17); i’th object n method and parameters This results in a network message, and eventually to a call to the real object’s method: In another. C file void foo: : bar(int x) {. . . 22

Charm++ Startup Process: Main Interface (. ci) file Special startup object module my. Module Charm++ Startup Process: Main Interface (. ci) file Special startup object module my. Module { array[1 D] foo { entry foo(int problem. No); entry void bar(int x); } mainchare my. Main { entry my. Main(int argc, char **argv); } }; In a. C file Called at startup Generated class #include “my. Module. decl. h” class my. Main : public CBase_my. Main { my. Main(int argc, char **argv) { int n. Elements=7, i=n. Elements/2; CProxy_foo f=CProxy_foo: : ck. New(2, n. Elements); f[i]. bar(3); } }; #include “my. Module. def. h” 23

Charm++ Array Definition Interface (. ci) file array[1 D] foo { entry foo(int problem. Charm++ Array Definition Interface (. ci) file array[1 D] foo { entry foo(int problem. No); entry void bar(int x); } In a. C file class foo : public CBase_foo { public: // Remote calls foo(int problem. No) {. . . } void bar(int x) {. . . } // Migration support: foo(Ck. Migrate. Message *m) {} void pup(PUP: : er &p) {. . . } }; 24

Charm++ Features: Object Arrays n Applications are written as a set of communicating objects Charm++ Features: Object Arrays n Applications are written as a set of communicating objects User’s view A[0] A[1] A[2] A[3] A[n] 25

Charm++ Features: Object Arrays n Charm++ maps those objects onto processors, routing messages as Charm++ Features: Object Arrays n Charm++ maps those objects onto processors, routing messages as needed User’s view A[0] A[1] A[2] A[3] A[n] System view A[0] A[3] 26

Charm++ Features: Object Arrays n Charm++ can re-map (migrate) objects for communication, load balance, Charm++ Features: Object Arrays n Charm++ can re-map (migrate) objects for communication, load balance, fault tolerance, etc. User’s view A[0] A[1] A[2] A[3] A[n] System view A[0] A[3] 27

Charm++ Handles: n Decomposition: left to user n n Mapping n n Which processor Charm++ Handles: n Decomposition: left to user n n Mapping n n Which processor does each task Scheduling (sequencing) n n What to do in parallel On each processor, at each instant Machine dependent expression n Express the above decisions efficiently for the particular parallel machine 28

Charm++ and AMPI: Portability n Runs on: n Any machine with MPI • Origin Charm++ and AMPI: Portability n Runs on: n Any machine with MPI • Origin 2000 • IBM SP PSC’s Lemieux (Quadrics Elan) n Clusters with Ethernet (UDP) n Clusters with Myrinet (GM) n Even Windows! n SMP-Aware (pthreads) n Uniprocessor debugging mode n 29

Build Charm++ and AMPI n Download from website n n Build Charm++ and AMPI Build Charm++ and AMPI n Download from website n n Build Charm++ and AMPI n n n http: //charm. cs. uiuc. edu/download. html . /build [compile flags] To build Charm++ and AMPI: • . /build AMPI net-linux -g Compile code using charmc Portable compiler wrapper n Link with “-language charm++” n n Run code using charmrun 30

Other Features Broadcasts and Reductions n Runtime creation and deletion n n n. D Other Features Broadcasts and Reductions n Runtime creation and deletion n n n. D and sparse array indexing Library support (“modules”) n Groups: per-processor objects n Node Groups: per-node objects n Priorities: control ordering n 31

AMPI Basics 32 AMPI Basics 32

Comparison: Charm++ vs. MPI n Advantages: Charm++ n Modules/Abstractions are centered on application data Comparison: Charm++ vs. MPI n Advantages: Charm++ n Modules/Abstractions are centered on application data structures • Not processors n n Abstraction allows advanced features like load balancing Advantages: MPI n n Highly popular, widely available, industry standard “Anthropomorphic” view of processor • Many developers find this intuitive n But mostly: n n MPI is a firmly entrenched standard Everybody in the world uses it 33

AMPI: “Adaptive” MPI interface, for C and Fortran, implemented on Charm++ n Multiple “virtual AMPI: “Adaptive” MPI interface, for C and Fortran, implemented on Charm++ n Multiple “virtual processors” per physical processor n n Implemented as user-level threads • Very fast context switching-- 1 us n n E. g. , MPI_Recv only blocks virtual processor, not physical Supports migration (and hence load balancing) via extensions to MPI 34

AMPI: User’s View 7 MPI threads 35 AMPI: User’s View 7 MPI threads 35

AMPI: System Implementation 7 MPI threads 2 Real Processors 36 AMPI: System Implementation 7 MPI threads 2 Real Processors 36

Example: Hello World! #include <stdio. h> #include <mpi. h> int main( int argc, char Example: Hello World! #include #include int main( int argc, char *argv[] ) { int size, myrank; MPI_Init(&argc, &argv); MPI_Comm_size(MPI_COMM_WORLD, &size); MPI_Comm_rank(MPI_COMM_WORLD, &myrank); printf( "[%d] Hello, parallel world!n", myrank ); MPI_Finalize(); return 0; } 37

Example: Send/Recv. . . double a[2] = {0. 3, 0. 5}; double b[2] = Example: Send/Recv. . . double a[2] = {0. 3, 0. 5}; double b[2] = {0. 7, 0. 9}; MPI_Status sts; if(myrank == 0){ MPI_Send(a, 2, MPI_DOUBLE, 1, 17, MPI_COMM_WORLD); }else if(myrank == 1){ MPI_Recv(b, 2, MPI_DOUBLE, 0, 17, MPI_COMM_WORLD, &sts); }. . . 38

How to Write an AMPI Program Write your normal MPI program, and then… n How to Write an AMPI Program Write your normal MPI program, and then… n Link and run with Charm++ n n Compile and link with charmc • charmc -o hello. c -language ampi • charmc -o hello 2 hello. f 90 -language ampif n Run with charmrun • charmrun hello 39

How to Run an AMPI program n Charmrun A portable parallel job execution script How to Run an AMPI program n Charmrun A portable parallel job execution script n Specify number of physical processors: +p. N n Specify number of virtual MPI processes: +vp. N n Special “nodelist” file for net-* versions n 40

AMPI Extensions Process Migration n Asynchronous Collectives n Checkpoint/Restart n 41 AMPI Extensions Process Migration n Asynchronous Collectives n Checkpoint/Restart n 41

AMPI and Charm++ Features 42 AMPI and Charm++ Features 42

Object Migration 43 Object Migration 43

Object Migration How do we move work between processors? n Application-specific methods n E. Object Migration How do we move work between processors? n Application-specific methods n E. g. , move rows of sparse matrix, elements of FEM computation n Often very difficult for application n n Application-independent methods E. g. , move entire virtual processor n Application’s problem decomposition doesn’t change 44 n

How to Migrate a Virtual Processor? Move all application state to new processor n How to Migrate a Virtual Processor? Move all application state to new processor n Stack Data n Subroutine variables and calls n Managed by compiler n n Heap Data Allocated with malloc/free n Managed by user n Global Variables n Open files, environment variables, etc. (not handled yet!) n 45

Stack Data n The stack is used by the compiler to track function calls Stack Data n The stack is used by the compiler to track function calls and provide temporary storage Local Variables n Subroutine Parameters n C “alloca” storage n n Most of the variables in a typical application are stack data 46

Migrate Stack Data n Without compiler support, cannot change stack’s address n n Because Migrate Stack Data n Without compiler support, cannot change stack’s address n n Because we can’t change stack’s interior pointers (return frame pointer, function arguments, etc. ) Solution: “isomalloc” addresses Reserve address space on every processor for every thread stack n Use mmap to scatter stacks in virtual memory efficiently n Idea comes from PM 2 n 47

Migrate Stack Data Processor A’s Memory Processor B’s Memory 0 x. FFFFFFFF Thread 1 Migrate Stack Data Processor A’s Memory Processor B’s Memory 0 x. FFFFFFFF Thread 1 stack Thread 2 stack Thread 3 stack Thread 4 stack Heap Migrate Thread 3 Heap Globals Code 0 x 00000000 48

Migrate Stack Data Processor A’s Memory Processor B’s Memory 0 x. FFFFFFFF Thread 1 Migrate Stack Data Processor A’s Memory Processor B’s Memory 0 x. FFFFFFFF Thread 1 stack Thread 2 stack Thread 4 stack Heap Migrate Thread 3 stack Heap Globals Code 0 x 00000000 49

Migrate Stack Data n Isomalloc is a completely automatic solution n No changes needed Migrate Stack Data n Isomalloc is a completely automatic solution n No changes needed in application or compilers Just like a software shared-memory system, but with proactive paging But has a few limitations n Depends on having large quantities of virtual address space (best on 64 -bit) • 32 -bit machines can only have a few gigs of isomalloc stacks across the whole machine n Depends on unportable mmap • Which addresses are safe? (We must guess!) • What about Windows? Blue Gene? 50

Heap Data n Heap data is any dynamically allocated data C “malloc” and “free” Heap Data n Heap data is any dynamically allocated data C “malloc” and “free” n C++ “new” and “delete” n F 90 “ALLOCATE” and “DEALLOCATE” n n Arrays and linked data structures are almost always heap data 51

Migrate Heap Data n Automatic solution: isomalloc all heap data just like stacks! “-memory Migrate Heap Data n Automatic solution: isomalloc all heap data just like stacks! “-memory isomalloc” link option n Overrides malloc/free n No new application code needed n Same limitations as isomalloc n n Manual solution: application moves its heap data Need to be able to size message buffer, pack data into message, and unpack on other side n “pup” abstraction does all three n 52

Migrate Heap Data: PUP n n Same idea as MPI derived types, but datatype Migrate Heap Data: PUP n n Same idea as MPI derived types, but datatype description is code, not data Basic contract: here is my data n n n Register “pup routine” with runtime F 90/C Interface: subroutine calls n n Sizing: counts up data size Packing: copies data into message Unpacking: copies data back out Same call works for network, memory, disk I/O. . . E. g. , pup_int(p, &x); C++ Interface: operator| overloading n E. g. , p|x; 53

Migrate Heap Data: PUP Builtins n Supported PUP Datatypes n n Basic types (int, Migrate Heap Data: PUP Builtins n Supported PUP Datatypes n n Basic types (int, float, etc. ) Arrays of basic types Unformatted bytes Extra Support in C++ n Can overload user-defined types • Define your own operator| n Support for pointer-to-parent class • PUP: : able interface n Supports STL vector, list, map, and string • “pup_stl. h” n Subclass your own PUP: : er object 54

Migrate Heap Data: PUP C++ Example #include “pup. h” #include “pup_stl. h” class my. Migrate Heap Data: PUP C++ Example #include “pup. h” #include “pup_stl. h” class my. Mesh { std: : vector nodes; std: : vector elts; public: . . . void pup(PUP: : er &p) { p|nodes; p|elts; } }; 55

Migrate Heap Data: PUP C Example struct my. Mesh { int nn, ne; float Migrate Heap Data: PUP C Example struct my. Mesh { int nn, ne; float *nodes; int *elts; }; void pup. Mesh(pup_er p, my. Mesh *mesh) { pup_int(p, &mesh->nn); pup_int(p, &mesh->ne); if(pup_is. Unpacking(p)) { /* allocate data on arrival */ mesh->nodes=new float[mesh->nn]; mesh->elts=new int[mesh->ne]; } pup_floats(p, mesh->nodes, mesh->nn); pup_ints(p, mesh->elts, mesh->ne); if (pup_is. Deleting(p)) { /* free data on departure */ delete. Mesh(mesh); } 56

Migrate Heap Data: PUP F 90 Example TYPE(my. Mesh) INTEGER : : nn, ne Migrate Heap Data: PUP F 90 Example TYPE(my. Mesh) INTEGER : : nn, ne REAL*4, ALLOCATABLE(: ) : : nodes INTEGER, ALLOCATABLE(: ) : : elts END TYPE SUBROUTINE pup. Mesh(p, mesh) USE MODULE. . . INTEGER : : p TYPE(my. Mesh) : : mesh fpup_int(p, mesh%nn) fpup_int(p, mesh%ne) IF (fpup_is. Unpacking(p)) THEN ALLOCATE(mesh%nodes(mesh%nn)) ALLOCATE(mesh%elts(mesh%ne)) END IF fpup_floats(p, mesh%nodes, mesh%nn); fpup_ints(p, mesh%elts, mesh%ne); IF (fpup_is. Deleting(p)) delete. Mesh(mesh); 57 END SUBROUTINE

Global Data n Global data is anything stored at a fixed place n n Global Data n Global data is anything stored at a fixed place n n Problem if multiple objects/threads try to store different values in the same place (thread safety) n n C/C++ “extern” or “static” data F 77 “COMMON” blocks F 90 “MODULE” data Compilers should make all of these perthread; but they don’t! Not a problem if everybody stores the same value (e. g. , constants) 58

Migrate Global Data n Automatic solution: keep separate set of globals for each thread Migrate Global Data n Automatic solution: keep separate set of globals for each thread and swap n n “-swapglobals” compile-time option Works on ELF platforms: Linux and Sun • Just a pointer swap, no data copying needed • Idea comes from Weaves framework n n One copy at a time: breaks on SMPs Manual solution: remove globals n n n Makes code threadsafe May make code easier to understand modify Turns global variables into heap data (for isomalloc or pup) 59

How to Remove Global Data: Privatize n Move global variables into a perthread class How to Remove Global Data: Privatize n Move global variables into a perthread class or struct (C/C++) Requires changing every reference to every global variable n Changes every function call n extern int foo, bar; void inc(int x) foo+=x; } { typedef struct my. Globals { int foo, bar; }; void inc(my. Globals *g, int x) { g->foo+=x; } 60

How to Remove Global Data: Privatize n Move global variables into a perthread TYPE How to Remove Global Data: Privatize n Move global variables into a perthread TYPE (F 90) MODULE my. Mod INTEGER : : foo INTEGER : : bar END MODULE SUBROUTINE inc(x) USE MODULE my. Mod INTEGER : : x foo = foo + x END SUBROUTINE MODULE my. Mod TYPE(my. Mod. Data) INTEGER : : foo INTEGER : : bar END TYPE END MODULE SUBROUTINE inc(g, x) USE MODULE my. Mod TYPE(my. Mod. Data) : : g INTEGER : : x g%foo = g%foo + x END SUBROUTINE 61

How to Remove Global Data: Use Class n Turn routines into C++ methods; add How to Remove Global Data: Use Class n Turn routines into C++ methods; add globals as class variables No need to change variable references or function calls n Only applies to C or C-style C++ n extern int foo, bar; void inc(int x) foo+=x; } { class my. Globals { int foo, bar; public: void inc(int x); }; void my. Globals: : inc(int x) { foo+=x; } 62

How to Migrate a Virtual Processor? Move all application state to new processor n How to Migrate a Virtual Processor? Move all application state to new processor n Stack Data n n n Automatic: isomalloc stacks Heap Data Use “-memory isomalloc” n Write pup routines n n -or- Global Variables Use “-swapglobals” n Remove globals entirely n -or 63

Checkpoint/Restart 64 Checkpoint/Restart 64

Checkpoint/Restart Any long running application must be able to save its state n When Checkpoint/Restart Any long running application must be able to save its state n When you checkpoint an application, it uses the pup routine to store the state of all objects n State information is saved in a directory of your choosing n Restore also uses pup, so no additional application code is needed (pup is all you need) n 65

Checkpointing Job n In AMPI, use MPI_Checkpoint(<dir>); n n Collective call; returns when checkpoint Checkpointing Job n In AMPI, use MPI_Checkpoint(

); n n Collective call; returns when checkpoint is complete In Charm++, use Ck. Checkpoint(, ); n Called on one processor; calls resume when checkpoint is complete 66

Restart Job from Checkpoint n The charmrun option ++restart <dir> is used to restart Restart Job from Checkpoint n The charmrun option ++restart

is used to restart n n Number of processors need not be the same You can also restart groups by marking them migratable and writing a PUP routine – they still will not load balance, though 67

Automatic Load Balancing (Sameer Kumar) 68 Automatic Load Balancing (Sameer Kumar) 68

Motivation n Irregular or dynamic applications n n Initial static load balancing Application behaviors Motivation n Irregular or dynamic applications n n Initial static load balancing Application behaviors change dynamically Difficult to implement with good parallel efficiency Versatile, automatic load balancers n n n Application independent No/little user effort is needed in load balance Based on Charm++ and Adaptive MPI 69

Load Balancing in Charm++ n n n Viewing an application as a collection of Load Balancing in Charm++ n n n Viewing an application as a collection of communicating objects Object migration as mechanism for adjusting load Measurement based strategy n n n Principle of persistent computation and communication structure. Instrument cpu usage and communication Overload vs. underload processor 70

Feature: Load Balancing n Automatic load balancing Balance load by migrating objects n Very Feature: Load Balancing n Automatic load balancing Balance load by migrating objects n Very little programmer effort n Plug-able “strategy” modules n n Instrumentation for load balancer built into our runtime Measures CPU load per object n Measures network usage n 71

Charm++ Load Balancer in Action Automatic Load Balancing in Crack Propagation 72 Charm++ Load Balancer in Action Automatic Load Balancing in Crack Propagation 72

Processor Utilization: Before and After 73 Processor Utilization: Before and After 73

Load Balancing Framework LB Framework 76 Load Balancing Framework LB Framework 76

Load Balancing Strategies 77 Load Balancing Strategies 77

Load Balancer Categories n Centralized n n Object load data are sent to processor Load Balancer Categories n Centralized n n Object load data are sent to processor 0 Integrate to a complete object graph Migration decision is broadcasted from processor 0 Global barrier n Distributed n n Load balancing among neighboring processors Build partial object graph Migration decision is sent to its neighbors No global barrier 78

Centralized Load Balancing Uses information about activity on all processors to make load balancing Centralized Load Balancing Uses information about activity on all processors to make load balancing decisions n Advantage: since it has the entire object communication graph, it can make the best global decision n Disadvantage: Higher communication costs/latency, since this requires information from all running chares n 79

Neighborhood Load Balancing Load balances among a small set of processors (the neighborhood) to Neighborhood Load Balancing Load balances among a small set of processors (the neighborhood) to decrease communication costs n Advantage: Lower communication costs, since communication is between a smaller subset of processors n Disadvantage: Could leave a system which is globally poorly balanced n 80

Main Centralized Load Balancing Strategies n n n Greedy. Comm. LB – a “greedy” Main Centralized Load Balancing Strategies n n n Greedy. Comm. LB – a “greedy” load balancing strategy which uses the process load and communications graph to map the processes with the highest load onto the processors with the lowest load, while trying to keep communicating processes on the same processor Refine. LB – move objects off overloaded processors to under-utilized processors to reach average load Others – the manual discusses several other load balancers which are not used as often, but may be useful in some cases; also, more are being developed 81

Neighborhood Load Balancing Strategies n Neighbor. LB – neighborhood load balancer, currently uses a Neighborhood Load Balancing Strategies n Neighbor. LB – neighborhood load balancer, currently uses a neighborhood of 4 processors 82

Strategy Example - Greedy. Comm. LB n Greedy algorithm n n Put the heaviest Strategy Example - Greedy. Comm. LB n Greedy algorithm n n Put the heaviest object to the most underloaded processor Object load is its cpu load plus comm cost n Communication cost is computed as α+βm 83

Strategy Example - Greedy. Comm. LB 84 Strategy Example - Greedy. Comm. LB 84

Strategy Example - Greedy. Comm. LB 85 Strategy Example - Greedy. Comm. LB 85

Strategy Example - Greedy. Comm. LB 86 Strategy Example - Greedy. Comm. LB 86

Compiler Interface n Link time options -module: Link load balancers as modules n Link Compiler Interface n Link time options -module: Link load balancers as modules n Link multiple modules into binary n n Runtime options +balancer: Choose to invoke a load balancer n Can have multiple load balancers n • +balancer Greedy. Comm. LB +balancer Refine. LB 87

When to Re-balance Load? n Default: Load balancer is periodic n. Provide n period When to Re-balance Load? n Default: Load balancer is periodic n. Provide n period as a runtime parameter (+LBPeriod) Programmer Control: At. Sync load balancing At. Sync method: enable load balancing at specific point n n Object ready to migrate Re-balance if needed At. Sync() called when your chare is ready to be load balanced – load balancing may not start right away Resume. From. Sync() called when load balancing for this chare has finished 88

NAMD case study Molecular dynamics n Atoms move slowly n Initial load balancing can NAMD case study Molecular dynamics n Atoms move slowly n Initial load balancing can be as simple as round-robin n Load balancing is only needed for once for a while, typically once every thousand steps n Greedy balancer followed by Refine strategy n 92

Load Balancing Steps Regular Timesteps Instrumented Timesteps Detailed, aggressive Load Balancing Refinement Load Balancing Load Balancing Steps Regular Timesteps Instrumented Timesteps Detailed, aggressive Load Balancing Refinement Load Balancing 93

Refinement Load Balancing Aggressive Load Balancing Processor Utilization against Time on (a) 128 (b) Refinement Load Balancing Aggressive Load Balancing Processor Utilization against Time on (a) 128 (b) 1024 processors On 128 processor, a single load balancing step suffices, but On 1024 processors, we need a “refinement” step. 94

Some overloaded processors Processor Utilization across processors after (a) greedy load balancing and (b) Some overloaded processors Processor Utilization across processors after (a) greedy load balancing and (b) refining Note that the underloaded processors are left underloaded (as they don’t impact perforamnce); refinement deals only with the overloaded ones 95

Communication Optimization (Sameer Kumar) 96 Communication Optimization (Sameer Kumar) 96

Optimizing Communication n The parallel-objects Runtime System can observe, instrument, and measure communication patterns Optimizing Communication n The parallel-objects Runtime System can observe, instrument, and measure communication patterns n Communication libraries can optimize • By substituting most suitable algorithm for each operation • Learning at runtime n E. g. All to all communication • Performance depends on many runtime characteristics • Library switches between different algorithms n Communication is from/to objects, not processors • Streaming messages optimization V. Krishnan, MS Thesis, 1999 Ongoing work: Sameer Kumar, G Zheng, and Greg Koenig 97

Collective Communication n Communication operation where all (or most) the processors participate n n Collective Communication n Communication operation where all (or most) the processors participate n n n For example broadcast, barrier, all reduce, all to all communication etc Applications: NAMD multicast, NAMD PME, CPAIMD Issues n n n Performance impediment Naïve implementations often do not scale Synchronous implementations do not utilize the co-processor effectively 98

All to All Communication n All processors send data to all other processors n All to All Communication n All processors send data to all other processors n All to all personalized communication (AAPC) • MPI_Alltoall n All to all multicast/broadcast (AAMC) • MPI_Allgather 99

Optimization Strategies n Short message optimizations High software over head (α) n Message combining Optimization Strategies n Short message optimizations High software over head (α) n Message combining n n Large messages n n Network contention Performance metrics Completion time n Compute overhead n 100

Short Message Optimizations n n Direct all to all communication is α dominated Message Short Message Optimizations n n Direct all to all communication is α dominated Message combining for small messages n n Reduce the total number of messages Multistage algorithm to send messages along a virtual topology Group of messages combined and sent to an intermediate processor which then forwards them to their final destinations AAPC strategy may send same message multiple times 101

Virtual Topology: Mesh Organize processors in a 2 D (virtual) Mesh Phase 1: Processors Virtual Topology: Mesh Organize processors in a 2 D (virtual) Mesh Phase 1: Processors send messages to row neighbors Phase 1: Processors send messages to column neighbors 2* messages instead of P-1 Message from (x 1, y 1) to (x 2, y 2) goes via (x 1, y 2) 102

Virtual Topology: Hypercube n 6 7 n 2 3 Dimensional exchange Log(P) messages instead Virtual Topology: Hypercube n 6 7 n 2 3 Dimensional exchange Log(P) messages instead of P-1 5 0 1 103

AAPC Performance 104 AAPC Performance 104

Radix Sort AAPC Time (ms) Size Direct Mesh 2 KB 333 221 4 KB Radix Sort AAPC Time (ms) Size Direct Mesh 2 KB 333 221 4 KB 256 416 8 KB 484 766 105

AAPC Processor Overhead Mesh Completion Time Direct Compute Time Mesh Compute Time Performance on AAPC Processor Overhead Mesh Completion Time Direct Compute Time Mesh Compute Time Performance on 1024 processors of Lemieux 106

Compute Overhead: A New Metric n n Strategies should also be evaluated on compute Compute Overhead: A New Metric n n Strategies should also be evaluated on compute overhead Asynchronous non blocking primitives needed n n Compute overhead of the mesh strategy is a small fraction of the total AAPC completion time A data driven system like Charm++ will automatically support this 107

NAMD Performance of Namd with the Atpase molecule. PME step in Namd involves an NAMD Performance of Namd with the Atpase molecule. PME step in Namd involves an a 192 X 144 processor collective operation with 900 byte messages 108

Large Message Issues n Network contention Contention free schedules n Topology specific optimizations n Large Message Issues n Network contention Contention free schedules n Topology specific optimizations n 109

Ring Strategy for Collective Multicast n n Performs all to all multicast by sending Ring Strategy for Collective Multicast n n Performs all to all multicast by sending messages along a ring formed by the processors Congestion free on most topologies …… 0 1 2 ……. . i i+1 P-1 110

Accessing the Communication Library n Charm++ n Creating a strategy //Creating an all to Accessing the Communication Library n Charm++ n Creating a strategy //Creating an all to all communication strategy Strategy s = new Each. To. Many. Strategy(USE_MESH); Comlib. Instance inst = Ck. Get. Comlib. Instance(); inst. set. Strategy(s); //In array entry method Comlib. Delegate(&aproxy); //begin aproxy. method(…. . ); //end 111

Compiling For strategies, you need to specify a communications topology, which specifies the message Compiling For strategies, you need to specify a communications topology, which specifies the message pattern you will be using n You must include –module commlib compile time option n 112

Streaming Messages Programs often have streams of short messages n Streaming library combines a Streaming Messages Programs often have streams of short messages n Streaming library combines a bunch of messages and sends them off n To use streaming create a Streaming. Strategy n Strategy *strat = new Streaming. Strategy(10); 113

AMPI Interface n The MPI_Alltoall call internally calls the communication library n Running the AMPI Interface n The MPI_Alltoall call internally calls the communication library n Running the program with +strategy option switches to the appropriate strategy charmrun pgm-ampi +p 16 +strategy USE_MESH n Asynchronous collectives n n n Collective operation posted Test/wait for its completion Meanwhile useful computation can utilize CPU MPI_Ialltoall( … , &req); /* other computation */ MPI_Wait(req); 114

CPU Overhead vs Completion Time breakdown of an all-to-all operation using Mesh library n CPU Overhead vs Completion Time breakdown of an all-to-all operation using Mesh library n n Computation is only a small proportion of the elapsed time A number of optimization techniques are developed to improve collective communication performance 115

Asynchronous Collectives Time breakdown of 2 D FFT benchmark [ms] n n n VP’s Asynchronous Collectives Time breakdown of 2 D FFT benchmark [ms] n n n VP’s implemented as threads Overlapping computation with waiting time of collective operations Total completion time reduced 116

Summary We present optimization strategies for collective communication n Asynchronous collective communication n n Summary We present optimization strategies for collective communication n Asynchronous collective communication n n New performance metric: CPU overhead 117

Future Work n Physical topologies ASCI-Q, Lemieux Fat-trees n Bluegene (3 -d grid) n Future Work n Physical topologies ASCI-Q, Lemieux Fat-trees n Bluegene (3 -d grid) n n Smart strategies for multiple simultaneous AAPCs over sections of processors 118

Big. Sim (Sanjay Kale) 120 Big. Sim (Sanjay Kale) 120

Overview n Big. Sim n Component based, integrated simulation framework n Performance prediction for Overview n Big. Sim n Component based, integrated simulation framework n Performance prediction for a large variety of extremely large parallel machines n Study alternate programming models 121

Our approach n Applications based on existing parallel languages n n AMPI Charm++ Facilitate Our approach n Applications based on existing parallel languages n n AMPI Charm++ Facilitate development of new programming languages Detailed/accurate simulation of parallel performance n n Sequential part : performance counters, instruction level simulation Parallel part: simple latency based network model, network simulator 122

Parallel Simulator n Parallel performance is hard to model n Communication subsystem • Out Parallel Simulator n Parallel performance is hard to model n Communication subsystem • Out of order messages • Communication/computation overlap n n Parallel Discrete Event Simulation n n Event dependencies, causality. Emulation program executes concurrently with event time stamp correction. Exploit inherent determinacy of application 123

Emulation on a Parallel Machine BG/C Nodes Simulating (Host) Processor Simulated processor 124 Emulation on a Parallel Machine BG/C Nodes Simulating (Host) Processor Simulated processor 124

Emulator to Simulator n Predicting time of sequential code n n n Predicting messaging Emulator to Simulator n Predicting time of sequential code n n n Predicting messaging performance n n User supplied estimated elapsed time Wallclock measurement time on simulating machine with suitable multiplier Performance counters Hardware simulator No contention modeling, latency based Back patching Network simulator Simulation can be in separate resolutions 125

Simulation Process n n Compile MPI or Charm++ program and link with simulator library Simulation Process n n Compile MPI or Charm++ program and link with simulator library Online mode simulation n Run the program with +bgcorrect Visualize the performance data in Projections Postmortem mode simulation n Run the program with +bglog Run POSE based simulator with network simulation on different number of processors Visualize the performance data 126

Projections before/after correction 127 Projections before/after correction 127

Validation 128 Validation 128

Lean. MD Performance Analysis • Benchmark 3 -away ERGRE • 36573 atoms • 1. Lean. MD Performance Analysis • Benchmark 3 -away ERGRE • 36573 atoms • 1. 6 million objects • 8 step simulation • 64 k BG processors • Running on PSC Lemieux 129

Predicted Lean. MD speedup 130 Predicted Lean. MD speedup 130

Performance Analysis 131 Performance Analysis 131

Projections is designed for use with a virtualized model like Charm++ or AMPI n Projections is designed for use with a virtualized model like Charm++ or AMPI n Instrumentation built into runtime system n Post-mortem tool with highly detailed traces as well as summary formats n Java-based visualization tool for presenting performance information 132 n

Trace Generation (Detailed) • Link-time option “-tracemode projections” n n n In the log Trace Generation (Detailed) • Link-time option “-tracemode projections” n n n In the log mode each event is recorded in full detail (including timestamp) in an internal buffer Memory footprint controlled by limiting number of log entries I/O perturbation can be reduced by increasing number of log entries Generates a . . log file for each processor and a . sts file for the entire application Commonly used Run-time options +traceroot DIR +logsize NUM 133

Visualization Main Window 134 Visualization Main Window 134

Post mortem analysis: views n Utilization Graph n n Mainly useful as a function Post mortem analysis: views n Utilization Graph n n Mainly useful as a function of processor utilization against time and time spent on specific parallel methods Profile: stacked graphs: n For a given period, breakdown of the time on each processor • Includes idle time, and message-sending, receiving times n Timeline: n n upshot-like, but more details Pop-up views of method execution, message arrows, user-level events 135

136 136

Projections Views: continued • Histogram of method execution times n n How many method-execution Projections Views: continued • Histogram of method execution times n n How many method-execution instances had a time of 0 -1 ms? 1 -2 ms? . . Overview n A fast utilization chart for entire machine across the entire time period 137

138 138

Message Packing Overhead Effect of Multicast Optimization on Integration Overhead By eliminating overhead of Message Packing Overhead Effect of Multicast Optimization on Integration Overhead By eliminating overhead of message copying and allocation. 139

Projections Conclusions Instrumentation built into runtime n Easy to include in Charm++ or AMPI Projections Conclusions Instrumentation built into runtime n Easy to include in Charm++ or AMPI program n Working on n Automated analysis n Scaling to tens of thousands of processors n Integration with hardware performance counters n 140

Charm++ FEM Framework 141 Charm++ FEM Framework 141

Why use the FEM Framework? n Makes parallelizing a serial code faster and easier Why use the FEM Framework? n Makes parallelizing a serial code faster and easier Handles mesh partitioning n Handles communication n Handles load balancing (via Charm) n n Allows extra features IFEM Matrix Library n Net. FEM Visualizer n Collision Detection Library n 142

Serial FEM Mesh Elemen t Surrounding Nodes E 1 N 3 N 4 E Serial FEM Mesh Elemen t Surrounding Nodes E 1 N 3 N 4 E 2 N 1 N 2 N 4 E 3 N 2 N 4 N 5 143

Partitioned Mesh Element Surrounding Nodes E 1 N 3 N 4 E 2 N Partitioned Mesh Element Surrounding Nodes E 1 N 3 N 4 E 2 N 1 N 2 N 3 Element Surrounding Nodes E 1 N 2 N 3 Shared Nodes A B N 2 N 1 N 4 N 3 144

FEM Mesh: Node Communication Summing forces from other processors only takes one call: FEM_Update_field FEM Mesh: Node Communication Summing forces from other processors only takes one call: FEM_Update_field Similar call for updating ghost regions 145

Scalability of FEM Framework 146 Scalability of FEM Framework 146

FEM Framework Users: CSAR Rocflu fluids solver, a part of GENx n Finite-volume fluid FEM Framework Users: CSAR Rocflu fluids solver, a part of GENx n Finite-volume fluid dynamics code n Uses FEM ghost elements n Author: Andreas Haselbacher n 147 Robert Fielder, Center for Simulation of Advanced Rockets

FEM Framework Users: DG Dendritic Growth n Simulate metal solidification process n Solves mechanical, FEM Framework Users: DG Dendritic Growth n Simulate metal solidification process n Solves mechanical, thermal, fluid, and interface equations n Implicit, uses Bi. CG n Adaptive 3 D mesh n Authors: Jung-ho Jeong, John Danzig n 148

Who uses it? 149 Who uses it? 149

Enabling CS technology of parallel objects and intelligent runtime systems (Charm++ and AMPI) has Enabling CS technology of parallel objects and intelligent runtime systems (Charm++ and AMPI) has led to several collaborative applications in CSE Quantum Chemistry (QM/MM) Molecular Dynamics Protein Folding Computational Cosmology Parallel Objects, Crack Propagation Adaptive Runtime System Libraries and Tools Space-time meshes Dendritic Growth Rocket Simulation 150

Some Active Collaborations n Biophysics: Molecular Dynamics (NIH, . . ) n n Long Some Active Collaborations n Biophysics: Molecular Dynamics (NIH, . . ) n n Long standing, 91 -, Klaus Schulten, Bob Skeel Gordon bell award in 2002, Production program used by biophysicists n n Quantum Chemistry (NSF) n n n QM/MM via Car. Parinello method + Roberto Car, Mike Klein, Glenn Martyna, Mark Tuckerman, Nick Nystrom, Josep Torrelas, Laxmikant Kale Material simulation (NSF) Rocket simulation (DOE) n n n Dendritic growth, quenching, space-time meshes, QM/FEM R. Haber, D. Johnson, J. Dantzig, + DOE, funded ASCI center Mike Heath, +30 faculty Computational Cosmology (NSF, NASA) n n Simulation: Scalable Visualization: 151

Molecular Dynamics in NAMD n Collection of [charged] atoms, with bonds n n Newtonian Molecular Dynamics in NAMD n Collection of [charged] atoms, with bonds n n Newtonian mechanics Thousands of atoms (1, 000 - 500, 000) 1 femtosecond time-step, millions needed! At each time-step n Calculate forces on each atom • Bonds: • Non-bonded: electrostatic and van der Waal’s • Short-distance: every timestep • Long-distance: every 4 timesteps using PME (3 D FFT) • Multiple Time Stepping n n Calculate velocities and advance positions Gordon Bell Prize in 2002 Collaboration with K. Schulten, R. Skeel, and coworkers 152

NAMD: A Production MD program n n n n NAMD Fully featured program NIH-funded NAMD: A Production MD program n n n n NAMD Fully featured program NIH-funded development Distributed free of charge (~5000 downloads so far) Binaries and source code Installed at NSF centers User training and support Large published simulations (e. g. , aquaporin simulation at left) 153

CPSD: Dendritic Growth n n Studies evolution of solidification microstructures using a phasefield model CPSD: Dendritic Growth n n Studies evolution of solidification microstructures using a phasefield model computed on an adaptive finite element grid Adaptive refinement and coarsening of grid involves repartitioning Jon Dantzig et al with O. Lawlor and Others from PPL 154

CPSD: Spacetime Meshing n Collaboration with: n n n Space-time mesh is generated at CPSD: Spacetime Meshing n Collaboration with: n n n Space-time mesh is generated at runtime n n Bob Haber, Jeff Erickson, Mike Garland, . . NSF funded center Mesh generation is an advancing front algorithm Adds an independent set of elements called patches to the mesh Each patch depends only on inflow elements (cone constraint) Completed: n n n Sequential mesh generation interleaved with parallel solution Ongoing: Parallel Mesh generation Planned: non-linear cone constraints, adaptive refinements 155

Rocket Simulation n n Dynamic, coupled physics simulation in 3 D Finite-element solids on Rocket Simulation n n Dynamic, coupled physics simulation in 3 D Finite-element solids on unstructured tet mesh Finite-volume fluids on structured hex mesh Coupling every timestep via a leastsquares data transfer Challenges: n n Multiple modules Dynamic behavior: burning surface, mesh adaptation Robert Fielder, Center for Simulation of Advanced Rockets Collaboration with M. Heath, P. Geubelle, others 156

Computational Cosmology n N body Simulation n n Output data Analysis: in parallel n Computational Cosmology n N body Simulation n n Output data Analysis: in parallel n n n N particles (1 million to 1 billion), in a periodic box Move under gravitation Organized in a tree (oct, binary (k-d), . . ) Particles are read in parallel Interactive Analysis Issues: Load balancing, fine-grained communication, tolerating communication latencies. n Multiple-time stepping Collaboration with T. Quinn, Y. Staedel, M. Winslett, others n 157

QM/MM n Quantum Chemistry (NSF) n n Current Steps: n n QM/MM via Car-Parinello QM/MM n Quantum Chemistry (NSF) n n Current Steps: n n QM/MM via Car-Parinello method + Roberto Car, Mike Klein, Glenn Martyna, Mark Tuckerman, Nick Nystrom, Josep Torrelas, Laxmikant Kale Take the core methods in Piny. MD (Martyna/Tuckerman) Reimplement them in Charm++ Study effective parallelization techniques Planned: n n n Lean. MD (Classical MD) Full QM/MM Integrated environment 158

Conclusions 159 Conclusions 159

Conclusions n AMPI and Charm++ provide a fully virtualized runtime system Load balancing via Conclusions n AMPI and Charm++ provide a fully virtualized runtime system Load balancing via migration n Communication optimizations n Checkpoint/restart n n Virtualization can significantly improve performance for real applications 160

Thank You! Free source, binaries, manuals, and more information at: http: //charm. cs. uiuc. Thank You! Free source, binaries, manuals, and more information at: http: //charm. cs. uiuc. edu/ Parallel Programming Lab at University of Illinois 161