Warning: Doulbe is not supported. Demoting to float Unexpected warning.

When compile a cuda code, I ran into a “Warning: double is not supported. Demoting to float”. But there is not double in my whole program. Need a explanation for this. Thanks in advance.

There probably is a double you missed. A common way is in a literal constant you don’t even think about.

float a, b, norm;



The above will give you the warning because of the literal 1.0 constant. You can use “1.0f” instead to hide the warning.

I found this is not due to a double type variable in the kernel, as mater of fact there is not double type in my kernel. It is so because I used a struct type variable in the kernel. And in the struct, there are float type and int type.

Thanks. I need test that.

Hi, SPWorley, Thanks for your suggestion. It did not show the warning in

float a, b, norm;



in my case. But use 1.0f is definitely a good suggestion.

The reason for the warning in my case is due to the usage of the struct in the kernel.

typedef struct


   float ro[3];

   float d[3];

   float t;

   int index;

} ray;

Are you sure,triston? How did you get the reason?

I’ve seen this same warning in one of my kernels, which also has no floats in it. I’ve ignored it so far, but maybe I should figure out what is going on. :)