A Pattern Language for Parallel Programming Beverly Sanders University of Florida.

Slides:



Advertisements
Similar presentations
Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Advertisements

Parallel Programming Patterns Eun-Gyu Kim June 10, 2004.
U NIVERSITY OF D ELAWARE C OMPUTER & I NFORMATION S CIENCES D EPARTMENT Optimizing Compilers CISC 673 Spring 2009 Potential Languages of the Future Chapel,
Parallel Programming Patterns Ralph Johnson. Why patterns? Patterns for Parallel Programming The road ahead.
Master/Slave Architecture Pattern Source: Pattern-Oriented Software Architecture, Vol. 1, Buschmann, et al.
Introduction CSCI 444/544 Operating Systems Fall 2008.
CISC 879 : Software Support for Multicore Architectures John Cavazos Dept of Computer & Information Sciences University of Delaware
ISBN Chapter 3 Describing Syntax and Semantics.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
CISC October Goals for today: Foster’s parallel algorithm design –Partitioning –Task dependency graph Granularity Concurrency Collective communication.
Reference: Message Passing Fundamentals.
Behavioral Design Outline –Design Specification –Behavioral Design –Behavioral Specification –Hardware Description Languages –Behavioral Simulation –Behavioral.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Parallel Programming in C with MPI and OpenMP Michael J. Quinn.
Parallel Programming Models and Paradigms
Ralph Johnson - University of Illinois1 Patterns: What They Are, and How to Write Them Ralph Johnson University of Illinois at Urbana-Champaign
CISC 879 : Software Support for Multicore Architectures John Cavazos Dept of Computer & Information Sciences University of Delaware
Describing Syntax and Semantics
OPL: Our Pattern Language. Background Design Patterns: Elements of Reusable Object-Oriented Software o Introduced patterns o Very influential book Pattern.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Programming Massively Parallel Processors.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
L15: Putting it together: N-body (Ch. 6) October 30, 2012.
ICOM 5995: Performance Instrumentation and Visualization for High Performance Computer Systems Lecture 7 October 16, 2002 Nayda G. Santiago.
Parallel Programming Models Jihad El-Sana These slides are based on the book: Introduction to Parallel Computing, Blaise Barney, Lawrence Livermore National.
Designing and Evaluating Parallel Programs Anda Iamnitchi Federated Distributed Systems Fall 2006 Textbook (on line): Designing and Building Parallel Programs.
CCA Common Component Architecture Manoj Krishnan Pacific Northwest National Laboratory MCMD Programming and Implementation Issues.
Computational issues in Carbon nanotube simulation Ashok Srinivasan Department of Computer Science Florida State University.
© 2009 Mathew J. Sottile, Timothy G. Mattson, and Craig E Rasmussen 1 Concurrency in Programming Languages Matthew J. Sottile Timothy G. Mattson Craig.
Chapter 3 Parallel Algorithm Design. Outline Task/channel model Task/channel model Algorithm design methodology Algorithm design methodology Case studies.
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Introduction, background, jargon Jakub Yaghob. Literature T.G.Mattson, B.A.Sanders, B.L.Massingill: Patterns for Parallel Programming, Addison- Wesley,
SE: CHAPTER 7 Writing The Program
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
1 What is OO Design? OO Design is a process of invention, where developers create the abstractions necessary to meet the system’s requirements OO Design.
Testing Extensible Design Patterns in OO Frameworks through Scenario Templates D.S. Sanders Software Verification & Validation.
Modeling VHDL in POSE. Overview Motivation Motivation Quick Introduction to VHDL Quick Introduction to VHDL Mapping VHDL to POSE (the Translator) Mapping.
CSC 480 Software Engineering Design With Patterns.
Lecture 4 TTH 03:30AM-04:45PM Dr. Jianjun Hu CSCE569 Parallel Computing University of South Carolina Department of.
Parallelization of likelihood functions for data analysis Alfio Lazzaro CERN openlab Forum on Concurrent Programming Models and Frameworks.
CS 484 Designing Parallel Algorithms Designing a parallel algorithm is not easy. There is no recipe or magical ingredient Except creativity We can benefit.
CS- 492 : Distributed system & Parallel Processing Lecture 7: Sun: 15/5/1435 Foundations of designing parallel algorithms and shared memory models Lecturer/
Architecture View Models A model is a complete, simplified description of a system from a particular perspective or viewpoint. There is no single view.
Design Reuse Earlier we have covered the re-usable Architectural Styles as design patterns for High-Level Design. At mid-level and low-level, design patterns.
Finding concurrency Jakub Yaghob. Finding concurrency design space Starting point for design of a parallel solution Analysis The patterns will help identify.
Parallelization Strategies Laxmikant Kale. Overview OpenMP Strategies Need for adaptive strategies –Object migration based dynamic load balancing –Minimal.
© David Kirk/NVIDIA and Wen-mei W. Hwu, ECE 498AL, University of Illinois, Urbana-Champaign 1 ECE 498AL Spring 2010 Lecture 13: Basic Parallel.
A Pattern Language for Parallel Programming Beverly Sanders University of Florida.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
3/12/2013Computer Engg, IIT(BHU)1 OpenMP-1. OpenMP is a portable, multiprocessing API for shared memory computers OpenMP is not a “language” Instead,
Parallel Computing Presented by Justin Reschke
Department of Computer Science, Johns Hopkins University Lecture 7 Finding Concurrency EN /420 Instructor: Randal Burns 26 February 2014.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Application of Design Patterns to Geometric Decompositions V. Balaji, Thomas L. Clune, Robert W. Numrich and Brice T. Womack.
Parallel Patterns.
Introduction to Design Patterns
Parallel Programming By J. H. Wang May 2, 2017.
Parallel Programming Patterns
Pattern Parallel Programming
Parallel Algorithm Design
Parallel Programming in C with MPI and OpenMP
Mattan Erez The University of Texas at Austin
Mattan Erez The University of Texas at Austin
HCI – DESIGN RATIONALE 20 November 2018.
Mattan Erez The University of Texas at Austin
CS 584.
DESIGN PATTERNS : Introduction
Mattan Erez The University of Texas at Austin
Parallel Programming in C with MPI and OpenMP
Mattan Erez The University of Texas at Austin
Presentation transcript:

A Pattern Language for Parallel Programming Beverly Sanders University of Florida

Overview of talk History of pattern languages Motivation for a pattern language for parallel programming Pattern example: Reengineering for Parallelism Tour through the entire pattern language via a programming example

History ‘60s and ‘70s Berkeley architecture professor Christopher Alexander 253 patterns for city planning, landscaping, and architecture Attempted to capture principles for “living” design.

Example: Six Foot Balcony Balconies less than six feet deep are hardly ever used Discussion of what makes a good balcony Therefore: Whenever you build a balcony or a porch, always make it at least six feet deep. If possible, recess at least a part of it into the building so that it is not cantilevered out and separated from the building by a simple line, and enclose it partially

A new approach to design Not just a collection of patterns, but a pattern language –Patterns lead to other patterns –Patterns are hierarchical and compositional –Embodies design methodology and vocabulary Small impact on architectural practice

Patterns in Object-oriented Programming OOPSLA’87 Kent Beck and Ward Cunningham 1995 Design Patterns: Elements of Reusable Object-Oriented Software Gang of Four (GOF): Gamma, Helm, Johnson, Vlissides, –catalog of patterns –Creation, structural, behavioral PLoP Conferences

GOF Pattern Example Behavioral Pattern: Visitor –Separate the structure of an object collection from the operations performed on that collection. –Example: Abstract syntax tree in a compiler Multiple node types (declaration, command, expression, etc.) Action during traversal depends on both type of node and compiler pass (type checking, code generation) Can add new functionality by implementing new visitor without modifying AST code.

