PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... •...

81
Introduction & Course Overview SS 2020– Parallel Programming Dr. Malte Schwerhoff, Dr. Hermann Lehner Slides (mainly) from Prof. Martin Vechev, Prof. Otmar Hilliges, Dr. Felix Friedrich

Transcript of PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... •...

Page 1: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Introduction & Course OverviewSS 2020– Parallel ProgrammingDr. Malte Schwerhoff, Dr. Hermann Lehner

Slides (mainly) from Prof. Martin Vechev, Prof. Otmar Hilliges, Dr. Felix Friedrich

Page 2: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

About this course

2

Lecturers:

Dr. Malte SchwerhoffDr. Hermann LehnerUNG F 15/16{firstname.lastname}@inf.ethz.ch

Teach Part IOffice hours: per email request

Prof. Torsten HoeflerCAB F [email protected]

Teaches Part IIOffice hours: per email request

https://spcl.inf.ethz.ch/Teaching/2020‐pp/

Page 3: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

3

• Dipl. Informatik‐Ingenieur at ETH

• PhD at ETH: Program semantics, formal verification

• 5 years in industry as software engineer and team lead

• ETH lecturer since 2016

• BSc at FH Gelsenkirchen

• MSc at ETH

• PhD at ETH: Language & tools forverifying parallel programs

• Semesters abroad in Tomsk (Russia),Leuven (Belgium)

• ETH lecturer since 2017

About us

Page 4: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

1. Parallel programming is a necessity – since 2000‐ish

2. A different way of computational thinking – who said everything needs a total order?

3. Generally fun (since always) – if you like to challenge your brain

4

Why this course?

Herb Sutter for Dr. Dobb’s Journal

Page 5: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Course Overview

Parallel Programming (252‐0029‐00L) • 4L + 2U• 7 ECTS Credits• Audience: Computer Science Bachelor• Part of Basisprüfung

• Lecture Language: Denglisch

5

Page 6: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Course Coordination

Communication via course website:https://spcl.inf.ethz.ch/Teaching/2020‐pp/

• Lectures 2 x week: • Tuesday 10‐12 HG F 7 (video transmission HG F 5)• Wednesday 13‐15 HG F 7 (video transmission HG F 5)

• Weekly Exercise Sessions• Enroll via myStudies• Wednesday 15‐17 or Friday 10‐12

6

Page 7: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

About this Course

Head TAs:• Pavol Bielik (first part)• Timo Schneider (second part)

Teaching Assistants:

7

Grades:• Class is part of Basisprüfung: written, centralized 

exam after the term• 100% of grade determined by final exam• Exercises not graded but essential• Yishai Oltchik

• Salvatore Di Girolamo• Andrei Ivanov• Grzegorz Kwasniewski• Johannes de Fine Licht• Nikoli Dryden• Alexandros Ziogas• Marc Ficher• Velko Vechev• Enis Ulqinaku

• Victor Cornillere• Marcin Copik• Neville Walo• Felix Stöger• Lasse Meinen• Robin Renggli• Soel Micheletti• Patrick Wicki• Andreas Bergmeister

Page 8: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

• Zero tolerance cheating policy (cheat = fail + being reported)• Homework• Don’t look at other students code• Don’t copy code from anywhere• Ok to discuss things – but then you have to do it alone• Code may be checked with tools

• Don’t copy‐paste• Code• Text• Images

8

Academic Integrity

Page 9: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Course Overview

9

Page 10: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

How does this course fit into the CS curriculum?

• Programming‐in‐the‐small

• Programming‐in‐the‐large

10

Program = Algorithms + Data Structures

=> Data Structures and Algorithms

System = Processes + Objects + Communication

This class

Intro to Programming

This class

Page 11: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

How does this course fit into the CS curriculum?

11

Process / Program

Algorithm

Data structure

Algorithm

Data structure

Process / Program

Algorithm Algorithm

Data structure

Operating System

Network

OS

