tex1Dfetch a float from a texture? without it being normalized?

Hi

Right now I’m doing the following:

//global memory

texture<float, 2, cudaReadModeElementType> neighbourTexture;

.....

float* neighbours = NULL;

CUDA_SAFE_CALL( cudaMalloc( (void**) &neighbours, numberOfParticles*numberOfParticles*sizeof(float)));

// Here are a few kernels to write into the neighbours array

	

cudaBindTexture(0, neighbourTexture, neighbours, numberOfParticles*numberOfParticles);

.........

//error here

tex1Dfetch(neighbourTexture,(int)(numberOfParticles*id+i))

The error is the following:

(296): error: no instance of overloaded function "tex1Dfetch" matches the argument list

argument types are: (texture<float, 2, cudaReadModeElementType>, int)

Am I not allowed to make a texture of floats?

texture<float, 2, cudaReadModeElementType>

You are declaring a 2 dimensional texture and attempting to read it with tex1Dfetch. Either declare the texture as 1-dimensional or read it with tex2D.

Oh I see. That was pretty dumb of me.

thx!

It’s easy to do. I think we should probably replace that integer value in the texture definition with an enum - cudaTexture1D, cudaTexture2D, cudaTexture3D, cudaCubemap etc.