A Reo Semantics for Reasoning about Speculative Execution - - PowerPoint PPT Presentation

a reo semantics for reasoning about speculative execution
SMART_READER_LITE
LIVE PREVIEW

A Reo Semantics for Reasoning about Speculative Execution - - PowerPoint PPT Presentation

A Reo Semantics for Reasoning about Speculative Execution Hans-Dieter A. Hiep Vrije Universiteit Amsterdam Centrum Wiskunde & Informatica November 13th, 2018 Overview 1. Motivation 2. Language 3. Foundation 4. Properties Motivation


slide-1
SLIDE 1

A Reo Semantics for Reasoning about Speculative Execution

Hans-Dieter A. Hiep

Vrije Universiteit Amsterdam Centrum Wiskunde & Informatica

November 13th, 2018

slide-2
SLIDE 2

Overview

  • 1. Motivation
  • 2. Language
  • 3. Foundation
  • 4. Properties
slide-3
SLIDE 3

Motivation

Recent security issues in processors are popularized as:

◮ Meltdown ◮ Spectre ◮ Foreshadow

Are caused by the combination of:

◮ Cache hierarchy ◮ Simultaneous multi-threading ◮ Speculative execution ◮ Irreversibility

Mitigation could reduce performance by 50% (as reported by “cloud” computing providers)

slide-4
SLIDE 4

Motivation: speculative execution

Increase throughput by reducing critical path length int outcome = slowOperation(); if (outcome < 0) doThis(); else doThat(); while slowOperation is executing, we speculate.

slide-5
SLIDE 5

Motivation: speculative execution

Increase throughput by reducing critical path length int outcome = slowOperation(); if (outcome < 0) doThis(); else doThat(); while slowOperation is executing, we speculate.

  • 1. A true speculation correctly predicts outcome:

reduction in critical path length

  • 2. A false speculation incorrectly predicts outcome:

all observable effects have to be reversed

slide-6
SLIDE 6

Motivation: reversible computing

Imagine a physical device: interface cache { void put(int value); int get(); } Is this device reversible?

slide-7
SLIDE 7

Motivation: reversible computing

Imagine a physical device: interface cache { void put(int value); int get(); } Is this device reversible? No! Overwriting: perform put twice

slide-8
SLIDE 8

Motivation

To increase trustworthiness of components, we investigate a logical formalism, in which we can unambiguously state desired safety, privacy and security properties. Ambition: certification by verification.

slide-9
SLIDE 9

Overview

  • 1. Motivation
  • 2. Language
  • 3. Foundation
  • 4. Properties
slide-10
SLIDE 10

Language: Analogy

slide-11
SLIDE 11

Language: Standard Components

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-12
SLIDE 12

Language: Input-only Components

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-13
SLIDE 13

Language: Output-only Components

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-14
SLIDE 14

Language: Interface

Definition

An interface U consists of:

  • 1. input ports I1,...,In
  • 2. ouput ports O1,...,Ok
  • 3. each port has an associated data type
  • O

2 O2 n O

  • Given interface U, by U⊥ we denote its dual.
slide-15
SLIDE 15

Language: Instances and References

  • B

C

  • B

C

slide-16
SLIDE 16

Language: Instances and References

  • B

C

  • B

C x y z

Component instances x,y,z,...

slide-17
SLIDE 17

Language: Instances and References

  • B

C

  • B

C x y z

Component instances x,y,z,... Qualified x.A and unqualified A.

slide-18
SLIDE 18

Language: Composition

  • B

C

  • B

C x y z

Definition

A composition is either:

◮ an instance

slide-19
SLIDE 19

Language: Composition

  • B

C

  • B

C x y z

Definition

A composition is either:

◮ an instance ◮ two compositions adjoined

slide-20
SLIDE 20

Language: Composition

  • B

C

  • B

C x y z

Definition

A composition is either:

◮ an instance ◮ two compositions adjoined ◮ identification of two references of a composition

slide-21
SLIDE 21

Language: Composition

  • B

C

  • B

C x y z B

  • C

Definition

A composition is either:

◮ an instance ◮ two compositions adjoined ◮ identification of two references of a composition

Well-formed if no unqualified references

slide-22
SLIDE 22

Language: Component

  • B

C

  • B

