List of lectures. Lecture content. Concurrent computing. TDDA69 Data and Program Structure Concurrent Computing Cyrille Berger

Size: px
Start display at page:

Download "List of lectures. Lecture content. Concurrent computing. TDDA69 Data and Program Structure Concurrent Computing Cyrille Berger"

Transcription

1 List of lectures TDDA69 Data and Program Structure Concurrent Computing Cyrille Berger 1Introduction and Functional Programming 2Imperative Programming and Data Structures 3Parsing 4Evaluation 5Object Oriented Programming 6Macros and decorators 7Virtual Machines and Bytecode 8Garbage Collection and Native Code 9Concurrent Computing 10Declarative Programming 11Logic Programming 12Summary 2 / 65 Lecture content Parallel Programming Multithreaded Programming The States Problems and Solutions Atomic actions Language and Interpreter Design Considerations Single Instruction, Multiple Threads Programming Distributed programming Message Passing MapReduce Concurrent computing In concurrent computing several computations are executed at the same time In parallel computing all computations units have access to shared memory (for instance in a single process) In distributed computing computations units communicate through messages passing 3 / 65 4 / 65

2 Benefits of concurrent computing Disadvantages of concurrent computing Faster computation Responsiveness Interactive applications can be performing two tasks at the same time: rendering, spell checking... Availability of services Load balancing between servers Controllability Tasks can be suspended, resumed and stopped. 5 / 65 Concurrency is hard to implement properly Safety Easy to corrupt memory Deadlock Tasks can wait indefinitely for each other Non-deterministic Not always faster! The memory bandwidth and CPU cache is limited 6 / 65 Concurrent computing programming Stream Programming in Functional Programming Four basic approach to computing: Sequencial programming: no concurrency Declarative concurrency: streams in a functional language Message passing: with active objects, used in distributed computing Atomic actions: on a shared memory, used in parallel computing No global state Functions only act on their input, they are reentrant Functions can then be executed in parallel As long as they do not depend on the output of an other function 7 / 65 8 / 65

3 Parallel Programming Parallel Programming In parallel computing several computations are executed at the same time and have access to shared memory Unit Unit Unit Memory 10 SIMD, SIMT, SMT (1/2) SIMD: Single Instruction, Multiple Data Elements of a short vector (4 to 8 elements) are processed in parallel SIMT: Single Instruction, Multiple Threads The same instruction is executed by multiple threads (from 128 to 3048 or more in the future) SMT: Simultaneous Multithreading General purpose, different instructions are executed by different threads SIMD, SIMT, SMT (2/2) SIMD: PUSH [1, 2, 3, 4] PUSH [4, 5, 6, 7] VEC_ADD_4 SIMT: execute([1, 2, 3, 4], [4, 5, 6, 7], lambda a,b,ti: a[ti]=a[ti] + max(b[ti], 5)) SMT: a = [1, 2, 3, 4] b = [4, 5, 6, 7]... Thread.new(lambda : a = a + b) Thread.new(lambda : c = c * b) 11 12

4 Why the need for the different models? Flexibility: SMT > SIMT > SIMD Less flexibility give higher performance Unless the lack of flexibility prevent to accomplish the task Performance: SIMD > SIMT > SMT Multithreaded Programming 13 Singlethreaded vs Multithreaded Multithreaded Programming Mode Start with a single root thread Fork: to create concurently executing threads Join: to synchronize threads Threads communicate through shared memory Threads execute assynchronously They may or may not execute on different processors sub 0 sub 0 main... main... main sub n sub n 15 16

