einpoklum
einpoklum

Reputation: 131533

Do cuDevicePrimaryCtxReset() and cudaDeviceReset() do the same thing?

Reading the CUDA Runtime API and Driver API docs, it seems that the two functions:

CUresult cuDevicePrimaryCtxReset ( CUdevice dev );
__host__ ​cudaError_t cudaDeviceReset ( void );

do the same thing (upto having to cudaSetDevice(dev) before the runtime API call):

Destroy all allocations and reset all state on the primary context.

for the first and

Destroy all allocations and reset all state on the current device in the current process.

Do they, indeed, do the same? Or are there perhaps subtle differences that I'm missing or that aren't documented? e.g. something related to threads-vs-processes?

Upvotes: 0

Views: 343

Answers (1)

einpoklum
einpoklum

Reputation: 131533

They're quite different.

Examining the program @RobertCrovella linked to, it seems that:

  • cuDevicePrimaryCtxReset() only destroys/resets the primary context, not touching other contexts.
  • cudaDeviceReset() destroys all contexts for the specified device, removing them from the context stack.

Upvotes: 1

Related Questions