0

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?

einpoklum
  • 118,144
  • 57
  • 340
  • 684
  • 1
    I don't think they do the same thing. A bit of fiddling with the code [here](https://stackoverflow.com/questions/62877646/what-does-cudasetdevice-do-to-a-cuda-devices-context-stack/62886715#62886715) may convince you of that. – Robert Crovella Jul 14 '20 at 02:51

1 Answers1

1

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.
einpoklum
  • 118,144
  • 57
  • 340
  • 684