cache-oblivious red-blueblue line segment intersectiong · intersections between a red segment and...

1
Cache-Oblivious Red-Blue Cache-Oblivious Red-Blue Motivation Ca Motivation Ca Line Segment intersection External mem Line Segment intersection External mem 2D line segment intersection problems are well studied topics in computational geometry CPU: Computa 2D line segment intersection problems are well studied topics in computational geometry . CPU: Computa Three common problem types: Memory: Finite Three common problem types: Disk: Elements General : Find all intersections between segments in a set Disk: Elements Red Bl e Gi en t o sets of line segments the red set and the bl e set find all Red-Blue : Given two sets of line segments, the red set and the blue set, find all it ti bt d t d bl t CPU intersections between a red segment and a blue segment. Common assumption: No two segments of the samme color intersect Common assumption: No two segments of the samme color intersect. Orthogonal : Given a set of axis-parallel line segments, find all intersections. Cache-oblivi Cache-oblivi In the cache-ob In the cache ob RAM model bu RAM model bu R lt Al ith Result: Algorith memory hierarc Orthogonal Red-Blue General Al ith b d Algorithm based o Contribution 1 S li l i Contribution 1. Split plane into This work solves the Red-Blue line segment intersection problem in the cache-oblivious This work solves the Red Blue line segment intersection problem in the cache oblivious model 2. Recurse on eac model. least one endpo The table below shows what’s been done previously for the three problems above. Note that all of the given bounds are optimal, except for the general external memory intersection 3. Use k-merger problem. Our solution is highlighted in red. 3.1. Intersecti 3.2. Intersect Internal Memory External Memory Cache-Oblivious O th l Orthogonal u u () Red-Blue l(u) Red Blue General Open Open σ l(u) MADALGO Center for Massive Data Algorithmics a MADALGO Center for Massive Data Algorithmics, a Th M lh Thomas Mølhave Aarhus University Aarhus University Line Segment Intersection Line Segment Intersection ache-Oblivious Model The k-Merger ache Oblivious Model The k Merger mory model k-merger: merges k sorted streams of total length at least k 2 mory model k merger: merges k sorted streams of total length at least k . P d d ation Can only access elements in memory Produces a sorted output stream. ation. Can only access elements in memory. Structure: Perfectly balanced binary tree with , holds M elements. Structure: Perfectly balanced binary tree with k leaves and buffers on the edges s transferred to/from disk in block of size B k leaves and buffers on the edges. B ff i d fi d i l b litti s transferred to/from disk in block of size B. Buffer sizes defined recursively by splitting The k-merger into k-mergers. k Each internal node is a binary merger Memory size M Disk k Each internal node is a binary merger. Block size B Block size B ous model ous model k k k blivious model algorithms are designed in the k k k blivious model algorithms are designed in the ut analyzed in the external memory model ut analyzed in the external memory model. h th t ffi i t ll l l hms that are efficient on all levels on any chy . Algorithm O er ie Algorithm Overview di id d t hi on divide and conquer technique: N lb ih N d i i h lb N slabs with N endpoints in each slab. ch slab to find intersections between segments with at oint in the slab. r multiple times to find: b 1 r 1 b 1 1 ons between short and long segments of different colors. b 4 r 2 tions between long red and long blue segments. b 3 b 4 r 2 b 2 b 3 b 2 σ 1 σ 2 σ 3 σ 4 σ 5 σ 6 σ 8 σ 7 Rf References () r(u) Performing steps 3.1 and 3.2 requires [1] L. Arge, T. Mølhave, N. Zeh, Cache-Oblivious Red-Blue Line b b 1 significant changes to the binary mergers Segment Intersection. In Proc. ESA, pp. 88-99, 2008. [2] GS B dl R F b C h bli i di t ib ti i b 2 b 3 of the k-merger. [2] G.S. Brodal, R. Fagerberg. Cache oblivious distribution sweeping. In Proc ICALP pp 426 438 2002 b 4 In Proc. ICALP, pp. 426438, 2002. [3] L Arge D E Vengroff J S Vitter External-memory algorithms for r [3] L. Arge, D.E. Vengroff, J.S. Vitter. External memory algorithms for processing line segments in geographic information systems. σ r(u) Algorithmica, 47:1–25, 2007. a Center of the Danish National Research Foundation a Center of the Danish National Research Foundation

Upload: others

Post on 11-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cache-Oblivious Red-BlueBlue Line Segment Intersectiong · intersections between a red segment and a blue segment. Common assumption: No two segments of the samme color intersect:

Cache-Oblivious Red-BlueCache-Oblivious Red-Blue Motivation CaMotivation Ca

Line Segment intersection External memLine Segment intersection External mem2D line segment intersection problems are well studied topics in computational geometry CPU: Computa2D line segment intersection problems are well studied topics in computational geometry. CPU: Computa

Three common problem types: Memory: FiniteThree common problem types:Disk: ElementsGeneral : Find all intersections between segments in a set Disk: Elements

Red Bl e Gi en t o sets of line segments the red set and the bl e set find allRed-Blue : Given two sets of line segments, the red set and the blue set, find all i t ti b t d t d bl t

CPUintersections between a red segment and a blue segment.

Common assumption: No two segments of the samme color intersectCommon assumption: No two segments of the samme color intersect.

Orthogonal : Given a set of axis-parallel line segments, find all intersections.g p g ,

Cache-obliviCache-obliviIn the cache-obIn the cache obRAM model buRAM model bu

R lt Al ithResult: Algorithmemory hierarc

Orthogonal Red-Blue Generalg

Al ith b dAlgorithm based o

Contribution 1 S li l iContribution 1. Split plane into

This work solves the Red-Blue line segment intersection problem in the cache-obliviousThis work solves the Red Blue line segment intersection problem in the cache obliviousmodel 2. Recurse on eacmodel.

least one endpoThe table below shows what’s been done previously for the three problems above. Note that all of the given bounds are optimal, except for the general external memory intersection 3. Use k-mergerg p p g yproblem. Our solution is highlighted in red.p g g

3.1. Intersecti

3.2. IntersectInternal Memory External Memory Cache-Oblivious

O th lOrthogonaluu

( )Red-Blue

l(u)Red Blue

General OpenGe e a Openσl(u)

MADALGO Center for Massive Data Algorithmics aMADALGO – Center for Massive Data Algorithmics, a

Th M lhThomas MølhaveAarhus UniversityAarhus University

Line Segment IntersectionLine Segment Intersectiongache-Oblivious Model The k-Mergerache Oblivious Model The k Merger

mory model k-merger: merges k sorted streams of total length at least k2mory model k merger: merges k sorted streams of total length at least k .

P d dation Can only access elements in memory

Produces a sorted output stream.ation. Can only access elements in memory.

Structure: Perfectly balanced binary tree with, holds M elements.

Structure: Perfectly balanced binary tree withk leaves and buffers on the edges

s transferred to/from disk in block of size Bk leaves and buffers on the edges.

B ff i d fi d i l b littis transferred to/from disk in block of size B. Buffer sizes defined recursively by splitting√The k-merger into √k-mergers. √

kEach internal node is a binary mergerMemory size M Disk

√kEach internal node is a binary merger.

Block size BBlock size B

ous modelous model √k

√k

√kblivious model algorithms are designed in the

√k

√k

√kblivious model algorithms are designed in the

ut analyzed in the external memory modelut analyzed in the external memory model.

h th t ffi i t ll l lhms that are efficient on all levels on any chy .

Algorithm O er ieAlgorithm Overview

di id d t h ion divide and conquer technique:

√N l b i h √N d i i h l b√N slabs with √N endpoints in each slab.

ch slab to find intersections between segments with at oint in the slab.

r multiple times to find:b1

r1b1r1

ons between short and long segments of different colors.

b4r2tions between long red and long blue segments. b3b4r2

b2

b3b2

σ1 σ2 σ3 σ4 σ5 σ6 σ8σ7

R fReferences( )r(u)

Performing steps 3.1 and 3.2 requires [1] L. Arge, T. Mølhave, N. Zeh, Cache-Oblivious Red-Blue Line bb1

significant changes to the binary mergers Segment Intersection. In Proc. ESA, pp. 88-99, 2008.[2] G S B d l R F b C h bli i di t ib ti i

b2

b3

of the k-merger. [2] G.S. Brodal, R. Fagerberg. Cache oblivious distribution sweeping. In Proc ICALP pp 426 438 2002

b4

In Proc. ICALP, pp. 426–438, 2002.[3] L Arge D E Vengroff J S Vitter External-memory algorithms for

r[3] L. Arge, D.E. Vengroff, J.S. Vitter. External memory algorithms for

processing line segments in geographic information systems. σr(u) p g g g g p y

Algorithmica, 47:1–25, 2007.

a Center of the Danish National Research Foundationa Center of the Danish National Research Foundation