This function only operates on the relocated memory whose new location is specified by ‘targetAccel’. optixAccelRelocate also returns the new OptixTraversableHandle associated with ‘targetAccel’. The memory pointed to by ‘targetAccel’ should be allocated with the same size as the source acceleration.
I think targetAccel is used to store the buffer generated after relocating. Why should we use the cudaMemcpy method to set targetAccel in the code sample?
This code sample is just copying an already built AS which resides in d_gasOutputBuffer to another device location d_relocateGas.
That new device pointer is the value for the optixAccelRelocate targetAccel argument which will patch up the pointers stored inside that copy in-place so that it works at that new device address d_relocateGas and returns the new traversable handle inside the targetHandle output argument.
After that step you have two identical GAS in d_gasOutputBuffer and d_relocateGas and their respective traversable handles.
Of course you wouldn’t actually do that, because that just wastes memory. It’s only an example of how to use the API.