I am getting this error “calling a device function from a host function is not allowed” but I am not sure what’s wrong, here is the code:
class dlbool {
int dvalue;
__device__ explicit dlbool(int v) : dvalue(v) { }
public:
__device__ dlbool() : dvalue(0) { }
__device__ dlbool(bool x) : dvalue((int)x*2-1) { }
__device__ int dtoInt(void) const { return dvalue; }
__device__ bool operator == (const dlbool& dother) const { return dvalue == dother.dvalue; }
__device__ bool operator != (const dlbool& dother) const { return dvalue != dother.dvalue; }
__device__ dlbool operator ~ (void) const { return dlbool(-dvalue); }
__device__ friend int dtoInt (dlbool l);
__device__ friend dlbool dtoLbool(int v);
};
__device__ inline int dtoInt (dlbool l) { return l.dtoInt(); }
__device__ inline dlbool dtoLbool(int v) { return dlbool(v); }
const dlbool dl_True = dtoLbool( 1);
const dlbool dl_False = dtoLbool(-1);
const dlbool dl_Undef = dtoLbool( 0);
The error I am getting (actually 3 errors) are from the last 3 lines. I know that “dtoLbool” is the one causing the error but I don’t see where the host here since everything is declared device. The code is part of a .cuh file. Your help is much appreciated…