Secrets of Supercomputing

22
Secrets of Secrets of Supercomputing Supercomputing Decoding the Language of Decoding the Language of Wizards Wizards Los Alamos National Laboratory Los Alamos National Laboratory

description

Brought to you by http://marcusmoon2022.org/ Sustainable, Green Lunar Colonization by 2022

Transcript of Secrets of Supercomputing

Page 1: Secrets of Supercomputing

Secrets of Secrets of SupercomputingSupercomputing

Decoding the Language of Decoding the Language of WizardsWizards

Los Alamos National LaboratoryLos Alamos National Laboratory

Page 2: Secrets of Supercomputing

Calculus and SupercomputingCalculus and Supercomputing

• Calculus and Supercomputing are intertwined. Why? Here is an example.

• A simple problem – Add up the volume of earth above sea-level for an island 500 ft high by half a mile wide and twenty miles long.

• Typical science homework problem using simple algebra. Can be done by hand. Not appropriate for supercomputing. Not enough complexity.

Page 3: Secrets of Supercomputing

Add ComplexityAdd Complexity

• The island profile is a jagged mountainous terrain cut by deep canyons. How do we add up the volume?

• Calculus – language of complexity– Addition – summing numbers– Multiplication – summing numbers with a constant

magnitude– Integration – summing numbers with an irregular

magnitude

Page 4: Secrets of Supercomputing

Divide and ConquerDivide and Conquer

• In discrete form

• Divide the island into small pieces and sum up the volume of each piece.

• Approaches the solution as the size of the intervals grows smaller for a jagged profile.

Page 5: Secrets of Supercomputing

Divide and ConquerDivide and Conquer

• In Continuous Form – Integration

• Think of the integral symbols as describing a shape that is continuously varying

• The accuracy of the solution can be improved by summing over smaller increments

• Lots of arithmetic operations – now you have a “computing” problem. Add more work and you have a “supercomputing” problem.

Page 6: Secrets of Supercomputing

Calculus - Describing ChangeCalculus - Describing Change

• Derivatives describe change.• Problem: The pine bark beetle epidemic is

sweeping the southwest. But the concentration of pine bark beetles is not constant. It varies by time and location. The variable P describes the population of pine bark beetles.

Page 7: Secrets of Supercomputing

Calculus and ChangeCalculus and Change

y

Pandx

P

t

P

,

• Derivatives describe the change in a variable (numerator or top variable) relative to another variable (denominator or bottom). These three derivatives describe the change in pine bark beetle population versus time, x-direction and y-direction.

Page 8: Secrets of Supercomputing

Calculus TerminologyCalculus Terminology

• Two branches of Calculus – Integral Calculus– Derivative Calculus

• P = f(x, y, t)– Population is a function of x, y, and t

• dP/dx – derivative, instantaneous rate of change, or slope of a function

• ∂P/∂x – partial derivative implying that P is a function of more than one variable

• ∫f(x)dx – definite integral, area under the curve, or summation

Page 9: Secrets of Supercomputing

Two Main Approaches to Divide up Two Main Approaches to Divide up ProblemProblem

• Eulerian – divide up by spatial coordinates– Track populations in a location– Observer frame of reference

• Lagrangian – divide up by objects– Track groups of pine bark beetles– Object frame of reference– Easier to track attributes of population since they

travel with the objects– Agent based modeling of Star Logo uses this– Can tangle

Page 10: Secrets of Supercomputing

Mixed RepresentationMixed Representation

• Exercise: Divide up the pine bark beetle problem with the pine bark beetles represented in a lagrangian framework and the tree population in a eulerian framework.

Page 11: Secrets of Supercomputing

EulerianEulerian

Eulerian – The area stays fixed and has a Population per area. We observe the change in population across the boundaries of the area.

Langrangian – The number of beetles stays fixed. The beetles move with velocity vx and vy and we move with them. The size of the area will change if the four vertexes of the rectangle move at different velocities. Changes in area will result in different densities.

Beetles move out of area

EulerianLagrangian

Beetles move and so does region

Page 12: Secrets of Supercomputing

ExerciseExercise

• Pick topic– Air, ants, blood, students, grass, water flow

• Decide Eulerian or Lagrangian

• Study the behavior (what variables?)– Eulerian – observe area or volume; what

crosses boundaries?– Lagrangian – follow object; what influences it?

Page 13: Secrets of Supercomputing

SupercomputingSupercomputing

