Hi
I have inherited some CUDA code which assigns memory on the device using cudaMallocManaged. This is preformed in a function called Resize which resizes the device vector. Initially the vector is NULL and empty, and the vector is incremented one element at a time, and cudaMallocManaged is called to increase the size of the vector an element at a time. However the pointer passed to the call to cudaMallocManaged is always the same (which is a protected member called _data of a class called cudaVector written by whoever wrote the code I have inherited).
My question is: is this method of incrementing the device vector OK? Should I instead create a new pointer, pass that new pointer to cudaMallocManaged, copy the data in the old pointer to the new pointer, delete the old pointer, then assign the protected pointer to the new pointer? I know this is an efficient way to initialise device vectors, but the pointers in the inherited code that cause problems are all assigned by cudaMallocManaged.
What happens to the memory in the current method of resizing described above?
Thanks.