5 A multithreaded example thread1 = new Thread( /* do some computation */ thread2 = new Thread( /* do some computation */ thread1.start(); thread2.start(); thread1.join(); thread2.join(); The States Problems and Solutions 17 Global States and multi-threading Example: var a = 0; thread1 = new Thread( a = a + 1; thread2 = new Thread( a = a + 1; thread1.start(); thread2.start(); What is the value of a? This is called a (data) race condition Atomic actions 19

6 Atomic operations Mutex An operation is said to be atomic, if it appears to happen instantaneously read/write, swap, fetch-and-add... test-and-set: set a value and return the old one To implement a lock: while(test-and-set(lock, 1) == 1) To unlock: lock = 0 Mutex is the short of Mutual exclusion It is a technique to prevent two threads to access a shared resource at the same time Example: var a = 0; var m = new Mutex(); thread1 = new Thread( m.lock(); a = a + 1; m.unlock(); thread2 = new Thread( m.lock(); a = a + 1; m.unlock(); thread1.start(); thread2.start(); Now a= Dependency Condition variable Example: var a = 1; var m = new Mutex(); thread1 = new Thread( m.lock(); a = a + 1; m.unlock(); thread2 = new Thread( m.lock(); a = a * 3; m.unlock(); thread1.start(); thread2.start(); What is the value of a? 4 or 6? A Condition variable is a set of threads waiting for a certain condition Example: var a = 1; var m = new Mutex(); var cv = new ConditionVariable(); thread1 = new Thread( m.lock(); a = a + 1; cv.notify(); m.unlock(); thread2 = new Thread( cv.wait(); m.lock(); a = a * 3; m.unlock(); thread1.start(); thread2.start(); a =

7 Deadlock Advantages of atomic actions What might happen: var a = 0; var b = 2; var ma = new Mutex(); var mb = new Mutex(); thread1 = new Thread( ma.lock(); mb.lock(); b = b - 1; a = a - 1; ma.unlock(); mb.unlock(); thread2 = new Thread( mb.lock(); ma.lock(); b = b - 1; a = a + b; mb.unlock(); ma.unlock(); thread1.start(); thread2.start(); thread1 waits for mb, thread2 waits for ma Very efficient Less overhead, faster than message passing Disadvantages of atomic actions Blocking Meaning some threads have to wait Small overhead Deadlock A low-priority thread can block a high priority thread A common source of programming errors Language and Interpreter Design Considerations 27

8 Common mistakes Forget to unlock a mutex Race condition Deadlocks Granularity issues: too much locking will kill the performance Forget to unlock a mutex Most programming language have, either: A guard object that will unlock a mutex upon destruction A synchronization statement some_rlock = threading.rlock() with some_rlock: print("some_rlock is locked while this executes") Race condition Can we detect potential race condition during compilation? In the rust programming language Objects are owned by a specific thread Types can be marked with Send trait indicate that the object can be moved between threads Types can be marked with Sync trait indicate that the object can be accessed by multiple threads safely Safe Shared Mutable State in rust (1/3) let mut data = vec![1, 2, 3]; for i in 0..3 thread::spawn(move data[i] += 1; Gives an error: "capture of moved value: `data`" 31 32

9 Safe Shared Mutable State in rust (2/3) Safe Shared Mutable State in rust (3/3) let mut data = Arc::new(vec![1, 2, 3]); for i in 0..3 let data = data.clone(); thread::spawn(move data[i] += 1; Arc add reference counting, is movable and syncable Gives error: cannot borrow immutable borrowed content as mutable let data = Arc::new(Mutex::new(vec![1, 2, 3])); for i in 0..3 let data = data.clone(); thread::spawn(move let mut data = data.lock().unwrap(); data[i] += 1; It now compiles and it works Single Instruction, Multiple Threads Programming Single Instruction, Multiple Threads Programming With SIMT, the same instructions is executed by multiple threads on different registers 36

10 Single instruction, multiple flow paths (1/2) Single instruction, multiple flow paths (1/2) Using a masking system, it is possible to support if/ else block Threads are always executing the instruction of both part of the if/else blocks data = [-2, 0, 1, -1, 2], data2 = [...] function f(thread_id, data, data2) if(data[thread_id] < 0) data[thread_id] = data[thread_id]-data2[thread_id]; else if(data[thread_id] > 0) data[thread_id] = data[thread_id]+data2[thread_id]; Benefits: Multiple flows are needed in many algorithms Drawbacks: Only one flow path is executed at a time, non running threads must wait Randomize memory access Elements of a vector are not accessed sequentially Programming Language Design for SIMT OpenCL, CUDA are the most common Very low level, C/C++-derivative General purpose programming language are not suitable Some work has been done to be able to write in Python and run on a GPU with float32[:], float32[:]], target='gpu') def add_matrix(a, B, C): A[cuda.threadIdx.x] = B[cuda.threadIdx.x] + C[cuda.threadIdx.x] with limitation on standard function that can be called Distributed programming 39

11 Distributed Programming (1/4) Distributed programming (2/4) In distributed computing several computations are executed at the same time and communicate through messages passing Unit Unit Unit Memory Memory Memory A distributed computing application consists of multiple programs running on multiple computers that together coordinate to perform some task. Computation is performed in parallel by many computers. Information can be restricted to certain computers. Redundancy and geographic diversity improve reliability Distributed programming (3/4) Distributed programming (4/4) Characteristics of distributed computing: Computers are independent they do not share memory. Coordination is enabled by messages passed across a network. Individual programs have differentiating roles. Distributed computing for largescale data processing: Databases respond to queries over a network. Data sets can be partitioned across multiple machines

12 Message Passing Message Passing Messages are (usually) passed through sockets Messages are exchanged synchronously or asynchronously Communication can be centralized or peer-to-peer 46 Python's Global Interpreter Lock (1/2) Python's Global Interpreter Lock (2/2) CPython can only interpret one single thread at a given time The lock is released, when: The current thread is blocking for I/O Every 100 interpreter ticks True multithreading is not possible with CPython 47 CPython can only interpret one single thread at a given time Single-threaded are faster (no need to lock in memory management) Many C-library used as extensions are not thread safe To eliminate the GIL Python developers have the following requirements: Simplicity Do actually improve performance Backward compatible Prompt and ordered destruction 48

13 Python's Multiprocessing module The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Global Interpreter Lock by using subprocesses instead of threads It implements transparent message passing, allowing to exchange Python objects between processes 49 Python's Message Passing (1/2) Example of message passing from multiprocessing import Process def f(name): print 'hello', name if name == ' main ': p = Process(target=f, args=('bob',)) p.start() p.join() Output hello bob 50 Python's Message Passing (2/2) Example of message passing with pipes from multiprocessing import Process, Pipe def f(conn): conn.send([42, None, 'hello']) conn.close() if name == ' main ': parent_conn, child_conn = Pipe() p = Process(target=f, args=(child_conn,)) p.start() print parent_conn.recv() p.join() Output [42, None, 'hello'] Transparent message passing is possible thanks to serialization 51 Serialization A serialized object is an object represented as a sequence of bytes that includes the object s data, its type and the types of data stored in the object. 52

14 pickle In Python, serialization is done with the pickle module It can serialize user-defined classes The class definition must be available before deserialization Works with different version of Python By default, use an ASCII format It can serialize: Basic types: booleans, numbers, strings Containers: tuples, lists, sets and dictionnary (of pickable objects) Top level functions and classes (only the name) Objects where dict or getstate() are pickable Example: pickle.loads(pickle.dumps(10)) Shared memory Memory can be shared between Python process with a Value or Array. from multiprocessing import Process, Value, Array def f(n, a): n.value = for i in range(len(a)): a[i] = -a[i] if name == ' main ': num = Value('d', 0.0) arr = Array('i', range(10)) p = Process(target=f, args=(num, arr)) p.start() p.join() print num.value print arr[:] And of course, you would need to use Mutex to avoid race condition Big Data Processing (1/2) MapReduce MapReduce is a framework for batch processing of big data. Framework: A system used by programmers to build applications Batch processing: All the data is available at the outset, and results are not used until processing completes Big data: Used to describe data sets so large and comprehensive that they can reveal facts about a whole population, usually from statistical analysis 56

15 Big Data Processing (2/2) The MapReduce idea: Data sets are too big to be analyzed by one machine Using multiple machines has the same complications, regardless of the application/ analysis Pure functions enable an abstraction barrier between data processing logic and coordinating a distributed application MapReduce Evaluation Model (1/2) Map phase: Apply a mapper function to all inputs, emitting intermediate key-value pairs The mapper takes an iterable value containing inputs, such as lines of text The mapper yields zero or more key-value pairs for each input MapReduce Evaluation Model (2/2) MapReduce Execution Model (1/2) Reduce phase: For each intermediate key, apply a reducer function to accumulate all values associated with that key The reducer takes an iterable value containing intermediate key-value pairs All pairs with the same key appear consecutively The reducer yields zero or more values, each associated with that intermediate key 59 60

16 MapReduce Execution Model (2/2) MapReduce example From a 1.1 billion people database (facebook?), we want to know the average number of friends per age In SQL: SELECT age, AVG(friends) FROM users GROUP BY age In MapReduce: the total set of users in splitted different users_set function map(users_set) for(user in users_set) send(user.age, user.friends.size); The keys are shuffled and assigned to reducers function reduce(age, friends): var r = 0; for(friend in friends) r += friend; send(age, r / friends.size); MapReduce Assumptions Constraints on the mapper and reducer: The mapper must be equivalent to applying a deterministic pure function to each input independently The reducer must be equivalent to applying a deterministic pure function to the sequence of values for each key Benefits of functional programming: When a program contains only pure functions, call expressions can be evaluated in any order, lazily, and in parallel Referential transparency: a call expression can be replaced by its value (or vis versa) without changing the program In MapReduce, these functional programming ideas allow: Consistent results, however computation is partitioned Re-computation and caching of results, as needed MapReduce Benefits Fault tolerance: A machine or hard drive might crash The MapReduce framework automatically re-runs failed tasks Speed: Some machine might be slow because it's overloaded The framework can run multiple copies of a task and keep the result of the one that finishes first Network locality: Data transfer is expensive The framework tries to schedule map tasks on the machines that hold the data to be processed Monitoring: Will my job finish before dinner?!? The framework provides a web-based interface describing jobs 63 64

17 Summary Parallel programming Multi-threading and how to help reduce programmer error Distributed programming and MapReduce 65 / 65

61A Lecture 36. Wednesday, November 30

61A Lecture 36. Wednesday, November 30 61A Lecture 36 Wednesday, November 30 Project 4 Contest Gallery Prizes will be awarded for the winning entry in each of the following categories. Featherweight. At most 128 words of Logo, not including

More information

Concurrency: a crash course

Concurrency: a crash course Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Concurrency: a crash course Concurrent computing Applications designed as a collection of computational units that may execute

More information

List of lectures. Lecture content. Symbolic Programming. TDDA69 Data and Program Structure Symbolic and Logic Programming Cyrille Berger

List of lectures. Lecture content. Symbolic Programming. TDDA69 Data and Program Structure Symbolic and Logic Programming Cyrille Berger List of lectures TDDA69 Data and Program Structure Symbolic and Logic Programming Cyrille Berger 1Introduction and Functional Programming 2Imperative Programming and Data Structures 3Parsing 4Evaluation

More information

Parallelism Marco Serafini

Parallelism Marco Serafini Parallelism Marco Serafini COMPSCI 590S Lecture 3 Announcements Reviews First paper posted on website Review due by this Wednesday 11 PM (hard deadline) Data Science Career Mixer (save the date!) November

More information

Parallel Programming: Background Information

Parallel Programming: Background Information 1 Parallel Programming: Background Information Mike Bailey mjb@cs.oregonstate.edu parallel.background.pptx Three Reasons to Study Parallel Programming 2 1. Increase performance: do more work in the same

More information

Parallel Programming: Background Information

Parallel Programming: Background Information 1 Parallel Programming: Background Information Mike Bailey mjb@cs.oregonstate.edu parallel.background.pptx Three Reasons to Study Parallel Programming 2 1. Increase performance: do more work in the same

More information

Discussion CSE 224. Week 4

Discussion CSE 224. Week 4 Discussion CSE 224 Week 4 Midterm The midterm will cover - 1. Topics discussed in lecture 2. Research papers from the homeworks 3. Textbook readings from Unit 1 and Unit 2 HW 3&4 Clarifications 1. The

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Graphical User Interfaces Robert Rand University of Pennsylvania December 03, 2015 Robert Rand (University of Pennsylvania) CIS 192 December 03, 2015 1 / 21 Outline 1 Performance

More information

CS 220: Introduction to Parallel Computing. Introduction to CUDA. Lecture 28

CS 220: Introduction to Parallel Computing. Introduction to CUDA. Lecture 28 CS 220: Introduction to Parallel Computing Introduction to CUDA Lecture 28 Today s Schedule Project 4 Read-Write Locks Introduction to CUDA 5/2/18 CS 220: Parallel Computing 2 Today s Schedule Project

More information

CSE Lecture 11: Map/Reduce 7 October Nate Nystrom UTA

CSE Lecture 11: Map/Reduce 7 October Nate Nystrom UTA CSE 3302 Lecture 11: Map/Reduce 7 October 2010 Nate Nystrom UTA 378,000 results in 0.17 seconds including images and video communicates with 1000s of machines web server index servers document servers

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 22 Shared-Memory Concurrency 1 Administrivia HW7 due Thursday night, 11 pm (+ late days if you still have any & want to use them) Course

More information

High Performance Computing. University questions with solution

High Performance Computing. University questions with solution High Performance Computing University questions with solution Q1) Explain the basic working principle of VLIW processor. (6 marks) The following points are basic working principle of VLIW processor. The

More information

CS510 Advanced Topics in Concurrency. Jonathan Walpole

CS510 Advanced Topics in Concurrency. Jonathan Walpole CS510 Advanced Topics in Concurrency Jonathan Walpole Threads Cannot Be Implemented as a Library Reasoning About Programs What are the valid outcomes for this program? Is it valid for both r1 and r2 to

More information

Rust for C++ Programmers

Rust for C++ Programmers Rust for C++ Programmers Vinzent Steinberg C++ User Group, FIAS April 29, 2015 1 / 27 Motivation C++ has a lot of problems C++ cannot be fixed (because of backwards compatibility) Rust to the rescue! 2

More information

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.

CPSC/ECE 3220 Fall 2017 Exam Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts. CPSC/ECE 3220 Fall 2017 Exam 1 Name: 1. Give the definition (note: not the roles) for an operating system as stated in the textbook. (2 pts.) Referee / Illusionist / Glue. Circle only one of R, I, or G.

More information

Lecture 16: Recapitulations. Lecture 16: Recapitulations p. 1

Lecture 16: Recapitulations. Lecture 16: Recapitulations p. 1 Lecture 16: Recapitulations Lecture 16: Recapitulations p. 1 Parallel computing and programming in general Parallel computing a form of parallel processing by utilizing multiple computing units concurrently

More information

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction

Lecture content. Course goals. Course Introduction. TDDA69 Data and Program Structure Introduction Lecture content TDDA69 Data and Program Structure Introduction Cyrille Berger Course Introduction to the different Programming Paradigm The different programming paradigm Why different paradigms? Introduction

More information

Threads Cannot Be Implemented As a Library

Threads Cannot Be Implemented As a Library Threads Cannot Be Implemented As a Library Authored by Hans J. Boehm Presented by Sarah Sharp February 18, 2008 Outline POSIX Thread Library Operation Vocab Problems with pthreads POSIX Thread Library

More information

CIS192 Python Programming

CIS192 Python Programming CIS192 Python Programming Profiling and Parallel Computing Harry Smith University of Pennsylvania November 29, 2017 Harry Smith (University of Pennsylvania) CIS 192 November 29, 2017 1 / 19 Outline 1 Performance

More information

Application Programming

Application Programming Multicore Application Programming For Windows, Linux, and Oracle Solaris Darryl Gove AAddison-Wesley Upper Saddle River, NJ Boston Indianapolis San Francisco New York Toronto Montreal London Munich Paris

More information

Systems research enables application development by defining and implementing abstractions:

Systems research enables application development by defining and implementing abstractions: 61A Lecture 36 Announcements Unix Computer Systems Systems research enables application development by defining and implementing abstractions: Operating systems provide a stable, consistent interface to

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution

More information

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday.

Administrivia. HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Administrivia HW1 due Oct 4. Lectures now being recorded. I ll post URLs when available. Discussing Readings on Monday. Keep posting discussion on Piazza Python Multiprocessing Topics today: Multiprocessing

More information

Apache Spark is a fast and general-purpose engine for large-scale data processing Spark aims at achieving the following goals in the Big data context

Apache Spark is a fast and general-purpose engine for large-scale data processing Spark aims at achieving the following goals in the Big data context 1 Apache Spark is a fast and general-purpose engine for large-scale data processing Spark aims at achieving the following goals in the Big data context Generality: diverse workloads, operators, job sizes

More information

Threads and Java Memory Model

Threads and Java Memory Model Threads and Java Memory Model Oleg Šelajev @shelajev oleg@zeroturnaround.com October 6, 2014 Agenda Threads Basic synchronization Java Memory Model Concurrency Concurrency - several computations are executing

More information

Last Class: Deadlocks. Where we are in the course

Last Class: Deadlocks. Where we are in the course Last Class: Deadlocks Necessary conditions for deadlock: Mutual exclusion Hold and wait No preemption Circular wait Ways of handling deadlock Deadlock detection and recovery Deadlock prevention Deadlock

More information

Performance Throughput Utilization of system resources

Performance Throughput Utilization of system resources Concurrency 1. Why concurrent programming?... 2 2. Evolution... 2 3. Definitions... 3 4. Concurrent languages... 5 5. Problems with concurrency... 6 6. Process Interactions... 7 7. Low-level Concurrency

More information

FLAT DATACENTER STORAGE. Paper-3 Presenter-Pratik Bhatt fx6568

FLAT DATACENTER STORAGE. Paper-3 Presenter-Pratik Bhatt fx6568 FLAT DATACENTER STORAGE Paper-3 Presenter-Pratik Bhatt fx6568 FDS Main discussion points A cluster storage system Stores giant "blobs" - 128-bit ID, multi-megabyte content Clients and servers connected

More information

Concurrent Preliminaries

Concurrent Preliminaries Concurrent Preliminaries Sagi Katorza Tel Aviv University 09/12/2014 1 Outline Hardware infrastructure Hardware primitives Mutual exclusion Work sharing and termination detection Concurrent data structures

More information

Introduction to Locks. Intrinsic Locks

Introduction to Locks. Intrinsic Locks CMSC 433 Programming Language Technologies and Paradigms Spring 2013 Introduction to Locks Intrinsic Locks Atomic-looking operations Resources created for sequential code make certain assumptions, a large

More information

The Google File System (GFS)

The Google File System (GFS) 1 The Google File System (GFS) CS60002: Distributed Systems Antonio Bruto da Costa Ph.D. Student, Formal Methods Lab, Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 2 Design constraints

More information

CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON. Created by Moritz Wundke

CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON. Created by Moritz Wundke CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON Created by Moritz Wundke INTRODUCTION Concurrent aims to be a different type of task distribution system compared to what MPI like system do. It adds a simple

More information

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University

CS 571 Operating Systems. Midterm Review. Angelos Stavrou, George Mason University CS 571 Operating Systems Midterm Review Angelos Stavrou, George Mason University Class Midterm: Grading 2 Grading Midterm: 25% Theory Part 60% (1h 30m) Programming Part 40% (1h) Theory Part (Closed Books):

More information

Parallelization and Synchronization. CS165 Section 8

Parallelization and Synchronization. CS165 Section 8 Parallelization and Synchronization CS165 Section 8 Multiprocessing & the Multicore Era Single-core performance stagnates (breakdown of Dennard scaling) Moore s law continues use additional transistors

More information

Introduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA)

Introduction to MapReduce. Adapted from Jimmy Lin (U. Maryland, USA) Introduction to MapReduce Adapted from Jimmy Lin (U. Maryland, USA) Motivation Overview Need for handling big data New programming paradigm Review of functional programming mapreduce uses this abstraction

More information

CS3350B Computer Architecture

CS3350B Computer Architecture CS3350B Computer Architecture Winter 2015 Lecture 7.2: Multicore TLP (1) Marc Moreno Maza www.csd.uwo.ca/courses/cs3350b [Adapted from lectures on Computer Organization and Design, Patterson & Hennessy,

More information

High Performance Computing Course Notes Shared Memory Parallel Programming

High Performance Computing Course Notes Shared Memory Parallel Programming High Performance Computing Course Notes 2009-2010 2010 Shared Memory Parallel Programming Techniques Multiprocessing User space multithreading Operating system-supported (or kernel) multithreading Distributed

More information

CSE Traditional Operating Systems deal with typical system software designed to be:

CSE Traditional Operating Systems deal with typical system software designed to be: CSE 6431 Traditional Operating Systems deal with typical system software designed to be: general purpose running on single processor machines Advanced Operating Systems are designed for either a special

More information

MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016

MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016 MPI and OpenMP (Lecture 25, cs262a) Ion Stoica, UC Berkeley November 19, 2016 Message passing vs. Shared memory Client Client Client Client send(msg) recv(msg) send(msg) recv(msg) MSG MSG MSG IPC Shared

More information

CS61A Lecture 42. Amir Kamil UC Berkeley April 29, 2013

CS61A Lecture 42. Amir Kamil UC Berkeley April 29, 2013 CS61A Lecture 42 Amir Kamil UC Berkeley April 29, 2013 Announcements HW13 due Wednesday Scheme project due tonight!!! Scheme contest deadline extended to Friday MapReduce Execution Model http://research.google.com/archive/mapreduce

More information

Modern Processor Architectures. L25: Modern Compiler Design

Modern Processor Architectures. L25: Modern Compiler Design Modern Processor Architectures L25: Modern Compiler Design The 1960s - 1970s Instructions took multiple cycles Only one instruction in flight at once Optimisation meant minimising the number of instructions

More information

CMSC 330: Organization of Programming Languages. Concurrency & Multiprocessing

CMSC 330: Organization of Programming Languages. Concurrency & Multiprocessing CMSC 330: Organization of Programming Languages Concurrency & Multiprocessing Multiprocessing Multiprocessing: The use of multiple parallel computations We have entered an era of multiple cores... Hyperthreading

More information

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions:

Techno India Batanagar Department of Computer Science & Engineering. Model Questions. Multiple Choice Questions: Techno India Batanagar Department of Computer Science & Engineering Model Questions Subject Name: Operating System Multiple Choice Questions: Subject Code: CS603 1) Shell is the exclusive feature of a)

More information

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4 Motivation Threads Chapter 4 Most modern applications are multithreaded Threads run within application Multiple tasks with the application can be implemented by separate Update display Fetch data Spell

More information

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year

Dr. Rafiq Zakaria Campus. Maulana Azad College of Arts, Science & Commerce, Aurangabad. Department of Computer Science. Academic Year Dr. Rafiq Zakaria Campus Maulana Azad College of Arts, Science & Commerce, Aurangabad Department of Computer Science Academic Year 2015-16 MCQs on Operating System Sem.-II 1.What is operating system? a)

More information

Parallel Programming using OpenMP

Parallel Programming using OpenMP 1 Parallel Programming using OpenMP Mike Bailey mjb@cs.oregonstate.edu openmp.pptx OpenMP Multithreaded Programming 2 OpenMP stands for Open Multi-Processing OpenMP is a multi-vendor (see next page) standard

More information

Synchronising Threads

Synchronising Threads Synchronising Threads David Chisnall March 1, 2011 First Rule for Maintainable Concurrent Code No data may be both mutable and aliased Harder Problems Data is shared and mutable Access to it must be protected

More information

Clustering Lecture 8: MapReduce

Clustering Lecture 8: MapReduce Clustering Lecture 8: MapReduce Jing Gao SUNY Buffalo 1 Divide and Conquer Work Partition w 1 w 2 w 3 worker worker worker r 1 r 2 r 3 Result Combine 4 Distributed Grep Very big data Split data Split data

More information

CS 179: GPU Programming LECTURE 5: GPU COMPUTE ARCHITECTURE FOR THE LAST TIME

CS 179: GPU Programming LECTURE 5: GPU COMPUTE ARCHITECTURE FOR THE LAST TIME CS 179: GPU Programming LECTURE 5: GPU COMPUTE ARCHITECTURE FOR THE LAST TIME 1 Last time... GPU Memory System Different kinds of memory pools, caches, etc Different optimization techniques 2 Warp Schedulers

More information

CSCI 4717 Computer Architecture

CSCI 4717 Computer Architecture CSCI 4717/5717 Computer Architecture Topic: Symmetric Multiprocessors & Clusters Reading: Stallings, Sections 18.1 through 18.4 Classifications of Parallel Processing M. Flynn classified types of parallel

More information

List of lectures. Lecture content. Imperative Programming. TDDA69 Data and Program Structure Imperative Programming and Data Structures

List of lectures. Lecture content. Imperative Programming. TDDA69 Data and Program Structure Imperative Programming and Data Structures List of lectures TDDA69 Data and Program Structure Imperative Programming and Data Structures Cyrille Berger 1Introduction and Functional Programming 2Imperative Programming and Data Structures 3Parsing

More information

Datacenter replication solution with quasardb

Datacenter replication solution with quasardb Datacenter replication solution with quasardb Technical positioning paper April 2017 Release v1.3 www.quasardb.net Contact: sales@quasardb.net Quasardb A datacenter survival guide quasardb INTRODUCTION

More information

2/26/2017. Originally developed at the University of California - Berkeley's AMPLab

2/26/2017. Originally developed at the University of California - Berkeley's AMPLab Apache is a fast and general engine for large-scale data processing aims at achieving the following goals in the Big data context Generality: diverse workloads, operators, job sizes Low latency: sub-second

More information

Parallel Programming using OpenMP

Parallel Programming using OpenMP 1 OpenMP Multithreaded Programming 2 Parallel Programming using OpenMP OpenMP stands for Open Multi-Processing OpenMP is a multi-vendor (see next page) standard to perform shared-memory multithreading

More information

multiprocessing HPC Python R. Todd Evans January 23, 2015

multiprocessing HPC Python R. Todd Evans January 23, 2015 multiprocessing HPC Python R. Todd Evans rtevans@tacc.utexas.edu January 23, 2015 What is Multiprocessing Process-based parallelism Not threading! Threads are light-weight execution units within a process

More information

CS5460: Operating Systems

CS5460: Operating Systems CS5460: Operating Systems Lecture 9: Implementing Synchronization (Chapter 6) Multiprocessor Memory Models Uniprocessor memory is simple Every load from a location retrieves the last value stored to that

More information

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono Introduction to CUDA Algoritmi e Calcolo Parallelo References This set of slides is mainly based on: CUDA Technical Training, Dr. Antonino Tumeo, Pacific Northwest National Laboratory Slide of Applied

More information

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono

Introduction to CUDA Algoritmi e Calcolo Parallelo. Daniele Loiacono Introduction to CUDA Algoritmi e Calcolo Parallelo References q This set of slides is mainly based on: " CUDA Technical Training, Dr. Antonino Tumeo, Pacific Northwest National Laboratory " Slide of Applied

More information

Putting it together. Data-Parallel Computation. Ex: Word count using partial aggregation. Big Data Processing. COS 418: Distributed Systems Lecture 21

Putting it together. Data-Parallel Computation. Ex: Word count using partial aggregation. Big Data Processing. COS 418: Distributed Systems Lecture 21 Big Processing -Parallel Computation COS 418: Distributed Systems Lecture 21 Michael Freedman 2 Ex: Word count using partial aggregation Putting it together 1. Compute word counts from individual files

More information

Shared state model. April 3, / 29

Shared state model. April 3, / 29 Shared state April 3, 2012 1 / 29 the s s limitations of explicit state: cells equivalence of the two s programming in limiting interleavings locks, monitors, transactions comparing the 3 s 2 / 29 Message

More information

CS 261 Fall Mike Lam, Professor. Threads

CS 261 Fall Mike Lam, Professor. Threads CS 261 Fall 2017 Mike Lam, Professor Threads Parallel computing Goal: concurrent or parallel computing Take advantage of multiple hardware units to solve multiple problems simultaneously Motivations: Maintain

More information

Java Concurrency in practice Chapter 9 GUI Applications

Java Concurrency in practice Chapter 9 GUI Applications Java Concurrency in practice Chapter 9 GUI Applications INF329 Spring 2007 Presented by Stian and Eirik 1 Chapter 9 GUI Applications GUI applications have their own peculiar threading issues To maintain

More information

PYTHON TRAINING COURSE CONTENT

PYTHON TRAINING COURSE CONTENT SECTION 1: INTRODUCTION What s python? Why do people use python? Some quotable quotes A python history lesson Advocacy news What s python good for? What s python not good for? The compulsory features list

More information

CONCURRENCY AND MAPREDUCE 15

CONCURRENCY AND MAPREDUCE 15 CONCURRENCY AND MAPREDUCE 15 COMPUTER SCIENCE 61A August 3, 2014 1 Concurrency On your computer, you often use multiple programs at the same time. You might be reading Piazza posts on your internet browser,

More information

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet:

Student Name:.. Student ID... Course Code: CSC 227 Course Title: Semester: Fall Exercises Cover Sheet: King Saud University College of Computer and Information Sciences Computer Science Department Course Code: CSC 227 Course Title: Operating Systems Semester: Fall 2016-2017 Exercises Cover Sheet: Final

More information

Module 10: Open Multi-Processing Lecture 19: What is Parallelization? The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program

Module 10: Open Multi-Processing Lecture 19: What is Parallelization? The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program The Lecture Contains: What is Parallelization? Perfectly Load-Balanced Program Amdahl's Law About Data What is Data Race? Overview to OpenMP Components of OpenMP OpenMP Programming Model OpenMP Directives

More information

multiprocessing and mpi4py

multiprocessing and mpi4py multiprocessing and mpi4py 02-03 May 2012 ARPA PIEMONTE m.cestari@cineca.it Bibliography multiprocessing http://docs.python.org/library/multiprocessing.html http://www.doughellmann.com/pymotw/multiprocessi

More information

Distributed Systems (5DV147)

Distributed Systems (5DV147) Distributed Systems (5DV147) Replication and consistency Fall 2013 1 Replication 2 What is replication? Introduction Make different copies of data ensuring that all copies are identical Immutable data

More information

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective

ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective ECE 7650 Scalable and Secure Internet Services and Architecture ---- A Systems Perspective Part II: Data Center Software Architecture: Topic 3: Programming Models Piccolo: Building Fast, Distributed Programs

More information

CMSC421: Principles of Operating Systems

CMSC421: Principles of Operating Systems CMSC421: Principles of Operating Systems Nilanjan Banerjee Assistant Professor, University of Maryland Baltimore County nilanb@umbc.edu http://www.csee.umbc.edu/~nilanb/teaching/421/ Principles of Operating

More information

Portland State University ECE 588/688. Graphics Processors

Portland State University ECE 588/688. Graphics Processors Portland State University ECE 588/688 Graphics Processors Copyright by Alaa Alameldeen 2018 Why Graphics Processors? Graphics programs have different characteristics from general purpose programs Highly

More information

POSIX Threads: a first step toward parallel programming. George Bosilca

POSIX Threads: a first step toward parallel programming. George Bosilca POSIX Threads: a first step toward parallel programming George Bosilca bosilca@icl.utk.edu Process vs. Thread A process is a collection of virtual memory space, code, data, and system resources. A thread

More information

CS370 Operating Systems Midterm Review

CS370 Operating Systems Midterm Review CS370 Operating Systems Midterm Review Yashwant K Malaiya Fall 2015 Slides based on Text by Silberschatz, Galvin, Gagne 1 1 What is an Operating System? An OS is a program that acts an intermediary between

More information

Batch Processing Basic architecture

Batch Processing Basic architecture Batch Processing Basic architecture in big data systems COS 518: Distributed Systems Lecture 10 Andrew Or, Mike Freedman 2 1 2 64GB RAM 32 cores 64GB RAM 32 cores 64GB RAM 32 cores 64GB RAM 32 cores 3

More information

Compiling for GPUs. Adarsh Yoga Madhav Ramesh

Compiling for GPUs. Adarsh Yoga Madhav Ramesh Compiling for GPUs Adarsh Yoga Madhav Ramesh Agenda Introduction to GPUs Compute Unified Device Architecture (CUDA) Control Structure Optimization Technique for GPGPU Compiler Framework for Automatic Translation

More information

CS6401- OPERATING SYSTEM

CS6401- OPERATING SYSTEM 1. What is an Operating system? CS6401- OPERATING SYSTEM QUESTION BANK UNIT-I An operating system is a program that manages the computer hardware. It also provides a basis for application programs and

More information

27. Parallel Programming I

27. Parallel Programming I 771 27. Parallel Programming I Moore s Law and the Free Lunch, Hardware Architectures, Parallel Execution, Flynn s Taxonomy, Scalability: Amdahl and Gustafson, Data-parallelism, Task-parallelism, Scheduling

More information

Parallel Computing: MapReduce Jin, Hai

Parallel Computing: MapReduce Jin, Hai Parallel Computing: MapReduce Jin, Hai School of Computer Science and Technology Huazhong University of Science and Technology ! MapReduce is a distributed/parallel computing framework introduced by Google

More information

CMSC 330: Organization of Programming Languages

CMSC 330: Organization of Programming Languages CMSC 330: Organization of Programming Languages Multithreading Multiprocessors Description Multiple processing units (multiprocessor) From single microprocessor to large compute clusters Can perform multiple

More information

Lecture 27: Pot-Pourri. Today s topics: Shared memory vs message-passing Simultaneous multi-threading (SMT) GPUs Disks and reliability

Lecture 27: Pot-Pourri. Today s topics: Shared memory vs message-passing Simultaneous multi-threading (SMT) GPUs Disks and reliability Lecture 27: Pot-Pourri Today s topics: Shared memory vs message-passing Simultaneous multi-threading (SMT) GPUs Disks and reliability 1 Shared-Memory Vs. Message-Passing Shared-memory: Well-understood

More information

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio

CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio CS 5523 Operating Systems: Midterm II - reivew Instructor: Dr. Tongping Liu Department Computer Science The University of Texas at San Antonio Fall 2017 1 Outline Inter-Process Communication (20) Threads

More information

Main Points of the Computer Organization and System Software Module

Main Points of the Computer Organization and System Software Module Main Points of the Computer Organization and System Software Module You can find below the topics we have covered during the COSS module. Reading the relevant parts of the textbooks is essential for a

More information

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University

CS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 Process creation in UNIX All processes have a unique process id getpid(),

More information

Aaron Turon! Mozilla Research

Aaron Turon! Mozilla Research Aaron Turon Mozilla Research C/C++ ML/Haskell Rust Safe systems programming Why Mozilla? Browsers need control. Browsers need safety. Servo: Next-generation browser built in Rust. C++ What is control?

More information

Processes and Threads

Processes and Threads COS 318: Operating Systems Processes and Threads Kai Li and Andy Bavier Computer Science Department Princeton University http://www.cs.princeton.edu/courses/archive/fall13/cos318 Today s Topics u Concurrency

More information

Message Passing. Advanced Operating Systems Tutorial 7

Message Passing. Advanced Operating Systems Tutorial 7 Message Passing Advanced Operating Systems Tutorial 7 Tutorial Outline Review of Lectured Material Discussion: Erlang and message passing 2 Review of Lectured Material Message passing systems Limitations

More information

Non-uniform memory access machine or (NUMA) is a system where the memory access time to any region of memory is not the same for all processors.

Non-uniform memory access machine or (NUMA) is a system where the memory access time to any region of memory is not the same for all processors. CS 320 Ch. 17 Parallel Processing Multiple Processor Organization The author makes the statement: "Processors execute programs by executing machine instructions in a sequence one at a time." He also says

More information

COMP 3361: Operating Systems 1 Final Exam Winter 2009

COMP 3361: Operating Systems 1 Final Exam Winter 2009 COMP 3361: Operating Systems 1 Final Exam Winter 2009 Name: Instructions This is an open book exam. The exam is worth 100 points, and each question indicates how many points it is worth. Read the exam

More information

Native POSIX Thread Library (NPTL) CSE 506 Don Porter

Native POSIX Thread Library (NPTL) CSE 506 Don Porter Native POSIX Thread Library (NPTL) CSE 506 Don Porter Logical Diagram Binary Memory Threads Formats Allocators Today s Lecture Scheduling System Calls threads RCU File System Networking Sync User Kernel

More information

Taming Dava Threads. Apress ALLEN HOLUB. HLuHB Darmstadt

Taming Dava Threads. Apress ALLEN HOLUB. HLuHB Darmstadt Taming Dava Threads ALLEN HOLUB HLuHB Darmstadt Apress TM Chapter l The Architecture of Threads l The Problems with Threads l All Nontrivial Java Programs Are Multithreaded 2 Java's Thread Support Is Not

More information

Modern Processor Architectures (A compiler writer s perspective) L25: Modern Compiler Design

Modern Processor Architectures (A compiler writer s perspective) L25: Modern Compiler Design Modern Processor Architectures (A compiler writer s perspective) L25: Modern Compiler Design The 1960s - 1970s Instructions took multiple cycles Only one instruction in flight at once Optimisation meant

More information

Lecture 9: Midterm Review

Lecture 9: Midterm Review Project 1 Due at Midnight Lecture 9: Midterm Review CSE 120: Principles of Operating Systems Alex C. Snoeren Midterm Everything we ve covered is fair game Readings, lectures, homework, and Nachos Yes,

More information

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017

Operating Systems. Lecture 4 - Concurrency and Synchronization. Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Operating Systems Lecture 4 - Concurrency and Synchronization Adrien Krähenbühl Master of Computer Science PUF - Hồ Chí Minh 2016/2017 Mutual exclusion Hardware solutions Semaphores IPC: Message passing

More information

Parallel Python using the Multiprocess(ing) Package

Parallel Python using the Multiprocess(ing) Package Parallel Python using the Multiprocess(ing) Package K. 1 1 Department of Mathematics 2018 Caveats My understanding of Parallel Python is not mature, so anything said here is somewhat questionable. There

More information

Department of Computer applications. [Part I: Medium Answer Type Questions]

Department of Computer applications. [Part I: Medium Answer Type Questions] Department of Computer applications BBDNITM, Lucknow MCA 311: OPERATING SYSTEM [Part I: Medium Answer Type Questions] UNIT 1 Q1. What do you mean by an Operating System? What are the main functions of

More information

Operating Systems Overview. Chapter 2

Operating Systems Overview. Chapter 2 Operating Systems Overview Chapter 2 Operating System A program that controls the execution of application programs An interface between the user and hardware Masks the details of the hardware Layers and

More information

R13 SET - 1 2. Answering the question in Part-A is compulsory 1 a) Define Operating System. List out the objectives of an operating system. [3M] b) Describe different attributes of the process. [4M] c)

More information

Table of Contents. Preface... xxi

Table of Contents. Preface... xxi Table of Contents Preface... xxi Chapter 1: Introduction to Python... 1 Python... 2 Features of Python... 3 Execution of a Python Program... 7 Viewing the Byte Code... 9 Flavors of Python... 10 Python

More information

Timers 1 / 46. Jiffies. Potent and Evil Magic

Timers 1 / 46. Jiffies. Potent and Evil Magic Timers 1 / 46 Jiffies Each timer tick, a variable called jiffies is incremented It is thus (roughly) the number of HZ since system boot A 32-bit counter incremented at 1000 Hz wraps around in about 50

More information

CS 241 Honors Concurrent Data Structures

CS 241 Honors Concurrent Data Structures CS 241 Honors Concurrent Data Structures Bhuvan Venkatesh University of Illinois Urbana Champaign March 27, 2018 CS 241 Course Staff (UIUC) Lock Free Data Structures March 27, 2018 1 / 43 What to go over

More information