Resource Analysis of Distributed and Concurrent Programs Elvira - - PowerPoint PPT Presentation

resource analysis of distributed and concurrent programs
SMART_READER_LITE
LIVE PREVIEW

Resource Analysis of Distributed and Concurrent Programs Elvira - - PowerPoint PPT Presentation

Resource Analysis of Distributed and Concurrent Programs Elvira Albert Complutense University of Madrid (Spain) DICE-FOPARA 2017 April 22-23, 2017, Uppsala, Sweden Elvira Albert, UCM Resource Analysis 1/37 what is resource analysis? The


slide-1
SLIDE 1

Resource Analysis of Distributed and Concurrent Programs

Elvira Albert

Complutense University of Madrid (Spain) DICE-FOPARA 2017

April 22-23, 2017, Uppsala, Sweden

Elvira Albert, UCM Resource Analysis 1/37

slide-2
SLIDE 2

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

Elvira Albert, UCM Resource Analysis 2/37

slide-3
SLIDE 3

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static

Elvira Albert, UCM Resource Analysis 2/37

slide-4
SLIDE 4

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

Elvira Albert, UCM Resource Analysis 2/37

slide-5
SLIDE 5

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Elvira Albert, UCM Resource Analysis 2/37

slide-6
SLIDE 6

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Elvira Albert, UCM Resource Analysis 2/37

slide-7
SLIDE 7

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Upper Bounds (worst case) Lower Bounds (best case)

Elvira Albert, UCM Resource Analysis 2/37

slide-8
SLIDE 8

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Elvira Albert, UCM Resource Analysis 2/37

slide-9
SLIDE 9

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Execution steps Visits to p Memory

Elvira Albert, UCM Resource Analysis 2/37

slide-10
SLIDE 10

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Execution steps Visits to p Memory

non-cumulative

Elvira Albert, UCM Resource Analysis 2/37

slide-11
SLIDE 11

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Execution steps Visits to p Memory Time? Energy?

Elvira Albert, UCM Resource Analysis 2/37

slide-12
SLIDE 12

what is resource analysis?

The aim of resource analysis is to bound the resource consumption (aka cost) of executing a given program P without actually executing P

static any

automatic

Execution steps Visits to p Memory Time? Energy?

platform dependent

Elvira Albert, UCM Resource Analysis 2/37

slide-13
SLIDE 13

what is it useful for?

  • Traditional applications

Elvira Albert, UCM Resource Analysis 3/37

slide-14
SLIDE 14

what is it useful for?

  • Traditional applications
  • Program optimization

U1 U2

  • Elvira Albert, UCM

Resource Analysis 3/37

slide-15
SLIDE 15

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees

Elvira Albert, UCM Resource Analysis 3/37

slide-16
SLIDE 16

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates

U = 2n2 + 3n Proof:

Elvira Albert, UCM Resource Analysis 3/37

slide-17
SLIDE 17

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates
  • New applications for distributed systems

Elvira Albert, UCM Resource Analysis 3/37

slide-18
SLIDE 18

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates
  • New applications for distributed systems
  • Load balance

2n + 2m 2n2 + 4m 5n + 3m n log(n) + 4m

Elvira Albert, UCM Resource Analysis 3/37

slide-19
SLIDE 19

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates
  • New applications for distributed systems
  • Load balance
  • Amount of data transmitted

2n + 2m 2n2 + 4m 5n + 3m n log(n) + 4m 3n+m n+m2 4m n2 ∗ m4 n ∗ m log(n)

Elvira Albert, UCM Resource Analysis 3/37

slide-20
SLIDE 20

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates
  • New applications for distributed systems
  • Load balance
  • Amount of data transmitted
  • Explotation of parallelism

2n + 2m 2n2 + 4m 5n + 3m n log(n) + 4m 3n+m n+m2 4m n2 ∗ m4 n ∗ m log(n)

Elvira Albert, UCM Resource Analysis 3/37

slide-21
SLIDE 21

what is it useful for?

  • Traditional applications
  • Program optimization
  • Verification: resource guarantees
  • Certification: resource usage certificates
  • New applications for distributed systems
  • Load balance
  • Amount of data transmitted
  • Explotation of parallelism
  • Model and dimension distributed systems

2n + 2m 2n2 + 4m 5n + 3m n log(n) + 4m 3n+m n+m2 4m n2 ∗ m4 n ∗ m log(n)

Elvira Albert, UCM Resource Analysis 3/37

