some wrong values in texture (using tex2D)

Hi all. I’m a newbie here, please help me.

I’m storing 80x160 float data into a 2D texture using the following code

texture<float, 2, cudaReadModeElementType> tex;

float * landdata;

cudaArray* cu_array;

cudaChannelFormatDesc channelDesc;

unsigned int size = meshW * meshH * sizeof(float);

...

channelDesc = cudaCreateChannelDesc(32, 0, 0, 0,cudaChannelFormatKindFloat);

cutilSafeCall( cudaMallocArray( &cu_array, &channelDesc, meshW, meshH ));

cutilSafeCall( cudaMemcpyToArray( cu_array, 0, 0, landdata, size, cudaMemcpyHostToDevice));	

tex.addressMode[0] = cudaAddressModeWrap;

tex.addressMode[1] = cudaAddressModeWrap;

tex.filterMode = cudaFilterModePoint;

tex.normalized = true;	

cudaBindTextureToArray( tex, cu_array, channelDesc);

...

// read texture in kernel

__global__ void landKernel(float4* pos, unsigned int width, unsigned int height)

{

unsigned int i = blockIdx.x*blockDim.x + threadIdx.x;

unsigned int j = blockIdx.y*blockDim.y + threadIdx.y;

//calculate pos coordinates

float posi = i / (float) width;

float posj = j / (float) height;

float y = tex2D(tex, posi, posj);

...

}

but I’ve checked it contains some wrong values. Could you tell me where I’m going wrong ? Currently, I’m using a GeForce 8400M G 128MB.

argh… it’s solved now. :D