35
1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai Lee http://charm.cs.uiuc.edu Parallel Programming Laboratory Dept. of Computer Science University of Illinois at Urbana Champaign

1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

Embed Size (px)

Citation preview

Page 1: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

1

Scaling Molecular Dynamics to 3000 Processors with Projections:

A Performance Analysis Case Study

Laxmikant Kale

Gengbin Zheng

Sameer Kumar

Chee Wai Lee

http://charm.cs.uiuc.eduParallel Programming Laboratory

Dept. of Computer Science

University of Illinois at Urbana Champaign

Page 2: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

2

Motivation

• Performance optimization is increasingly challenging– Modern applications are complex and dynamic

– Some may involve small amount of computation per step

– Performance issues and obstacles change:

• As the number of processors change– Performance tuning on small machines isn’t enough

• Need very good Performance Analysis tools– Feedback at the level of applications

– Analysis capabilities

– Scalable views

– Automatic instrucmentation

Page 3: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

3

Projections

• Many performance analysis systems exist– And are very useful in their own way

– Paragraph, Upshot, Pablo, ..

• The system we present is “Projections”– Designed for message-driven programs

– Has some unique benefits compared with others

• The next few slides

• Outline:– Processor virtualization and message-driven execution

– Projections: trace generation

– Projections: views

– Case Study: NAMD, Molecular Dynamics program that won a Gordon Bell award at SC’02 by scaling MD for biomolecules to 3,000 procs

Page 4: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

4

Virtualization: Object-based Parallelization

User View

System implementation

User is only concerned with interaction between objects

Page 5: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

5

Data driven execution

Scheduler Scheduler

Message Q Message Q

Page 6: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

6

Charm++ and Adaptive MPIRealizations of Virtualization Approach

Charm++

• Parallel C++– Asynchronous methods

• In development for over a decade

• Basis of several parallel applications

• Runs on all popular parallel machines and clusters

AMPI

• A migration path for MPI codes – Allows them dynamic load

balancing capabilities of Charm++

• Minimal modifications to convert existing MPI programs

• Bindings for – C, C++, and Fortran90

Both available from http://charm.cs.uiuc.edu

Page 7: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

7

Benefits of Virtualization• Software Engineering

– Number of virtual processors can be independently controlled

– Separate VPs for modules

• Message Driven Execution– Adaptive overlap

– Modularity

– Predictability:

• Automatic Out-of-core

• Dynamic mapping– Heterogeneous clusters:

• Vacate, adjust to speed, share

– Automatic checkpointing

– Change the set of processors

• Principle of Persistence:– Enables Runtime

Optimizations

– Automatic Dynamic Load Balancing

– Communication Optimizations

– Other Runtime Optimizations

More info:

http://charm.cs.uiuc.edu

Page 8: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

8

Measurement Based Load Balancing

• Principle of persistence– Object communication patterns and computational loads

tend to persist over time

– In spite of dynamic behavior

• Abrupt but infrequent changes

• Slow and small changes

• Runtime instrumentation– Measures communication volume and computation time

• Measurement based load balancers– Use the instrumented data-base periodically to make new

decisions

Page 9: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

9

Trace Generation

• Automatic instrumentation by runtime system• Detailed

• Summary

Page 10: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

10

Post mortem analysis: views

• Utilization Graph– As a function of time interval or processor

– Shows processor utilization

– As well as: time spent on specific parallel methods

• Timeline: – upshot-like, but more details

– Pop-up views of method execution, message arrows, user-level events

• Profile: stacked graphs: – For a given period, breakdown of the time on each processor

• Includes idle time, and message-sending, receiving times

Page 11: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

11

Prtojections Views: continued

• Animation of utilization• Histogram of method execution times

– How many method-execution instances had a time of 0-1 ms? 1-2 ms? ..

• Performance counters:– Associated with each entry method

– Usual counters, interface to PAPI

Page 12: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

12

Case Study: NAMD

• We illustrate the use of Projections– Using a case study

