I have a Monte Carlo simulation code that uses instances of a mutable struct that contain arrays. These arrays can be really large when the number of particles in the simulation increase. In the code, I have one instance (call it W1) of that struct, and at the end of an iteration I need to create a new instance (call it W2) where I have to copy only one array from W1. But prior to copying, I have to initialize to zero all arrays in W2.
Trouble is that I run out of GPU memory when initializing (filling with 0.f0) W2 WHILE W1 is still there. So my question is this: is there a way to explicitly kill W1, freeing GPU memory, before creating W2? If that was the case, I could simply copy from W1 the array I need to copy to W2, then delete W1, Initialize W2, copy the stored array, and go…
Thanks a lot,