Texturing from CUDA array Problem with texturing from CUDA 2D array

Hello,

I have a problem accessing the texture with the tex2D(). When I use texture reference

texture<float4, 2, cudaReadModeElementType> texRefA;

and then

tex2D(texRefA, ax, bx);

everything works fine. But when I use

texture<double2, 2, cudaReadModeElementType> texRefAd;

tex2D(texRefAd, ax, bx);

I get a compilation error:

no instance of overloaded function “tex2D” matches the argument list

There is no support of texturing double2 type? Or it’s some other problem?

Indeed, I believe there is no double supported at this time.

Correct. Dig through the forums a bit and there is some example code on how to turn a float2 texture read of a region of doubles in memory into doubles in the kernel. Extending this to a float4 read -> double2 should be easy.

I thought so to. But in the Programming Guide 2.1 I found this:

texture<Type, Dim, ReadMode> texRef;

Type specifies the type of data that is returned when fetching the texture; Type

is restricted to the basic integer and single-precision floating-point types and any

of the 1-, 2-, and 4-component vector types defined in Section 4.3.1.1;

And double2 vector type is defined in Section 4.3.1.1. That’s why I’m not sure.

Maybe there’s a mistake in the Programming guide, anyway, you can use tex1Dfetch with the following trick :

texture<int4,1> tex_x_double2;

inline device double2 fetch_x(const int& i, const double2 * x)

{

     int4 v=tex1Dfetch(tex_x_double2, i);

     return make_double2(__hiloint2double(v.y, v.x),__hiloint2double(v.w, v.z));

}