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
- The Vector Add Kernel
- Wiring Up the Host Side
- Verifying the Result on the CPU
- Timing Your First Speedup