38 template<
typename T> __device__ __host__
inline const T& f2d_fun(
const T &v) {
return v; }
40 __device__
inline double f2d_fun(
const float &v)
45 #define f2d(T, x) f2d_fun(x)
50 typedef const T& cTref;
51 __host__ __device__
static cTref cvt(cTref v) {
return v; }
55 __host__ __device__
static double cvt(
const float &v) {
return v; }
58 #define f2d(T, x) f2dstruct<T>::cvt(x)
62 template<
typename L,
int N,
typename T1,
typename T2,
typename T3>
63 __host__ __device__
inline void lprintf(
L &log,
const char (&fmt)[N],
const T1 &v1,
const T2 &v2,
const T3 &v3)
65 log.write(
MSG_PRINTF, fmt, f2d(v1), f2d(v2), f2d(v3));
68 #include "bits/gpulog_printf.h"
73 inline std::string
run_printf(gpulog::logrecord &lr)
76 using namespace gpulog;
85 char fmtbuf[1024], *fmt = fmtbuf;
96 std::ostringstream out;
97 char *p = strchr ( fmt,
'%' );
107 p += strcspn ( p,
"%cdiouxXeEfgGaAnps" );
114 char specifier = *p++;
129 sprintf(buf, format, data_int);
142 sprintf(buf, format, data_double);
149 sprintf(buf, format, data_str);
174 inline int replay_printf(std::ostream &out, gpulog::ilogstream &ls)
176 using namespace gpulog;
180 while(lr = ls.next())
191 inline int replay_printf(std::ostream &out,
const gpulog::host_log &log)
193 gpulog::ilogstream ls(log);
194 return replay_printf(out, ls);
200 #endif // lprintf_h__