Optimal Shuffle Code with Permutation Instructions Sebastian - - PowerPoint PPT Presentation

optimal shuffle code with permutation instructions
SMART_READER_LITE
LIVE PREVIEW

Optimal Shuffle Code with Permutation Instructions Sebastian - - PowerPoint PPT Presentation

Optimal Shuffle Code with Permutation Instructions Sebastian Buchwald, Manuel Mohr, Ignaz Rutter Chair for Programming Paradigms & Chair for Algorithmics, Karlsruhe Institute of Technology (KIT) 1 August 5, 2015 Sebastian Buchwald, Manuel


slide-1
SLIDE 1

1

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Chair for Programming Paradigms & Chair for Algorithmics, Karlsruhe Institute of Technology (KIT)

Optimal Shuffle Code with Permutation Instructions

Sebastian Buchwald, Manuel Mohr, Ignaz Rutter

KIT – University of the State of Baden-Wuerttemberg and National Research Center of the Helmholtz Association

www.kit.edu

slide-2
SLIDE 2

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d

slide-3
SLIDE 3

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d

slide-4
SLIDE 4

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d

slide-5
SLIDE 5

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d

slide-6
SLIDE 6

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d Register Transfer Graph (RTG) 1 2 3 4 5 copy r1, r2 swap r3, r4

slide-7
SLIDE 7

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d Register Transfer Graph (RTG) 1 2 3 4 5 copy r1, r2 swap r3, r4

slide-8
SLIDE 8

Register Allocation and Shuffle Code

2

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

a = 10; b = 20; c = 30; d = 40; . . . p r i n t (a , a , c , b , d ) ; a b b c d r1 r2 r3 r4 r5 r1 r2 r3 r4 r5 a a c b d Register Transfer Graph (RTG) 1 2 3 4 5 copy r1, r2 swap r3, r4

Shuffle Code Generation Problem

Find a shortest shuffle code that implements a given RTG.

slide-9
SLIDE 9

Permutation Instructions

3

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

For large RTGs, implementations can get lengthy ⇒ Proposed more powerful permutation instructions [Mohr et al. 2013]

slide-10
SLIDE 10

Permutation Instructions

3

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

For large RTGs, implementations can get lengthy ⇒ Proposed more powerful permutation instructions [Mohr et al. 2013] 1 2 3 4 5 permi5 r1, r2, r3, r4, r5 1 2 permi5 r1, r2

slide-11
SLIDE 11

Permutation Instructions

3

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

For large RTGs, implementations can get lengthy ⇒ Proposed more powerful permutation instructions [Mohr et al. 2013] 1 2 3 4 5 permi5 r1, r2, r3, r4, r5 1 2 permi5 r1, r2 1 2 3 4 5 permi23 r1, r2, r3, r4, r5 1 2 3 4 permi23 r1, r2, r3, r4

slide-12
SLIDE 12

Permutation Instructions

3

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

For large RTGs, implementations can get lengthy ⇒ Proposed more powerful permutation instructions [Mohr et al. 2013] 1 2 3 4 5 permi5 r1, r2, r3, r4, r5 1 2 permi5 r1, r2 1 2 3 4 5 permi23 r1, r2, r3, r4, r5 1 2 3 4 permi23 r1, r2, r3, r4 Exists as FPGA-based prototype processor with modified compiler [Mohr et al. 2013]

Improves performance in practice Uses greedy heuristic

slide-13
SLIDE 13

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy.

slide-14
SLIDE 14

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy. 1 2 3 4 5 6 Naive implementation: copy r1, r2 copy r1, r3 permi5 r4, r5, r6

slide-15
SLIDE 15

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy. 1 2 3 4 5 6

slide-16
SLIDE 16

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy. 1 2 3 4 5 6 Optimal implementation: permi23 r1, r2, r4, r5, r6 copy r2, r3

slide-17
SLIDE 17

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy. 1 2 3 4 5 6

slide-18
SLIDE 18

Shuffle Code with Permutation Instructions

4

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

SCGP with permutation instructions

Given RTG, find a shortest shuffle code using permi5, permi23 and copy. 1 2 3 4 5 6 Optimal implementation: copy r1, r2 copy r1, r3 permi5 r4, r5, r6

slide-19
SLIDE 19

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [(1 2) ◦ (2 3)]• 1 2 3

?

− → = 1 2 3

slide-20
SLIDE 20

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [(1 2) ◦ (2 3)]• 1 2 3

