How CUDA state suspension and resumption works
mainA process's CUDA state is initially running.
Suspension (Running $\rightarrow$ Suspended):
When cuda-checkpoint suspends CUDA:
- Lock: Any CUDA driver APIs that launch work, manage resources, or impact GPU state are locked.
- Complete: Already-submitted CUDA work (including stream callbacks) is completed.
- Copy-out: Device memory is copied to the host into allocations managed by the CUDA driver.
- Release: All of CUDA's GPU resources are released.
Note: CPU threads are not suspended and can continue to interact with CUDA by calling APIs (which may block) or accessing host memory (e.g., cudaMallocHost).
Resumption (Suspended $\rightarrow$ Running):
When cuda-checkpoint resumes CUDA:
- Acquire: GPUs are re-acquired by the process.
- Copy-in: Device memory is copied back to the GPU, and memory mappings are restored to original addresses.
- Restore: CUDA objects like streams and contexts are restored.
- Unlock: CUDA driver APIs are unlocked.
Once resumed, CUDA calls unblock and execution continues on the GPU.