slide-22
SLIDE 22

Plan of the talk

Part 1: Cost analysis in sequential programs

Generation of cost relations Inference of upper bounds

Elvira Albert, UCM Resource Analysis 4/37

slide-23
SLIDE 23

Plan of the talk

Part 1: Cost analysis in sequential programs

Generation of cost relations Inference of upper bounds

Part 2: Cost analysis in concurrent programs

Loops with concurrent interleavings May-happen-in-parallel analysis Rely-guarantee reasoning

Elvira Albert, UCM Resource Analysis 4/37

slide-24
SLIDE 24

Plan of the talk

Part 1: Cost analysis in sequential programs

Generation of cost relations Inference of upper bounds

Part 2: Cost analysis in concurrent programs

Loops with concurrent interleavings May-happen-in-parallel analysis Rely-guarantee reasoning

Part 3: Cost analysis of distributed systems

Dynamic distributed locations Resource analysis with cost centers New performance indicators Parallel and peak cost

Elvira Albert, UCM Resource Analysis 4/37

slide-25
SLIDE 25

Part 1: Resource Analysis of Sequential Code

Sequential Programs

Elvira Albert, UCM Resource Analysis 5/37

slide-26
SLIDE 26

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-27
SLIDE 27

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 3∗size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-28
SLIDE 28

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 3∗size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-29
SLIDE 29

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); ⇐ programpoint }

(number of visits to a program point)

1 + 2∗size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-30
SLIDE 30

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); ⇐ program point }

(number of visits to a program point)

size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-31
SLIDE 31

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); ⇐ program point }

(memory)

size(l)

Elvira Albert, UCM Resource Analysis 6/37

slide-32
SLIDE 32

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

while (l != null) { l = l.next; new C(); }

(number of instructions)

1 + 2∗size(l)

while (l != null) { l = l.next; new C(); ⇐ memory }

(memory)

size(l)∗size(C)

Elvira Albert, UCM Resource Analysis 6/37

slide-33
SLIDE 33

Resource Analysis of Sequential Code

Program

(Cost Model)

Upper Bound

A Classical approach [Wegbreit’75] to cost analysis consists of:

  • 1. expressing the cost of a program

by means of recurrence relations.

  • 2. solving the relations by
  • btaining a closed-form upper

bound (a function of the input data sizes).

Elvira Albert, UCM Resource Analysis 7/37

slide-34
SLIDE 34

Resource Analysis of Sequential Code

Program

(Cost Model)

Cost Relations CRs Solver

Upper Bound

A Classical approach [Wegbreit’75] to cost analysis consists of:

  • 1. expressing the cost of a program

by means of recurrence relations.

  • 2. solving the relations by
  • btaining a closed-form upper

bound (a function of the input data sizes).

Elvira Albert, UCM Resource Analysis 8/37

slide-35
SLIDE 35

Resource Analysis of Sequential Code

Program

(Cost Model) Static Analysis

Cost Relations CRs Solver

Upper Bound

Elvira Albert, UCM Resource Analysis 9/37

slide-36
SLIDE 36

Resource Analysis of Sequential Code

Program

(Cost Model) Static Analysis

Cost Relations CRs Solver

Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Static Analysis

while (l != null) l = l.next;

Elvira Albert, UCM Resource Analysis 9/37

slide-37
SLIDE 37

Resource Analysis of Sequential Code

Program

(Cost Model)

Static Analysis Cost Relations

Elvira Albert, UCM Resource Analysis 10/37

slide-38
SLIDE 38

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

Elvira Albert, UCM Resource Analysis 10/37

slide-39
SLIDE 39

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′).

Elvira Albert, UCM Resource Analysis 10/37

slide-40
SLIDE 40

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′).

Elvira Albert, UCM Resource Analysis 10/37

slide-41
SLIDE 41

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′).

Elvira Albert, UCM Resource Analysis 10/37

slide-42
SLIDE 42

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′).

Elvira Albert, UCM Resource Analysis 10/37

slide-43
SLIDE 43

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-44
SLIDE 44

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-45
SLIDE 45

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-46
SLIDE 46

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-47
SLIDE 47

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-48
SLIDE 48

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-49
SLIDE 49

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-50
SLIDE 50

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-51
SLIDE 51

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

while(l) = 1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-52
SLIDE 52

Resource Analysis of Sequential Code

Program

(Cost Model)

Recursive Representation Size Analysis

Cost Relations

