Ray tracing
- Want to render a scene using ray tracing
- Generate rays through pixels in the image plane
- The rays bounce from objects following reflection/refraction laws
- New rays get generated: tree of rays from a root ray
- Need to correctly simulate paths of all rays
- The outcome is color and opacity of the objects in the scene: thus you render a scene
- Concurrency across ray trees and subtrees
Writing a parallel program
- Start from a sequential description
- Identify work that can be done in parallel
- Partition work and/or data among threads or processes
- Decomposition and assignment
- Add necessary communication and synchronization
- Map threads to processors (Mapping)
- How good is the parallel program?
- Measure speedup = sequential execution time/parallel execution time = number of processors ideally
Some definitions
- Task
- Arbitrary piece of sequential work
- Concurrency is only across tasks
- Fine-grained task vs. coarse-grained task: controls granularity of parallelism (spectrum of grain: one instruction to the whole sequential program)
- Process/thread
- Logical entity that performs a task
- Communication and synchronization happen between threads
- Processors
- Physical entity on which one or more processes execute
Decomposition of Iterative Equation Solver
- Find concurrent tasks and divide the program into tasks
- Level or grain of concurrency needs to be decided here
- Too many tasks: may lead to too much of overhead communicating and synchronizing between tasks
- Too few tasks: may lead to idle processors
- Goal: Just enough tasks to keep the processors busy
- Number of tasks may vary dynamically
- New tasks may get created as the computation proceeds: new rays in ray tracing
- Number of available tasks at any point in time is an upper bound on the achievable speedup
|