hash join
hash join

Reputation: 83

How to efficiently overwrite the memory region on GPU?

I allocate the data block on GPU. And I have an algorithm to generate new data to replace the old one. The new buffer has the same data size. There is a solution is to bring the old data back to the cpu and then erase it but I think that’s highly inefficient and very slow. Is it possible to overwrite the old element with the new data at the same location?

Upvotes: 0

Views: 215

Answers (1)

Michael
Michael

Reputation: 2414

If your kernels accept a pointer that's pointing to some buffer region, you may be able to just pass the original data pointer to that kernel, causing your input data to be overwritten by the results of the kernel.

Or if you're working with an algorithm that requires using a buffer, you could use cudaMemcpy to copy the results stored in the buffer to the region of memory holding your input data, overwriting it in the process.

Upvotes: 1

Related Questions