while (l != null) l = l.next; while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). while(l, l) ← l=null. while(l, l′) ← l=null, l′′=l.next, while(l′′, l′). size1 ← {l=0} size2 ← {l>0, l>l′′}

while(l) = 1 {l=0} while(l) = 2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 10/37

slide-53
SLIDE 53

Resource Analysis of Sequential Code

Program

(Cost Model)

Cost Relations CRs Solver

Upper Bound

Elvira Albert, UCM Resource Analysis 11/37

slide-54
SLIDE 54

Resource Analysis of Sequential Code

Program

(Cost Model)

Cost Relations CRs Solver

Upper Bound

  • Elvira Albert, UCM

Resource Analysis 11/37

slide-55
SLIDE 55

Resource Analysis of Sequential Code

Program

(Cost Model)

Cost Relations CRs Solver

Upper Bound

  • while (l != null) l = l.next;

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

  • Elvira Albert, UCM

Resource Analysis 11/37

slide-56
SLIDE 56

Resource Analysis of Sequential Code

Program

(Cost Model)

Cost Relations CRs Solver

Upper Bound

  • while (l != null) l = l.next;

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

  • k1 + k2 ∗ l

Elvira Albert, UCM Resource Analysis 11/37

slide-57
SLIDE 57

Resource Analysis of Sequential Code

Cost Relations

CRs Solver Upper Bound

Elvira Albert, UCM Resource Analysis 12/37

slide-58
SLIDE 58

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Elvira Albert, UCM Resource Analysis 12/37

slide-59
SLIDE 59

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l)

Elvira Albert, UCM Resource Analysis 12/37

slide-60
SLIDE 60

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l) while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

Elvira Albert, UCM Resource Analysis 12/37

slide-61
SLIDE 61

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l) while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

Maximization remains the same k1 and k2 are constants

Elvira Albert, UCM Resource Analysis 12/37

slide-62
SLIDE 62

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l) while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

Elvira Albert, UCM Resource Analysis 12/37

slide-63
SLIDE 63

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l) while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l)

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l∗k2

Elvira Albert, UCM Resource Analysis 12/37

slide-64
SLIDE 64

Resource Analysis of Sequential Code

Cost Relations

Ranking function Maximization Upper Bound

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′} while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l) while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

Maximization remains the same k1 and k2 are constants

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l ∗ k2

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l)

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l∗k2

while(l) = k1 {l=0} while(l) = k2+while(l′′) {l>0, l>l′′}

RF(l) = l

(linear expression on l)

Maximization remains the same k1 and k2 are constants

while+(l) = cost+

bc + RF(l) ∗ cost+ loop

while+(l) = k1 + l∗k2

Elvira Albert, UCM Resource Analysis 12/37

slide-65
SLIDE 65

Summary Sequential

The process involves a series of transformations and analyses:

Transformation into recursive form Size analysis Generation of cost relations Ranking functions and maximization

We cover polynomial, exponential, logarithmic complexities From now on: given task m, we assume cost Um Main references: ESOP’07, SAS’08 Handling fields: SAS’10, FM’11

Elvira Albert, UCM Resource Analysis 13/37

slide-66
SLIDE 66

Part 2: Concurrent Programs

Concurrent Programs

Elvira Albert, UCM Resource Analysis 14/37

slide-67
SLIDE 67

Adding Concurrency

p Different tasks interleave execution in the same processor

Elvira Albert, UCM Resource Analysis 15/37

slide-68
SLIDE 68

Adding Concurrency

p m Different tasks interleave execution in the same processor Asynchronous task invocations

m(¯ x)

Elvira Albert, UCM Resource Analysis 15/37

slide-69
SLIDE 69

Adding Concurrency

p m

release release

Different tasks interleave execution in the same processor Asynchronous task invocations

m(¯ x)

Non-preemptive concurrency by explicitly releasing the processor

release

Elvira Albert, UCM Resource Analysis 15/37

slide-70
SLIDE 70

Adding Concurrency

p m

release release

f x y

Different tasks interleave execution in the same processor Asynchronous task invocations

m(¯ x)

Non-preemptive concurrency by explicitly releasing the processor

release

Shared memory among the different tasks

Elvira Albert, UCM Resource Analysis 15/37

slide-71
SLIDE 71

Resource Analysis with interleavings (I)

p

release f=3 f=2 f=1 release f=*

f x y while ( f >0){ . . . f = f −1; r e l e a s e ; }

1st approach: assume that shared memory changes after every release

Elvira Albert, UCM Resource Analysis 16/37

slide-72
SLIDE 72

Resource Analysis with interleavings (I)

p

release f=3 f=2 f=1 release f=*

f x y

f=?

while ( f >0){ . . . f = f −1; r e l e a s e ; }

1st approach: assume that shared memory changes after every release Loss of information, poor results → loops based on shared variables cannot be bound.

Elvira Albert, UCM Resource Analysis 16/37

slide-73
SLIDE 73

Resource Analysis with interleavings (II)

p m

f=3 f=2 f=1 release release x=3 y=7

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 x = 3 7 y = 7;

p() m() 2nd approach: use a May-Happen-in-Parallel analysis to infer instructions pairs that can interleave: . . . (4, 6), (4, 7) . . .

Elvira Albert, UCM Resource Analysis 17/37

slide-74
SLIDE 74

Resource Analysis with interleavings (II)

p m

f=3 f=2 f=1 release release x=3 y=7 f=1

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 x = 3 7 y = 7;

p() m() 2nd approach: use a May-Happen-in-Parallel analysis to infer instructions pairs that can interleave: . . . (4, 6), (4, 7) . . . Shared memory can only change if an update can interleave with

release → improve results

Elvira Albert, UCM Resource Analysis 17/37

slide-75
SLIDE 75

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times

Elvira Albert, UCM Resource Analysis 18/37

slide-76
SLIDE 76

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

x=1 f=100 release

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times

Elvira Albert, UCM Resource Analysis 18/37

slide-77
SLIDE 77

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

x=1 f=100 release f=100 f=99 . . . f=1 release

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times

Elvira Albert, UCM Resource Analysis 18/37

slide-78
SLIDE 78

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

x=1 f=100 release f=100 f=99 . . . f=1 release x=0 f=100 release

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times

Elvira Albert, UCM Resource Analysis 18/37

slide-79
SLIDE 79

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

x=1 f=100 release f=100 f=99 . . . f=1 release x=0 f=100 release f=100 f=99 . . . f=1 release

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times

Elvira Albert, UCM Resource Analysis 18/37

slide-80
SLIDE 80

Resource Analysis with interleavings (III)

p

f=3 f=2 f=1 release

m

x=1 f=100 release f=100 f=99 . . . f=1 release x=0 f=100 release f=100 f=99 . . . f=1 release

f x y

1 while

( f >0){

2

. . .

3

f = f −1;

4

r e l e a s e ;

5 } 6 while

( x>0){

7

x = x −1;

8

f = 100;

9

r e l e a s e ;

10 }

p() m() 3rd approach: interleavings that modify shared memory are safe if they can only happen a finite number of times Rely-guarantee reasoning: max(f ) × (max(x) + 1)

Elvira Albert, UCM Resource Analysis 18/37

slide-81
SLIDE 81

Summary Concurrent Programs

Basic resource analysis for sound results APLAS’11 May-happen-in-parallel analysis FORTE’12, LPAR’13, SAS’15 Rely-guarantee reasoning ATVA’13, JAR’17 From now on: given a concurrent task m, we assume cost Um

Elvira Albert, UCM Resource Analysis 19/37

slide-82
SLIDE 82

Part 3: Distributed Systems

Distributed Systems

Elvira Albert, UCM Resource Analysis 20/37

slide-83
SLIDE 83

Adding distribution

x

X = newLoc to create a

distributed location

Elvira Albert, UCM Resource Analysis 21/37

slide-84
SLIDE 84

Adding distribution

x

p q

X = newLoc to create a

distributed location A location has a queue of pending tasks and one active task

Elvira Albert, UCM Resource Analysis 21/37

slide-85
SLIDE 85

Adding distribution

x

p q

y

r p

z

t u

X = newLoc to create a

distributed location A location has a queue of pending tasks and one active task Multiple locations can be created dynamically y=newLoc; z=newLoc

Elvira Albert, UCM Resource Analysis 21/37

slide-86
SLIDE 86

Adding distribution

x

p q

y

r p

z

t u

x

p q m

X = newLoc to create a

distributed location A location has a queue of pending tasks and one active task Multiple locations can be created dynamically y=newLoc; z=newLoc Asynchronous tasks can be added among locations: x.m(w) (in z)

Elvira Albert, UCM Resource Analysis 21/37

slide-87
SLIDE 87

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

Elvira Albert, UCM Resource Analysis 22/37

