Measuring the Speedup
Comparing naive vs tiled performance.
Measuring the Speedup is a free CUDA Academy lesson on CoddyKit — lesson 4 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.
Prove the Win
You built a tiled kernel, but how much faster is it really? Measuring turns a guess into a number you can trust. 📊
Time on the GPU's Clock
Use CUDA events to time kernels. They sit in the GPU stream and measure exactly when work starts and finishes.
cudaEvent_t start, stop;
cudaEventCreate(&start);
cudaEventCreate(&stop);Bracket the Kernel
Record an event before the launch and another after, then synchronize so the timing actually waits for the GPU to finish.
cudaEventRecord(start);
matmul<<<g,b>>>(...);
cudaEventRecord(stop);
cudaEventSynchronize(stop);Read the Elapsed Time
Ask for the gap between events in milliseconds. That single number is your kernel's measured runtime.
float ms;
cudaEventElapsedTime(&ms, start, stop);Warm Up First
The very first launch pays one-time setup costs. Run a warm-up kernel before timing so you measure steady-state speed, not startup.
Average Several Runs
One sample is noisy. Time the kernel several times and take the average for a stable, honest result.
Compute Speedup
Speedup is simply naive time divided by tiled time. A value of 4x means the tiled kernel ran four times faster.
float speedup = naive_ms / tiled_ms;Think in GFLOPS
Matmul does about 2 * N^3 floating-point operations. Divide that by your time to report performance in GFLOPS, the standard yardstick.
double gflops = (2.0*N*N*N) / (ms * 1e6);Why Tiling Wins
The speedup comes from slashing global memory traffic. Shared-memory reuse keeps the cores fed instead of waiting on slow loads.
Always Verify Correctness
A fast wrong answer is useless. Compare your GPU result against a CPU reference before you celebrate the speedup. ✅
Know Your Ceiling
Even tiled matmul trails hand-tuned cuBLAS. Knowing the gap tells you when to optimize further and when to call a library.
Quick Check
Recall the right tool for timing GPU kernels.
Recap
You timed with CUDA events, warmed up, averaged, computed speedup and GFLOPS, and verified correctness. You now prove your optimizations. 🏁
Frequently asked questions
Is the “Measuring the Speedup” lesson free?
Yes — the full text of “Measuring the Speedup” 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 “Measuring the Speedup”?
Comparing naive vs tiled performance. 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 4 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “Measuring the Speedup” 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 Naive Matmul Kernel
- Tiling the Inner Product
- Looping Over Tile Phases
- Measuring the Speedup