– Illustrate different “views”

– Show performance debugging methodology

Page 13: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

13

NAMD: A Production MD program

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 featured in SC’02 keynote)

Page 14: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

14

NAMD, CHARMM27, PMENpT ensemble at 310 or 298 K 1ns equilibration, 4ns production

Protein:~ 15,000 atomsLipids (POPE): ~ 40,000 atomsWater: ~ 51,000 atomsTotal: ~ 106,000 atoms

3.5 days / ns - 128 O2000 CPUs11 days / ns - 32 Linux CPUs.35 days/ns–512 LeMieux CPUs

Acquaporin Simulation

F. Zhu, E.T., K. Schulten, FEBS Lett. 504, 212 (2001)M. Jensen, E.T., K. Schulten, Structure 9, 1083 (2001)

Page 15: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

15

Molecular Dynamics in NAMD

• Collection of [charged] atoms, with bonds– Newtonian mechanics

– Thousands of atoms (10,000 - 500,000)

• At each time-step– Calculate forces on each atom

• Bonds:

• Non-bonded: electrostatic and van der Waal’s– Short-distance: every timestep

– Long-distance: using PME (3D FFT)

– Multiple Time Stepping : PME every 4 timesteps

– Calculate velocities and advance positions

• Challenge: femtosecond time-step, millions needed!

Collaboration with K. Schulten, R. Skeel, and coworkers

Page 16: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

16

Sizes of Simulations Over Time

BPTI3K atoms

Estrogen Receptor36K atoms (1996)

ATP Synthase327K atoms

(2001)

Page 17: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

17

F1F0 ATP-Synthase (ATP-ase)

•CConverts the electrochemical energy of the proton gradient into the mechanical energy of the central stalk rotation, driving ATP synthesis (G = 7.7 kcal/mol).

327,000 atoms total,51,000 atoms -- protein and nucletoide276,000 atoms -- water and ions

The Benchmark

Page 18: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

18

Traditional Approaches: non isoefficient

• Replicated Data:– All atom coordinates stored on each processor

• Communication/Computation ratio: P log P

• Partition the Atoms array across processors– Nearby atoms may not be on the same processor

– C/C ratio: O(P)

• Distribute force matrix to processors– Matrix is sparse, non uniform,

– C/C Ratio: sqrt(P)

Page 19: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

19

Spatial Decomposition Via Charm

•Atoms distributed to cubes based on their location

• Size of each cube :

•Just a bit larger than cut-off radius

•Communicate only with neighbors

•Work: for each pair of nbr objects

•C/C ratio: O(1)

•However:

•Load Imbalance

•Limited Parallelism

Cells, Cubes or“Patches”

Charm++ is useful to handle this

Page 20: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

20

Object Based Parallelization for MD:

Force Decomposition + Spatial Decomposition

•Now, we have many objects to load balance:

–Each diamond can be assigned to any proc.

– Number of diamonds (3D):

–14·Number of Patches

Page 21: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

22

700 VPs

NAMD Parallelization using Charm++

These 30,000+ Virtual Processors (VPs) are mapped to real processors by charm runtime system

9,800 VPs

Page 22: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

23

Adding PME

• PME involves:– A grid of modest size (e.g. 192x144x144)

– Need to distribute charge from patches to grids

– 3D FFT over the grid

• Strategy:– Use a smaller subset (non-dedicated) of processors for PME

– Overlap PME with cutoff computation

– Use individual processors for both PME and cutoff computations

– Multiple timestepping

Page 23: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

24

700 VPs

192 + 144 VPs

30,000 VPs

NAMD Parallelization using Charm++ : PME

These 30,000+ Virtual Processors (VPs) are mapped to real processors by charm runtime system

Page 24: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

25

Some Challenges

• Here, we will focus on cut-off only (no PME) simulation– For simplicity of presentation of performance issues

• New parallel machine with faster processors– PSC Lemieux

– 1 processor performance:

