cudaBindTexture2D typo in Programming Guide? A code snippet from the Programming Guide doesn't c

I took a couple of lines from the CUDA Programming Guide (v4.0, but older versions are identical for this purpose)

texture<float, cudaTextureType2D, cudaReadModeElementType> texRef;

int

main(int argc, char** argv) 

{

  float *devPtr;

const size_t width = 1024;

  const size_t height = 1024;

  const size_t pitch = width*sizeof(float);

cudaMalloc((void**) &devPtr, pitch*height);

cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc<float>();

  cudaBindTexture2D(0, texRef, devPtr, &channelDesc,

                    width, height, pitch);

}

When I try to compile above code (with nvcc 4.0), it claims that this instance of cudaBindTexture2D does not exist:

test.cu(18): error: no instance of overloaded function “cudaBindTexture2D” matches the argument list

        argument types are: (int, texture<float, 2, cudaReadModeElementType>, float *, cudaChannelFormatDesc *, const size_t, const size_t, const size_t)

It seems that both the channel description and the texture have to be passed by reference, not just the channel description. Is this a typo in the programming guide, or am I missing something?

Hi,

I have also the same problem, but i’m using v3.2 , vs2010.

The decleration in the cuda_runtime_api.h is showing the channel desc as pointer while nvcc needs this as reference.

Any help?

A little more detail may help it seems.
The installation is cuda 3.2.
now the vs2010 ide shows error in line cudaBindTextureToArray( texIP, m_fpGpuProjection, channelDesc ); , showing the channel desc should be a pointer and the decleraton for this function is “extern host cudaError_t CUDARTAPI cudaBindTextureToArray(const struct textureReference *texref, const struct cudaArray *array, const struct cudaChannelFormatDesc *desc);”
but if the usage is modifoed like cudaBindTextureToArray( texIP, m_fpGpuProjection, &channelDesc ); , nvcc will throw compilation error " error: no instance of overloaded function “cudaBindTexture2D” matches the argument list
"

Any idea?

Thank you for bringing this documentation issue to our attention. Our documentation team intends to fix this for the next CUDA release.