Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci

Similar documents
SFDV3006 Concurrent Programming

Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci

[module 2.2] MODELING CONCURRENT PROGRAM EXECUTION

Parallelization Strategy

SISTEMI CONCORRENTI E DI RETE LS II Facoltà di Ingegneria - Università di Bologna - Cesena - a.a / 2009 COURSE PRESENTATION

EE382N (20): Computer Architecture - Parallelism and Locality Lecture 13 Parallelism in Software IV

EE382N (20): Computer Architecture - Parallelism and Locality Spring 2015 Lecture 14 Parallelism in Software I

Parallel Programming Concepts. Parallel Algorithms. Peter Tröger

EE382N (20): Computer Architecture - Parallelism and Locality Fall 2011 Lecture 11 Parallelism in Software II

Principles of Parallel Algorithm Design: Concurrency and Decomposition

Introduction to System Design

Design of Parallel Algorithms. Models of Parallel Computation

Parallelism in Software

Parallelization Strategy

Patterns of Parallel Programming with.net 4. Ade Miller Microsoft patterns & practices

COURSE PRESENTATION. PROGRAMMAZIONE AVANZATA E PARADIGMI Ingegneria e Scienze Informatiche Università di Bologna - Cesena - a.a.

An Introduction to Software Architecture. David Garlan & Mary Shaw 94

Sorting Algorithms. Slides used during lecture of 8/11/2013 (D. Roose) Adapted from slides by

Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci

Coordination Patterns

Diseño y Evaluación de Arquitecturas de Software. Architecture Based Design Method

COSC 6374 Parallel Computation. Parallel Design Patterns. Edgar Gabriel. Fall Design patterns

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

Dynamic Programming Group Exercises

EE382N (20): Computer Architecture - Parallelism and Locality Fall 2011 Lecture 14 Parallelism in Software V

EE382N (20): Computer Architecture - Parallelism and Locality Lecture 10 Parallelism in Software I

Architectural Styles. Reid Holmes

CS:2820 (22C:22) Object-Oriented Software Development

simpa An Agent-Oriented Approach for Prototyping Concurrent Applications on Top of Java

Principles of Parallel Algorithm Design: Concurrency and Mapping

Architectural Styles. Software Architecture Lecture 5. Copyright Richard N. Taylor, Nenad Medvidovic, and Eric M. Dashofy. All rights reserved.

Software Architecture

10.1 Big Objects, Business Objects, and UML Components

Some aspects of parallel program design. R. Bader (LRZ) G. Hager (RRZE)

Architectural Design

Architectural Patterns: From Mud to Structure

Patterns for! Parallel Programming II!

Design patterns for HPC: an introduction. Paolo Ciancarini Department of Informatics University of Bologna

EE382N (20): Computer Architecture - Parallelism and Locality Lecture 11 Parallelism in Software II

21. Document Component Design

Concurrent Object-Oriented Development with Behavioral Design Patterns

Marco Danelutto. May 2011, Pisa

Analysis and Design with the Universal Design Pattern

Principles of Parallel Algorithm Design: Concurrency and Mapping

Patterns for! Parallel Programming!

The Design Patterns Matrix From Analysis to Implementation

Architectural Design

Concurrent Programming Introduction

Framework for Design of Dynamic Programming Algorithms

IN5050: Programming heterogeneous multi-core processors Thinking Parallel

Middleware-Konzepte. Tuple Spaces. Dr. Gero Mühl

Task-oriented engineering of coordinated software systems

CS555: Distributed Systems [Fall 2017] Dept. Of Computer Science, Colorado State University

Parallel Computing. Slides credit: M. Quinn book (chapter 3 slides), A Grama book (chapter 3 slides)

Something to think about. Problems. Purpose. Vocabulary. Query Evaluation Techniques for large DB. Part 1. Fact:

Business Process Modeling. Version 25/10/2012

Episode 3. Principles in Network Design

Unit Wise Questions. Unit-1 Concepts

Geometric Streaming Algorithms with a Sorting Primitive (TR CS )

