[b]Hi all,
I have a question on how to use texture memory in the context I will describe below:
I have a structure:[/b]
typedef struct {
double x;
double y;
double z;
} VecR;
[b]I want to use the texture memory for a vector of elements VecR.
The size of the vector of VecR elements is N.
Is it correct to use the texture like this:[/b]
int widthTex = ceil(sqrt(N));
texture<double, 2, cudaReadModeElementType> texCoord;
texCoord.addressMode[0] = cudaAddressModeClamp;
texCoord.addressMode[1] = cudaAddressModeClamp;
texCoord.filterMode = cudaFilterModePoint;
texCoord.normalized = false;
cudaChannelFormatDesc channelDesc_V;
channelDesc_V = cudaCreateChannelDesc();
// coordDev is a vector of N elements of type VecR which resides on the device memory
cudaArray *coordCuArray;
cudaMallocArray (&coordCuArray, &channelDesc_V, 3*widthTex, widthTex);
cudaMemcpyToArray(coordCuArray, 0, 0, coordDev, sizeof(VecR)*(N), cudaMemcpyDeviceToDevice);
cudaBindTextureToArray (texCoord, coordCuArray, channelDesc_V );
and then for retrieving the elements of VecR of the element index of the vector (coordDev[index]):
VecR temp;
temp.x = tex2D(texCoord, (index)%(3*widthTex), index/widthTex);
temp.y = tex2D(texCoord, (index+1)%(3*widthTex), index/widthTex);
temp.z = tex2D(texCoord, (index+2)%(3*widthTex), index/widthTex);
[b]I cannot even compile using texture memory like this. How can I do to resolve my problem?
Does anyone have any idea for that?
Thank you in advance,
Ardita[/b]