optimal shuffle code with permutation instructions
play

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


  1. Observations on Shuffle Code Normalized π Copy a → b followed by transposition τ = ( c d ) rewrite to Transposition ( c d ) followed by copy τ ( a ) → τ ( b ) 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  2. Observations on Shuffle Code Normalized π Copy a → b followed by transposition τ = ( c d ) rewrite to Transposition ( c d ) followed by copy τ ( a ) → τ ( b ) 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  3. Observations on Shuffle Code Normalized π Copy a → b followed by transposition τ = ( c d ) rewrite to Transposition ( c d ) followed by copy τ ( a ) → τ ( b ) 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  4. Observations on Shuffle Code Normalized π Copy a → b followed by transposition τ = ( c d ) rewrite to Transposition ( c d ) followed by copy τ ( a ) → τ ( b ) 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  5. Observations on Shuffle Code Normalized π Can transform shuffle code such that in π G , for every copy u → v : u v . . . no outgoing edge . . . 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  6. Observations on Shuffle Code Normalized π Can transform shuffle code such that in π G , for every copy u → v : u v . . . no outgoing edge . . . 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  7. Observations on Shuffle Code Normalized π Can transform shuffle code such that in π G , for every copy u → v : u v . . . no outgoing edge . . . All outgoing edges of u in π G are copies 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  8. Observations on Shuffle Code 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 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  9. Observations on Shuffle Code 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 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  10. Observations on Shuffle Code 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 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  11. Observations on Shuffle Code 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 6 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  12. Strategy & Outline 3 5 6 1 2 4 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  13. Strategy & Outline 3 5 6 1 2 4 Step 1: Pick a copy set C . (For each vertex, color one outgoing edge red, rest blue.) 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  14. Strategy & Outline 3 5 6 1 2 4 Step 1: Pick a copy set C . (For each vertex, color one outgoing edge red, rest blue.) 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  15. Strategy & Outline 3 5 6 1 2 4 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.) 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  16. Strategy & Outline 3 5 6 1 2 4 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.) 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  17. Strategy & Outline 3 5 6 1 2 4 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. 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  18. Strategy & Outline Choice of copy set is crucial: 3 5 6 1 2 4 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. 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  19. Strategy & Outline Choice of copy set is crucial: 3 5 6 1 2 4 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. 7 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  20. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) Complete each directed path into directed cycle 3 5 6 7 8 9 1 2 4 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  21. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) Complete each directed path into directed cycle 3 5 6 7 8 9 1 2 4 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  22. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 3 1 2 4 permi5 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  23. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 3 5 6 7 1 2 4 permi5 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  24. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  25. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 3 5 1 2 4 permi23 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  26. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 3 5 6 7 8 1 2 4 permi23 permi23 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  27. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 3 5 6 7 8 9 1 2 4 permi23 permi23 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  28. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  29. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 , a 2 , a 3 ) X = Σ σ ∈ G ⌊ size ( σ ) / 4 ⌋ a i = |{ σ ∈ G | size ( σ ) = i mod 4 }| 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  30. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 , a 2 , a 3 ) X = Σ σ ∈ G ⌊ size ( σ ) / 4 ⌋ a i = |{ σ ∈ G | size ( σ ) = i mod 4 }| � ⌈ ( a 2 + a 3 ) / 2 ⌉ if a 2 ≥ a 3 Cost function G REEDY ( G ) = X + ⌈ ( a 2 + 2 a 3 ) / 3 ⌉ if a 2 < a 3 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  31. The G REEDY Algorithm (adapted from [Mohr et al. 2013]) 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 , a 2 , a 3 ) X = Σ σ ∈ G ⌊ size ( σ ) / 4 ⌋ a i = |{ σ ∈ G | size ( σ ) = i mod 4 }| � ⌈ ( a 2 + a 3 ) / 2 ⌉ if a 2 ≥ a 3 Cost function G REEDY ( G ) = X + ⌈ ( a 2 + 2 a 3 ) / 3 ⌉ if a 2 < a 3 Theorem G REEDY is optimal for PRTGs. 8 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  32. Proof Outline G REEDY ( G ) G Trivial RTG G REEDY ( π G ) 1 ( π ) π G 9 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  33. Proof Outline G REEDY ( G ) G Trivial RTG G REEDY ( π G ) 1 ( π ) π G 9 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  34. Proof Outline G REEDY ( G ) G Trivial RTG G REEDY ( π G ) 1 ( π ) π G Take arbitrary permutation instruction π 9 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  35. Proof Outline G REEDY ( G ) G Trivial RTG G REEDY ( π G ) 1 ( π ) π G Take arbitrary permutation instruction π Show that always G REEDY ( G ) ≤ G REEDY ( π G ) + 1 ⇔ G REEDY ( G ) − G REEDY ( π G ) ≤ 1 9 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  36. Transpositions 3 2 4 2 3 merge 7 5 1 6 1 split 8 4 6 8 5 7 10 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  37. Transpositions 3 2 4 2 3 merge 7 5 1 6 1 split 8 4 6 8 5 7 10 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  38. Transpositions 3 2 4 2 3 merge 7 5 1 6 1 split 8 4 6 8 5 7 10 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  39. Transpositions 3 2 4 2 3 merge 7 5 1 6 1 split 8 4 6 8 5 7 10 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  40. Merges Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  41. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  42. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) → 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  43. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) → 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  44. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) Cost change only depends on signature change 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  45. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) Cost change only depends on signature change 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 1 1 ⁄ 2 0 1 ⁄ 2 1 1 ⁄ 3 1 ⁄ 3 1 ⁄ 3 2 0 0 2 1 ⁄ 3 0 3 1 ⁄ 2 3 0 a 2 ≥ a 3 a 2 < a 3 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  46. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) Cost change only depends on signature change 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 1 1 ⁄ 2 0 1 ⁄ 2 1 1 ⁄ 3 1 ⁄ 3 1 ⁄ 3 2 0 0 2 1 ⁄ 3 0 3 1 ⁄ 2 3 0 a 2 ≥ a 3 a 2 < a 3 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  47. Merges Cycle sizes modulo 4 0 1 2 3 0 ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) ( 0 , 0 , 0 ) 1 ( 0 , 1 , 0 ) ( 0 , − 1 , 1 ) ( 1 , 0 , − 1 ) ( 1 , − 2 , 0 ) ( 1 , − 1 , − 1 ) 2 ( 1 , 1 , − 2 ) 3 Look at all possible signature changes ( ∆ X , ∆ 2 , ∆ 3 ) Cost change only depends on signature change 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 1 1 ⁄ 2 0 1 ⁄ 2 1 1 ⁄ 3 1 ⁄ 3 1 ⁄ 3 2 0 0 2 1 ⁄ 3 0 3 1 ⁄ 2 3 0 a 2 ≥ a 3 a 2 < a 3 ⇒ Merges are never worthwhile! 11 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  48. Splits 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 1 1 ⁄ 2 0 1 ⁄ 2 1 1 ⁄ 3 1 ⁄ 3 1 ⁄ 3 2 0 0 2 1 ⁄ 3 0 3 1 ⁄ 2 3 0 a 2 ≥ a 3 a 2 < a 3 12 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  49. Splits 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 − 1 ⁄ 2 − − − − − 1 ⁄ 2 1 0 1 − 1 ⁄ 3 − − − − − 1 ⁄ 3 − − − 1 ⁄ 3 2 0 0 2 − − − 1 ⁄ 3 0 − 3 − 1 ⁄ 2 − 3 0 a 2 ≥ a 3 a 2 < a 3 12 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  50. Splits 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 − − − 1 ⁄ 2 − − 1 ⁄ 2 − 1 0 1 − − − 1 ⁄ 3 − − − 1 ⁄ 3 − − 1 ⁄ 3 − 2 0 0 2 − − 1 ⁄ 3 − 0 − 3 − 1 ⁄ 2 − 3 0 a 2 ≥ a 3 a 2 < a 3 permi5 can implement 4 transpositions ⇒ − 1 ⁄ 2 · 4 = − 2? 12 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  51. Splits 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 − − 1 ⁄ 2 − − 1 ⁄ 2 − − 1 0 1 − − − 1 ⁄ 3 − 1 ⁄ 3 − − − − − 1 ⁄ 3 2 0 0 2 − − − 1 ⁄ 3 0 − 3 − 1 ⁄ 2 − 3 0 a 2 ≥ a 3 a 2 < a 3 permi5 can implement 4 transpositions ⇒ − 1 ⁄ 2 · 4 = − 2? However: because of structure of instructions, not every transposition can reduce costs 12 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  52. Splits 0 1 2 3 0 1 2 3 0 0 0 0 0 0 0 0 0 0 − − − 1 ⁄ 2 − 1 ⁄ 2 − − 1 0 1 − − 1 ⁄ 3 − − 1 ⁄ 3 − − − − 1 ⁄ 3 − 2 0 0 2 − − − 1 ⁄ 3 0 − 3 − 1 ⁄ 2 − 3 0 a 2 ≥ a 3 a 2 < a 3 permi5 can implement 4 transpositions ⇒ − 1 ⁄ 2 · 4 = − 2? However: because of structure of instructions, not every transposition can reduce costs G REEDY is optimal for PRTGs G REEDY computes an optimal shuffle code for PRTGs in linear time. 12 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  53. Finding optimal copy sets Given G , have to find copy set C , s.t. G REEDY ( G − C ) is minimal 13 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  54. Finding optimal copy sets Given G , have to find copy set C , s.t. G REEDY ( G − C ) is minimal Equivalent to minimizing � X + a 2 2 + a 3 if a 2 ≥ a 3 G REEDY ′ ( G − C ) = 2 3 + 2 a 3 X + a 2 if a 2 < a 3 3 Distinguish cases with diff ( G − C ) = a 2 − a 3 13 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  55. Finding optimal copy sets Given G , have to find copy set C , s.t. G REEDY ( G − C ) is minimal Equivalent to minimizing � X + a 2 2 + a 3 2 = : cost 1 ( G − C ) if a 2 ≥ a 3 G REEDY ′ ( G − C ) = 3 + 2 a 3 X + a 2 3 = : cost 2 ( G − C ) if a 2 < a 3 Distinguish cases with diff ( G − C ) = a 2 − a 3 13 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  56. Finding optimal copy sets Given G , have to find copy set C , s.t. G REEDY ( G − C ) is minimal Equivalent to minimizing � X + a 2 2 + a 3 2 = : cost 1 ( G − C ) if a 2 ≥ a 3 G REEDY ′ ( G − C ) = 3 + 2 a 3 X + a 2 3 = : cost 2 ( G − C ) if a 2 < a 3 Distinguish cases with diff ( G − C ) = a 2 − a 3 Dynamic program with tables T 1 [ · ] , T 2 [ · ] T i [ d ] = min { cost i ( G − C ) | C copyset with diff ( G − C ) = d } 13 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  57. Finding optimal copy sets Given G , have to find copy set C , s.t. G REEDY ( G − C ) is minimal Equivalent to minimizing � X + a 2 2 + a 3 2 = : cost 1 ( G − C ) if a 2 ≥ a 3 G REEDY ′ ( G − C ) = 3 + 2 a 3 X + a 2 3 = : cost 2 ( G − C ) if a 2 < a 3 Distinguish cases with diff ( G − C ) = a 2 − a 3 Dynamic program with tables T 1 [ · ] , T 2 [ · ] T i [ d ] = min { cost i ( G − C ) | C copyset with diff ( G − C ) = d } − n n 0 T 1 [ · ] T 2 [ · ] 13 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  58. Computing Tables for Different RTG Shapes 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 O ( n 2 ) Disconnected RTGs 14 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  59. Computing Tables for Different RTG Shapes 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 O ( n 2 ) Disconnected RTGs O ( n 3 ) Tree RTGs 14 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  60. Computing Tables for Different RTG Shapes 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 O ( n 2 ) Disconnected RTGs O ( n 3 ) Tree RTGs O ( n 4 ) Connected RTGs containing cycle 14 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  61. Conclusion Problem 1: Given copy set C , compute optimal shuffle code for G − C . Shown that G REEDY is optimal for PRTGs, runs in O ( n ) time Equivalent to factoring permutation into shortest product of permutations of maximum size 5 15 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  62. Conclusion Problem 1: Given copy set C , compute optimal shuffle code for G − C . Shown that G REEDY 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 ( n 4 ) time 15 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  63. Conclusion Problem 1: Given copy set C , compute optimal shuffle code for G − C . Shown that G REEDY 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 ( n 4 ) 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? 15 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  64. Backup Slides 16 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  65. Speedup Measurements Reduction of # executed instructions [%] 20 Copy Coalescing ILP Recoloring Biased 15 Naive 10 5 0 k r x y m 2 p e f r c f t p e l c s p o i p c f b a t z a m r r i w v g l g z g r a r o . . . c e . b t . 5 p v . 4 6 1 4 . . p . 0 7 7 6 . 6 6 8 7 5 5 . 0 1 1 8 3 5 1 1 9 2 5 3 1 5 2 1 2 2 17 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  66. Disconnected RTGs H 1 H 2 x x x x x x x x x x x x x x x x x x x x 18 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  67. Disconnected RTGs H 1 H 2 x x x x x x x x x x x x x x x x x x x x 18 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  68. Disconnected RTGs H 1 H 2 x x x x x x x x x x x x x x x x x x x x C : = C 1 ∪ C 2 cost ( G − C ) = cost ( H 1 − C 1 ) + cost ( H 2 − C 2 ) diff ( G − C ) = diff ( H 1 − C 1 ) + diff ( H 2 − C 2 ) 18 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  69. Disconnected RTGs H 1 H 2 x x x x x x x x x x x x x x x x x x x x C : = C 1 ∪ C 2 cost ( G − C ) = cost ( H 1 − C 1 ) + cost ( H 2 − C 2 ) diff ( G − C ) = diff ( H 1 − C 1 ) + diff ( H 2 − C 2 ) ⇒ Can find optimal copy set C by trying all pairs C 1 , C 2 ⇒ Can be computed in O ( n 2 ) time 18 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  70. Tree RTGs x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion 19 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  71. Tree RTGs x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion 19 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  72. Tree RTGs x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion 19 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

  73. Tree RTGs x x x x ... ... ... x ... ... Process tree RTGs in bottom-up fashion 19 August 5, 2015 Sebastian Buchwald, Manuel Mohr, Ignaz Rutter – Optimal Shuffle Code with Permutation Instructions IPD, ITI

Recommend


More recommend