Im doing an image registration on the gpu and implented it via global memory.
Now wanted to test if i can benefit from the texture memory and looked up an official example and used its code.
I didn’t expect to get the same values but not a difference of 76 between 2 elements.
What i dont understand, normaly there shouldn’t be any interpolation in case im fetching the voxel exactly (what I am doing)?
Anybody got an idea what could be the problem.
Below you find the code and the output of my comparison.
I would be really really thankful if somebody could help me.
[codebox]void copyImagetoDevice(const uchar *h_volumeA, cudaExtent volumeSizeA) {
// Copy Images to Device
// create 3D array
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<uchar> ();
cutilSafeCall( cudaMalloc3DArray(&d_volumeA, &channelDesc, volumeSizeA) );
// copy data to 3D array
cudaMemcpy3DParms copyParams = { 0 };
copyParams.srcPtr = make_cudaPitchedPtr((void*) h_volumeA, volumeSizeA.width * sizeof(uchar), volumeSizeA.width, volumeSizeA.height);
copyParams.dstArray = d_volumeA;
copyParams.extent = volumeSizeA;
copyParams.kind = cudaMemcpyHostToDevice;
cutilSafeCall( cudaMemcpy3D(©Params) );
// set texture parameters
texA.normalized = false; // access with normalized texture coordinates
texA.filterMode = cudaFilterModeLinear; // linear interpolation
texA.addressMode[0] = cudaAddressModeClamp; // wrap texture coordinates
texA.addressMode[1] = cudaAddressModeClamp;
texA.addressMode[2] = cudaAddressModeClamp;
// bind array to 3D texture
cutilSafeCall(cudaBindTextureToArray(texA, d_volumeA, channelDesc));
}[/codebox]
Then i wrote an method too compare the values of my array with the ones of the texture memory:
0 → no difference (with little tolerance)
1 → difference between two elements was 1
…
difference[0]: 6102472
difference[1]: 493923
difference[2]: 231352
difference[3]: 145625
difference[4]: 109717
difference[5]: 90542
difference[74]: 3
difference[75]: 0
difference[76]: 2