slide-88
SLIDE 88

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Elvira Albert, UCM Resource Analysis 22/37

slide-89
SLIDE 89

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

Elvira Albert, UCM Resource Analysis 22/37

slide-90
SLIDE 90

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

When we analyze an instruction i, its cost Ci is added to the cost center of the x component: c(x) · Ci

Elvira Albert, UCM Resource Analysis 22/37

slide-91
SLIDE 91

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

When we analyze an instruction i, its cost Ci is added to the cost center of the x component: c(x) · Ci Global cost expression:

c(x)·(Up+Uq+Um)+c(y)·(Ur+Up)+c(z)·(Ut+Uu)

Elvira Albert, UCM Resource Analysis 22/37

slide-92
SLIDE 92

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

When we analyze an instruction i, its cost Ci is added to the cost center of the x component: c(x) · Ci Global cost expression:

c(x)·(Up+Uq+Um)+✭✭✭✭✭

c(y)·(Ur+Up)+✭✭✭✭✭

c(z)·(Ut+Uu)

Elvira Albert, UCM Resource Analysis 22/37

slide-93
SLIDE 93

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

When we analyze an instruction i, its cost Ci is added to the cost center of the x component: c(x) · Ci Global cost expression: ✭✭✭✭✭✭✭ ✭

c(x)·(Up+Uq+Um) + c(y)·(Ur+Up) +✭✭✭✭✭

c(z)·(Ut+Uu)

Elvira Albert, UCM Resource Analysis 22/37

slide-94
SLIDE 94

Resource analysis with cost centers

x

p q m

y

r p

z

t u

Using cost analysis so far:

C = Up + Uq + Um + Ur + Up + · · · + Ut + Uu

We aim at having the cost at the level of distributed components

Cx = Up + Uq + Um Cy = Ur + Up . . .

Idea: use cost centers to separate the cost

c(x), c(y), c(z)

When we analyze an instruction i, its cost Ci is added to the cost center of the x component: c(x) · Ci Global cost expression: ✭✭✭✭✭✭✭ ✭

c(x)·(Up+Uq+Um) +✭✭✭✭✭

c(y)·(Ur+Up) + c(z)·(Ut+Uu)

Elvira Albert, UCM Resource Analysis 22/37

slide-95
SLIDE 95

Cost centers of different types

x

p q m

y

r p

z

t u

Cost centers are a general concept that allows us to distinguish within the UB different aspects:

Elvira Albert, UCM Resource Analysis 23/37

slide-96
SLIDE 96

Cost centers of different types

x

p q m

y

r p

z

t u

Cost centers are a general concept that allows us to distinguish within the UB different aspects: Component cost centers: c(x), c(y)..

Elvira Albert, UCM Resource Analysis 23/37

slide-97
SLIDE 97

Cost centers of different types

x

p q m

y

r p

z

t u

Cost centers are a general concept that allows us to distinguish within the UB different aspects: Component cost centers: c(x), c(y).. Program point cost centers: cost center c(pp) per pp:acquire(e) for (x=0;x<n;x++) pp:acquire(e) c(pp) ∗ n ∗ max(e) +c(pp2) ∗ ...

Elvira Albert, UCM Resource Analysis 23/37

slide-98
SLIDE 98

Cost centers of different types

x

p q m

y

r p

z

t u

Cost centers are a general concept that allows us to distinguish within the UB different aspects: Component cost centers: c(x), c(y).. Program point cost centers: cost center c(pp) per pp:acquire(e) for (x=0;x<n;x++) pp:acquire(e) c(pp) ∗ n ∗ max(e) +c(pp2) ∗ ... Task level centers: cost center c(m) per method c(m) ∗ Cm+c(p) ∗ ...

Elvira Albert, UCM Resource Analysis 23/37

slide-99
SLIDE 99

Cost centers of different types

x

p q m

y

r p

z

t u

Cost centers are a general concept that allows us to distinguish within the UB different aspects: Component cost centers: c(x), c(y).. Program point cost centers: cost center c(pp) per pp:acquire(e) for (x=0;x<n;x++) pp:acquire(e) c(pp) ∗ n ∗ max(e) +c(pp2) ∗ ... Task level centers: cost center c(m) per method c(m) ∗ Cm+c(p) ∗ ... Multi-component cost centers: cost centers of the form c(z, x), i.e., when we find an instruction x.m(w) in z we do c(z, x) ∗ size(w)