?

− → = 1 2 3

slide-21
SLIDE 21

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [(1 2) ◦ (2 3)]• 1 2 3

?

− → = 1 2 3

slide-22
SLIDE 22

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [(1 2) ]• 1 2 3

?

− → = 1 2 3

slide-23
SLIDE 23

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [ ]• 1 2 3

?

− → = 1 2 3

slide-24
SLIDE 24

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [ ]• 1 2 3

?

− → = 1 2 3 Defines group action of permutations on RTGs For permutation RTGs (PRTGs): make given PRTG trivial

slide-25
SLIDE 25

Shuffle Code Generation as a Graph Problem

5

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Effect of a permutation: π

  • (V, E)

(V, {(π(u), v) | (u, v) ∈ E}) = [ ]• 1 2 3

?

− → = 1 2 3 Defines group action of permutations on RTGs For permutation RTGs (PRTGs): make given PRTG trivial Effect of a copy: [1 → 2]◦ 1 2 3 = 1 2 3

  • r

1 2 3

?

Copies not expressible in RTGs

slide-26
SLIDE 26

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π

slide-27
SLIDE 27

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Copy a → b followed by transposition τ = (c d) rewrite to Transposition (c d) followed by copy τ(a) → τ(b)

slide-28
SLIDE 28

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Copy a → b followed by transposition τ = (c d) rewrite to Transposition (c d) followed by copy τ(a) → τ(b)

slide-29
SLIDE 29

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Copy a → b followed by transposition τ = (c d) rewrite to Transposition (c d) followed by copy τ(a) → τ(b)

slide-30
SLIDE 30

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Copy a → b followed by transposition τ = (c d) rewrite to Transposition (c d) followed by copy τ(a) → τ(b)

slide-31
SLIDE 31

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Copy a → b followed by transposition τ = (c d) rewrite to Transposition (c d) followed by copy τ(a) → τ(b)

slide-32
SLIDE 32

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge

slide-33
SLIDE 33

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge

slide-34
SLIDE 34

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge All outgoing edges

  • f u in πG are copies
slide-35
SLIDE 35

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge All outgoing edges (except one) of u in πG are copies

slide-36
SLIDE 36

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge All outgoing edges (except one) of u in πG are copies π permutes edge sources in G

slide-37
SLIDE 37

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge All outgoing edges (except one) of u in πG are copies π permutes edge sources in G ⇒ All outgoing edges (except one) of u in G correspond to copies

slide-38
SLIDE 38

Observations on Shuffle Code

6

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Normalized π Can transform shuffle code such that in πG, for every copy u → v: u v . . . . . . no outgoing edge All outgoing edges (except one) of u in πG are copies π permutes edge sources in G ⇒ All outgoing edges (except one) of u in G correspond to copies → copy set

slide-39
SLIDE 39

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6

slide-40
SLIDE 40

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.)

slide-41
SLIDE 41

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.)

slide-42
SLIDE 42

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.) Step 2: Find an optimal shuffle code for the red RTG G − C. (Has maximum out-degree 1.)

slide-43
SLIDE 43

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.) Step 2: Find an optimal shuffle code for the red RTG G − C. (Has maximum out-degree 1.)

slide-44
SLIDE 44

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.) Step 2: Find an optimal shuffle code for the red RTG G − C. (Has maximum out-degree 1.) Step 3: Implement blue edges using copy operations.

slide-45
SLIDE 45

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Choice of copy set is crucial: 1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.) Step 2: Find an optimal shuffle code for the red RTG G − C. (Has maximum out-degree 1.) Step 3: Implement blue edges using copy operations.

slide-46
SLIDE 46

Strategy & Outline

7

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Choice of copy set is crucial: 1 2 3 4 5 6 Step 1: Pick a copy set C. (For each vertex, color one outgoing edge red, rest blue.) Step 2: Find an optimal shuffle code for the red RTG G − C. (Has maximum out-degree 1.) Step 3: Implement blue edges using copy operations. Problem 1: Given copy set C, compute optimal shuffle code for G − C. Problem 2: Find copy set C where G − C requires fewest instructions.

slide-47
SLIDE 47

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle 1 2 3 4 5 6 7 8 9

slide-48
SLIDE 48

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle 1 2 3 4 5 6 7 8 9

slide-49
SLIDE 49

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

1 2 3 4 permi5

slide-50
SLIDE 50

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