Impact of GOF book Good solutions to frequently recurring problems New vocabulary Pattern catalog Significant influence on object-oriented programming!

Design Pattern High quality solution to frequently recurring problem in some domain Each pattern has a name, providing a vocabulary for discussing the solutions Written in prescribed format to allow the reader to quickly understand the solution and its context

A pattern format Name Also known as ProblemContextForcesSolution Examples and known uses Related patterns …

Pattern Language Carefully structured collection of patterns Structure embodies a design methodology and leads user through the language so that complex designs can be developed using patterns Provides domain specific advice to the designer Not a programming language

Parallel Programming Parallel hardware becoming increasingly mainstream and inexpensive –Multicore CPUs in desktop PCs and servers –Clusters Software to fully exploit the hardware currently rare (except specialized area of high performance computing) Can a pattern language providing guidance for the entire development process make parallel programming easier?

Structure of the pattern language –Reengineering for Parallelism pattern for dealing with legacy sequential code 4 Design spaces –Finding Concurrency Help designer expose exploitable concurrency— find high level task and data decomposition –Algorithm Structure Help designer map tasks to processes or threads to best take advantage of the potential concurrency

Structure of the pattern language, continued –Supporting Structures Code structuring patterns Distributed and thread-safe data structures –Implementation Mechanisms Low level mechanisms used to write parallel programs 3 categories of mechanisms –UE (process/thread) Management –Synchronization –Communication

Starting with legacy sequential application? Reengineering for Parallelism pattern provides guidance to –Manage the process –Determine what to change We’ll look at this as an example pattern

Reengineering for Parallelism Problem: How can existing applications be parallelized using PLPP to improve performance by making use of parallel hardware? Context: We have legacy code that cannot be rewritten from scratch, need to improve performance… Forces: –User base has expectations for behavior –Existing application may not be fully understood –Amdahl’s law pushes programmer to avoid sequential bottlenecks at any cost, which may imply wholesale restructuring of the program –Starting point is working code that embodies significant programming work, bug fixes, and knowledge. Minimizing changes is desirable. It is rarely feasible to make sweeping rewrites. –Concurrency introduces new classes of errors that are hard to detect and make software difficult to validate.

Solution:Preparation Survey the landscape –Pattern provides a list of questions to help assess existing code –Many are the same as in any reengineering project –Is program numerically well-behaved? Define the scope and get users’ buy-in –Required precision of results –Input range –Performance –Feasibility (back of envelope calculations) Define a testing protocol

Solution: Continued Identify hot spots—where is most of the time spent? –Look at code –Use profiling tools Parallelization –Start with hot spots first –As much as possible, make sequence of small changes, each followed by testing –Use PLPP patterns (pattern provides guidance)

Reengineering for Parallelism Pattern, continued Extended example Discussion of related patterns –Patterns for legacy code –Patterns for parallel programming

Example: Molecular dynamics Simulate motion in large molecular system Example application: how protein interacts with drug Forces –Bonded forces within a molecule –Long-range forces between molecules Not tractable N 2 Use cutoff method—only consider forces from neighbors that are “close enough”

Sequential Molecular dynamics simulation real atoms(3,N) real atoms(3,N) real force(3,N) real force(3,N) int neighbors(2,M) int neighbors(2,M) loop over time steps Compute bonded forces Compute neighbors Compute long-range forces Update position … end loop

Starting with legacy sequential code? If so start with the Reengineering for Parallelism pattern Next: Finding Concurrency Design Space

Decomposition Patterns Finding Concurrency Design Space Dependency Analysis Patterns Design Evaluation

Decomposition Patterns Finding Concurrency Design Space Dependency Analysis Patterns Design Evaluation Task DecompositionData Decomposition