Elvira Albert, UCM Resource Analysis 23/37

slide-100
SLIDE 100

Part 3: Distributed Systems

Parallel Cost

Elvira Albert, UCM Resource Analysis 24/37

slide-101
SLIDE 101

Parallel Cost

Serial cost: accumulate costs from different locations Limitation: ignore the parallelism of the distributed execution model. New analysis: infer the parallel cost of distributed systems (maximum cost between parallel tasks) Use: know if an application succeeds in exploiting the parallelism of the distributed locations, overall resource consumption

Elvira Albert, UCM Resource Analysis 25/37

slide-102
SLIDE 102

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

Elvira Albert, UCM Resource Analysis 26/37

slide-103
SLIDE 103

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

Trace

1

  • x

y

m1 m2 m3 p q

P1

Elvira Albert, UCM Resource Analysis 26/37

slide-104
SLIDE 104

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

Trace

1

  • x

y

m1 m2 m3 p q

P1

P1 = Um1 + Um2 + Um3

Elvira Albert, UCM Resource Analysis 26/37

slide-105
SLIDE 105

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

P1 = Um1 + Um2 + Um3 Trace

2

  • x

y

m1 m2 m3 p q

P2

Elvira Albert, UCM Resource Analysis 26/37

slide-106
SLIDE 106

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

P1 = Um1 + Um2 + Um3 Trace

2

  • x

y

m1 m2 m3 p q

P2

P2 = Um1 + Up

Elvira Albert, UCM Resource Analysis 26/37

slide-107
SLIDE 107

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

P1 = Um1 + Um2 + Um3 P2 = Um1 + Up Trace

3

  • x

y

m1 m2 m3 p q

P3

Elvira Albert, UCM Resource Analysis 26/37

slide-108
SLIDE 108

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

P1 = Um1 + Um2 + Um3 P2 = Um1 + Up Trace

3

  • x

y

m1 m2 m3 p q

P3

P3 = Um1 + Um2 + Uq

Elvira Albert, UCM Resource Analysis 26/37

slide-109
SLIDE 109

Parallel Cost

void m ( int n) { . . . // m1 x . p(n) ; . . . // m2 y . q(n) ; . . . // m3 }

P1 = Um1 + Um2 + Um3 P2 = Um1 + Up Trace

3

  • x

y

m1 m2 m3 p q

P3

P3 = Um1 + Um2 + Uq The parallel cost of the program is the maximum of all possible traces: P = max(P1, P2, P3) < Serial

Elvira Albert, UCM Resource Analysis 26/37

slide-110
SLIDE 110

Parallel Cost Analysis

Program Distributed Flow Graph

Elvira Albert, UCM Resource Analysis 27/37

slide-111
SLIDE 111

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q

Elvira Albert, UCM Resource Analysis 27/37

slide-112
SLIDE 112

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 m3

Elvira Albert, UCM Resource Analysis 27/37

slide-113
SLIDE 113

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 m3

N1={m1, m2, m3}

Elvira Albert, UCM Resource Analysis 27/37

slide-114
SLIDE 114

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 p

N1={m1, m2, m3}

Elvira Albert, UCM Resource Analysis 27/37

slide-115
SLIDE 115

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 p

N1={m1, m2, m3} N2={m1, p}

Elvira Albert, UCM Resource Analysis 27/37

slide-116
SLIDE 116

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 q

N1={m1, m2, m3} N2={m1, p}

Elvira Albert, UCM Resource Analysis 27/37

slide-117
SLIDE 117

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 q

N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q}

Elvira Albert, UCM Resource Analysis 27/37

slide-118
SLIDE 118

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q

N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-119
SLIDE 119

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 m3

N1={m1, m2, m3} N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-120
SLIDE 120

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 m3

N1={m1, m2, m3} N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3 Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 +✘✘✘ ✘ c(p)·Up +✘✘✘ ✘ c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-121
SLIDE 121

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 p

N1={m1, m2, m3} N2={m1, p} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3

Elvira Albert, UCM Resource Analysis 27/37

slide-122
SLIDE 122

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 p

N1={m1, m2, m3} N2={m1, p} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3 UBN2=Um1 + Up Serial=c(m1)·Um1 +✘✘✘✘ ✘ c(m2)·Um2 +✘✘✘✘ ✘ c(m3)·Um3 + c(p)·Up +✘✘✘ ✘ c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-123
SLIDE 123

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 q

N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3 UBN2=Um1 + Up