1 2 3 4 5 6 7 permi5

slide-51
SLIDE 51

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

slide-52
SLIDE 52

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23

1 2 3 4 5 permi23

slide-53
SLIDE 53

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23

1 2 3 4 5 6 7 8 permi23 permi23

slide-54
SLIDE 54

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23 Only 3-cycles available: resolve groups of three using permi23

1 2 3 4 5 6 7 8 9 permi23 permi23

slide-55
SLIDE 55

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23 Only 3-cycles available: resolve groups of three using permi23

slide-56
SLIDE 56

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23 Only 3-cycles available: resolve groups of three using permi23

Signature sig(G) = (X, a2, a3) X = Σσ∈G⌊size(σ)/4⌋ ai = |{σ ∈ G | size(σ) = i mod 4}|

slide-57
SLIDE 57

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23 Only 3-cycles available: resolve groups of three using permi23

Signature sig(G) = (X, a2, a3) X = Σσ∈G⌊size(σ)/4⌋ ai = |{σ ∈ G | size(σ) = i mod 4}| Cost function GREEDY(G) = X +

  • ⌈(a2 + a3)/2⌉

if a2 ≥ a3 ⌈(a2 + 2a3)/3⌉ if a2 < a3

slide-58
SLIDE 58

The GREEDY Algorithm (adapted from [Mohr et al. 2013])

8

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Complete each directed path into directed cycle Phase 1

While there is a cycle K of size 4 or more: use permi5 to reduce K’s size

Phase 2: Only cycles of size ≤ 3 left

2-cycle and 3-cycle available: resolve using permi23 Only 2-cycles available: resolve pairs using permi23 Only 3-cycles available: resolve groups of three using permi23

Signature sig(G) = (X, a2, a3) X = Σσ∈G⌊size(σ)/4⌋ ai = |{σ ∈ G | size(σ) = i mod 4}| Cost function GREEDY(G) = X +

  • ⌈(a2 + a3)/2⌉

if a2 ≥ a3 ⌈(a2 + 2a3)/3⌉ if a2 < a3

Theorem

GREEDY is optimal for PRTGs.

slide-59
SLIDE 59

Proof Outline

9

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

G Trivial RTG πG GREEDY(G) 1 ( π ) GREEDY(πG)

slide-60
SLIDE 60

Proof Outline

9

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

G Trivial RTG πG GREEDY(G) 1 ( π ) GREEDY(πG)

slide-61
SLIDE 61

Proof Outline

9

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

G Trivial RTG πG GREEDY(G) 1 ( π ) GREEDY(πG) Take arbitrary permutation instruction π

slide-62
SLIDE 62

Proof Outline

9

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

G Trivial RTG πG GREEDY(G) 1 ( π ) GREEDY(πG) Take arbitrary permutation instruction π Show that always GREEDY(G) ≤ GREEDY(πG) + 1 ⇔ GREEDY(G) − GREEDY(πG) ≤ 1

slide-63
SLIDE 63

Transpositions

10

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 merge split

slide-64
SLIDE 64

Transpositions

10

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 merge split

slide-65
SLIDE 65

Transpositions

10

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 merge split

slide-66
SLIDE 66

Transpositions

10

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8 merge split

slide-67
SLIDE 67

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Look at all possible signature changes (∆X, ∆2, ∆3)

slide-68
SLIDE 68

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3)

slide-69
SLIDE 69

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) →

slide-70
SLIDE 70

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) →

slide-71
SLIDE 71

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) Cost change only depends on signature change

slide-72
SLIDE 72

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) Cost change only depends on signature change 1 2 3 1

1⁄2 1⁄2

2 3

1⁄2

a2 ≥ a3 1 2 3 1

1⁄3 1⁄3 1⁄3

2

1⁄3

3 a2 < a3

slide-73
SLIDE 73

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) Cost change only depends on signature change 1 2 3 1

1⁄2 1⁄2

2 3

1⁄2

a2 ≥ a3 1 2 3 1

1⁄3 1⁄3 1⁄3

2

1⁄3

3 a2 < a3

slide-74
SLIDE 74

Merges

11

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Cycle sizes modulo 4

1 2 3 (0, 0, 0) (0, 0, 0) (0, 0, 0) (0, 0, 0) 1 (0, 1, 0) (0, −1, 1) (1, 0, −1) 2 (1, −2, 0) (1, −1, −1) 3 (1, 1, −2) Look at all possible signature changes (∆X, ∆2, ∆3) Cost change only depends on signature change 1 2 3 1

