in-place super scalar samplesort - kitalgo2.iti.kit.edu/sanders/courses/algen17/ipsssso.pdf ·...
TRANSCRIPT
![Page 1: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/1.jpg)
In-place (Parallel) Super Scalar Samplesort
Algorithm Engineering Lecture · June 13, 2017Michael Axtmann, Sascha Witt, Daniel Ferizovic, Peter Sanders
KIT – University of the State of Baden-Wuerttemberg andNational Laboratory of the Helmholtz Association
Institute of Theoretical Informatics · Algorithmics Group
www.kit.edu
![Page 2: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/2.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
Overview
Quicksort BlockQuicksort SSSS ISSSS
Decoupled control anddata flow
no yes yes yes
Conditional branches yes no no noData transfers / element ≈ log2 n ≈ log2 n ≈ logk n ≈ logk nAdditional space O(1) O(b) O(n) O(kb)Parallelization yes no no yes
1
![Page 3: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/3.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
2
![Page 4: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/4.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
b Elements
2
![Page 5: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/5.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot b Elements
2
![Page 6: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/6.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot b Elements
2
![Page 7: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/7.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot b Elements
2
![Page 8: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/8.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot b Elements
2
![Page 9: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/9.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot b Elements
2
![Page 10: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/10.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place: O (b) additional space
Pivot
DrawbacksO(
nb log2
nn0
)block transfers
b Elements
2
![Page 11: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/11.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesk-way distributionCache/IO-efficient
O(
ntb logk
nn0
)block transfers
In-place: O (kb) additional spaceEasy to parallelize
3
![Page 12: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/12.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Local classification
Block permutation
Input
4
![Page 13: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/13.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Local classification
Block permutation
Cleanup
Input
4
![Page 14: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/14.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Flush ?
Local classificationk-way decision tree without branchesk buffer blocks of size B
Flush buffer block if charged
k buffer blocks
5
![Page 15: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/15.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
6
![Page 16: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/16.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
6
![Page 17: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/17.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w2 w3 w4w1 r1 r2 r3 r4
6
![Page 18: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/18.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 19: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/19.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 20: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/20.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 21: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/21.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 22: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/22.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 23: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/23.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
Swap buffers
b1 b2 b3 b4 b5w1 w2 w3 w4r1 r2 r3 r4
6
![Page 24: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/24.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b3 b5w1 w2 w3r1 r2 r3
Swap buffers
b4 w4r4
6
![Page 25: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/25.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b3 b4 b5w2 w3 w4w1 r1 r2 r3 r4
Swap buffers
6
![Page 26: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/26.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1 r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 27: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/27.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1 r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 28: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/28.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1 r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 29: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/29.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1 r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 30: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/30.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 31: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/31.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1r1 r2
Swap buffers
b3w2 r3 b4w3 w4r4
6
![Page 32: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/32.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1
w4r1 r2
Swap buffers
b3w2 r3 b4w3 r4
6
![Page 33: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/33.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
Block permutationInvariant
Permuted blocks [bi , wi )Unpermuted blocks [wi , ri ]Empty Blocks (ri , bi+1)
Two buffers to swap blocks
b1 b2 b5w1
w4r1 r2
Swap buffers
b3w2 r3 b4w3 r4
6
![Page 34: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/34.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
DiscussionWhy blocks
Just n + n/b classifications per levelReduced TLB misses
Local classification: buffers on same pageWrite and read whole blocks
Better prefetching and less cache misses
7
![Page 35: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/35.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Super Scalar Samplesort
28 211 214 217 220 223 226 2290
2
4
6
Item count n
Runn
ingtim
e/
nlo
g 2n[µ
s]
IS4o BlockQ std-sorts3-sort DualPivot
Sequential on two Xeon E5-2683 v4 16-core processors – Uniform Input
8
![Page 36: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/36.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
Shared-memory parallelism with t threadsLocal classification: divide input into stripes – one for each threadBlock permutation: fetch blocks atomically
atomic read pointers and end pointersAccess with fetch-and-add operations
Blocks of size Ω(t) to avoid starvationBuffers for each threadCall sequential subroutines in parallel if n ≤ ninit/t
9
![Page 37: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/37.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
One of two Intel Xeon E5-2683 v4 16-core processors – Uniform InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
10
![Page 38: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/38.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
Two Intel Xeon E5-2683 v4 16-core processors – Uniform InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
11
![Page 39: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/39.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
Two Intel Xeon E5-2683 v4 16-core processors – Exponential InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
12
![Page 40: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/40.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
Two Intel Xeon E5-2683 v4 16-core processors – RootDup InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
13
![Page 41: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/41.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
Two Intel Xeon E5-2683 v4 16-core processors – TwoDup InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
14
![Page 42: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/42.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
In-place Parallel Super Scalar Samplesort
215 218 221 224 227 2300
0.2
0.4
0.6
Two Intel Xeon E5-2683 v4 16-core processors – AlmostSorted InputItem count n
Runn
ingtim
e/
nlo
g 2n[µ
s]IPS4o MCSTLubq MCSTLbqPBBS MCSTLmwm TBB
15
![Page 43: In-place Super Scalar Samplesort - KITalgo2.iti.kit.edu/sanders/courses/algen17/IPSSSSo.pdf · 2017. 6. 20. · In-place (Parallel) Super Scalar Samplesort Algorithm Engineering Lecture](https://reader036.vdocument.in/reader036/viewer/2022071410/6103d93461b0581db46b7529/html5/thumbnails/43.jpg)
M. Axtmann, S. Witt, D. Ferizovic, P. Sanders – In-place Super Scalar Samplesort Institute of Theoretical Informat-icsAlgorithmics Group
BlockQuicksort
GoalsPartially decoupling control flow from data flowAvoid conditional branchesIn-place
16