I want to ask whether calling to cudaFree after some asynchronous calls is valid? For example
int* dev_a;
// prepare dev_a...
// launch a kernel to process dev_a (asynchronously)
cudaFree(dev_a);
In this case, since kernel launch is asynchronous, when the cudaFree part is reached, the kernel may haven't finish running yet. Then will the cudaFree(dev_a) immediately after it destroy the data?