CAS 703 Software Design

App Engine MapReduce. Mike Aizatsky 11 May Hashtags: #io2011 #AppEngine Feedback:

Object Oriented Analysis and Design - Part2(Design)

Design Pattern- Creational pattern 2015

Module 4: Tree-Structured Indexing

Task Graph. Name: Problem: Context: D B. C Antecedent. Task Graph

Behavioral Design Patterns Used in Data Structures Implementation

THE CASE FOR MESSAGE PASSING ON MANY-CORE CHIPS

CSCI 3130 Software Architectures 1/3. February 5, 2013

Software Engineering (CSC 4350/6350) Rao Casturi

Big Ideas. Chapter Computational Recipes

Progress Report. Object-Oriented Software Development: Requirements elicitation (ch. 4) and analysis (ch. 5) Object-oriented software development

Data Structure. Measuring Input size. Composite Data Structures. Linear data structures. Data Structure is: Abstract Data Type 1/9/2014

FOUNDATIONS OF A CROSS-DISCIPLINARY PEDAGOGY FOR BIG DATA *

Software Service Engineering

Systems I: Programming Abstractions

Lecture 6B Hierarchical/Concurrent State Machine Models (HCFSM)

Software Development Chapter 1

Design and Analysis of Parallel Programs. Parallel Cost Models. Outline. Foster s Method for Design of Parallel Programs ( PCAM )

Lesson 11. W.C.Udwela Department of Mathematics & Computer Science

Contemporary Design. Traditional Hardware Design. Traditional Hardware Design. HDL Based Hardware Design User Inputs. Requirements.

DM204 - Scheduling, Timetabling and Routing

Introduction to Object-Oriented Programming

Design Process Overview. At Each Level of Abstraction. Design Phases. Design Phases James M. Bieman

Practical Concurrency. Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited.

CS 307: Software Engineering. Lecture 10: Software Design and Architecture

Multi-Paradigm Approach for Teaching Programming

Measuring Input size. Last lecture recap.

6/20/2018 CS5386 SOFTWARE DESIGN & ARCHITECTURE LECTURE 5: ARCHITECTURAL VIEWS C&C STYLES. Outline for Today. Architecture views C&C Views

Enterprise Architect Training Courses

Coordination in Situated Systems

Lecture 13: Divide and Conquer (1997) Steven Skiena. skiena

CS 206 Introduction to Computer Science II

Module 5: Concurrent and Parallel Programming

Apache Flink. Alessandro Margara

MapReduce: Simplified Data Processing on Large Clusters. By Stephen Cardina

Computer Vision 5 Segmentation by Clustering

Parallel Programming

Java SE 8 Programming

SoberIT Software Business and Engineering Institute. SoberIT Software Business and Engineering Institute. Contents

High Performance Computing Prof. Matthew Jacob Department of Computer Science and Automation Indian Institute of Science, Bangalore

Transcription:

v1.0 20140421 Programmazione Avanzata e Paradigmi Ingegneria e Scienze Informatiche - UNIBO a.a 2013/2014 Lecturer: Alessandro Ricci [module 3.1] ELEMENTS OF CONCURRENT PROGRAM DESIGN 1

STEPS IN DESIGN SPACE (1/2) Analyzing the problem to identify exploitable concurrency identifying task & data decomposition and their dependencies Task definition sequence of instructions that operate together as a group corresponding to some logical part of an algorithm or a program a specific piece of work required to be done as a duty or responsibility of some agent more abstract / design-oriented definition 2

STEPS IN DESIGN SPACE (2/2) Choosing a suitable concurrent architecture mapping tasks into agents active entities responsible of performing tasks encapsulate the logic & control of task execution shared resources encapsulating result of agent work passive / monitor-like entities coordination media/resources to shape agent interaction and manage task dependencies passive / monitor-like entities message passing protocols 3

PROBLEM ANALYSIS Objective: identifying task / data decomposition and their dependencies Two steps Task and Data Decomposition Analysis Dependency Analysis 4

