2D Texture Fetches not working on GPU Fetch working in emu mode only!

I need to perform a 2D texture fetch in CUDA, i am able to do so only in emu mode.

When trying to run on GPU, it looks like the Memcopy function is failing, as I am getting only Zero Values on copy-back

I am working with a 2D array of float2’s

My code is below:

//Declared Globally

texture<float2, 2, cudaReadModeElementType> tex;   



//Host-Side Code

       cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc <float2>();

        cudaArray *Ad;

        float2 *Bd;

       int size=h*w*sizeof(float2);

        CUDA_SAFE_CALL( cudaMallocArray(&Ad,&channelDesc,w,h));


        CUDA_SAFE_CALL( cudaMemcpyToArray( Ad,0,0, A, size, cudaMemcpyHostToDevice));

       tex.addressMode[0] = cudaAddressModeWrap;

        tex.addressMode[1] = cudaAddressModeWrap;

        tex.filterMode = cudaFilterModePoint;

        tex.channelDesc = channelDesc;

        tex.normalized = false;

       CUDA_SAFE_CALL( cudaBindTextureToArray(tex,Ad));



         //Launch Kernel - using tex2d to fetch inside kernel,

         //write result back to B (in global memory)






The texture fetches are working in emu mode but not on the GPU.

I even tried a simple copy to the cudaArray and back to host, but even that doesn’t work on the GPU, it works fine in emu mode.

Can anyone throw some light on why the cudaMemcopyArray might be failing or if its some other issue?

Personally I have the following i my code where I use a 2D texture:

CUDA_SAFE_CALL( cudaBindTextureToArray( tex, array, channelDesc));

So it looks like you missed an input-parameter, the rest looked the same as here.

You should compile in debug mode, so you get the error-message printed on screen because you use CUDA_SAFE_CALL

I tried this, but to no avail.

On debug, the error I get is:

Cuda error in file ‘mattrans.cu’ in line : feature is not yet implemented.

This error refers to line where I called cudaMallocArray. I’m using the BETA 2.0 Toolkit by the way, did not try on 1.1 yet. Has any major change been done to the texturing functions in the API?

You can get “Feature is not yet implemented” if your driver version and CUDA toolkit version don’t match. Try re-installing the CUDA 2.0 beta drivers or switch to CUDA 1.1. Unless you need 3D textures, 9800 GX2, or Vista support, there isn’t any real advantage to CUDA 2.0 right now.

Exactly, problem solved! Thanks…