• 57 seconds on ASCI red to 7.08 seconds on Lemieux

– Makes is harder to parallelize:

• E.g. larger communication-to-computation ratio

• Each timestep is few milliseconds on 1000’s of processors

Page 25: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

27

Summary and Conclusion

• Processor virtualization – A useful technique for complex applications– Charm++ and AMPI embody this – Can be downloaded at http://charm.cs.uiuc.edu

• Projections:– Performance analysis tool especially suited for processor

virtualization

• NAMD performance was optimized to scale to 3000 processors using projections

• Future:– Further automation of analysis– On-demand displays (via a query-and-display language)

Page 26: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

28

Grainsize and Amdahls’s law

• A variant of Amdahl’s law, for objects:– The fastest time can be no shorter than the time for the

biggest single object!

– Lesson from previous efforts

• Splitting computation objects:– 30,000 nonbonded compute objects

– Instead of approx 10,000

Page 27: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

29

Mode: 700 us

Distribution of execution times of

non-bonded force computation objects (over 24 steps)

Page 28: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

31

Load Balancing Steps

Regular Timesteps

Instrumented Timesteps

Detailed, aggressive Load Balancing

Refinement Load Balancing

Page 29: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

32

Another New Challenge

• Jitter due small variations– On 2k processors or more

– Each timestep, ideally, will be about 12-14 msec for ATPase

– Within that time: each processor sends and receives :

• Approximately 60-70 messages of 4-6 KB each

– Communication layer and/or OS has small “hiccups”

• No problem until 512 processors

• Small rare hiccups can lead to large performance impact– When timestep is small (10-20 msec), AND

– Large number of processors are used

Page 30: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

33

Benefits of Avoiding Barrier• Problem with barriers:

– Not the direct cost of the operation itself as much

– But it prevents the program from adjusting to small variations

• E.g. K phases, separated by barriers (or scalar reductions)

• Load is effectively balanced. But,– In each phase, there may be slight non-determistic load imbalance

– Let Li,j be the load on I’th processor in j’th phase.

• In NAMD, using Charm++’s message-driven execution:– The energy reductions were made asynchronous

– No other global barriers are used in cut-off simulations

k

jjii L

1, }{max }{max

1,

k

jjii LWith barrier: Without:

Page 31: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

34

100 milliseconds

Page 32: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

35

Substep Dynamic Load Adjustments

• Load balancer tells each processor its expected (predicted) load for each timestep

• Each processor monitors its execution time for each timestep – after executing each force-computation object

• If it has taken well beyond its allocated time:– Infers that it has encountered a “stretch”

– Sends a fraction of its work in the next 2-3 steps to other processors

• Randomly selected from among the least loaded processors

migrate Compute(s) away in this step

Page 33: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

36

Performance: NAMD on Lemieux

Time (ms) Speedup GFLOPSProcs Per Node Cut PME MTS Cut PME MTS Cut PME MTS

1 1 24890 29490 28080 1 1 1 0.494 0.434 0.48128 4 207.4 249.3 234.6 119 118 119 59 51 57256 4 105.5 135.5 121.9 236 217 230 116 94 110512 4 55.4 72.9 63.8 448 404 440 221 175 211510 3 54.8 69.5 63 454 424 445 224 184 213

1024 4 33.4 45.1 36.1 745 653 778 368 283 3731023 3 29.8 38.7 33.9 835 762 829 412 331 3971536 3 21.2 28.2 24.7 1175 1047 1137 580 454 5451800 3 18.6 25.8 22.3 1340 1141 1261 661 495 6052250 3 14.4 23.5 17.54 1728 1256 1601 850 545 770

ATPase: 320,000+ atoms including water

Page 34: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

37

200 milliseconds

Page 35: 1 Scaling Molecular Dynamics to 3000 Processors with Projections: A Performance Analysis Case Study Laxmikant Kale Gengbin Zheng Sameer Kumar Chee Wai

38

Using all 4 processors on each Node

300 milliseconds