Page 12: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Learning Objectives

By the end of the course you should1. have mastered fundamental concepts in parallelism2. know how to construct parallel algorithms using different parallel

programming paradigms (e.g., task parallelism, data parallelism) andmechanisms (e.g., threads, tasks, locks, communication channels).

3. be qualified to reason about correctness and performance of parallelalgorithms

4. be ready to implement parallel programs for real‐world applicationtasks (e.g. searching large data sets)

12

Page 13: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Requirements

Basic understanding of Computer Science concepts

Basic knowledge of programming concepts:We will do a quick review of Java and briefly discuss JVMs

Basic understanding of computer architectures:No detailed knowledge necessary (we will cover some)

13

Page 14: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Image source: http://jolyon.co.uk14

Page 15: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

15

Page 16: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Motivation – Why Parallelism?

16

Moore’s Law Recap: Transistor counts double every two years Means: Smaller transistors => can put more on chip => computational power grows exponentially => your 

sequential program automatically gets faster.   Also applies to RAM size and pixel densities

Page 17: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Motivation – Why Parallelism? 

17

Page 18: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Why don’t we keep increasing clock speeds?

Transistors have not stopped getting smaller + faster (Moore lives)

Heat and power have become the primary concern in modern computer architecture! 

Consequence:• Smaller, more efficient Processors• More processors – often in one package

18

Page 19: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Main design constraint today is power

Single‐Core CPUs: Complex Control Hardware Pro: Flexibility + Performance! Con: Expensive in terms of power (Ops / Watt)

Many‐Core/GPUs etc: Simpler Control Hardware Pro: Potentially more power efficient (Ops / Watt) Con: More restrictive / complex programming models [but useful in 

many domains, e.g. deep learning].19

What kind of processors do we build then?

Page 20: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Class Overview

20

Parallelism

• Understanding and detecting parallelism

• Intro to PC Architectures

• Formalizing parallelism

• Programming models for parallelism

(Parallel) Programming

• Recap: Programming in Java + a bit of JVM

• Parallelism in Java (Threads)

Concurrency

• Shared data• Race Conditions• Locks, 

Semaphores, etc.• Lock‐free 

programming• Communication 

across tasks and processes

Parallel Algorithms

• Useful & common algorithms in parallel

• Data structures for parallelism

• Sorting & Searching, etc.

Page 21: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

1. MUTUAL EXCLUSIONThree stories

21

Page 22: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Alice’s Cat vs. Bob’s Dog

22

A B

Page 23: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Requirement I: Mutual Exclusion !

23

A B

Page 24: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

24

A B

Page 25: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Requirement II: No Lockout when free

25

A B

Page 26: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Communication: Idea 1 [Alternate]

26

A B

catdog

Dog is allowed in yard

Page 27: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Access Protocol [Alternate]

27

A B

catdog

Now cat is allowed in yard

Page 28: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Problem: starvation!

28

A B

catdog

Page 29: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Communication: Idea 2[Notification]

29

A B

My pet is in the yard

Page 30: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Access Protocol 2.1: Idea

30

A B

Cat wants to get out

Page 31: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

31

A B

Page 32: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

32

A B

Page 33: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Another Scenario

33

A B

Cat wants to get out

Dog wants to get out

Page 34: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

34

A B

Page 35: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

35

A B

Page 36: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Problem: no Mutual Exclusion!

36

A B

Page 37: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Checking flags twice does not help: deadlock!

37

A B

Page 38: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Access Protocol 2.2

38

A B

Cat wants to get out

Page 39: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

39

A B

Page 40: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

40

A B

Page 41: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

41

A B

Page 42: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

42

A B

Dog wants to get out

Page 43: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

43

A B

Page 44: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

44

A B

Page 45: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Access Protocol 2.2 is provably correct

45

A B

Page 46: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Minor (?) Problems: Livelock, Starvation

46

A B

Page 47: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

47

A B

catdogdog goes first

Page 48: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

