I want to implement a shift operation for a volume texture in CUDA. I thought of an implementation that does several iterations of a memcpy-operation that moves data inside a cudaArray from one position to another.
What am I doing wrong, because I always get the invalid argument error? Here is a sketch of what I am doing:
/* My volume texture */
cudaArray* g_pVolumeTexture // its size is 256^3 voxels of type uchar2
...
cudaMemcpy3DParms prms;
prms.srcArray = g_pVolumeTexture;
prms.dstArray = g_pVolumeTexture; // src = dst, because I wanna rather shift than
// copy
prms.extent = make_cudaExtent(24, 256, 256);
prms.srcPos = make_cudaPos(0, 0, 0);
prms.dstPos = make_cudaPos(48, 0, 0); // this will mean a move of 48 voxels in
// x-direction; the piece of data moved
// measures 24 voxels in x-direction
cudaMemcpy3D(&prms);
// Here cudaGetLastError always returns 'invalid argument error'
The answer is yes: It is possible to use the Memcpy3D command with same srcArray as dstArray. The problem I faced appeared due to the nonexistance of an initial reset of the cudaMemcpy3DParms with: