0Pricing
CUDA Academy · Lesson

Verifying the Result on the CPU

Comparing against a reference answer.

Trust, but Verify

A kernel that runs without crashing is not proof it is correct. You must check the numbers, because silent logic bugs are easy to miss. 🔍

Compute a Reference

The simplest check is a plain CPU loop that does the same math. This reference result is your trusted source of truth.

for (int i = 0; i < n; i++)
    ref[i] = h_A[i] + h_B[i];

All lessons in this course

  1. The Vector Add Kernel
  2. Wiring Up the Host Side
  3. Verifying the Result on the CPU
  4. Timing Your First Speedup
← Back to CUDA Academy