Swap device Pointers

Hi guys :)

I’m really sorry for the very basic question but I cannot find a straight answer on any of the online resources I have checked.

I am writing some code in cuda that ‘ping pongs’ on two sets of data, reading from one and writing to the other.

What I need to know is does the following piece of code actually work on DEVICE pointers in cuda. This is memory that has already been allocated on the device. I call the below in a method at the start of each frame.

cData* temp = d_data;
d_data= d_dataOld;
d_dataOld= temp;

If not can you suggest alternatives to simply changing which pointers I send to the kernels - I prefer to avoid that method in order to keep the code easy to read!

Thanks :)

It works. A pointer in C is just a number.

A DEVICE pointer in cuda is just a C pointer, after all. There’s no magic here.

Fantastic news, thank you :)