TASK DECOMPOSITION PATTERN Following a divide-at-impera principle, the problem can be naturally decomposed into a collection of independent or nearly independent tasks tasks must be sufficiently independent so as that managing dependencies takes only a small fraction of the program s overall execution time First tasks are identified, then how data can be decomposed given the task decomposition in this case, data decomposition follows task decomposition Example producers/consumers systems 5

DATA DECOMPOSITION PATTERN Problem's data can be easily decomposed into units that can be operated on relatively independently first data units are identified, then task related to that units can be identified in this case, task decomposition follows data decomposition Scale well with the available number of processors Example matrix multiplication 6

FINER CLASSIFICATION Some specific kind of problem decompositions functional decomposition data decomposition recursive decomposition 7

FUNCTIONAL DECOMPOSITION The functions to be performed on data are split into multiple concurrent tasks These tasks can then be performed concurrently by different processes on different data. this often leads to so-called pipelines. Not scaling well with the number of processors there is only a limited amount of functions available in each program to split up 8

DATA DECOMPOSITION Typically applied in the processing of data structures with large amounts of similar data The tasks in this strategy consist of groups of data input data, output data or even intermediate data decompositions to all varieties are possible and may be useful. All processes perform the same operations on these data, which are often independent from one another Example? matrix multiplication 9

RECURSIVE DECOMPOSITION A problem is divided into subproblems, which are again divided into subproblems recursively until a trivial solution can be calculated afterwards, the results of the subproblems are merged together when needed. As the smaller tasks are usually independent of one another they can be calculated in parallel, often leading to wellscaling parallel algorithms Example sorting 10

DEPENDENCY ANALYSIS Analyzing dependencies among the tasks within a problem's decomposition to group and order tasks according to the type of dependencies in order to maximize performances Possible kinds of dependencies temporal dependencies data / resource dependencies A classification of dependencies in coordination problem can be found in [MAL-93] interdisciplinary issue 11

DESIGN LEVEL - SOME CONCEPTUAL CLASSES From analysis to design: basic architectural classes proposed in literature [CAR-89] Result parallelism envisioning parallelism in terms of program s result Specialist parallelism envisioning parallelism in terms of an ensemble of specialists (the crew) that collectively constitute the programs Agenda parallelism envisioning parallelism in terms of program s agenda of tasks 12

RESULT PARALLELISM Designing the system around the data structure or resource yielded as the ultimate result we get parallelism by computing all the elements of the result simultaneously strictly related to the data-decomposition pattern Each agent is assigned to produce one piece of the result they all work in parallel up to the natural restriction imposed by the problem Proper shared data structures are designed to wrap the result (data) under construction encapsulating mutex and synchronization issues 13

RESULT PARALLELISM: BUILDING A HOUSE EXAMPLE Think about the components of the house front, rear, side walls, interior walls, foundations, roof, etc. Proceed by building all the components simultaneously assembling them as they are completed Use separate agents (workers) set to work on the different parts proceeding in parallel up to the point where work on one component can t proceed until another is finished 14

SPECIALIST PARALLELISM Designing the system around an ensemble of specialists connected into a logical network of some kind parallelism results from all the nodes of the logical network (all the specialists) being active simultaneously Each agent is assigned to perform one specified kind of task they all work in parallel up to the natural restriction imposed by the problem Coordination means (communication protocols, shared data structures) are used to support specialists communication and coordination examples: message boxes, blackboards, event services Opposite approach with respect to result parallelism 15

SPECIALIST PARALLELISM: BUILDING A HOUSE EXAMPLE! Identify the separate skills required to build the house surveyors, excavators, foundation builders, carpenters, roofers, etc different kind of tasks Then assemble a constructor crew in which each skill is represented by a separated specialist worker They all start simultaneously but initially most workers will have to wait around once the project is well underway, however, many skills (hence many workers) will be called to play simultaneously Remarks strong role of worker interaction and coordination different kind of strategies e.g. pipelined jobs 16