C x y z B

  • C

Definition (to be continued)

A component is either:

◮ primitive

slide-23
SLIDE 23

Language: Component

  • B

C

  • B

C x y z B

  • C

Definition (to be continued)

A component is either:

◮ primitive ◮ composite

slide-24
SLIDE 24

Language: Results

  • 1. Formal graphical language for Reo
  • 2. Implemented prototype in Java
  • 3. Designed normalization procedure and type checker
  • cf. A survey of graphical languages for monoidal categories,

P . Selinger, 2009

  • cf. Sequent calculus: a logic and a language for computation and duality,

P . Downen, 2017

slide-25
SLIDE 25

Overview

  • 1. Motivation
  • 2. Language
  • 3. Foundation
  • 4. Properties
slide-26
SLIDE 26

Foundation: Data domains

Data types α, β, ...

◮ contain special ‘null’ value ∗

Examples

Signals: Signal = {∗,0} Naturals: Nat = {∗,0,1,2,...}

slide-27
SLIDE 27

Foundation: Stream domains

Data streams (N → α), (N → β), ...

◮ functions from naturals to data types

Examples

σ : N → Signal is a data stream over signals head σ(0) is ∗ or 0 tail σ′ is stream derivative

  • cf. On Streams and Coinduction, J.J.M.M. Rutten, 2002
slide-28
SLIDE 28

Foundation: Multi-sorted logic

Sorts:

◮ each data type is a distinct sort ◮ each data stream is a distinct sort ◮ there is a sort for naturals, N

Non-logical symbols:

◮ ∗α null constant ◮ dα data constant ◮ ⊥ proposition ◮ = equality predicate ◮ 0,1,2,... and +,−,×,≤ for naturals ◮ atα with arity (N → α),N,α ◮ skipα with arity (N → α),N,(N → α)

slide-29
SLIDE 29

Foundation: Multi-sorted logic

Terms: standard

◮ variables xs ◮ constants ◮ function symbols

Formulas: standard

◮ propositions ◮ predicates of terms ◮ standard logical symbols ¬, ∧, ∨, →, ↔ ◮ first-order quantification ∃xs, ∀xs binders for xs

Treat sorts implicitly. Write at(X,t) as X(t), called applications. Write skip(X,t) as X (t), called derivations.

slide-30
SLIDE 30

Foundation: Coordination Protocols

Definition

A coordination protocol is a first-order formula such that all free variables X s are of a data stream sort s = (N → α)

slide-31
SLIDE 31

Foundation: Components

Definition

A component φ(U) is a coordination protocol φ and interface U.

◮ Primitive components given as φ(U),

where free variables of φ are ports of U.

◮ Composite components by induction:

◮ Adjoined components φ(U) and ψ(V):

take φ ∧ψ

◮ Identification of references X and Y on φ(U):

take ∃X.∃Y.(φ ∧∀t.(X(t) = Y(t)))

slide-32
SLIDE 32

Foundation: Coordination Protocols

Coordination protocols induce a set of infinite tables

(cf. Rule-Based Form for Stream Constraints, K. Dokter, 2018)

◮ Columns: ports ◮ Rows: simultaneous “observations”

X1 X2 ... Xn ∗ d ... ∗ ∗ ∗ ... e . . . . . . . . . Table: “execution” Set of tables: “computation”

slide-33
SLIDE 33

Foundation: Coordination Protocols

Examples

Let X be a port of data type Signal. Consider φ = ∀t.(X(t) = ∗∨X(t) = 0) Solution: assignment of X to a data stream L (φ) = X ∗ ∗ . . . , X ∗ . . . , X ∗ . . . , X . . . , ...

slide-34
SLIDE 34

Foundation: Coordination Protocols

Fact: coordination protocols only ‘interact’ for shared variables

Examples (No interaction)

Consider φ = ∀t.(X(t) = ∗) and ψ = ∀t.(Y(t) = 0)∨∀t.(Y(t) = ∗) L (φ) = X ∗ ∗ . . .

  • and L (ψ) =

Y . . . , Y ∗ ∗ . . .

  • L (φ ∧ψ) =

X Y ∗ ∗ . . . . . . , X Y ∗ ∗ ∗ ∗ . . . . . .

slide-35
SLIDE 35

