use of printf() with single precision floating: how to avoid conversion to double?


is there a way to prevent a printf("%f", fp32variable) inside a CUDA kernel from casting the float arguments to double?

I am using the following PTXAS option to detect unintended use of double in my code, but on pretty much any printf statement that puts a float in the argument list the warning will get triggered.

--warn-on-double-precision-use                      (-warn-double-usage)        
        Warning if double(s) are used in an instruction.

ok, my temporary workaround is to neuter all printfs in the .cu module temporarily with this macro hack.

#if 1
#define printf(...) myprintf()

__host__ __device__ int myprintf ()
    /*... no-op ... */

No, there is no way to prevent that. In variable argument functions (those having … in the prototype), floats are always converted (coerced) to doubles in the C and C++ languages.