Reputation: 132290
Mark Harris wrote here once - albeit 9 years ago by now - that:
In fact
cudaFree(0)
is commonly used to initialize the CUDA context!
and I see this (somewhat questionable) idiom used in this example program repository of NVIDIA's, used in presented in this year's GTC.
So, is cudaFree(0)
guaranteed to actually do anything?
Upvotes: 0
Views: 1555
Reputation: 132290
Following the sages' comments:
The documentation, if anything, suggests no action. Empirically, using cudaFree(0)
, possibly after a cudaSetDevice()
, forces the establishment of a context. I would speculate it does something similar to cuDevicePrimaryCtxRetain()
(which is what one might use in a naive implementation of cudaFree()
using the driver API).
Upvotes: 1