Foundation: Coordination Protocols

Fact: coordination protocols only ‘interact’ for shared variables

Examples (Interaction)

Consider φ = ∀t.(X(t) = ∗)∨∀t.(X(t) = 0) and ψ = ∃t.(X(t) = 0) L (φ) = X ∗ ∗ . . . , X . . .

  • and L (ψ) =

X ∗ . . . , X ∗ . . . , ... L (φ ∧ψ) = X . . .

slide-36
SLIDE 36

Foundation: Primitives

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-37
SLIDE 37

Foundation: Frame Conditions

Insight: modeling of buffers using frame conditions.

X M Z ∗ X M Z X M Z ∗ d d ∗ ∗ d d ∗ ∗ d d

These are overlapping as follows:

X Z

  • d
  • d
  • d
  • d

d

slide-38
SLIDE 38

Foundation: Frame Conditions

Definition of buffer

X M Z ∗ X M Z X M Z ∗ d d ∗ ∗ d d ∗ ∗ d d

∀t.(( Z(t) = ∗ ∧M(t) = ∗∧M(t +1) = X(t)) ∨ (X(t) = ∗∧Z(t) = ∗ ∧M(t) = ∗∧M(t +1) = M(t)) ∨ (X(t) = ∗∧Z(t) = M(t)∧M(t) = ∗∧M(t +1) = ∗))

slide-39
SLIDE 39

Foundation: Frame Conditions

Definition of buffer

X M Z ∗ X M Z X M Z ∗ d d ∗ ∗ d d ∗ ∗ d d

∀t.(( Z(t) = ∗ ∧M(t) = ∗∧M(t +1) = X(t)) ∨ (X(t) = ∗∧Z(t) = ∗ ∧M(t) = ∗∧M(t +1) = M(t)) ∨ (X(t) = ∗∧Z(t) = M(t)∧M(t) = ∗∧M(t +1) = ∗)) Problem: column M is not a port of buffer. Can we get rid of it?

slide-40
SLIDE 40

Foundation: Frame Conditions

Alternative definition of buffer

X Z ∗ X Z ∗ ∗ ∗ d d ∗ ∗

∀t.( Z(t) = ∗∧X(t) = ∗ ∨ (Z(t) = ∗∧∃j.t < j ∧X(j) = ∗∧Z(j) = X(t) ∧ ∀i.t < i ∧i < j → X(i) = ∗∧Z(i) = ∗) ∨ (X(t) = ∗∧∃j.j < t ∧X(j) = Z(t)∧Z(j) = ∗ ∧ ∀i.j < i ∧i < t → X(i) = ∗∧Z(i) = ∗))

slide-41
SLIDE 41

Foundation: Frame Conditions

Alternative definition of buffer

X Z ∗ X Z ∗ ∗ ∗ d d ∗ ∗

∀t.( Z(t) = ∗∧X(t) = ∗ ∨ (Z(t) = ∗∧∃j.t < j ∧X(j) = ∗∧Z(j) = X(t) ∧ ∀i.t < i ∧i < j → X(i) = ∗∧Z(i) = ∗) ∨ (X(t) = ∗∧∃j.j < t ∧X(j) = Z(t)∧Z(j) = ∗ ∧ ∀i.j < i ∧i < t → X(i) = ∗∧Z(i) = ∗)) Question: are these definitions equivalent?

slide-42
SLIDE 42

Foundation: Frame Conditions

Alternative definition of buffer

X Z ∗ X Z ∗ ∗ ∗ d d ∗ ∗

∀t.( Z(t) = ∗∧X(t) = ∗ ∨ (Z(t) = ∗∧∃j.t < j ∧X(j) = ∗∧Z(j) = X(t) ∧ ∀i.t < i ∧i < j → X(i) = ∗∧Z(i) = ∗) ∨ (X(t) = ∗∧∃j.j < t ∧X(j) = Z(t)∧Z(j) = ∗ ∧ ∀i.j < i ∧i < t → X(i) = ∗∧Z(i) = ∗)) Question: are these definitions equivalent? No.

slide-43
SLIDE 43

Foundation: Duals

Definition

A dual of a component Uφ is U⊥φ.

  • B
  • B
  • B
  • B
slide-44
SLIDE 44

Foundation: Results

  • 1. Found logical formalism

