Notes on Assignment 3 OpenMP Stencil Pattern

Slides:



Advertisements
Similar presentations
Partial Differential Equations
Advertisements

Practical techniques & Examples
Sharks and Fishes – The problem
1 ITCS 4/5010 CUDA Programming, UNC-Charlotte, B. Wilkinson, Feb 26, 2013, DyanmicParallelism.ppt CUDA Dynamic Parallelism These notes will outline CUDA.
CSCI-455/552 Introduction to High Performance Computing Lecture 26.
Warm Up Solve each equation. 1. 2x = 7x x = –3
Numerical Algorithms • Matrix multiplication
CSCI 317 Mike Heroux1 Sparse Matrix Computations CSCI 317 Mike Heroux.
Give qualifications of instructors: DAP
NAE C_S2001 FINAL PROJECT PRESENTATION LASIC ISMAR 04/12/01 INSTRUCTOR: PROF. GUTIERREZ.
Chapter 13 Finite Difference Methods: Outline Solving ordinary and partial differential equations Finite difference methods (FDM) vs Finite Element Methods.
Solve an equation with variables on both sides
Finite Difference Methods Or Computational Calculus.
Monte Carlo Methods in Partial Differential Equations.
Nawaf M Albadia Introduction. Components. Behavior & Characteristics. Classes & Rules. Grid Dimensions. Evolving Cellular Automata using Genetic.
Exercise problems for students taking the Programming Parallel Computers course. Janusz Kowalik Piotr Arlukowicz Tadeusz Puzniakowski Informatics Institute.
Introduction to COMSOL Travis Campbell Developed for CHE 331 – Fall 2012 Oregon State University School of Chemical, Biological and Environmental Engineering.
Lecture 8 – Stencil Pattern Stencil Pattern Parallel Computing CIS 410/510 Department of Computer and Information Science.
Molecular Dynamics Sathish Vadhiyar Courtesy: Dr. David Walker, Cardiff University.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
April 24, 2002 Parallel Port Example. April 24, 2002 Introduction The objective of this lecture is to go over a simple problem that illustrates the use.
Solving Partial Differential Equation Numerically Pertemuan 13 Matakuliah: S0262-Analisis Numerik Tahun: 2010.
Solve a two-step equation by combining like terms EXAMPLE 2 Solve 7x – 4x = 21 7x – 4x = 21 Write original equation. 3x = 21 Combine like terms. Divide.
ERT 216 HEAT & MASS TRANSFER Sem 2/ Dr Akmal Hadi Ma’ Radzi School of Bioprocess Engineering University Malaysia Perlis.
An Introduction to Computational Fluids Dynamics Prapared by: Chudasama Gulambhai H ( ) Azhar Damani ( ) Dave Aman ( )
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! 1 ITCS 4/5145 Parallel Computing,
Relaxation Methods in the Solution of Partial Differential Equations
Parallel Computing and Parallel Computers
Parallel Programming for Wave Equation
Courtesy: Dr. David Walker, Cardiff University
High Altitude Low Opening?
Parallel Programming By J. H. Wang May 2, 2017.
Synchronous Computations
Pattern Parallel Programming
Lecture 19 MA471 Fall 2003.
Stencil Pattern A stencil describes a 2- or 3- dimensional layout of processes, with each process able to communicate with its neighbors. Appears in simulating.
Using compiler-directed approach to create MPI code automatically
Pattern Parallel Programming
Solving One-Step Equations
Hidden Markov Models Part 2: Algorithms
ME/AE 339 Computational Fluid Dynamics K. M. Isaac Topic2_PDE
Numerical Algorithms • Parallelizing matrix multiplication
Solve an equation by combining like terms
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt Oct 24, 2013.
Sathish Vadhiyar Courtesy: Dr. David Walker, Cardiff University
Stencil Quiz questions
Stencil Quiz questions
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
CS6068 Applications: Numerical Methods
Parallel Computing Demand for High Performance
Graph Coverage for Source Code
COMP60621 Designing for Parallelism
Solving one- and two-step equations
Parallel Computing Demand for High Performance
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson, 2012 slides5.ppt March 20, 2014.
Pipeline Pattern ITCS 4/5145 Parallel Computing, UNC-Charlotte, B. Wilkinson slides5.ppt August 17, 2014.
Using compiler-directed approach to create MPI code automatically
Patterns Paraguin Compiler Version 2.1.
All-to-All Pattern A pattern where all (slave) processes can communicate with each other Somewhat the worst case scenario! ITCS 4/5145 Parallel Computing,
Jacobi Project Salvatore Orlando.
Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson Oct 14, 2014 slides6b.ppt 1.
Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson Jan 28,
Quiz Questions Iterative Synchronous Pattern
Introduction to High Performance Computing Lecture 16
Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson StencilPattern.ppt Oct 14,
Example 2B: Solving Linear Systems by Elimination
Parallel Programming in C with MPI and OpenMP
Quiz Questions Iterative Synchronous Pattern
CS 201 Compiler Construction
Presentation transcript:

Notes on Assignment 3 OpenMP Stencil Pattern ITCS 4/5145 Parallel computing, UNC-Charlotte, B. Wilkinson Feb 25, 2014 Assign3Notes.ppt 1

Stencil Pattern Examples A stencil describes a 2- or 3- dimensional layout of processes, with each process able to communicate only with its neighbors. Appears in simulating many real-life situations. Examples Solving partial differential equations using discretized methods, which may be for: Modeling engineering structures Weather forecasting, see intro to course slides1a-1 Particle dynamics simulations Modeling chemical and biological structures 2

Stencil pattern On each iteration, each node communicates with neighbors to get stored computed values Two-way connection Compute node Source/sink 3

(Iterative synchronous) stencil pattern Often globally synchronous and iterative: Processes compute and communicate only with their neighbors, exchanging results Check termination condition Repeat Stop 4

Finite Difference Method Example application Finite Difference Method Find values of f(x,y) in this area, given boundary conditions. Divide space into an array of solution points

Example (Static) heat distribution Static heat equation (Laplace’s equation):

Value of f(x,y) given by average of four neighboring point (left, right, up, down).

Sequential Code Assume N x N array of points, h[i][j], including fixed boundary points. Using a fixed number of iterations for (iteration = 0; iteration < limit; iteration++) { for (i = 1; i < n-1; i++) for (j = 1; j < n-1; j++) g[i][j] = 0.25*(h[i-1][j]+h[i+1][j]+h[i][j-1]+h[i][j+1]); for (i = 1; i < n; i++) /* update points */ for (j = 1; j < n; j++) h[i][j] = g[i][j]; } 1 to n-2, skip boundary edges (values 0 and n-1) Newly computed values are placed in a new array. Then copied back to the original. Called a Jacobi iteration when next iteration use only last iteration values Multiplying by 0.25 faster than dividing by 4 6b.8

Improved Jacobi Iteration int main() { int i, j, current, next; double A[2][N][M]; // A[0] is initialized with data somehow and duplicated into A[1] current = 0; next = (current + 1) % 2; for (time = 0; time < MAX_ITERATION; time++) { for (i = 1; i < N-1; i++) for (j = 1; j < M-1; j++) A[next][i][j] = (A[current][i-1][j] + A[current][i+1][j] + A[current][i][j-1] + A[current][i][j+1]) * 0.25; current = next; } // Final result is in A[current] ... Add another dimension of size 2 to A. A[0] is h and A[1] is g, alternating. We toggle between copies of the array Avoids copying values back into original array.

Application Example A room has four walls and a fireplace. Temperature of wall is 20°C, and temperature of fireplace is 100°C. Write a parallel program using Jacobi iteration to compute the temperature inside the room and plot (preferably in color) temperature contours at 10°C intervals. 10

Sample student output 11

Adding heat sources One can add heat sources inside the room such as humans (stationary). Just make these points of fixed values in array Similar problems -- heat distribution on a printed circuit board.

Extra credit Dynamic Heat Equation  

   

Possible code for (int t=t0; t<t1; t++) for (int x=1; x<M; x++) for (int y=1; y<L; y++) F(t+1,x,y) = F(t, x, y) + CX * (F(t,x-1,y) + F(t,x+1,y) -2*F(t,x,y)) + CY * (F(t,x,y-1) + F(t,x,y+1) -2*F(t,x,y)); where:CX =α∆t/∆x2, and CY = α∆t/∆y2 See http://courses.csail.mit.edu/6.884/spring10/labs/lab3.pdf

Questions