Free portion of array on device?

Hello,

If I have allocated and copied an array onto the device, is there a way to free some number of elements at the end of the array?

For example, suppose I have a 200-element array on the device, I do some processing, and now I would like to free the last 50 elements.

On the CPU, I could call realloc(), but I can’t seem to find anything similar for a device. Thanks for any help.

No, CUDA doesn’t have a realloc() function, you would need to free the memory and then do another allocation.

If you need to do a lot of this, you’re probably better off allocating a big chunk up front and then doing the allocation within this block yourself.