with data types and data streams

  • 2. Defined primitive components
  • 3. Two different kinds of nodes (Reo only has below)

O O2

  • 2

n O

  • 4. Prophet is dual of buffer
slide-45
SLIDE 45

Overview

  • 1. Motivation
  • 2. Language
  • 3. Foundation
  • 4. Properties
slide-46
SLIDE 46

Properties

◮ Time independence

(stuttering)

◮ Linearity

(reversibility)

◮ Causality

(speculative execution)

◮ Instantaneous

(stateless)

◮ Synchronous and asynchronous

(clocked and unclocked)

◮ Termination and progress

(safety and liveness)

slide-47
SLIDE 47

Properties (here)

◮ Time independence

(stuttering)

◮ Linearity

(reversibility)

◮ Causality

(speculative execution)

◮ Instantaneous

(stateless)

◮ Synchronous and asynchronous

(clocked and unclocked)

◮ Termination and progress

(safety and liveness)

slide-48
SLIDE 48

Properties: Sentences

Given a coordination protocol φ. A schematic property P(φ) is a sentence after substituting a coordination protocol φ. Validity of P(φ): P(φ) Classes of components: {φ | P(φ)}

slide-49
SLIDE 49

Properties: Time Independence

Time independence is a closure condition: L (φ) = X ∗ ∗ . . . , ..., X ∗ . . . , ...

◮ May remove rows with all ∗ ◮ May insert row with all ∗

  • 1. No real-time clocks
  • 2. Independence is not compositional
slide-50
SLIDE 50

Properties: Time Independence

Let φ(U) be a component. stretch(φ) := ∀ X : U.(φ( X) → ∀t.∃ Y : U.(φ( Y)∧ all-silent( Y,t)∧precong( X, Y,t)∧cong( X (t), Y (t+1)))) shrink(φ) := ∀ X : U.(φ( X) → ∀t.∃ Y : U.(φ( Y)∧ (all-silent( X,t) → precong( X, Y,t)∧cong( X (t+1), Y (t))))) Time independence is stretch(φ)∧shrink(φ).

slide-51
SLIDE 51

Properties: Time Independence

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-52
SLIDE 52

Properties: Linearity

Event: (time, port, value) Bijection between input events and output events of same value X Y ∗ d d ∗ e e f ∗ ∗ f . . . . . . Intuition: no duplication, no garbage, no arbitrary

slide-53
SLIDE 53

Properties: Linearity

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-54
SLIDE 54

Properties: Causality

Event: (time, port, value) Relation between input events and output events of same value Such that every output is not related to future input X Y ∗ ∗ d d ∗ d f d ∗ f . . . . . . Intuition: explain output only by seen observations

slide-55
SLIDE 55

Properties: Causality

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-56
SLIDE 56

Properties: Termination and Progress

Productivity (execution): prod( X : P) := ∃t.

  • i∈P

Xi(t) = ∗ Terminating (execution): term( X : P) := ∃t.(¬prod( X (t))) Terminating (computation): term(φ) := ∀ X : P.(φ( X) → term( X)) Deadlock: deadlock(φ, X : P) := φ( X)∧term( X)∧¬term(φ) a terminating execution in a non-terminating computation

slide-57
SLIDE 57

Properties: Termination and Progress

  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B
  • B

C

  • B

C

  • B

C

  • B

C

slide-58
SLIDE 58

Reasoning about Speculative Execution

  • 1. We have prophets that intuitively models speculations,
  • 2. If a prophet generates a true speculation,

then troughput is increased (critical path length reduced).

  • 3. If a prophet generates a false speculation

then the system may come to a standstill,

  • 4. Enforcing productivity with a pull,

such deadlock behavior is ruled out: therefore, only true speculations are specified.

slide-59
SLIDE 59

Reasoning about Speculative Execution

  • 1. The present model abstracts low-level details

(message passing, shared memory, locks, etc.)

  • 2. Interesting properties formulated unambiguously
  • 3. Specifications seem implementable in numerous ways:

◮ Sequentially, using backtracking ◮ Cooperatively, by scheduling components ◮ Parallel, one processor for each component ◮ Distributed, components reach consensus on observations ◮ etc.

  • 4. A correct implementation preserves all properties of model