The Data Reuse Problem
Why naive kernels re-read global memory.
The Data Reuse Problem is a free CUDA Academy lesson on CoddyKit — lesson 1 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the CUDA Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
The Hidden Cost
A kernel can be correct yet slow because it keeps fetching the same data from slow global memory over and over. 🐢
Memory Is the Bottleneck
On the GPU, arithmetic is cheap but reaching global memory is expensive. Many kernels wait on memory far more than they compute.
Data Reuse Defined
Data reuse means one value loaded from global memory is used by many computations instead of being read again each time.
A Naive Stencil
Picture blurring an image. Each output pixel averages its neighbors, so every input pixel gets read by several different threads.
out[i] = (in[i-1] + in[i] + in[i+1]) / 3.0f;Counting the Reads
In that blur, the value in[i] is read by threads i-1, i, and i+1. The same byte travels across the slow PCIe-fed bus three times.
Redundancy Adds Up
With a wider window or a 2D grid, each element may be re-read dozens of times. This redundant traffic dominates the runtime.
Bandwidth Is Finite
Global memory has a fixed peak bandwidth. Reading the same data repeatedly wastes that budget on bytes you already had.
Compute Sits Idle
While warps stall waiting on repeated global loads, the math units sit idle. You paid for cores you are barely using. 😴
Arithmetic Intensity
Arithmetic intensity is the ratio of math operations to bytes moved. Low intensity means memory, not compute, limits you.
The Goal: Read Once
The fix is to load each needed value once into fast on-chip storage, then let many threads reuse it from there.
Enter Shared Memory
That fast on-chip storage is shared memory. Staging data there is the foundation of every tiling optimization ahead.
Quick Check
Why is a naive stencil kernel often slow?
Recap
Naive kernels re-read shared data from global memory, wasting bandwidth and stalling compute. Tiling exists to load once and reuse. ✅
Frequently asked questions
Is the “The Data Reuse Problem” lesson free?
Yes — the full text of “The Data Reuse Problem” is free to read here on the web, and the CUDA Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the CUDA Academy course, upgrade to CoddyKit PRO.
What will I learn in “The Data Reuse Problem”?
Why naive kernels re-read global memory. You practise CUDA Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start CUDA Academy?
No prior experience is required. CUDA Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 1 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “The Data Reuse Problem” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this CUDA Academy lesson?
Yes. Every CUDA Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- The Data Reuse Problem
- The Load-Sync-Compute Pattern
- Stencil and Sliding Windows
- Handling Edge Tiles