liveBook · Manning

cudaGetLastError

As explained in Grokking GPU Programming

cudaGetLastError is a CUDA runtime API function that returns the latest CUDA error status for the calling host thread.

A kernel launch can fail without updating its output, leaving old or stale data. Call `cudaGetLastError()` immediately after a launch to check for an error. section 3.16 section 11.12

Catch an oversized shared-memory request

If a kernel requests more shared memory per block than the hardware allows, its launch fails and the output may remain stale. Check with `cudaGetLastError()` after the launch to catch the failure. section 11.12

How Grokking GPU Programming covers it

How deep it goes
Shows when to check and the failure symptoms, but does not detail error-code interpretation.
Examples
Uses oversized thread blocks and excessive shared-memory requests as kernel-launch failure cases.
What you can do after
Diagnose launch failures by checking immediately after kernel launches with `cudaGetLastError()`.
How it connects
Links kernel launches and shared-memory limits, and notes occupancy effects from large legal allocations.

This explainer was generated by Manning's knowledge graph from the text of Grokking GPU Programming. The section links point to the parts of the book it draws on.