GPU Programming
Which processing tends to run inefficiently on a GPU?
- AWalking a linked list one node at a time, changing behavior based on each element's value
- BElement-wise addition of two large arrays
- CDoubling the brightness of every pixel in a large image
Show answer and explanation
Answer: A. Walking a linked list one node at a time, changing behavior based on each element's value
In a linked list the next element's location is unknown until the current one is read, so it cannot be traversed in parallel. If behavior also depends on values, threads within a lockstep group diverge, lowering efficiency, and scattered memory locations prevent combined reads. GPUs suit work that is independent per element and applies the same operation to data at consecutive addresses.
- A. Correct. It cannot be parallelized and involves many branches.
- B. Each element is independent, so it suits a GPU.
- C. Each pixel is independent, so it suits a GPU.