AGENDA PARALLELISM Designing the system around a particular agenda of tasks (activities in [CAR-89]) and then assign many workers to each step and also possibly carry on different steps in parallel workflow Each agent is assigned to help out with the current item on the agenda they all work in parallel up to the natural restriction imposed by the problem Shared data structures are designed to manage data consumed and produced by agenda activities examples: bounded-buffers 17

AGENDA PARALLELISM: BUILDING A HOUSE EXAMPLE! We write out a sequential agenda and carry it in order, but at each stage we assign many workers to the current activity doing the foundation, doing the frame, doing the roof, etc We assemble a work team of generalists each capable of performing any construction step The team is set to work stage by stage following the agenda 18

REMARKS The boundaries between the three classes are not rigid we will often mix elements of several approaches in getting a particular job done e.g. a specialist approach might make secondary use of agenda parallelism, for example, by assigning a team of workers to some speciality However the three approaches represent three clearly separate ways of thinking about the problem result parallelism focuses on the shape of the finished product specialist parallelism focuses on the makeup of the work crew agenda parallelism focuses on the list of tasks to be performed The approach can be recursively applied following task and data decomposition 19

USING CONCEPTUAL CLASSES - BASIC STEPS To write a concurrent program (adapted from [CAR-89]): choose the concept class that is most natural for the problem; write a program using the method that is most natural for that conceptual class; and if the resulting program is not acceptably efficient, transform it methodically into a more efficient version by switching from a more-natural method to a moreefficient one 20

FROM CONCEPTUAL CLASSES TO ARCHITECTURES & PATTERNS Some specific architectures can help to bridge the gap between the conceptual class and the implementation (adapted from [MAG-99]) Master-Workers Fork-Join Filter-Pipeline Announcer-Listeners Event-Based Coordination pattern 21

MASTER-WORKERS Description the architecture is composed by a master agent and a possibly dynamic set of worker agents, interacting through a proper coordination medium functioning as a bag of tasks master agent decompose the global task in subtasks assign the subtasks by inserting their description in the bag collect tasks result worker agent get the task to do from the bag, execute the tasks and communicate the results variant: proper monitor data structures can be used to aggregate results bag of tasks resource typically implemented as a blackboard or a bounded buffer Example of problems quadrature problem 22

FORK-JOIN Description applying the master worker architecture recursively workers are themselves masters, producing tasks and collecting results effective approach to implement a concurrent divide-and-conquer strategies can be realized either using using a bag of tasks or directly Example of problems adaptive quadrature problem merge-sort 23

FILTER-PIPELINE Description the architecture is composed by a linear chain of agents interacting through some pipe or bounded buffer or channel resources generator agent the agent starting the chain, generating the data to be processed by the pipeline filter agent an intermediate agent of the chain, consuming input information from a pipe and producing information into another pipe sink agent the agent terminating the chain, collecting the results Example of problems image processing 24

ANNOUNCER-LISTENERS Description the architecture is composed by an announcer agent and a dynamic set of listener agents, interacting through an eventservice announcer agent announce the occurrence of events on the event service listener agents register on the event service so as to be notified of the occurrence of events interesting for the listener event-service resource uncouple announcer-listeners interaction collect and dispatch events Example of problems parallelization of event-driven applications achieved by parallelizing the execution of event handlers 25

BIBLIOGRAPHY [CAR-89] Nicholas Carriero and David Gelernter, "How to write parallel programs: a guide to the perplexed", ACM Computing Surveys (CSUR). Volume 21, Issue 3 (1989) [MAT-05] T. Mattson, B. Sanders, B. Massingill, "Patterns for Parallel Programming", Addison Wesley (2005) [MAG-99] Jeff Magee and Jeff Kramer, "Concurrency - State Models and Java Programs", Wiley (http://www.doc.ic.ac.uk/~jnm/book/) [MAL-93] Thomas W. Malone, Kevin Crowston. "The interdisciplinary study of coordination". Center for Coordination Science, Alfred P. Sloan School of Management, Massachusetts Institute of Technology, 1993 26