1⁄2 1⁄2

2 3

1⁄2

a2 ≥ a3 1 2 3 1

1⁄3 1⁄3 1⁄3

2

1⁄3

3 a2 < a3 ⇒ Merges are never worthwhile!

slide-75
SLIDE 75

Splits

12

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 1

1⁄2 1⁄2

2 3

1⁄2

a2 ≥ a3 1 2 3 1

1⁄3 1⁄3 1⁄3

2

1⁄3

3 a2 < a3

slide-76
SLIDE 76

Splits

12

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 1 − − −1⁄2 − − −1⁄2 2 3 − − −1⁄2 a2 ≥ a3 1 2 3 1 − − −1⁄3 − − −1⁄3 − − −1⁄3 2 − − −1⁄3 3 a2 < a3

slide-77
SLIDE 77

Splits

12

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 1 − − −1⁄2 − − −1⁄2 2 3 − − −1⁄2 a2 ≥ a3 1 2 3 1 − − −1⁄3 − − −1⁄3 − − −1⁄3 2 − − −1⁄3 3 a2 < a3 permi5 can implement 4 transpositions ⇒ −1⁄2 · 4 = −2?

slide-78
SLIDE 78

Splits

12

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 1 − − −1⁄2 − − −1⁄2 2 3 − − −1⁄2 a2 ≥ a3 1 2 3 1 − − −1⁄3 − − −1⁄3 − − −1⁄3 2 − − −1⁄3 3 a2 < a3 permi5 can implement 4 transpositions ⇒ −1⁄2 · 4 = −2? However: because of structure of instructions, not every transposition can reduce costs

slide-79
SLIDE 79

Splits

12

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

1 2 3 1 − − −1⁄2 − − −1⁄2 2 3 − − −1⁄2 a2 ≥ a3 1 2 3 1 − − −1⁄3 − − −1⁄3 − − −1⁄3 2 − − −1⁄3 3 a2 < a3 permi5 can implement 4 transpositions ⇒ −1⁄2 · 4 = −2? However: because of structure of instructions, not every transposition can reduce costs

GREEDY is optimal for PRTGs

GREEDY computes an optimal shuffle code for PRTGs in linear time.

slide-80
SLIDE 80

Finding optimal copy sets

13

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Given G, have to find copy set C, s.t. GREEDY(G − C) is minimal

slide-81
SLIDE 81

Finding optimal copy sets

13

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Given G, have to find copy set C, s.t. GREEDY(G − C) is minimal Equivalent to minimizing GREEDY′(G − C) =

  • X + a2

2 + a3 2

if a2 ≥ a3 X + a2

3 + 2a3 3

if a2 < a3 Distinguish cases with diff(G − C) = a2 − a3

slide-82
SLIDE 82

Finding optimal copy sets

13

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Given G, have to find copy set C, s.t. GREEDY(G − C) is minimal Equivalent to minimizing GREEDY′(G − C) =

  • X + a2

2 + a3 2 =: cost1(G − C)

if a2 ≥ a3 X + a2

3 + 2a3 3 =: cost2(G − C)

if a2 < a3 Distinguish cases with diff(G − C) = a2 − a3

slide-83
SLIDE 83

Finding optimal copy sets

13

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Given G, have to find copy set C, s.t. GREEDY(G − C) is minimal Equivalent to minimizing GREEDY′(G − C) =

  • X + a2

2 + a3 2 =: cost1(G − C)

if a2 ≥ a3 X + a2

3 + 2a3 3 =: cost2(G − C)

if a2 < a3 Distinguish cases with diff(G − C) = a2 − a3 Dynamic program with tables T 1[·], T 2[·] T i[d] = min{costi(G − C) | C copyset with diff(G − C) = d}

slide-84
SLIDE 84

Finding optimal copy sets

13

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Given G, have to find copy set C, s.t. GREEDY(G − C) is minimal Equivalent to minimizing GREEDY′(G − C) =

  • X + a2

2 + a3 2 =: cost1(G − C)

if a2 ≥ a3 X + a2

3 + 2a3 3 =: cost2(G − C)

if a2 < a3 Distinguish cases with diff(G − C) = a2 − a3 Dynamic program with tables T 1[·], T 2[·] T i[d] = min{costi(G − C) | C copyset with diff(G − C) = d} T 1[·] T 2[·] −n n

