Master the fundamental concepts of gpu architecture through this focused micro-challenge.
A modern GPU can issue hundreds of billions of floating-point operations per second, but global memory bandwidth is typically 1-2 terabytes per second. With thousands of concurrent threads, each thread gets only a thin slice of that bandwidth unless accesses are merged efficiently.
Memory coalescing is the mechanism that combines requests from threads in the same warp into as few cache-line transactions as possible. Coalescing is about transaction count, not bytes transferred.
Consider 32 threads in a warp, each reading a 4-byte integer with 128-byte cache lines:
cLoading…
For example, in pattern (a), threads 0-31 read addresses base+0 through base+124, all within one 128-byte line. In pattern (b), each thread touches a different line despite requesting the same total bytes.
You will implement a transaction counter for coalesced, strided, and misaligned patterns, then compare row-major vs column-major matrix reads. This task requires you to print a summary table with efficiency percentages. The analysis you build here is the same reasoning CUDA kernel authors apply when nvcc warns about uncoalesced global loads.
Write a C program that simulates memory coalescing and calculates transaction counts.
Requirements:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github