Elvira Albert, UCM Resource Analysis 27/37

slide-124
SLIDE 124

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q m1 m2 q

N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3 UBN2=Um1 + Up UBN3 = Um1 + Um2 + Uq Serial=c(m1)·Um1 + c(m2)·Um2 +✘✘✘✘ ✘ c(m3)·Um3 +✘✘✘ ✘ c(p)·Up + c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-125
SLIDE 125

Parallel Cost Analysis

Program Distributed Flow Graph

m1 m2 m3 p q

N1={m1, m2, m3} N2={m1, p} N3={m1, m2, q} Serial=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq UB|N1=Um1+Um2+Um3 UBN2=Um1 + Up UBN3 = Um1 + Um2 + Uq

The parallel cost of the program is the maximum of all possible UB’s: UBP = max(UBN1, UBN2, UBN3) < Serial

UB=c(m1)·Um1 + c(m2)·Um2 + c(m3)·Um3 + c(p)·Up + c(q)·Uq

Elvira Albert, UCM Resource Analysis 27/37

slide-126
SLIDE 126

Demo SACO

Elvira Albert, UCM Resource Analysis 28/37

slide-127
SLIDE 127

Part 2: Distributed Systems

Peak Cost

Elvira Albert, UCM Resource Analysis 29/37

slide-128
SLIDE 128

Motivation

Non-cumulative resources: are acquired and then released New notion of cost: infer the peak cost vs. the total cost Technical difficulty: not enough to reason on the final state

  • f the execution, the upper bound on the cost can happen at

any intermediate step Key feature: framework can be instantiated to measure any type of non-cumulative resource that is acquired and (optionally) freed.

Elvira Albert, UCM Resource Analysis 30/37

slide-129
SLIDE 129

Handling resources

Two instructions for handling resources:

y = acquire(e) allocates the amount of resources stated by expression e. release y releases resources referenced by y.

resource leaks when

Reusing a resource variable without releasing previous resources. Reaching the end of a method without releasing a resource variable.

Elvira Albert, UCM Resource Analysis 31/37

slide-130
SLIDE 130

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Elvira Albert, UCM Resource Analysis 32/37

slide-131
SLIDE 131

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2

Elvira Albert, UCM Resource Analysis 32/37

slide-132
SLIDE 132

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2 r:k2 x:k1 L3

Elvira Albert, UCM Resource Analysis 32/37

slide-133
SLIDE 133

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4

Elvira Albert, UCM Resource Analysis 32/37

slide-134
SLIDE 134

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5

Elvira Albert, UCM Resource Analysis 32/37

slide-135
SLIDE 135

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6

Elvira Albert, UCM Resource Analysis 32/37

slide-136
SLIDE 136

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

Elvira Albert, UCM Resource Analysis 32/37

slide-137
SLIDE 137

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Total = k1 + k2 + s + n

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

Elvira Albert, UCM Resource Analysis 32/37

slide-138
SLIDE 138

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Total = k1 + k2 + s + n

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

P1 = k1 + k2 + s P1

Elvira Albert, UCM Resource Analysis 32/37

slide-139
SLIDE 139

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Total = k1 + k2 + s + n

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

P1 = k1 + k2 + s P2 = k1 + k2 + n P2

Elvira Albert, UCM Resource Analysis 32/37

slide-140
SLIDE 140

Peak Cost: Motivating Example

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Total = k1 + k2 + s + n

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

P1 = k1 + k2 + s P2 = k1 + k2 + n The peak cost is the maximum between them: Peak = max(P1, P2) < Total

Elvira Albert, UCM Resource Analysis 32/37

slide-141
SLIDE 141

Simultaneous resource analysis

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

Elvira Albert, UCM Resource Analysis 33/37

slide-142
SLIDE 142

Simultaneous resource analysis

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

A1 = {a2, a3, a4}

➠ ➠ ➠

Elvira Albert, UCM Resource Analysis 33/37

slide-143
SLIDE 143

Simultaneous resource analysis

1 main ( int

s , int n) {

2

x = acquire(k1 ) ;

3

r = acquire(k2 ) ;

4

r = acquire( s ) ;

5

release r ;

6

y = acquire(n) ;

7

release x ;

8 }

A1 = {a2, a3, a4}

➠ ➠ ➠

A2 = {a2, a3, a6}

Elvira Albert, UCM Resource Analysis 33/37

slide-144
SLIDE 144

Simultaneous resource analysis

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

A1 A2