slide-85
SLIDE 85

Computing Tables for Different RTG Shapes

14

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Disconnected RTGs O(n2)

slide-86
SLIDE 86

Computing Tables for Different RTG Shapes

14

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Disconnected RTGs O(n2) Tree RTGs O(n3)

slide-87
SLIDE 87

Computing Tables for Different RTG Shapes

14

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x x Disconnected RTGs O(n2) Tree RTGs O(n3) Connected RTGs containing cycle O(n4)

slide-88
SLIDE 88

Conclusion

15

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Problem 1: Given copy set C, compute optimal shuffle code for G − C. Shown that GREEDY is optimal for PRTGs, runs in O(n) time Equivalent to factoring permutation into shortest product of permutations of maximum size 5

slide-89
SLIDE 89

Conclusion

15

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Problem 1: Given copy set C, compute optimal shuffle code for G − C. Shown that GREEDY is optimal for PRTGs, runs in O(n) time Equivalent to factoring permutation into shortest product of permutations of maximum size 5 Problem 2: Find copy set C s.t. G − C requires fewest instructions. Used dynamic programming to solve optimally Runs in O(n4) time

slide-90
SLIDE 90

Conclusion

15

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Problem 1: Given copy set C, compute optimal shuffle code for G − C. Shown that GREEDY is optimal for PRTGs, runs in O(n) time Equivalent to factoring permutation into shortest product of permutations of maximum size 5 Problem 2: Find copy set C s.t. G − C requires fewest instructions. Used dynamic programming to solve optimally Runs in O(n4) time Future work: Works for k = 3, 4, 5, 6, what about larger sizes? Problem NP-complete if permutation size is part of input ⇒ FPT-algorithm?

slide-91
SLIDE 91

16

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Backup Slides

slide-92
SLIDE 92

Speedup Measurements

17

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

5 10 15 20

1 6 4 . g z i p 1 7 5 . v p r 1 7 6 . g c c 1 8 1 . m c f 1 8 6 . c r a f t y 1 9 7 . p a r s e r 2 5 3 . p e r l b m k 2 5 4 . g a p 2 5 5 . v

  • r

t e x 2 5 6 . b z i p 2 3 . t w

  • l

f

Reduction of # executed instructions [%]

Copy Coalescing ILP Recoloring Biased Naive

slide-93
SLIDE 93

Disconnected RTGs

18

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x H1 x x x x x x x x x H2

slide-94
SLIDE 94

Disconnected RTGs

18

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x H1 x x x x x x x x x H2

slide-95
SLIDE 95

Disconnected RTGs

18

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x H1 x x x x x x x x x H2 C := C1 ∪ C2 cost(G − C) = cost(H1 − C1) + cost(H2 − C2) diff(G − C) = diff(H1 − C1) + diff(H2 − C2)

slide-96
SLIDE 96

Disconnected RTGs

18

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x H1 x x x x x x x x x H2 C := C1 ∪ C2 cost(G − C) = cost(H1 − C1) + cost(H2 − C2) diff(G − C) = diff(H1 − C1) + diff(H2 − C2) ⇒ Can find optimal copy set C by trying all pairs C1, C2 ⇒ Can be computed in O(n2) time

slide-97
SLIDE 97

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion

slide-98
SLIDE 98

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion

slide-99
SLIDE 99

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion

slide-100
SLIDE 100

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion

slide-101
SLIDE 101

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion Extend table to track length of path starting at root

slide-102
SLIDE 102

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion Extend table to track length of path (modulo 4) starting at root

slide-103
SLIDE 103

Tree RTGs

19

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion Extend table to track length of path (modulo 4) starting at root ⇒ Can find optimal copy set C by trying all outgoing edges of root ⇒ Can be computed in time O(n3)

slide-104
SLIDE 104

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x

slide-105
SLIDE 105

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set

slide-106
SLIDE 106

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set

slide-107
SLIDE 107

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set

slide-108
SLIDE 108

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set Or cut K, G − C is a tree

slide-109
SLIDE 109

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set Or cut K, G − C is a tree

slide-110
SLIDE 110

Connected RTGs

20

August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

x x x x x x x x x x x x x x x x x Either keep cycle K and put edges leaving K into copy set Or cut K, G − C is a tree ⇒ Can find optimal copy set C by trying all of K’s edges (or keeping K) ⇒ Can be computed in time O(n4)