Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf ·...
Transcript of Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf ·...
![Page 1: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/1.jpg)
Legion Bootcamp 2017 1
Overview
![Page 2: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/2.jpg)
Legion & Regent
• Legion is – a C++ runtime – a programming model
• Regent is a programming language – For the Legion programming model – Current implementation is embedded in Lua – Has an optimizing compiler
• The bootcamp will focus on Regent
Legion Bootcamp 2017 2
![Page 3: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/3.jpg)
Regent/Legion Design Goals
• Sequential semantics – The better to understand what you write – Parallelism is extracted automatically
• Throughput-oriented – The latency of a single thread/process is (mostly) irrelevant – The overall time is what matters
• Runtime decision making – Because machines are unpredictable/dynamic
Legion Bootcamp 2017 3
![Page 4: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/4.jpg)
Throughput-Oriented
• Keep the machine busy
• How? Ideally, – Every core has a queue of independent work to do – Every memory unit has a queue of transfers to do – At all times
Legion Bootcamp 2017 4
![Page 5: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/5.jpg)
Consequences
• Highly asynchronous – Minimize synchronization – Esp. global synchronization
• Sequential semantics but support for parallelism
• Emphasis on describing the structure of data – Later
Legion Bootcamp 2017 5
![Page 6: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/6.jpg)
Regent Stack
Legion Bootcamp 2017 6
Regent Language and
compiler
Legion High-level runtime
Realm Low-level runtime
Terra Sequential
performance
Lua Host language
![Page 7: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/7.jpg)
Regent in Lua
• Embedded in Lua – Popular scripting language in the graphics
community
• Excellent interoperation with C – And with other languages
• Python-ish syntax – For both Lua and Regent
Legion Bootcamp 2017 7
![Page 8: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/8.jpg)
• Examples Overview/1.rg & 2.rg
• To run: – ssh –l USER bootcamp.regent-lang.org – cd Bootcamp/Overview – qsub r1.sh
Legion Bootcamp 2017 8
![Page 9: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/9.jpg)
Tasks
Legion Bootcamp 2017 9
![Page 10: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/10.jpg)
Tasks
• Tasks are Regent’s unit of parallel execution – Distinguished functions that can be executed
asynchronously
• No preemption – Tasks run until they block or terminate – And ideally they don’t block …
Legion Bootcamp 2017 10
![Page 11: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/11.jpg)
Blocking
• Blocking means a task cannot continue – So the task stops running
• Blocking does not prevent independent work from being done – If the processor has something else to do – Does prevent the task from continuing and
launching more tasks
• Avoid blocking. Legion Bootcamp 2017 11
![Page 12: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/12.jpg)
Subtasks
• Tasks can call subtasks – Nested parallelism
• Terminology: parent and child tasks
Legion Bootcamp 2017 12
![Page 13: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/13.jpg)
Example
task tester(sum: int64) … end task main() var sum: int64 = summer(10) sum = tester(sum) c.printf("The answer is: %d\n",sum) end Legion Bootcamp 2017 13
![Page 14: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/14.jpg)
If a parent task inspects the result of a child task, the parent task blocks pending
completion of the child task.
Legion Bootcamp 2017 14
![Page 15: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/15.jpg)
• Examples Tasks/1.rg & 2.rg
• Reminder: cd Bootcamp/Tasks qsub r1.sh
Legion Bootcamp 2017 15
![Page 16: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/16.jpg)
Legion Prof
Legion Bootcamp 2017 16
![Page 17: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/17.jpg)
Legion Prof
• A tool for showing performance timeline – Each processor is a timeline – Each operation is a time interval – Different kinds of operations have different colors
• White space = idle time
Legion Bootcamp 2017 17
![Page 18: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/18.jpg)
Example 1: Legion Prof
cd Bootcamp/Tasks qsub rp1.sh make prof
http://bootcamp.regent-lang.org/~USER/prof1
Legion Bootcamp 2017 18
![Page 19: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/19.jpg)
Example 2: Legion Prof
cd Bootcamp/Tasks qsub rp2.sh make prof
http://bootcamp.regent-lang.org/~USER/prof2
Legion Bootcamp 2017 19
![Page 20: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/20.jpg)
Mapping
• How does Regent/Legion decide on which processor to run tasks?
• This decision is under the mapper’s control
• Here we are using the default mapper – Passes out tasks to which CPU on a node is not busy – Programmers can write their own mappers – More on mapping later
Legion Bootcamp 2017 20
![Page 21: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/21.jpg)
Parallelism
Legion Bootcamp 2017 21
![Page 22: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/22.jpg)
Example Tasks/3.rg
• “for all” style parallelism
• Note the order of completion of the tasks – main() finishes first (or almost first)! – All subtasks managed by the runtime system – Subtasks execute in non-deterministic order
• How? – Regent notices that the tasks are independent – No task depends on another task for its inputs
Legion Bootcamp 2017 22
![Page 23: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/23.jpg)
Runtime Dependence Analysis
• Example Tasks/4.rg is more involved – Positive tasks (print a positive integer) – Negative tasks (print a negative integer)
• Some tasks are dependent – The task for -5 depends on the task for 5 – Note loop in main() does not block on the value of j!
• Some are independent – Positive tasks are independent of each other – Negative tasks are independent of each other
Legion Bootcamp 2017 23
![Page 24: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/24.jpg)
Legion Spy
Legion Bootcamp 2017 24
![Page 25: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/25.jpg)
Legion Spy
• A tool for showing ordering dependencies
• Very useful for figuring out why things are not running in parallel
Legion Bootcamp 2017 25
![Page 26: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/26.jpg)
Example Tasks/4.rg: Legion Spy
cd Bootcamp/Tasks qsub rs4.sh make spy http://bootcamp.regent-lang.org/~USER/spy4.pdf
Legion Bootcamp 2017 26
![Page 27: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/27.jpg)
Workflow
• Use Legion Prof to find idle time – white space
• Use Legion Spy to examine tasks that are delayed – What are they waiting for?!
Legion Bootcamp 2017 27
![Page 28: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/28.jpg)
Exercise 1
Legion Bootcamp 2017 28
![Page 29: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/29.jpg)
Computing the Area of a Unit Circle
• A Monte Carlo simulation to compute the area of a unit circle inscribed in a square
• Throw darts – Fraction of darts landing
in the circle = ratio of circle’s area to square’s area
Legion Bootcamp 2017 29
1
x
y
![Page 30: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/30.jpg)
Computing the Area of a Unit Circle
• Example Pi/1.rg – Slow! – Why?
Legion Bootcamp 2017 30
![Page 31: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/31.jpg)
Exercise 1
• Modify Pi/1.rg – Edit x1.rg – make multiple trials per subtask
• Use – 4 subtasks – 2500 trials per subtask
• Produce both prof and spy output – See Makefile
Legion Bootcamp 2017 31
![Page 32: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/32.jpg)
Terra
Legion Bootcamp 2017 32
![Page 33: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/33.jpg)
Leaf Tasks
• Leaf tasks call no other tasks – The “leaves” of the task tree
• Leaf tasks are sequential programs – And generally where the heavy compute will be
• Thus, leaf tasks should be optimized for latency, not throughput – Want them to finish as fast as possible!
Legion Bootcamp 2017 33
![Page 34: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/34.jpg)
Terra
• Terra is a low-level, typed language embedded in Lua
• Designed to be like C – And to compile to similarly efficient code
• Also supports vector intrinsics – Not illustrated today
Legion Bootcamp 2017 34
![Page 35: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/35.jpg)
Terra Example
• Terra/1.rg converts the hits task in Terra/x1.rg to a Terra function
• Trivial in this example – Just change ”task” to “terra” – Marginally faster
• On average …
Legion Bootcamp 2017 35
![Page 36: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/36.jpg)
Considerations in Writing Regent Programs
• The granularity of tasks must be sufficient – Don’t write very short running tasks
• Don’t block in tasks that launch many subtasks
• Terra is an option for heavy sequential computations
Legion Bootcamp 2017 36
![Page 37: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/37.jpg)
Structured Regions
Legion Bootcamp 2017 37
![Page 38: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/38.jpg)
Regions
• A region is a (typed) collection
• Regions are the cross product of – An index space – A field space
Legion Bootcamp 2017 38
![Page 39: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/39.jpg)
StructuredRegions/1.rg
Legion Bootcamp 2017 39
false
false
false
false
false
true
true
true
true
false
0
1
2
3
4
5
6
7
8
9
Bit
![Page 40: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/40.jpg)
Discussion
• Regions are the way to organize large data collections in Regent
• Regions can be – Structured (e.g., like arrays) – Unstructured (e.g., pointer data structures)
• Any number of fields • Built-in support for 1D, 2D and 3D index spaces
Legion Bootcamp 2017 40
![Page 41: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/41.jpg)
Privileges
• A task that takes region arguments must – Declare its privileges on the region – Reads, Writes, Reduces
• The task may only perform operations for which it has privileges – Including any subtasks it calls
Legion Bootcamp 2017 41
![Page 42: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/42.jpg)
• Example StructuredRegions/2.rg
• Example StructuredRegions/3.rg
Legion Bootcamp 2017 42
![Page 43: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/43.jpg)
Reduction Privileges
• StructuredRegions/4.rg – A sequence of tasks that increment elements of a region – With Read/Write privileges
• StructuredRegions/5.rg – 4.rg but with Reduction privileges
• Note: Reductions can create additional copies – To get more parallelism – Under mapper control – Not always preferred to Read/Write privileges
Legion Bootcamp 2017 43
![Page 44: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/44.jpg)
Partitioning
Legion Bootcamp 2017 44
![Page 45: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/45.jpg)
Partitioning
• To enable parallelism on a region, partition it into smaller pieces – And then run a task on each piece
• Legion/Regent have a rich set of partitioning primitives
Legion Bootcamp 2017 45
![Page 46: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/46.jpg)
Partitioning Example
Legion Bootcamp 2017 46
false
false
false
false
false
true
true
true
true
false
0
1
2
3
4
5
6
7
8
9
Bit
![Page 47: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/47.jpg)
Partitioning Example
Legion Bootcamp 2017 47
false
false
false
false
false
true
true
true
true
false
0
1
2
3
4
5
6
7
8
9
Bit
bit_region_partition[0]
bit_region_partition[1]
![Page 48: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/48.jpg)
Equal Partitions
• One commonly used primitive is to split a region into a number of (nearly) equal size subregions
• Partitioning/1.rg
• Partitioning/2.rg
Legion Bootcamp 2017 48
![Page 49: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/49.jpg)
Discussion
• Partitioning does not create copies – It names subsets of the data
• Partitioning does not remove the parent region – It still exists and can be used
• Regions and partitions are first-class values – Can be created, destroyed, stored in data structures, passed
to and returned from tasks
Legion Bootcamp 2017 49
![Page 50: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/50.jpg)
Region Trees
Legion Bootcamp 2017 50
0
bit_region
1 2 3 4 5
![Page 51: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/51.jpg)
More Discussion
• The same data can be partitioned multiple ways – Again, these are just names for subsets
• Subregions can themselves be partitioned
Legion Bootcamp 2017 51
![Page 52: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/52.jpg)
Dependence Analysis
• Regent uses tasks’ region arguments to compute which tasks can run in parallel – What region is being accessed
• Does it overlap with another region that is in use? – What field is being accessed
• If a task is using an overlapping region, is it using the same field?
– What are the privileges? • If two tasks are accessing the same field, are they both
reading or both reducing?
Legion Bootcamp 2017 52
![Page 53: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/53.jpg)
A Crucial Fact
• Regent analyzes sibling tasks – Tasks launched directly by the same parent task
• Theorem: Analyzing dependencies between sibling tasks is sufficient to guarantee sequential semantics
• Never check for dependencies otherwise – Crucial to the overall design of Regent
Legion Bootcamp 2017 53
![Page 54: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/54.jpg)
Consequences
• Dependence analysis is a source of runtime overhead
• Can be reduced by reducing the number of sibling tasks – Group some tasks into subtasks
• But beware! – This may also reduce the available parallelism
• Partitioning/3.rg
Legion Bootcamp 2017 54
![Page 55: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/55.jpg)
Partitioning/3.rg
• Note that passing a region to a task does not mean the data is copied to where that task runs – C.f., launcher task must name the parent region for
type checking reasons
• If the task doesn’t touch a region/field, that data doesn’t need to move
Legion Bootcamp 2017 55
![Page 56: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/56.jpg)
Fills
• A better way to initialize regions is to use fill operations
fill(region.field, value)
• Partitioning/4.rg
Legion Bootcamp 2017 56
![Page 57: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/57.jpg)
Multiple Partitions
Legion Bootcamp 2017 57
0
bit_region
1 2 3 4 5 0 1 2
20 elements each 10 elements each
![Page 58: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/58.jpg)
Discussion
• Different views onto the same data
• Again, can have multiple views in use at the same time
• Regent will figure out the data dependencies
Legion Bootcamp 2017 58
![Page 59: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/59.jpg)
Exercise 2
• Modify Partitioning/4.rg to
• Have two partitions of bit_region – One with 3 subregions of size 20 – One with 6 subregions of size 10
• In a loop, alternately launch subtasks on one partition and then the other
• Edit x2.rg Legion Bootcamp 2017 59
![Page 60: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/60.jpg)
Aliased Partitions
• So far all of our examples have been disjoint partitions
• It is also possible for partitions to be aliased – The subregions overlap
• Partitioning/5.rg
Legion Bootcamp 2017 60
![Page 61: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/61.jpg)
Partitioning Summary
• Significant Regent applications have interesting region trees – Multiple views – Aliased partitions – Multiple levels of nesting
• And complex task dependencies – Subregions, fields, privileges, coherence
• Regions express locality – Data that will be used together – An example of a “local address space” design
• Tasks can only access their region arguments
Legion Bootcamp 2017 61
![Page 62: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/62.jpg)
Image Blur
Legion Bootcamp 2017 62
![Page 63: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/63.jpg)
Index Notation
• First example with a 2D region
• Rect2d type – 2D rectangle – To construct: rect2d { lo, hi } – Note lo and hi are 2D points! – Fields: r.lo, r.hi – Operation: r.lo + {1,1}, r.hi – {1,1}
• The following works (modulo bounds): for x in r do r[x + {1,1}]
Legion Bootcamp 2017 63
![Page 64: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/64.jpg)
Blur
• Compute a Gaussian blur of an image
• Edit Blur/blur.rg – Search for TODO – … in two separate places … – Test with qsub rpblur.sh
• Solution is in blur_solution.rg – Also scripts for running the solution – With and without GPUs
Legion Bootcamp 2017 64
![Page 65: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/65.jpg)
Unstructured Regions
Legion Bootcamp 2017 65
![Page 66: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/66.jpg)
Regions Review
• A region is a (typed) collection
• Regions are the cross product of – An index space – A field space
• A structured region has a structured index space – E.g., int1d, int2d, int3d
Legion Bootcamp 2017 66
![Page 67: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/67.jpg)
new(…)
• Unstructured regions have a size
• But initially they have no elements
• Elements are allocated using new(…) – Occupies one (as yet) unallocated element of the
region
Legion Bootcamp 2017 67
![Page 68: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/68.jpg)
UnstructuredRegions/1.rg and 2.rg
Legion Bootcamp 2017 68
0
1
2
3
4
5
6
7
8
9
Nodes Edges
source dest id
![Page 69: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/69.jpg)
Partitioning By Field
• A field can be used as a coloring
• Write elements of the color space into the field f – Using an arbitrary computation
• Then call partition(region.f, colors) – UnstructureRegions/3.rg
Legion Bootcamp 2017 69
![Page 70: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/70.jpg)
Dependent Partitioning
Legion Bootcamp 2017 70
![Page 71: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/71.jpg)
Partitioning, Revisited
• Why do we want to partition data? – For parallelism – We will launch many tasks over many subregions
• A problem – We often need to partition multiple data
structures in a consistent way – E.g., given that we have partitioned the nodes a
particular way, that will dictate the desired partitioning of the edges
Legion Bootcamp 2017 71
![Page 72: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/72.jpg)
Dependent Partitioning
• Distinguish two kinds of partitions
• Independent partitions – Computed from the parent region, using, e.g.,
• partition(equals, … )
• Dependent partitions – Computed using another partition
Legion Bootcamp 2017 72
![Page 73: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/73.jpg)
Dependent Partitioning Operations
• Image – Use the image of a field in a partition to define a
new partition
• Preimage – Use the pre-image of a field in a partition …
• Set operations – Form new partitions using the intersection, union,
and set difference of other partitions Legion Bootcamp 2017 73
![Page 74: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/74.jpg)
Image
• Computes elements reachable via a field lookup – Can be applied to index space or
another partition – Computation is distributed
based on location of data
• Regent understands relationship between partitions – Can check safety of region
relation assertions at compile time IS1
s1 s2 s3
IS1 IS2
IS2
s1 s2 s3
LR1
Legion Bootcamp 2017 74
source partition
pointer field destination
index space
![Page 75: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/75.jpg)
Preimage • Inverse of image
– Computes elements that reach a given subspace
– Preserves disjointness
• Multiple images/preimages can be combined – Can capture complex task
access patterns
IS1
s1 s2 s3
IS1 IS2
IS2
s1 s2 s3
Legion Bootcamp 2017 75
source partition pointer
field destination index space
![Page 76: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/76.jpg)
DependentPartitioning/1.rg
• Partition the nodes – Equal partitioning
• Then partition the edges – Preimage of the source node of each edge
• For each node subregion r, form a subregion of those edges where the source node is in r
Legion Bootcamp 2017 76
![Page 77: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/77.jpg)
DependentPartitioning/2.rg
• Partition the edges – Equal partitioning
• Then partition the nodes – Image of the source node of each edge
• For each edge subregion r, form a subregion of those nodes that are source nodes in r
Legion Bootcamp 2017 77
![Page 78: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/78.jpg)
Discussion
• Note that these two examples compute (almost) the same partition
• Can derive the node partition from the edges, or vice versa
Legion Bootcamp 2017 78
![Page 79: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/79.jpg)
Exercise
• What would the example look like if we partitioned based on the destination node?
• Let’s find out … – Modify 2.rg to partition using the destination node – Code is in DependentPartitioning/x3.rg
Legion Bootcamp 2017 79
![Page 80: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/80.jpg)
Set Operations: Set Difference
• Partition the edges – Equal partition
• Compute the source and destination node partitions of the previous two examples
• The final node partition is the set difference – What does this compute? – Examples DepedendentPartitioning/4.rg & 5.rg
Legion Bootcamp 2017 80
![Page 81: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/81.jpg)
Set Operations: Set Intersection
• Partition the edges – Equal partition
• Compute the source & destination node partitions
• Final node partition is the intersection – What does this compute? – Example DependentPartitioning/6.rg
Legion Bootcamp 2017 81
![Page 82: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/82.jpg)
DependentPartitioning/7.rg
• Same as the last example
• Once the final node partition is computed, compute a partition of the edges such that each edge subregion has only the edges connecting the nodes in the corresponding node subregion
Legion Bootcamp 2017 82
![Page 83: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/83.jpg)
Some Comments on Type Checking
Legion Bootcamp 2017 83
![Page 84: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/84.jpg)
TypeChecking/1.rg
• Pointers point into a particular region – And this is part of the pointer’s type
• Partitioning can change which region(s) a pointer points to – May lead to typechecking issues, depending on
which region you want to use for an operation
Legion Bootcamp 2017 84
![Page 85: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/85.jpg)
TypeChecking/2.rg
• The right way to fix type issues is to use type casts
• Very analogous to downcasting from a more general object type to a more specific object type in an object-oriented language
• But, this solution does not currently work! – Casting of region types not yet implemented
Legion Bootcamp 2017 85
![Page 86: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/86.jpg)
TypeChecking/3.rg
• The fix/workaround is to use wild in field space arguments when allocating regions
• Wild effectively turns off typechecking for those region arguments.
Legion Bootcamp 2017 86
![Page 87: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/87.jpg)
Page Rank
Legion Bootcamp 2017 87
![Page 88: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/88.jpg)
The Algorithm
Legion Bootcamp 2017 88
• The page rank algorithm computes an iterative solution to the following equation, where – PR(p) is the probability that page p is visited – N is the number of pages – L(p) is the number of outgoing links from p – d is a “damping factor” between 0 and 1
![Page 89: Overview - Legion Programming Systemlegion.stanford.edu/pdfs/bootcamp2017/TutorialPart1.pdf · Legion Bootcamp 2017 2 . Regent/Legion Design Goals • Sequential semantics – The](https://reader031.fdocuments.net/reader031/viewer/2022030707/5af4ea087f8b9a4d4d8e52cb/html5/thumbnails/89.jpg)
Exercise
• Modify Pagerank/pagerank.rg
• Play with the partitioning of the graph • And possibly the permissions (hint!)
Legion Bootcamp 2017 89