Count Memory Transactions for One Wavefront Access
Last updated: November 29, 2026
Quick Overview
Each lane of a 64-lane GPU wavefront issues a load of access_size bytes at its own address (or is inactive). Given the lane addresses and a cache line size, return how many distinct cache lines the wavefront touches, which approximates the number of memory transactions.
AMD
November 29, 20260
0
0 solved
Each lane of a 64-lane GPU wavefront issues a load of access_size bytes at its own address (or is inactive). Given the lane addresses and a cache line size, return how many distinct cache lines the wavefront touches, which approximates the number of memory transactions.
A technical screen in the style of AMD ROCm performance and compiler teams, where memory coalescing decides whether a HIP kernel runs at HBM bandwidth or a fraction of it. The interviewer checks that you handle accesses straddling a line boundary, inactive lanes, and that you can explain what access patterns are good or bad.
What the Interviewer Expects
- Map each access to its first and last cache line with integer division
- Count lines spanned by straddling accesses
- Skip inactive lanes
- Use a set to deduplicate lines
- Explain why stride-1 access is ideal and large strides are worst case
- State O(lanes) time for bounded access size
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would the count change for 128-byte lines?
- How would you report the efficiency ratio of useful bytes to fetched bytes?
- What compiler or kernel changes improve a strided pattern, for example transposing through LDS?
- How do you detect this pattern from a profiler trace instead of addresses?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: lane_addrs, a list of up to 64 byte addresses or None for inactive lanes, access_size in bytes, and line_size (default 64). Output: number of distinct cache lines covered by all active ...
High-Level Design
Line index of byte x is x // line_size. For each active lane compute the first and last line of its access and add every line in that range to a set. The set size is the transaction estimate. This...