Hardware-Aware Algorithms and Data Structures
Gabriel Moruz BRICS University of Aarhus
1
Hardware-Aware Algorithms and Data Structures Gabriel Moruz BRICS - - PowerPoint PPT Presentation
Hardware-Aware Algorithms and Data Structures Gabriel Moruz BRICS University of Aarhus 1 Hardware /nm./: the part of the computer that you can kick. Geeky folklore. Gabriel Moruz: Hardware aware algorithms and data structures 2
1
Gabriel Moruz: Hardware aware algorithms and data structures
2
Gabriel Moruz: Hardware aware algorithms and data structures
3
cherchez la femme, the lost city of Atlantis, the bad Mafia guys, the dark Mordor, pirates’ treasure chest etc.
Gabriel Moruz: Hardware aware algorithms and data structures
4
Gabriel Moruz: Hardware aware algorithms and data structures
5
Gabriel Moruz: Hardware aware algorithms and data structures
6
Gabriel Moruz: Hardware aware algorithms and data structures
6
Gabriel Moruz: Hardware aware algorithms and data structures
6
Gabriel Moruz: Hardware aware algorithms and data structures
6
Gabriel Moruz: Hardware aware algorithms and data structures
6
1 2 4 5 6 7 8 9 10 11 12 14 15 3 13 7 5 8 10 12 13 15 18 21 24 22 35 28 31 42 3
← → → A
Gabriel Moruz: Hardware aware algorithms and data structures
7
1 2 4 5 6 7 8 9 10 11 12 14 15 3 13 7 5 8 10 12 13 15 18 21 24 22 35 28 31 42 3
← → → A
Gabriel Moruz: Hardware aware algorithms and data structures
7
Gabriel Moruz: Hardware aware algorithms and data structures
8
Gabriel Moruz: Hardware aware algorithms and data structures
9
Gabriel Moruz: Hardware aware algorithms and data structures
9
CPU Memory
Gabriel Moruz: Hardware aware algorithms and data structures
10
Gabriel Moruz: Hardware aware algorithms and data structures
11
Gabriel Moruz: Hardware aware algorithms and data structures
11
Gabriel Moruz: Hardware aware algorithms and data structures
11
Gabriel Moruz: Hardware aware algorithms and data structures
11
0.5 1 1.5 2 10 20 30 40 50 60 70 80 90 100 Running time param Running time
Gabriel Moruz: Hardware aware algorithms and data structures
12
0.5 1 1.5 2 10 20 30 40 50 60 70 80 90 100 Running time param Running time 0.05 0.1 0.15 0.2 0.25 0.3 0.35 20 40 60 80 100 Running time param No opt Opt -O3
Gabriel Moruz: Hardware aware algorithms and data structures
12
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
13
Gabriel Moruz: Hardware aware algorithms and data structures
14
0.5 1 1.5 2 10 20 30 40 50 60 70 80 90 100 Running time param Running time 0.05 0.1 0.15 0.2 0.25 0.3 0.35 20 40 60 80 100 Running time param No opt Opt -O3
Gabriel Moruz: Hardware aware algorithms and data structures
15
Gabriel Moruz: Hardware aware algorithms and data structures
16
1 2 1 2 3 4 1 2 3 4 5 1 2 3 4 5 6 7 8 9 10
Gabriel Moruz: Hardware aware algorithms and data structures
17
0.5 1 1.5 2 5 10 15 20 25 30 Running time log n
Gabriel Moruz: Hardware aware algorithms and data structures
18
0.5 1 1.5 2 5 10 15 20 25 30 Running time log n 500 1000 1500 2000 2500 3000 5 10 15 20 25 30 Running time log n
Gabriel Moruz: Hardware aware algorithms and data structures
18
L1 cache CPU L2 cache RAM Hard disk
S p e e d S i z e
Gabriel Moruz: Hardware aware algorithms and data structures
19
500 1000 1500 2000 2500 3000 5 10 15 20 25 30 Running time log n 2 4 6 8 10 5 10 15 20 25 30 Running time log n
Gabriel Moruz: Hardware aware algorithms and data structures
20
Gabriel Moruz: Hardware aware algorithms and data structures
21
Gabriel Moruz: Hardware aware algorithms and data structures
22
Gabriel Moruz: Hardware aware algorithms and data structures
23
Gabriel Moruz: Hardware aware algorithms and data structures
24
Gabriel Moruz: Hardware aware algorithms and data structures
24
Gabriel Moruz: Hardware aware algorithms and data structures
25
1. On the Adaptiveness of Quicksort. G. S. Brodal, R. Fagerberg, and G. Moruz. In Proc. 7th Workshop on Algorithm Engineering and Experiments (ALENEX), 2005. 2. Cache-Aware and Cache-Oblivious Adaptive Sorting. G. S. Brodal, R. Fagerberg, and
3. Tradeoffs Between Branch Mispredictions and Comparisons for Sorting
Data Structures (WADS), 2005. 4. Skewed Binary Search Trees. G. S. Brodal and G. Moruz. In Proc. 14th Annual European Symposium on Algorithms (ESA), 2006. 5. Adapting Parallel Algorithms to the W-Stream Model, with Applications to Graph
Symposium on Mathematical Foundations of Computer Science (MFCS), 2007. 6. Resilient Priority Queues. A. G. Jørgensen, G. Moruz, and T. Mølhave. In Proc. 10th
7. Optimal Resilient Dynamic Dictionaries. G. S. Brodal, R. Fagerberg, I. Finocchi, F . Grandoni, G. F . Italiano, A. G. Jørgensen, G. Moruz, and T. Mølhave. In Proc. 15th Annual European Symposium on Algorithms (ESA), 2007. To appear.
Gabriel Moruz: Hardware aware algorithms and data structures
26
Optimal resilient dictionaries Optimal resilient dictionaries Resilient Search Trees: Randomization and Prejudice Optimal resilient dictionaries Resilient Search Trees: Randomization and Prejudice
Submissions:
Reviewers deciding: Acceptance notification:
Gabriel Moruz: Hardware aware algorithms and data structures
27
Gabriel Moruz: Hardware aware algorithms and data structures
28
Gabriel Moruz: Hardware aware algorithms and data structures
28
7 9 12 14 16 18 21 27 30 15 32 33 39 42 44 45 49 37 1 41 7 9 12 14 16 18 21 27 30 15 32 33 39 42 44 45 49 13 1 41 7 9 12 13 16 18 21 27 30 15 32 33 39 42 44 45 49 1 37
Gabriel Moruz: Hardware aware algorithms and data structures
29
[Finocchi and Italiano ’04, Finocchi et al. ’06, Finocchi et al. ’07, Jørgensen et al. ’07]
Gabriel Moruz: Hardware aware algorithms and data structures
30
Gabriel Moruz: Hardware aware algorithms and data structures
31
Gabriel Moruz: Hardware aware algorithms and data structures
31
4 7 9 12 13 16 18 21 27 30 25 32 33 39 42 44 45 46 37 1 12 21 32 42 4 13 25 33 44 7 16 27 37 45 46 39 30 18 1 9
A S1 S2 S3 S4
Gabriel Moruz: Hardware aware algorithms and data structures
32
4 7 9 12 13 16 18 21 10 30 25 32 33 39 42 44 45 46 37 1 12 21 32 42 4 13 25 33 44 7 16 37 45 46 39 30 18 9 1 10
A S1 S2 S3 S4
R
Gabriel Moruz: Hardware aware algorithms and data structures
33
Gabriel Moruz: Hardware aware algorithms and data structures
34
Gabriel Moruz: Hardware aware algorithms and data structures
34
Gabriel Moruz: Hardware aware algorithms and data structures
34
Gabriel Moruz: Hardware aware algorithms and data structures
35
Gabriel Moruz: Hardware aware algorithms and data structures
36
LV RV Q
Block
Gabriel Moruz: Hardware aware algorithms and data structures
37
47 31 25 23 29 32 35 41 10 12 13 8 4 3 18 21 14
−∞ 8 7 6 5 4 3 2 1 −1 9 10 11 12 13 14 15 16 17 +∞ ← → Sk
Gabriel Moruz: Hardware aware algorithms and data structures
38
47 31 25 23 29 32 35 41 10 12 13 8 4 3 18 21 14
−∞ 8 7 6 5 4 3 2 1 −1 9 10 11 12 13 14 15 16 17 +∞ ← → Sk
Gabriel Moruz: Hardware aware algorithms and data structures
38
47 31 25 23 29 32 35 41 10 12 13 8 4 3 18 21 14
−∞ 8 7 6 5 4 3 2 1 −1 9 10 11 12 13 14 15 16 17 +∞ ← → ← ← Sk
Gabriel Moruz: Hardware aware algorithms and data structures
38
3 5 7 12 14 18 21 23 24 28 49 31 32 35 40 41 45 . . . . . . → ← cl cr 38 71
Qi RVi
Qi+1 RVi+1 1 1
Gabriel Moruz: Hardware aware algorithms and data structures
39
3 5 7 12 14 18 21 23 24 28 49 31 32 35 40 41 45 . . . . . . → → ← 2 cl cr ← 38 71
Qi RVi
Qi+1 RVi+1 2
Gabriel Moruz: Hardware aware algorithms and data structures
39
3 5 7 12 14 18 21 23 24 28 49 31 32 35 40 41 45 . . . . . . → → → ← 2 3 cl cr → ← 38 71 1 2
Qi RVi
Qi+1 RVi+1
Gabriel Moruz: Hardware aware algorithms and data structures
39
3 5 7 12 14 18 21 23 24 28 49 31 32 35 40 41 45 . . . . . . → → → → ← 2 3 4 cl cr → → ← 38 71 1 2
Qi RVi
Qi+1 RVi+1
Gabriel Moruz: Hardware aware algorithms and data structures
39
Gabriel Moruz: Hardware aware algorithms and data structures
40
Gabriel Moruz: Hardware aware algorithms and data structures
41
Gabriel Moruz: Hardware aware algorithms and data structures
42
Leaf structure Top tree
O(1)
Θ(δ)
Θ(δ) Θ(log n) B B0 B1 Bb−1
Gabriel Moruz: Hardware aware algorithms and data structures
43
O(1)
Gabriel Moruz: Hardware aware algorithms and data structures
44
Θ(δ)
Θ(δ) Θ(log n) B B0 B1 Bb−1
Gabriel Moruz: Hardware aware algorithms and data structures
45
Leaf structure Top tree
O(1)
Θ(δ)
. . .
Θ(δ) Θ(log n) B B0 B1 Bb−1
Gabriel Moruz: Hardware aware algorithms and data structures
46
Leaf structure Top tree
O(1)
Θ(δ)
. . .
Θ(δ) Θ(log n) B B0 B1 Bb−1
Gabriel Moruz: Hardware aware algorithms and data structures
46
Leaf structure Top tree
O(1)
Θ(δ)
. . .
Θ(δ) Θ(log n) B B0 B1 Bb−1
Gabriel Moruz: Hardware aware algorithms and data structures
47
Gabriel Moruz: Hardware aware algorithms and data structures
48