Mattan Erez The University of Texas at Austin

Slides:



Advertisements
Similar presentations
Parallel Programming Patterns Eun-Gyu Kim June 10, 2004.
Advertisements

ILP: IntroductionCSCE430/830 Instruction-level parallelism: Introduction CSCE430/830 Computer Architecture Lecturer: Prof. Hong Jiang Courtesy of Yifeng.
Vector Processing. Vector Processors Combine vector operands (inputs) element by element to produce an output vector. Typical array-oriented operations.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lecture 14: Basic Parallel Programming Concepts.
CISC 879 : Software Support for Multicore Architectures John Cavazos Dept of Computer & Information Sciences University of Delaware
Includes slides from “Multicore Programming Primer” course at Massachusetts Institute of Technology (MIT) by Prof. Saman Amarasinghe and Dr. Rodric Rabbah.
An Introduction To PARALLEL PROGRAMMING Ing. Andrea Marongiu
ECE669 L4: Parallel Applications February 10, 2004 ECE 669 Parallel Computer Architecture Lecture 4 Parallel Applications.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 Structuring Parallel Algorithms.
CISC 879 : Software Support for Multicore Architectures John Cavazos Dept of Computer & Information Sciences University of Delaware
High Performance Computing 1 Parallelization Strategies and Load Balancing Some material borrowed from lectures of J. Demmel, UC Berkeley.
Multiscalar processors
Computer Organization and Architecture
A Pattern Language for Parallel Programming Beverly Sanders University of Florida.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Programming Massively Parallel Processors.
Rechen- und Kommunikationszentrum (RZ) Parallelization at a Glance Christian Terboven / Aachen, Germany Stand: Version 2.3.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
Introduction, background, jargon Jakub Yaghob. Literature T.G.Mattson, B.A.Sanders, B.L.Massingill: Patterns for Parallel Programming, Addison- Wesley,
Parallel Processing - introduction  Traditionally, the computer has been viewed as a sequential machine. This view of the computer has never been entirely.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 Basic Parallel Programming Concepts Computational.
CS 484 Designing Parallel Algorithms Designing a parallel algorithm is not easy. There is no recipe or magical ingredient Except creativity We can benefit.
Lecture 3 : Performance of Parallel Programs Courtesy : MIT Prof. Amarasinghe and Dr. Rabbah’s course note.
Finding concurrency Jakub Yaghob. Finding concurrency design space Starting point for design of a parallel solution Analysis The patterns will help identify.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Spring 2010 Lecture 13: Basic Parallel.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Lecture 15: Basic Parallel Programming Concepts.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Spring 2010 Programming Massively Parallel.
3/12/2013Computer Engg, IIT(BHU)1 INTRODUCTION-1.
A Pattern Language for Parallel Programming Beverly Sanders University of Florida.
3/12/2013Computer Engg, IIT(BHU)1 CONCEPTS-1. Pipelining Pipelining is used to increase the speed of processing It uses temporal parallelism In pipelining,
Concurrency and Performance Based on slides by Henri Casanova.
Department of Computer Science, Johns Hopkins University Lecture 7 Finding Concurrency EN /420 Instructor: Randal Burns 26 February 2014.
These slides are based on the book:
Chapter 7 Memory Management
Auburn University COMP8330/7330/7336 Advanced Parallel and Distributed Computing Parallel Hardware Dr. Xiao Qin Auburn.
Advanced Computer Systems
Parallel Patterns.
Algorithms and Problem Solving
Code Optimization.
Introduction to Parallel Computing: MPI, OpenMP and Hybrid Programming
Lecture 1 Introduction Richard Gesick.
Conception of parallel algorithms
Introduction to Design Patterns
Multiscalar Processors
Parallel Processing - introduction
Parallel Programming By J. H. Wang May 2, 2017.
Parallel Programming Patterns
CS101 Introduction to Computing Lecture 19 Programming Languages
Parallel Algorithm Design
EE 193: Parallel Computing
Mattan Erez The University of Texas at Austin
Pipelining and Vector Processing
Mattan Erez The University of Texas at Austin
Chapter 4: Threads.
Mattan Erez The University of Texas at Austin
Central Processing Unit
Mattan Erez The University of Texas at Austin
CSE403 Software Engineering Autumn 2000 Design (Overview)
CS 584.
Parallelismo.
Operating System Chapter 7. Memory Management
Algorithms and Problem Solving
PERFORMANCE MEASURES. COMPUTATIONAL MODELS Equal Duration Model:  It is assumed that a given task can be divided into n equal subtasks, each of which.
Mattan Erez The University of Texas at Austin
Chapter 4: Threads & Concurrency
Mattan Erez The University of Texas at Austin
© David Kirk/NVIDIA and Wen-mei W. Hwu,
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
Mattan Erez The University of Texas at Austin
Presentation transcript:

Mattan Erez The University of Texas at Austin EE382N (20): Computer Architecture - Parallelism and Locality Spring 2015 Lecture 14 – Parallelism in Software I Mattan Erez The University of Texas at Austin EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Credits Most of the slides courtesy Dr. Rodric Rabbah (IBM) Taken from 6.189 IAP taught at MIT in 2007 Parallel Scan slides courtesy David Kirk (NVIDIA) and Wen-Mei Hwu (UIUC) Taken from EE493-AI taught at UIUC in Sprig 2007 EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Parallel programming from scratch Start with an algorithm Formal representation of problem solution Sequence of steps Make sure there is parallelism In each algorithm step Minimize synchronization points Don’t forget locality Communication is costly Performance, Energy, System cost More often start with existing sequential code EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Reengineering for Parallelism Define a testing protocol Identify program hot spots: where is most of the time spent? Look at code Use profiling tools Parallelization Start with hot spots first Make sequences of small changes, each followed by testing Patterns provide guidance EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

4 Common Steps to Creating a Parallel Program Partitioning decomposi t ion assignment orchest rat ion mapping UE0 UE1 UE0 UE1 UE0 UE1 UE2 UE3 UE2 UE3 UE2 UE3 Sequential Computation Tasks Units of Execution Parallel Processors program EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Main consideration: coverage and Amdahl’s Law Decomposition Identify concurrency and decide at what level to exploit it Break up computation into tasks to be divided among processes Tasks may become available dynamically Number of tasks may vary with time Enough tasks to keep processors busy Number of tasks available at a time is upper bound on achievable speedup Main consideration: coverage and Amdahl’s Law EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Coverage Amdahl's Law: The performance improvement to be gained from using some faster mode of execution is limited by the fraction of the time the faster mode can be used. Demonstration of the law of diminishing returns EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Amdahl’s Law Potential program speedup is defined by the fraction of code that can be parallelized time Use 5 processors for parallel work 25 seconds + sequential 25 seconds + sequential parallel 50 seconds + 10 seconds + sequential sequential 25 seconds 25 seconds 100 seconds 60 seconds EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Amdahl’s Law Speedup = old running time / new running time Use 5 processors for parallel work 25 seconds + sequential 25 seconds + sequential parallel 50 seconds + 10 seconds + sequential sequential 25 seconds 25 seconds 100 seconds 60 seconds Speedup = old running time / new running time = 100 seconds / 60 seconds = 1.67 (parallel version is 1.67 times faster) EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Amdahl’s Law p = fraction of work that can be parallelized n = the number of processor fraction of time to complete parallel work fraction of time to complete sequential work EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Implications of Amdahl’s Law Speedup tends to as number of processors tends to infinity Super linear speedups are possible due to registers and caches Typical speedup is less than linear linear speedup (100% efficiency) number of processors speedup Parallelism only worthwhile when it dominates execution EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Main considerations: granularity and locality Assignment Specify mechanism to divide work among PEs Balance work and reduce communication Structured approaches usually work well Code inspection or understanding of application Well-known design patterns As programmers, we worry about partitioning first Independent of architecture or programming model? Complexity often affects decisions Architectural model affects decisions Main considerations: granularity and locality EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Fine vs. Coarse Granularity Coarse-grain Parallelism High computation to communication ratio Large amounts of computational work between communication events Harder to load balance efficiently Fine-grain Parallelism Low computation to communication ratio Small amounts of computational work between communication stages High communication overhead Potential HW assist EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Load Balancing vs. Synchronization Fine Coarse PE0 PE1 PE0 PE1 EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Load Balancing vs. Synchronization Fine Coarse PE0 PE1 PE0 PE1 Expensive sync  coarse granularity Few units of exec + time disparity  fine granularity EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Orchestration and Mapping Computation and communication concurrency Preserve locality of data Schedule tasks to satisfy dependences early Survey available mechanisms on target system Main considerations: locality, parallelism, mechanisms (efficiency and dangers) EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Parallel Programming by Pattern Provides a cookbook to systematically guide programmers Decompose, Assign, Orchestrate, Map Can lead to high quality solutions in some domains Provide common vocabulary to the programming community Each pattern has a name, providing a vocabulary for discussing solutions Helps with software reusability, malleability, and modularity Written in prescribed format to allow the reader to quickly understand the solution and its context Otherwise, too difficult for programmers, and software will not fully exploit parallel hardware EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