• Our Working definition of Supercomputing– Harnessing lots of processors to do lots of

small calculations– There are many other definitions

• Writing a program– Data parallel model

• Distributed data split across processors• All other data replicated across processors

Page 14: Secrets of Supercomputing

Data Parallel ModelData Parallel Model

P(400) – distributed

Ptot -- replicated

Proc 1

P(1-100)

Ptot

Proc 2

P(101-200)

Ptot

Proc 3

P(201–300)

Ptot

Proc 4

P(301-400)

Ptot

Serial operations are done on every processor so that replicated data is the same on every processor.

This may seem like a waste of work, but it is easier than synchronizing data values.

Sections of distributed data are “owned” by each processor. This is where the parallel speedups occur.

Often ghost cells around each processor’s data is a way to handle communication.

Page 15: Secrets of Supercomputing

Message Passing Interface (MPI)Message Passing Interface (MPI)

• A software library to communicate across processors

• Defacto standard for parallel processing– MPICH from Argonne National Lab is the most

common MPI package– OpenMPI is an open source consortium including Los

Alamos National Laboratory and is the best supported MPI in Eclipse

– LAM is a common MPI package in Linux distros.

Page 16: Secrets of Supercomputing

MPI ProgramMPI Program

• Example Program is called Beetlemania– Models a pine bark beetle infestation.– Initial population placed at center of mesh.– New population is the sum of the population in the

current cell and the surrounding eight cells divided by nine (called a stencil operation).

– Trees are placed in a linearly increasing profile from the top of the screen to the bottom.

– Random number is initially applied to tree distribution to make it less smooth.

– Population is multiplied by the tree density each time step. Trees are reduced by a function of beetle population.

Page 17: Secrets of Supercomputing

ToolsTools

• MPE -- graphics calls that comes with MPICH. Graphics calls are done in parallel from each processor! Most linux distros have an MPICH package.

• Eclipse -- Programmers Workbench. This is an open source project and Los Alamos National Lab (LANL) is contributing an Parallel Tools module including MPI and Fortran. Download tools from http://www.eclipse.org

Page 18: Secrets of Supercomputing

Setting up EclipseSetting up Eclipse

• Download from www.eclipse.org (may need to go to Calisteo download to find platform module)– eclipse-SDK-3.2.1-linux-gtk.tar– eclipse-platform-3.2.1-linux-gtk.tar– org.eclipse.cdt-3.1.1-linux.x86.tar– org.eclipse.ptp-1.0.0.tar– org.eclipse.ptp.mpi-1.0.tar– org.eclipse.ptp.orte-linux-x86-1.0.0.tar– org.eclipse.ptp.debug-orte-linux-x86-1.0.0.tar

• Untar using ark, tar or other Linux utility• You are ready to go

Page 19: Secrets of Supercomputing

Setting up Project in EclipseSetting up Project in Eclipse

• Right click on project name and select Properties at bottom of long menu. Select C/C++ Build– Select Configuration and change to Release– Under C compiler, Directories

• Set include path to /usr/lib/mpich/include

– Under C linker, Libraries• Set libraries directories to /usr/lib/mpich/lib• Set libraries to

– mpe– mpich– X11– pthread– rt– m

Page 20: Secrets of Supercomputing

Eclipse (cont)Eclipse (cont)

• MPI run is still buggy so set up a C executable run project. This will only run one processor.– Select run on top menus, and run from pulldown menu

• Name: Beetlemania• Project: Beetlemania• C/C++ Application: Release/Beetlemania

– Click on Apply and then Run– Prompts appear in bottom screen. Enter

• X size: 400, Y size 400, and Iterations: 1000

• To run multiple processors, go to project directory (workspace/Beetlemania) and type– “mpirun –np 4 Release/Beetlemania”

Page 21: Secrets of Supercomputing

Programming LanguageProgramming Language

• Beetlemania is written in C, a functional language, and is in a single routine.

• Could be converted to C++. Java is trickier because the MPI interface (C) is difficult to handle from Java. C++ and Java support is well-supported in Eclipse.

Page 22: Secrets of Supercomputing

ExerciseExercise

• Try modifying the sample program– Change initial tree distribution– Change stencil operator to weigh neighbors differently– Add another variable such as wind, rain

• Comparing to data is critical– A narrow strip without trees would block spread –

population should be dependent on a wider region.– Are there other unrealistic behaviors of the model?– Design an experiment to isolate variable effects. This

can greatly improve your model.