1 CALCOLO SCIENTIFICO (PARALLELO) Prof. Luca F. Pavarino Dipartimento di Matematica Universita` di Milano a.a. 20010-2011

Slides:



Advertisements
Similar presentations
Parallel Programming and Algorithms : A Primer Kishore Kothapalli IIIT-H Workshop on Multi-core Technologies International Institute.
Advertisements

1 Computational models of the physical world Cortical bone Trabecular bone.
Computer Abstractions and Technology
1 Chapter 1 Why Parallel Computing? An Introduction to Parallel Programming Peter Pacheco.
1 METODI NUMERICI PER EDP3 (CALCOLO PARALLELO) Prof. Luca F. Pavarino Dipartimento di Matematica Universita` di Milano a.a
Parallel Programming Yang Xianchun Department of Computer Science and Technology Nanjing University Introduction.
ICS 556 Parallel Algorithms Ebrahim Malalla Office: Bldg 22, Room
PARALLEL PROCESSING COMPARATIVE STUDY 1. CONTEXT How to finish a work in short time???? Solution To use quicker worker. Inconvenient: The speed of worker.
1 CALCOLO SCIENTIFICO (PARALLELO) Prof. Luca F. Pavarino Dipartimento di Matematica Universita` di Milano a.a
Claude TADONKI Mines ParisTech – LAL / CNRS / INP 2 P 3 University of Oujda (Morocco) – October 7, 2011 High Performance Computing Challenges and Trends.
CS61C L28 Parallel Computing (1) A Carle, Summer 2005 © UCB inst.eecs.berkeley.edu/~cs61c/su05 CS61C : Machine Structures Lecture #28: Parallel Computing.
Languages and Compilers for High Performance Computing Kathy Yelick EECS Department U.C. Berkeley.
CS CS 5150 Software Engineering Lecture 19 Performance.
CS267 L1 IntroDemmel Sp 1999 CS267 / E233 Applications of Parallel Computers Lecture 1: Introduction 1/18/99 James Demmel
Computational Astrophysics: Methodology 1.Identify astrophysical problem 2.Write down corresponding equations 3.Identify numerical algorithm 4.Find a computer.
Introduction What is Parallel Algorithms? Why Parallel Algorithms? Evolution and Convergence of Parallel Algorithms Fundamental Design Issues.
09/22/2008CS49601 CS4960: Parallel Programming Guest Lecture: Parallel Programming for Scientific Computing Mary Hall September 22, 2008.
01/19/2005CS267-Lecture 11 CS267/E233 Applications of Parallel Computers Lecture 1: Introduction James Demmel
1 CALCOLO SCIENTIFICO (PARALLELO) Prof. Luca F. Pavarino Dipartimento di Matematica Universita` di Milano a.a
Parallel Algorithms - Introduction Advanced Algorithms & Data Structures Lecture Theme 11 Prof. Dr. Th. Ottmann Summer Semester 2006.
Lecture 1: Introduction to High Performance Computing.
01/17/2007CS267-Lecture 11 CS267/E233 Applications of Parallel Computers Lecture 1: Introduction Kathy Yelick
Introduction to Parallel Computing. Outline Introduction Large important problems require powerful computers Why powerful computers must be parallel processors.
08/23/2011CS4961 CS4961 Parallel Programming Lecture 1: Introduction Mary Hall August 23,
CPU Performance Assessment As-Bahiya Abu-Samra *Moore’s Law *Clock Speed *Instruction Execution Rate - MIPS - MFLOPS *SPEC Speed Metric *Amdahl’s.
CSE 260 Parallel Computation Allan Snavely, Henri Casanova
Lecture 2 : Introduction to Multicore Computing Bong-Soo Sohn Associate Professor School of Computer Science and Engineering Chung-Ang University.
08/21/2012CS4230 CS4230 Parallel Programming Lecture 1: Introduction Mary Hall August 21,
Global Address Space Applications Kathy Yelick NERSC/LBNL and U.C. Berkeley.
© Fujitsu Laboratories of Europe 2009 HPC and Chaste: Towards Real-Time Simulation 24 March
Lecture 2 : Introduction to Multicore Computing
1 Interconnects Shared address space and message passing computers can be constructed by connecting processors and memory unit using a variety of interconnection.
01/19/2005CS267-Lecture 11 CS267/E233 Applications of Parallel Computers Lecture 1: Introduction James Demmel
Multi-core Programming Introduction Topics. Topics General Ideas Moore’s Law Amdahl's Law Processes and Threads Concurrency vs. Parallelism.
Introduction, background, jargon Jakub Yaghob. Literature T.G.Mattson, B.A.Sanders, B.L.Massingill: Patterns for Parallel Programming, Addison- Wesley,
Performance Measurement n Assignment? n Timing #include double When() { struct timeval tp; gettimeofday(&tp, NULL); return((double)tp.tv_sec + (double)tp.tv_usec.
Loosely Coupled Parallelism: Clusters. Context We have studied older archictures for loosely coupled parallelism, such as mesh’s, hypercubes etc, which.
Performance Measurement. A Quantitative Basis for Design n Parallel programming is an optimization problem. n Must take into account several factors:
08/24/2010CS4961 CS4961 Parallel Programming Lecture 1: Introduction Mary Hall August 24,
Problem is to compute: f(latitude, longitude, elevation, time)  temperature, pressure, humidity, wind velocity Approach: –Discretize the.
Reminder Lab 0 Xilinx ISE tutorial Research Send me an if interested Looking for those interested in RC with skills in compilers/languages/synthesis,
Parallel Simulation of Continuous Systems: A Brief Introduction
CS267 L1 Intro CS267 Applications of Parallel Computers Lecture 1: Introduction David H. Bailey Based on previous notes by Prof. Jim Demmel and Prof. David.
Parallel Processing Sharing the load. Inside a Processor Chip in Package Circuits Primarily Crystalline Silicon 1 mm – 25 mm on a side 100 million to.
PARALLEL APPLICATIONS EE 524/CS 561 Kishore Dhaveji 01/09/2000.
CSCI-455/522 Introduction to High Performance Computing Lecture 1.
CS 240A Applied Parallel Computing John R. Gilbert Thanks to Kathy Yelick and Jim Demmel at UCB for.
Computer Organization & Assembly Language © by DR. M. Amer.
Introduction to Research 2011 Introduction to Research 2011 Ashok Srinivasan Florida State University Images from ORNL, IBM, NVIDIA.
Computing Environment The computing environment rapidly evolving ‑ you need to know not only the methods, but also How and when to apply them, Which computers.
Department of Computer Science University of the West Indies Part II.
CS591x -Cluster Computing and Parallel Programming
Outline Why this subject? What is High Performance Computing?
Chapter VI What should I know about the sizes and speeds of computers?
3/12/2013Computer Engg, IIT(BHU)1 INTRODUCTION-1.
3/12/2013Computer Engg, IIT(BHU)1 INTRODUCTION-2.
3/12/2013Computer Engg, IIT(BHU)1 PARALLEL COMPUTERS- 3.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Towards a Digital Human Kathy Yelick EECS Department U.C. Berkeley.
1/50 University of Turkish Aeronautical Association Computer Engineering Department Ceng 541 Introduction to Parallel Computing Dr. Tansel Dökeroğlu
Hardware Trends CSE451 Andrew Whitaker. Motivation Hardware moves quickly OS code tends to stick around for a while “System building” extends way beyond.
Hardware Trends CSE451 Andrew Whitaker. Motivation Hardware moves quickly OS code tends to stick around for a while “System building” extends way beyond.
SPRING 2012 Assembly Language. Definition 2 A microprocessor is a silicon chip which forms the core of a microcomputer the concept of what goes into a.
Introduction to Parallel Computing: MPI, OpenMP and Hybrid Programming
Web: Parallel Computing Rabie A. Ramadan , PhD Web:
CS427 Multicore Architecture and Parallel Computing
The University of Adelaide, School of Computer Science
Parallel Programming Lecture 1: Introduction
What is Parallel and Distributed computing?
Computer Evolution and Performance
Presentation transcript:

1 CALCOLO SCIENTIFICO (PARALLELO) Prof. Luca F. Pavarino Dipartimento di Matematica Universita` di Milano a.a Corso di Laurea Magistrale e Dottorati in Matematica Applicata

2 Struttura del corso Orario -Lunedi` Aula 4 -Mertedi` Aula 5 (compattare?) -Mercoledi` Aula 3 -Venerdi` Aula settimane, 9 cfu (6 lezione, 3 laboratorio) Laboratorio in Aula 2 o LIR o LID: esercitazioni con - Nostro Cluster Linux (ulisse.mat.unimi.it), 104 processori - Nostro nuovo Cluster Linux Nemo - Cluster Linux del Cilea (avogadro.cilea.it), ~1700 processori -(nuovo IBM SP6 del Cineca (sp6.sp.cineca.it), ~5300 processori) -Uso della libreria standard per “message passing” MPI -Uso della libreria parallela di calcolo scientifico PETSc dell’Argonne National Lab., basata su MPI hardware software

3 Materiale e Testi Slides in inglese basate su corsi di calcolo parallelo tenuti a Univ. Illinois da Michael Heath, UC Berkeley da Jim Demmel, (+ MIT da Alan Edelmann) Possibili testi: - A. Grama, A. Gupta, G. Karipys, V. Kumar, Introduction to parallel computing, 2 nd ed., Addison Wesley, L. R. Scott, T. Clark, B. Bagheri, Scientific Parallel Computing, Princeton University Press, 2005 Molto materiale on-line, e.g. : - www-unix.mcs.anl.gov/dbpp/ (Ian Foster’s book) - (Demmel’s course) -www-math.mit.edu/~edelman/ (Edelman’s course) - (Heath’s course) - (Nan’s ref page)

4 Schedule of Topics 1. Introduction 2. Parallel architectures 3. Networks 4. Interprocessor communications: point-to-point, collective 5. Parallel algorithm design 6. Parallel programming, MPI: message passing interface 7. Parallel performance 8. Vector and matrix products 9. LU factorization 10. Cholesky factorization 11. PETSc parallel library 12. Iterative methods for linear systems 13. Nonlinear equations and ODEs 14. Partial Differential Equations 15. Domain Decomposition Methods 16. QR factorization 17. Eigenvalues

5 1) Introduction What is parallel computing Large important problems require powerful computers Why powerful computers must be parallel processors Why writing (fast) parallel programs is hard Principles of parallel computing performance

6 What is parallel computing It is an example of parallel processing: -division of task (process) into smaller tasks (processes) -assign smaller tasks to multiple processing units that work simultaneously -coordinate, control and monitor the units Many examples from nature: -human brain consists of ~10^11 neurons -complex living organisms consist of many cells (although monocellular organism are estimated to be ½ of the earth biomass) -leafs of trees... Many examples from daily life: -highways tollbooths, supermarket cashiers, bank tellers, … -elections, races, competitions, … -building construction -written exams...

7 Parallel computing is the use of multiple processors to execute different parts of the same program (task) simultaneously Main goals of parallel computing are: -Increase the size of problems that can be solved -bigger problem would not be solvable on a serial computer in a reasonable amount of time  decompose it into smaller problems -bigger problem might not fit in the memory of a serial computer  distribute it over the memory of many computer nodes -Reduce the “wall-clock” time to solve a problem  Solve (much) bigger problems (much) faster Subgoal: save money using cheapest available resources (clusters, beowulf, grid computing,...)

8 Not at all trivial that more processors help to achieve these goals: “If a man can dig a hole of 1 m 3 in 1 hour, can 60 men dig the same hole in 1 minute (!) ? Can 3600 men do it in 1 second (!!) ?” “I know how to make 4 horses pull a cart, but I do not know how to make 1024 chickens do it” (Enrico Clementi) “ What happens if the mean-time to failure for nodes on the Tflops machine is shorter than the boot time ? (Courtenay Vaughan)

9 Why we need powerful computers

10 Simulation: The Third Pillar of Science Traditional scientific and engineering method: (1) Do theory or paper design (2) Perform experiments or build system Limitations: –Too difficult—build large wind tunnels –Too expensive—build a throw-away passenger jet –Too slow—wait for climate or galactic evolution –Too dangerous—weapons, drug design, climate experimentation Computational science and engineering paradigm: (3) Use high performance computer systems to simulate and analyze the phenomenon -Based on known physical laws and efficient numerical methods -Analyze simulation results with computational tools and methods beyond what is used traditionally for experimental data analysis Simulation Theory Experiment

11 Some Particularly Challenging Computations Science -Global climate modeling, weather forecasts -Astrophysical modeling -Biology: Genome analysis; protein folding (drug design) -Medicine: cardiac modeling, physiology, neurosciences Engineering -Airplane design -Crash simulation -Semiconductor design -Earthquake and structural modeling Business -Financial and economic modeling -Transaction processing, web services and search engines Defense -Nuclear weapons (ASCI), cryptography, …

12 $5B World Market in Technical Computing Source: IDC 2004, from NRC Future of Supercomputer Report

13 Units of Measure in HPC High Performance Computing (HPC) units are: -Flops: floating point operations -Flops/s: floating point operations per second -Bytes: size of data (a double precision floating point number is 8) Typical sizes are millions, billions, trillions… MegaMflop/s = 10 6 flop/secMbyte = 2 20 = ~ 10 6 bytes GigaGflop/s = 10 9 flop/secGbyte = 2 30 ~ 10 9 bytes TeraTflop/s = flop/secTbyte = 2 40 ~ bytes PetaPflop/s = flop/secPbyte = 2 50 ~ bytes ExaEflop/s = flop/secEbyte = 2 60 ~ bytes ZettaZflop/s = flop/secZbyte = 2 70 ~ bytes YottaYflop/s = flop/secYbyte = 2 80 ~ bytes Current fastest (public) machine ~ 1.5 Pflop/s Up-to-date lisy at

14 Ex. 1: Global Climate Modeling Problem Problem is to compute: f(latitude, longitude, elevation, time)  temperature, pressure, humidity, wind velocity Atmospheric model: equation of fluid dynamics  Navier-Stokes system of nonlinear partial differential equations Approach: -Discretize the domain, e.g., a measurement point every 1km -Devise an algorithm to predict weather at time t+1 given t Uses: -Predict major events, e.g., El Nino -Use in setting air emissions standards Source:

15 Climate Modeling on the Earth Simulator System  Development of ES started in 1997 in order to make a comprehensive understanding of global environmental changes such as global warming.  26.58Tflops was obtained by a global atmospheric circulation code Tflops was obtained by a global atmospheric circulation code.  35.86Tflops (87.5% of the peak performance) is achieved in the Linpack benchmark.  Its construction was completed at the end of February, 2002 and the practical operation started from March 1, 2002

16 Ex. 2: Cardiac simulation Very difficult problem spanning many disciplines: -Electrophysiology (spreading of electrical excitation front) -Structural Mechanics (large deformation of incompressible biomaterial) -Fluid Dynamics (flow of blood inside the heart) Large-scale simulations in computational electrophysiology ( joint work with P. Colli-Franzone and S. Scacchi ) -Bidomain model (system of 2 reaction-diffusion equations) coupled with Luo-Rudy 1 gating (system of 7 ODEs) in 3D -Q1 finite elements in space + adaptive semi-implicit method in time -Parallel solver based on PETSc library -Linear systems up to 36 M unknowns each time-step (128 procs of Cineca SP4) solved in seconds or minutes -Simulation of full heartbeat (4 M unknowns in space, thousands of time-steps) took more than 6 days on 25 procs of Cilea HP Superdome, then about 50 hours on 36 procs of our cluster, now 6.5 hours using multilevel preconditioner

17 3D simulations: isochrones of acti, repo, APD

18 Hemodynamics in circulatory system ( work in Quarteroni’s group at MOX, Polimi ) Blood flow in the heart ( Peskin’s group, CIMS, NYU ) -Modeled as an elastic structure in an incompressible fluid. -The “immersed boundary method” due to Peskin and McQueen. -20 years of development in model -Many applications other than the heart: blood clotting, inner ear, paper making, embryo growth, and others -Use a regularly spaced mesh (set of points) for evaluating the fluid - Uses -Current model can be used to design artificial heart valves -Can help in understand effects of disease (leaky valves) -Related projects look at the behavior of the heart during a heart attack -Ultimately: real-time clinical work

19 Ex. 3: latest breakthrough

20

21

22

23

24

25

26

27

28

29

30 Ex. 4: Parallel Computing in Data Analysis Web search: -Functional parallelism: crawling, indexing, sorting -Parallelism between queries: multiple users -Finding information amidst junk -Preprocessing of the web data set to help find information Google physical structure (2004 estimate, check current status on e.g. wikipedia): -about nodes (126,544 cpus) GB RAM -5,062 TB hard drive space ( This would make Google server farm one of the most powerful supercomputer in the world ) Google index size (June 2005 estimate): -about 8 billion web pages, 1 billion images

31 - Note that the total Surface Web ( = publically indexable, i.e. reachable by web crawlers) has been estimated (Jan. 2005) at over 11.5 billion web pages. -Invisible (or Deep) Web ( = not indexed by search engines; it consists of dynamic web pages, subscription sites, searchable databases) has been estimated (2001) at over 550 billion documents. -Invisible Web not to be confused with Dark Web consisting of machines or network segments not connected to the Internet Data collected and stored at enormous speeds (Gbyte/hour) -remote sensor on a satellite -telescope scanning the skies -microarrays generating gene expression data -scientific simulations generating terabytes of data -NSA analysis of telecommunications

32 Why powerful computers are parallel

33 Tunnel Vision by Experts “I think there is a world market for maybe five computers.” -Thomas Watson, chairman of IBM, “There is no reason for any individual to have a computer in their home” -Ken Olson, president and founder of Digital Equipment Corporation, “640K [of memory] ought to be enough for anybody.” -Bill Gates, chairman of Microsoft,1981. Slide source: Warfield et al.

34 Technology Trends: Microprocessor Capacity 2X transistors/Chip Every years Called “Moore’s Law” Moore’s Law Microprocessors have become smaller, denser, and more powerful. Gordon Moore (co-founder of Intel) predicted in 1965 that the transistor density of semiconductor chips would double roughly every 18 months. Slide source: Jack Dongarra

35 Impact of Device Shrinkage What happens when the feature size shrinks by a factor of x ? Clock rate goes up by x -actually less than x, because of power consumption Transistors per unit area goes up by x 2 Die size also tends to increase -typically another factor of ~x Raw computing power of the chip goes up by ~ x 4 ! -of which x 3 is devoted either to parallelism or locality

36 Microprocessor Transistors per Chip Growth in transistors per chipIncrease in clock rate

37 But there are limiting forces Moore’s 2 nd law (Rock’s law): costs go up Demo of 0.06 micron CMOS Source: Forbes Magazine Yield -What percentage of the chips are usable? -E.g., Cell processor (PS3) is sold with 7 out of 8 “on” to improve yield Manufacturing costs and yield problems limit use of density

38 Revolution is Happening Now Chip density is continuing increase ~2x every 2 years -Clock speed is not -Number of processor cores may double instead There is little or no more hidden parallelism (ILP) to be found Parallelism must be exposed to and managed by software Source: Intel, Microsoft (Sutter) and Stanford (Olukotun, Hammond)

39 Parallelism in ? These arguments are no longer theoretical All major processor vendors are producing multicore chips -Every machine will soon be a parallel machine -To keep doubling performance, parallelism must double Which commercial applications can use this parallelism? -Do they have to be rewritten from scratch? Will all programmers have to be parallel programmers? -New software model needed -Try to hide complexity from most programmers – eventually -In the meantime, need to understand it Computer industry betting on this big change, but does not have all the answers -Berkeley ParLab established to work on this

40 Physical limits: how fast can a serial computer be? Consider the 1 Tflop/s sequential machine : -Data must travel some distance, r, to get from memory to CPU. -Go get 1 data element per cycle, this means times per second at the speed of light, c = 3x10 8 m/s. Thus r < c/10 12 = 0.3 mm. Now put 1 Tbyte of storage in a 0.3 mm 0.3 mm area : (in fact 0.3^2 mm^2/10^12 = 9 10^(-2) 10^(-6) m^2/10^12 = 9 10^(-20) m^2 = (3 10^(-10))^2 m^2 = 3^2 A^2  -Each byte occupies less than 3 square Angstroms, or the size of a small atom! (1 Angstrom = 10^(-10) m = 0.1 nanometer) No choice but parallelism r = 0.3 mm 1 Tflop/s, 1 Tbyte sequential machine

41 More Exotic Solutions on the Horizon GPUs - Graphics Processing Units (eg NVidia) -Parallel processor attached to main processor -Originally special purpose, getting more general FPGAs – Field Programmable Gate Arrays -Inefficient use of chip area -More efficient than multicore now, maybe not later -Wire routing heuristics still troublesome Dataflow and tiled processor architectures -Have considerable experience with dataflow from 1980’s -Are we ready to return to functional programming languages? Cell -Software controlled memory uses bandwidth efficiently -Programming model not yet mature

42 “Automatic” Parallelism in Modern Machines Bit level parallelism: within floating point operations, etc. Instruction level parallelism (ILP): multiple instructions execute per clock cycle. Memory system parallelism: overlap of memory operations with computation. OS parallelism: multiple jobs run in parallel on commodity SMPs. There are limitations to all of these:  to achieve high performance, the programmer needs to identify, schedule and coordinate parallel tasks and data.

43 Processor-DRAM Gap (latency) µProc 60%/yr. DRAM 7%/yr DRAM CPU 1982 Processor-Memory Performance Gap: (grows 50% / year) Performance Time “Moore’s Law”

44 Principles of Parallel Computing Parallelism and Amdahl’s Law Finding and exploiting granularity Preserving data locality Load balancing Coordination and synchronization Performance modeling All of these issues makes parallel programming harder than sequential programming.

45 Amdahl’s law: Finding Enough Parallelism Suppose only part of an application seems parallel Amdahl’s law -Let s be the fraction of work done sequentially, so (1-s) is fraction parallelizable. -P = number of processors. Speedup(P) = Time(1)/Time(P) <= 1/(s + (1-s)/P) <= 1/s Even if the parallel part speeds up perfectly, we may be limited by the sequential portion of code. Ex: if only s = 1%, then speedup <= 100  not worth it using more than p = 100 processors

46 Overhead of Parallelism Given enough parallel work, this is the most significant barrier to getting desired speedup. Parallelism overheads include: -cost of starting a thread or process -cost of communicating shared data -cost of synchronizing -extra (redundant) computation Each of these can be in the range of milliseconds (= millions of flops) on some systems Tradeoff: Algorithm needs sufficiently large units of work to run fast in parallel (i.e. large granularity), but not so large that there is not enough parallel work.

47 Locality and Parallelism Large memories are slow, fast memories are small. Storage hierarchies are large and fast on average. Parallel processors, collectively, have large, fast memories -- the slow accesses to “remote” data we call “communication”. Algorithm should do most work on local data. Proc Cache L2 Cache L3 Cache Memory Conventional Storage Hierarchy Proc Cache L2 Cache L3 Cache Memory Proc Cache L2 Cache L3 Cache Memory potential interconnects

48 Load Imbalance Load imbalance is the time that some processors in the system are idle due to -insufficient parallelism (during that phase). -unequal size tasks. Examples of the latter -adapting to “interesting parts of a domain”. -tree-structured computations. -fundamentally unstructured problems -Adaptive numerical methods in PDE (adaptivity and parallelism seem to conflict). Algorithm needs to balance load -but techniques to balance load often reduce locality

49 Measuring Performance: Real Performance? , Teraflops 1996 Peak Performance grows exponentially, a la Moore’s Law l In 1990’s, peak performance increased 100x; in 2000’s, it will increase 1000x But efficiency (the performance relative to the hardware peak) has declined l was 40-50% on the vector supercomputers of 1990s l now as little as 5-10% on parallel supercomputers of today Close the gap through... l Mathematical methods and algorithms that achieve high performance on a single processor and scale to thousands of processors l More efficient programming models and tools for massively parallel supercomputers Performance Gap Peak Performance Real Performance

50 Performance Levels Peak advertised performance (PAP) -You can’t possibly compute faster than this speed LINPACK -The “hello world” program for parallel computing -Solve Ax=b using Gaussian Elimination, highly tuned Gordon Bell Prize winning applications performance -The right application/algorithm/platform combination plus years of work Average sustained applications performance -What one reasonable can expect for standard applications When reporting performance results, these levels are often confused, even in reviewed publications

51 Performance Levels (for example on NERSC-5) Peak advertised performance (PAP): 100 Tflop/s LINPACK (TPP): 84 Tflop/s Best climate application: 14 Tflop/s -WRF code benchmarked in December 2007 Average sustained applications performance: ? Tflop/s -Probably less than 10% peak! We will study performance -Hardware and software tools to measure it -Identifying bottlenecks -Practical performance tuning (Matlab demo)

52

53

54

55

56

57

58

59 Simple example 1: sum of N numbers, P procs Also known as reduction (of the vector [a 1,…,a N ] to the scalar A) - Assume N is an integer multiple of P: N = kP - Divide the sum into P partial sums: Then P parallel tasks, each with k -1 additions of k = N/P data Global sum (not parallel, communication needed)

60 Simple example 2: pi - Use composite midpoints quadrature rule: where h = 1/N and -Decompose sum into P parallel partial sums + 1 global sum, (as before or with stride P) On processor myid = 0,…,P-1, (P = numprocs) compute: sum = 0; for I = myid + 1:numprocs:N, x = h*(I – 0.5); sum = sum + 4/(1+x*x); end; mypi = h*sum; global sum the local mypi into glob_pi (reduction)

61 Simple example 3: prime number sieve See exercise in class Simple example 4: Jacobi method for BVP See exercise in class