define whether compiled for host or device

Hi,

I’m trying to overload operator* for the float2 data type.

host device inline float2 operator*(const float2 a, const float2 B)
{

}

Now, I need to call __fmul_rn() on device, which is not defined on host.
Is there any way to exclude __fmul_rn() invocation on host? Any define like HOST or DEVICE?

Thanks a lot,
Agnonchik.

device functions do not support the complete set of C++. I think that you couldn’t overload an operator as a device function.

I only know of such define for DEVICE_EMULATION, but that is not equivalent to host code.

How about defining your own __fmul_rn() host function? Will that take precedence over the device implementation?

Christian

Sorry,

I didn’t understand the question. What Agnonchik said makes really sense.

What I was trying to say is that if __fmul_rn() is not available as a host function, then try to define and implement your own host __fmul_rn() that simply

takes two floats a and b and returns a*b. If you are lucky, this will not collide with the existing device function __fmul_rn() and it may allow you to use this intrinsic also in host code.