A1 = {a2, a3, a4} A2 = {a2, a3, a6}

Elvira Albert, UCM Resource Analysis 33/37

slide-145
SLIDE 145

Simultaneous resource analysis

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

A1 = {a2, a3, a4} A2 = {a2, a3, a6}

Total = c(a2) · k1 + c(a3) · k2 + c(a4) · s + c(a6) · n

Elvira Albert, UCM Resource Analysis 33/37

slide-146
SLIDE 146

Simultaneous resource analysis

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

A1

A1 = {a2, a3, a4} A2 = {a2, a3, a6}

Total = c(a2) · k1 + c(a3) · k2 + c(a4) · s + c(a6) · n Total = c(a2) · k1 + c(a3) · k2 + c(a4) · s +✘✘✘

c(a6) · n

UB|A1 = k1 + k2 + s

Elvira Albert, UCM Resource Analysis 33/37

slide-147
SLIDE 147

Simultaneous resource analysis

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

A2

A1 = {a2, a3, a4} A2 = {a2, a3, a6}

Total = c(a2) · k1 + c(a3) · k2 + c(a4) · s + c(a6) · n Total = c(a2) · k1 + c(a3) · k2 +✘✘✘

c(a4) · s + c(a6) · n

UB|A1 = k1 + k2 + s UB|A2 = k1 + n + k2

Elvira Albert, UCM Resource Analysis 33/37

slide-148
SLIDE 148

Simultaneous resource analysis

x:k1 L2 r:k2 x:k1 L3 r:s r:k2 x:k1 L4 r:k2 x:k1 L5 y:n r:k2 x:k1 L6 y:n r:k2 L7

A1 = {a2, a3, a4} A2 = {a2, a3, a6}

Total = c(a2) · k1 + c(a3) · k2 + c(a4) · s + c(a6) · n Total = c(a2) · k1 + c(a3) · k2 + c(a4) · n + c(a6) · s

UB|A1 = k1 + k2 + s UB|A2 = k1 + n + k2

The UB on the peak cost of the program is the maximum of all UB’s: UBN = max(UBA1, UBA2) < Total

Elvira Albert, UCM Resource Analysis 33/37

slide-149
SLIDE 149

Demo SACO

Elvira Albert, UCM Resource Analysis 34/37

slide-150
SLIDE 150

Summary Distributed Systems

Cost centers based resource analysis APLAS’11 New performance indicators iFM’13 Parallel cost analysis SAS’15 Peak cost analysis TACAS’15

Elvira Albert, UCM Resource Analysis 35/37

slide-151
SLIDE 151

Conclusions

Cost Analysis

research on cost analysis dates back to 1975 generating and solving different forms of recurrence relations

Elvira Albert, UCM Resource Analysis 36/37

slide-152
SLIDE 152

Conclusions

Cost Analysis

research on cost analysis dates back to 1975 generating and solving different forms of recurrence relations

From sequential to concurrent systems

Concurrent interleavings May-happen-in-parallel based analysis Rely-guarantee

Elvira Albert, UCM Resource Analysis 36/37

slide-153
SLIDE 153

Conclusions

Cost Analysis

research on cost analysis dates back to 1975 generating and solving different forms of recurrence relations

From sequential to concurrent systems

Concurrent interleavings May-happen-in-parallel based analysis Rely-guarantee

From concurrent to distributed systems

New performance indicators New notions of cost

Parallel cost Peak cost

Elvira Albert, UCM Resource Analysis 36/37

slide-154
SLIDE 154

Conclusions

Cost Analysis

research on cost analysis dates back to 1975 generating and solving different forms of recurrence relations

From sequential to concurrent systems

Concurrent interleavings May-happen-in-parallel based analysis Rely-guarantee

From concurrent to distributed systems

New performance indicators New notions of cost

Parallel cost Peak cost

Integrated in the SACO system, Static Analyzer for Concurrent Objects

Elvira Albert, UCM Resource Analysis 36/37

slide-155
SLIDE 155

Credits

http://costa.ls.fi.upm.es Elvira Albert Puri Arenas Einar Broch Johnsen Jes´ us Correas Jes´ us Domenech Antonio Flores Samir Genaim Miguel G´

  • mez-Zamalloa

Pablo Gordillo Miguel Isabel Enrique Mart´ ın-Mart´ ın Germ´ an Puebla Guillermo Rom´ an Damiano Zanardini

Elvira Albert, UCM Resource Analysis 37/37