Texture fetching for double precision floats

Hi, all,

I have a question about reading “double” from texture memory. I want to bind texture memory on a double precision floats array and fetch their values in kernels.

I saw its answer from CUDA2.1 FAQ BUT the solution does not work for me…

[b]

texture<int2,1> my_texture;

static inline device double fetch_double(texture<int2, 1> t, int i)

{

int2 v = tex1Dfetch(t,i);

return __hiloint2double(v.y, v.x);

}[/b]

This is the code given by 2.1 FAQ.

And I bind texture

by

[b]cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(64, 0, 0, 0, cudaChannelFormatKindFloat);

cudaBindTexture(0, texRef, d_x, channelDesc);[/b]

d_x is a device memory ptr of type double.

I put 64 there coz it is the size of a double var,

and cudaChannelFormatKindFloat ? (not sure here)

And I did exactly the same thing in kernel as shown in the code given by 2.1 FAQ

Any suggestion?

Thanks a lot!

Textures only support up to 32-bits per channel, which is why we’re using the int2 type (2 x 32 bits) to store doubles. So you need to declare the channel format as something like:

cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 32, 0, 0, cudaChannelFormatKindSigned);

Textures only support up to 32-bits per channel, which is why we’re using the int2 type (2 x 32 bits) to store doubles. So you need to declare the channel format as something like:

cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 32, 0, 0, cudaChannelFormatKindSigned);