Molecular dynamics decomposition Each function is a loop over atoms Suggests task decomposition with each task corresponding to a loop iteration (update of an atom) –tasks for bonded forces –tasks for long -range forces –tasks to update positions –tasks to compute neighbor list Data shared between the tasks

Decomposition Patterns Finding Concurrency Design Space Dependency Analysis Patterns Design Evaluation Group tasksOrder tasksData Sharing

Molecular dynamics dependency analysis Bonded forces Neighbor list Update position Long-range forces next time step

Molecular dynamics dependency analysis Bonded forces Neighbor list Update position Long-range forces next time step atoms(3,N) forces(3,N) neighbors Read Write Accumulate

Decomposition Patterns Finding Concurrency Design Space Dependency Analysis Patterns Design Evaluation Suitability for target platform Design Quality (flexibility, efficiency, simplicity) Preparation for the next phase

Design evaluation for molecular dynamics Target architecture for example: distributed memory cluster, message passing Data sharing has enough special properties (read only, accumulate, temporal constraints) that we should be able to make it work in a distributed memory environment. Design seems OK, move to next design space

Algorithm structure design space Map tasks to Units of Execution (threads or processes) Target platform properties –number of UEs –communication between UEs Major organizing principle

Organize by tasks? Recursive? Task Parallelism Divide and Conquer yes no

Organize by data? Recursive? Geometric Decomposition Recursive Data yes no

Organize by ordering? Regular? Event-based Coordination Pipeline yes no

Algorithm structure for molecular dynamics Organized by task Task decomposition pattern –Granularity: decide bonded forces not worth parallelizing now. –Load balancing: static OK, partition iterations of original loop (over atoms) to UEs –Termination: easy since number of UEs can be determined in advance

Separable dependencies Multiple tasks update force array concurrently by adding to its value. This type of update is called accumulation Allows dependencies to be separated from concurrent part of computation –Each UE gets a local copy of data –Updates local copy –After local updates completed, reduce (combine results using associative operator)

Supporting Structures Design Space A intermediate stage between algorithm structures and implementation mechanisms (Similar level to GOF) Program structuring patterns –SPMD, Fork/Join, Loop Parallelism, Master/Worker Data structures –Shared queue, Distributed array, Shared data

Choose SPMD Pattern Single program multiple data. –Each UE executes exactly the same program –Uses process ID to determine behavior –Issues: replicate or partition data, computation?

Replicate or partition data in MD? –Replicate atoms, force. –Partition neighbor list Duplicate non-parallelized parts of computation, or designate one process to compute? –Duplicate all computation except I/O.

Parallel Simulation real atoms(3,N) real atoms(3,N) real force(3,N) real force(3,N) int neighbors(2,M) int neighbors(2,M) myID = getProcessID myID = getProcessID nprocs = getNumberProcesses nprocs = getNumberProcesses loop over time steps Compute bonded forces //replicate computation Compute neighbors //only for atoms assigned to myID //only for atoms assigned to myID Compute long range forces globalSum(N,&forces) //reduction to combine all force arrays //reduction to combine all force arrays Update position … end loop if (myid == printID) printResults

Implementation Mechanisms Describes low level mechanisms used to write parallel programs 3 categories of mechanisms –UE (process/thread) Management –Synchronization –Communication Not in pattern format We discuss OpenMP, MPI, and Java

Implement Simulation For our target platform, MPI is the best choice Need to add standard code for initialization and MPI specific reduction operator to previous solution

Pattern languages evolve A pattern language should not be considered a static document: –Evaluate and revise –Extend with new patterns: new parallel programming models, specific application domains –We added the Reengineering for Parallelism pattern as a result of feedback from readers

For more information Mattson, Sanders, and Massingill. Patterns for Parallel Programming. Addison-Wesley Software Patterns Series Reengineering for Parallelism, PLoP05

Acknowledgements and collaborators The pattern language is joint work with: –Tim Mattson, Intel –Berna Massingill, Trinity University Supported by NSF and Intel