We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byKelly Manford
Modified about 1 year ago
© 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 Part 1 – Finding Concurrency in Problems
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 2 Tentative Plan Week 7: 10/1-10/3 –Mon, 10/1:Lecture 13 - Lecture 16 – Application performance insight, matrix multiplication, convolution – Tue, 10/2:Lecture 14 - Parallel programming - problem decomposition –Wed,10/3:Lecture 15 –Parallel programming - algorithm styles Week 8: 10/8-10/10 –Mon, 10/8: Parallel programming - coding style –Tue, 10/9:Lecture 17 - (gust lecture, Dan Vivoli) GPU computing market and applications –Wed, 10/7: Lecture 18 – Application performance insight, scan VMD, NAMD, etc. Week 9: 10/15-10/17 – Mon,10/15: Lecture 19 – Application performance insight, scan VMD, NAMD, etc. –Tue, 10/16:Lecture 20 – (guest lecture) Other types of parallelism –Wed, 10/17:Lecture 21 – (guest lecture) Other types of parallel processors Week 10: 10/22-10/24 –Final project work time, no lecture –Wed, 10/24: Project Proposal Workshop (6 hours, 4 lectures) Week 11: 10/29-10/31 – Final project work time, no lecture Week 12: 11/5-11/7 –Final project work time, no lecture –Wed, 11/7: exam Week 13: 11/12-11/14 –Final project work time, no lecture Week 14: 11/19-11/21 –Fall Break – no lectures Week 15: 11/26-11/28 –Final project work time, no lecture –Project checkup – TA feedback Week 16: 12/3-12/5 Final project work time, no lecture Wed, 12/14 : Project Presentations (6 hours, 4 lectures)
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 3 “If you build it, they will come.” “And so we built them. Multiprocessor workstations, massively parallel supercomputers, a cluster in every department … and they haven’t come. Programmers haven’t come to program these wonderful machines. … The computer industry is ready to flood the market with hardware that will only run at full speed with parallel programs. But who will write these programs?” - Mattson, Sanders, Massingill (2005)
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 4 Objective To provide you with a framework based on the techniques and best practices used by experienced parallel programmers for –Thinking about the problem of parallel programming –Discussing your work with others –Addressing performance and functionality issues in your parallel program –Using or building useful tools and environments
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 5 Fundamentals of Parallel Computing Parallel computing requires that –The problem can be decomposed into sub-problems that can be safely solved at the same time –The programmer structures the code and data to solve these sub-problems concurrently The goals of parallel computing are –To solve problems in less time, and/or –To solve bigger problems The problems must be large enough to justify parallel computing and to exhibit exploitable concurrency.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 6 A Recommended Reading Mattson, Sanders, Massingill, Patterns for Parallel Programming, Addison Wesley, 2005, ISBN –We draw quite a bit from the book –A good overview of challenges, best practices, and common techniques in all aspects of parallel programming
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 7 Key Parallel Programming Steps 1)To find the concurrency in the problem 2)To structure the algorithm so that concurrency can be exploited 3)To implement the algorithm in a suitable programming environment 4)To execute and tune the performance of the code on a parallel system Unfortunately, these have not been separated into levels of abstractions that can be dealt with independently.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 8 Challenges of Parallel Programming Finding and exploiting concurrency often requires looking at the problem from a non-obvious angle Dependences need to be identified and managed –The order of task execution may change the answers Obvious: One step feeds result to the next steps Subtle: numeric accuracy may be affected by ordering steps that are logically parallel with each other Performance can be drastically reduced by many factors –Overhead of parallel processing –Load imbalance among processor elements –Inefficient data sharing patterns –Saturation of critical resources such as memory bandwidth
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 9 Shared Memory vs. Message Passing We will focus on shared memory parallel programming –This is what CUDA is based on –Future massively parallel microprocessors are expected to support shared memory at the chip level The programming considerations of message passing model is quite different!
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 10 Finding Concurrency in Problems Identify a decomposition of the problem into sub- problems that can be solved simultaneously –A task decomposition that identifies tasks that can execute concurrently –A data decomposition that identifies data local to each task –A way of grouping tasks and ordering the groups to satisfy temporal constraints –An analysis on the data sharing patterns among the concurrent tasks –A design evaluation that assesses of the quality the choices made in all the steps
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 11 Finding Concurrency – The Process Task Decomposition Data Decomposition Data Sharing Order Tasks Decomposition Group Tasks Dependence Analysis Design Evaluation This is typically a iterative process. Opportunities exist for dependence analysis to play earlier role in decomposition.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 12 Task Decomposition Many large problems have natural independent tasks –The number of tasks used should be adjustable to the execution resources available. –Each task must include sufficient work in order to compensate for the overhead of managing their parallel execution. –Tasks should maximize reuse of sequential program code to minimize effort. “In an ideal world, the compiler would find tasks for the programmer. Unfortunately, this almost never happens.” - Mattson, Sanders, Massingill
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 13 Task Decomposition Example - Square Matrix Multiplication P = M * N of WIDTH ● WIDTH –One natural task (sub-problem) produces one element of P –All tasks can execute in parallel M N P WIDTH
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 14 Task Decomposition Example: MPEG Independent IPPP sequences I Frames: independent 16x16 pel macroblocks Localized dependence of P- frame macroblocks on previous frame Steps of macroblock processing exhibit finer grained parallelism
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 15 Task Decomposition Example – Molecular Dynamics Simulation of motions of a large molecular system A natural task is to perform calculations of individual atoms in parallel For each atom, there are natural tasks to calculate –Vibrational forces –Rotational forces –Neighbors that must be considered in non-bonded forces –Non-bonded forces –Update position and velocity –Misc physical properties based on motions Some of these can go in parallel for an atom It is common that there are multiple ways to decompose any given problem.
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 16 NAMD SPEC_NAMD 6 Different NAMD Configurations (all independent) SelfComputes Objects PairComputes Objects … iterations (per patch) Independent Iterations …. Force & Energy Calculation Inner Loops 1872 iterations (per patch pair) ….. PatchList Data Structure
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 17 Data Decomposition The most compute intensive parts of many large problem manipulate a large data structure –Similar operations are being applied to different parts of the data structure, in a mostly independent manner. –This is what CUDA is optimized for. The data decomposition should lead to –Efficient data usage by tasks within the partition –Few dependencies across the tasks that work on different partitions –Adjustable partitions that can be varied according to the hardware characteristics
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 18 Data Decomposition Example - Square Matrix Multiplication P Row blocks (adjacent rows) –Computing each partition requires access to entire N array Square sub-blocks –Only bands of M and N are needed M N P WIDTH
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 19 Tasks Grouping Sometimes natural tasks of a problem can be grouped together to improve efficiency –Reduced synchronization overhead – all tasks in the group can use a barrier to wait for a common dependence –All tasks in the group efficiently share data loaded into a common on-chip, shared storage (Shard Memory) –Grouping and merging dependent tasks into one task reduces need for synchronization
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 20 Task Grouping Example - Square Matrix Multiplication Tasks calculating a P sub-block –Extensive input data sharing, reduced memory bandwidth using Shared Memory –All synched in execution M N P WIDTH
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 21 Task Ordering Identify the data and resource required by a group of tasks before they can execute them –Find the task group that creates it –Determine a temporal order that satisfy all data constraints
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 22 Task Ordering Example: Molecular Dynamics Neighbor List Vibrational and Rotational Forces Non-bonded Force Next Time Step Update atomic positions and velocities
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 23 Data Sharing Data sharing can be a double-edged sword –Excessive data sharing can drastically reduce advantage of parallel execution –Localized sharing can improve memory bandwidth efficiency Efficient memory bandwidth usage can be achieved by synchronizing the execution of task groups and coordinating their usage of memory data –Efficient use of on-chip, shared storage Read-only sharing can usually be done at much higher efficiency than read-write sharing, which often requires synchronization
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 24 Data Sharing Example – Matrix Multiplication Each task group will finish usage of each sub-block of N and M before moving on –N and M sub-blocks loaded into Shared Memory for use by all threads of a P sub-block –Amount of on-chip Shared Memory strictly limits the number of threads working on a P sub-block Read-only shared data can be more efficiently accessed as Constant or Texture data
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 25 Data Sharing Example – Molecular Dynamics The atomic coordinates –Read-only access by the neighbor list, bonded force, and non-bonded force task groups –Read-write access for the position update task group The force array –Read-only access by position update group –Accumulate access by bonded and non-bonded task groups The neighbor list –Read-only access by non-bonded force task groups –Generated by the neighbor list task group
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 26 Design Evaluation Key questions to ask –How many threads can be supported? –How many threads are needed? –How are the data structures shared? –Is there enough work in each thread between synchronizations to make parallel execution worthwhile?
© David Kirk/NVIDIA and Wen-mei W. Hwu, 2007 ECE 498AL, University of Illinois, Urbana-Champaign 27 Design Evaluation Example – Matrix Multiplication Each thread likely need at least 32 FOPS between synchronizations to make parallel processing worthwhile At least 192 threads are needed in a block to fully utilize the hardware The M and N sub-blocks of each thread group must fit into 16KB of Shared Memory The design will likely end up with about 16 ● 16 sub-blocks given all the constraints The minimal matrix size is around 1K elements in each dimension to make parallel execution worthwhile
1. Parallel Databases Introduction I/O Parallelism Interquery Parallelism Intraquery Parallelism Intraoperation Parallelism Interoperation Parallelism.
Architectural Design IS301 – Software Engineering Lecture # 14 – M. E. Kabay, PhD, CISSP Dept of Computer Information Systems Norwich University.
Distributed Computing Dr. Eng. Ahmed Moustafa Elmahalawy Computer Science and Engineering Department.
Chapter 6 – Architectural Design 1Chapter 6 Architectural design Software Engineering Ian Sommerville, Software Engineering, 9 th Edition Pearson.
The first-generation Cell Broadband Engine (BE) processor is a multi-core chip comprised of a 64-bit Power Architecture processor core and eight synergistic.
Introduction to cloud computing Jiaheng Lu Department of Computer Science Renmin University of China
Quality Tools and Techniques in the School and Classroom.
1 Computer Systems & Architecture Lesson 3 5. Designing the Architecture.
Copyright 2004 Bernd Brügge TUM Software Engineering WS TUM System Design II Bernd Brügge Technische Universität München Applied Software Engineering.
Decision Support Systems and Executive Support Systems.
Search Engines Information Retrieval in Practice All slides ©Addison Wesley, 2008.
The Project Cycle Management Course presented by Simon Pluess World Alliance of YMCAs.
File Concept A file is a named collection of related information that is recorded on secondary storage. A file has a define structure, which we must know.
1 GREY BOX TESTING Web Apps & Networking Session 10 Boris Grinberg
Agent Based Software Development Michael Luck, Ronald Ashri and Mark dInverno Chapter 4: Methodologies and Modeling Languages.
Chapter 13 Instruction-Level Parallelism and Superscalar Processors.
תהליך הפיתוח האחוד (The Unified Process) 1. Motivation: Analysis and Design Should Be Done Iteratively! Presented 1981, this is one of the most famous.
Efficient Multiprogramming for Multicores with SCAF Published in MICRO-46, December Published by Timothy Creech, Aparna Kotha and Rajeev Barua. Presented.
WORKSHOP II: Planning for Course Redesign Review of Workshop Homework Innovative Course Redesign Practices Break-out Sessions: Redesign Plans Preparing.
1 Data Warehousing Denis Manley Enterprise Systems FT228/3.
Software Development QA Best Practices May 20, 2010 Suzette Hackl, CSM Senior Project Manager Skyline Technologies, Inc.
Chapter 6 Architectural Design Slide 1 Chapter 6 Architectural Design.
Collaborative Code Construction: Code Reviews and Pair Programming CPSC 315 – Programming Studio Spring 2009.
1 Copyright © 2010, Elsevier Inc. All rights Reserved Chapter 1 Why Parallel Computing? An Introduction to Parallel Programming Peter Pacheco.
Ch:8 Design Concepts S.W Design should have following quality attribute: –Functionality –Usability –Reliability –Performance –Supportability (extensibility,
Ahmad Aljebaly Department of Computer Science Western Michigan University.
UNIT V: LEARNING. LEARNING Learning from Observation Inductive Learning Decision Trees Explanation based Learning Statistical Learning methods Reinforcement.
The Client/Server Database Environment CS263 Lecture 12.
INTERMEDIATE 1 PHYSICAL EDUCATION STRUCTURES AND STRATEGIES INFORMATION PACK Name : _____________________________________ Class : _________ Year : ______.
RISC Instruction Pipelines and Register Windows By: Andy Le CS147 – Dr. Sin-Min Lee San Jose State University, Fall 2003.
© 2016 SlidePlayer.com Inc. All rights reserved.