48

A B

catdog

Dog wants to get out

Cat wants to get out

Page 49: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

49

A B

catdog

Page 50: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

50

A B

catdog

Page 51: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

51

A B

catdog

Page 52: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Final Solution

52

A B

catdog

Next time cat goes first

Page 53: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Still: General Problem of Waiting ...

53

A B

Page 54: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

2. PRODUCER‐CONSUMERThree stories

54

Page 55: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Producer‐Consumer

55

A B

Page 56: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Producer‐Consumer

56

A B

Page 57: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Rules

57

A B

Page 58: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

58

A B

Page 59: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

59

A B

Page 60: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Communication

60

A BFood is empty

Page 61: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Protocol

61

A B

Page 62: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

62

A B

not any more

Page 63: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

63

A B

Page 64: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

64

A BEmpty again

Oh dear...

Page 65: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

3. READERS‐WRITERSThree stories

65

Page 66: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

66

A B

PET

PET

Page 67: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

67

A B

LOVESPET LOVES

Page 68: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

68

A B

HAMPET LOVES

Page 69: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

69

A B

IPET LOVES

Page 70: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

70

A B

HATEPET LOVES

Page 71: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

71

A B

SALADPET LOVESSALAD

Page 72: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

The bad news

Reality of parallel computing is much more complicated than this.

The results of one action, such as the lifting of a flag by one thread, can become visible by other threads delayed or even in different order, making the aforementioned protocols even more tricky.

Precise reasons will become clear much later in your studies. But we will understand consequences in the lectures later.

72

Page 73: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

The good news

On parallel hardware we will find an interesting tool to deal with low level concurrency issues.

There is sufficient abstraction in the programming models of different programming languages.

Later on, we will not really have to deal with such low level concurrency issues. But we should have understood them once.

73

Page 74: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Language Landscape

C, C++

Java

Python, Ruby, Perl

Scala, Clojure, Groovy

Erlang, Go, Rust

Haskell, OCaml

JavaScript

74

Page 75: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Why use Java?Is ubiquitous (see oracle installer)• Many (very useful) libraries• Excellent online tutorials & booksParallelism is well supported• In the language and via frameworksInteroperable with modern JVM languages• E.g., Akka frameworkYet, not perfect• Tends to be verbose, lots of boilerplate code

75

Page 76: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Concepts and PracticeOur goal is twofold:

• Learn how to write parallel programs in practice Using Java for the most part

And showing how it works in C

• Understand the underlying fundamental concepts Generic concepts outlive specific tools

There are other approaches than Java's

76

Page 77: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

You are Encouraged to:• Ask questions:

helps us keep a good pace

helps you understand the material

let's make the course interactive

class or via e‐mail

• Use the web to find additional information Javadocs

Stack Overflow

• Write Code & Experiment

77

Page 78: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

What are Exercises for?Learning tool

Seeing a correct solution is not enough

You should try to solve the problem yourselves

Hence, exercise sessions are

for guiding you to solve the problem

not for spoon‐feeding you solutions

78

Page 79: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Introduction to Java Programming

Introduction to Java Programming, 2014. 

Daniel Liang. 

ISBN‐13: 9780133813463

Chapters 1‐13 (with some omissions) 

Week 1‐3

79

Page 80: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Java Concurrency in Practice

Java Concurrency in Practice, 2006. 

Brian Goetz, Tim Peierls, Joshua Bloch, Joseph Bowbeer, David Holmes, Doug Lea. 

ISBN‐13: 9780321349606

Week 4‐9

80

Page 81: PP-L01-INTRODUCTION COURSE OVERVIEW€¦ · Concurrency • Shared data • Race Conditions ... • E.g., Akka framework Yet, not perfect • Tends to be verbose, lots of boilerplate

Theory and beyond

• Fundamental treatment of concurrency

• In particular the "Principles" part is unique

• Not easy

• In this course Theory of concurrency

Behind locks

Lock‐free programming

81