Explain GPU Register Spills and Their Performance Cost
Company: AMD
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Onsite
What is a register spill in a GPU kernel, why does it happen, and how would you determine whether it is hurting performance?
### Constraints & Assumptions
Discuss compiler-managed per-thread registers and the storage used when values cannot remain in registers. Do not confuse a spill with explicitly declared shared/local scratchpad memory; terminology differs across programming systems.
### Clarifying Questions
What is the kernel's register usage and live-variable pressure? Is occupancy limited by registers? Does the compiler report spills? What memory traffic and stalls appear in profiling?
### What a Strong Answer Covers
Live ranges, finite register allocation, spill loads/stores, occupancy tradeoffs, and changes justified by measurements.
### Follow-up Questions
Can forcing a lower register limit make a kernel slower? How can unrolling or large local arrays affect pressure? When might recomputation be cheaper than preserving a value?
Overview: Explain GPU register spills through live-variable pressure, compiler allocation, spill traffic, occupancy tradeoffs, and measured optimization choices.
What is a register spill in a GPU kernel, why does it happen, and how would you determine whether it is hurting performance?
Constraints & Assumptions
Discuss compiler-managed per-thread registers and the storage used when values cannot remain in registers. Do not confuse a spill with explicitly declared shared/local scratchpad memory; terminology differs across programming systems.
Clarifying Questions Guidance
What is the kernel's register usage and live-variable pressure? Is occupancy limited by registers? Does the compiler report spills? What memory traffic and stalls appear in profiling?
What a Strong Answer Covers Guidance
Live ranges, finite register allocation, spill loads/stores, occupancy tradeoffs, and changes justified by measurements.
Follow-up Questions Guidance
Can forcing a lower register limit make a kernel slower? How can unrolling or large local arrays affect pressure? When might recomputation be cheaper than preserving a value?