History Berkeley architecture professor Christopher Alexander In 1977, patterns for city planning, landscaping, and architecture in an attempt to capture principles for “living” design EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Example 167 (p. 783): 6ft Balcony Not just a collection of patterns, but a pattern language/ Patterns leads to other patterns. Patterns are hierarchical and compositional. Embodies design methodology and vocabulary. EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Patterns in Object-Oriented Programming Design Patterns: Elements of Reusable Object- Oriented Software (1995) Gang of Four (GOF): Gamma, Helm, Johnson, Vlissides Catalogue of patterns Creation, structural, behavioral Design patterns describe successful solutions to recurring design problems, and are organized hierarchically into a pattern language. Their form has proven to be a useful tool to model design experience, in architecture where they were originally conceived [1, 2] EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Patterns for Parallelizing Programs 4 Design Spaces Algorithm Expression Finding Concurrency Expose concurrent tasks Algorithm Structure Map tasks to processes to exploit parallel architecture Software Construction Supporting Structures Code and data structuring patterns Implementation Mechanisms Low level mechanisms used to write parallel programs Patterns for Parallel Programming. Mattson, Sanders, and Massingill (2005). EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Here’s my algorithm. Where’s the concurrency? MPEG Decoder MPEG bit stream VLD macroblocks, motion vectors split frequency encoded macroblocks differentially coded motion vectors ZigZag IQuantization Motion Vector Decode IDCT Repeat Saturation spatially encoded macroblocks motion vectors join Motion Compensation recovered picture Picture Reorder Color Conversion Display EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Here’s my algorithm. Where’s the concurrency? MPEG Decoder MPEG bit stream Task decomposition Independent coarse-grained computation Inherent to algorithm Sequence of statements (instructions) that operate together as a group Corresponds to some logical part of program Usually follows from the way programmer thinks about a problem VLD macroblocks, motion vectors split frequency encoded macroblocks differentially coded motion vectors ZigZag IQuantization Motion Vector Decode IDCT Repeat Saturation spatially encoded macroblocks motion vectors join Motion Compensation recovered picture Picture Reorder Color Conversion Display EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Here’s my algorithm. Where’s the concurrency? MPEG Decoder MPEG bit stream Task decomposition Parallelism in the application Pipeline task decomposition Data assembly lines Producer-consumer chains VLD macroblocks, motion vectors split frequency encoded macroblocks differentially coded motion vectors ZigZag IQuantization Motion Vector Decode IDCT Repeat Saturation spatially encoded macroblocks motion vectors join Motion Compensation recovered picture Picture Reorder Color Conversion Display EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Here’s my algorithm. Where’s the concurrency? MPEG Decoder MPEG bit stream Task decomposition Parallelism in the application Pipeline task decomposition Data assembly lines Producer-consumer chains Data decomposition Same computation is applied to small data chunks derived from large data set VLD macroblocks, motion vectors split frequency encoded macroblocks differentially coded motion vectors ZigZag IQuantization Motion Vector Decode IDCT Repeat Saturation spatially encoded macroblocks motion vectors join Motion Compensation recovered picture Picture Reorder Color Conversion Display EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Guidelines for Task Decomposition Algorithms start with a good understanding of the problem being solved Programs often naturally decompose into tasks Two common decompositions are Function calls and Distinct loop iterations Easier to start with many tasks and later fuse them, rather than too few tasks and later try to split them EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Guidelines for Task Decomposition Flexibility Program design should afford flexibility in the number and size of tasks generated Tasks should not tied to a specific architecture Fixed tasks vs. Parameterized tasks Efficiency Tasks should have enough work to amortize the cost of creating and managing them Tasks should be sufficiently independent so that managing dependencies doesn’t become the bottleneck Simplicity The code has to remain readable and easy to understand, and debug EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Case for Pipeline Decomposition Data is flowing through a sequence of stages Assembly line is a good analogy What’s a prime example of pipeline decomposition in computer architecture? Instruction pipeline in modern CPUs What’s an example pipeline you may use in your UNIX shell? Pipes in UNIX: cat foobar.c | grep bar | wc Other examples Signal processing Graphics ZigZag IQuantization IDCT Saturation EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Guidelines for Data Decomposition Data decomposition is often implied by task decomposition Programmers need to address task and data decomposition to create a parallel program Which decomposition to start with? Data decomposition is a good starting point when Main computation is organized around manipulation of a large data structure Similar operations are applied to different parts of the data structure EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Common Data Decompositions Geometric data structures Decomposition of arrays along rows, columns, blocks Decomposition of meshes into domains EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Common Data Decompositions Geometric data structures Decomposition of arrays along rows, columns, blocks Decomposition of meshes into domains Recursive data structures Example: decomposition of trees into sub-trees problem subproblem split subproblem split split compute subproblem compute subproblem compute subproblem compute subproblem merge merge subproblem subproblem merge solution EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Guidelines for Data Decomposition Flexibility Size and number of data chunks should support a wide range of executions Efficiency Data chunks should generate comparable amounts of work (for load balancing) Simplicity Complex data compositions can get difficult to manage and debug EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Data Decomposition Examples Molecular dynamics Compute forces Update accelerations and velocities Update positions Decomposition Baseline algorithm is N2 All-to-all communication Best decomposition is to treat mols. as a set Some advantages to geometric discussed in future lecture EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez

Data Decomposition Examples Molecular dynamics Geometric decomposition Merge sort Recursive decomposition problem subproblem split subproblem split split compute subproblem compute subproblem compute subproblem compute subproblem merge merge subproblem subproblem merge solution EE382N: Parallelilsm and Locality, Spring 2015 -- Lecture 14 (c) Rodric Rabbah, Mattan Erez