Bartvbl
Bartvbl

Reputation: 2928

Can I shorten a CUDA allocated buffer?

I'm implementing an algorithm on the GPU using CUDA which is certain to give incorrect results when a specific input buffer (3D float vectors) contains duplicate entries. For this reason I want to do a pre-processing step to remove any duplicates which are present.

Since I know the input data contains a significant number of duplicates, explicitly trimming the buffer can free up much needed memory for some of the processing steps. Since I have a lot of data to work with, I intend to do this in place within the already allocated buffer.

Does CUDA have a mechanism which allows the end of a cudaMalloc()'d buffer to be trimmed and freed?

Upvotes: 0

Views: 166

Answers (1)

talonmies
talonmies

Reputation: 72349

What you are asking about is the equivalent of a "realloc" function, and no such functionality exists in either the runtime or driver APIs.

Also note that cudaMalloc and cudaFree probably do not work the way you might imagine, and freeing memory will not necessarily change the amount of available free memory on the device.

Upvotes: 1

Related Questions