Overloading __host__ and __device__ function

Hi everyone.

I can’t believe it, but i can’t find a solution to overload function for host and device,

what i mean is:

device void func();
host void func();

that will produce an error: func has already been defined.

really, there is no possibility to make different functions’ version for HOST and DEVICE?

or at least some macro:
host device
void
func() {
#if HOST
(some HOST code… for example calling pure host functions)
#else
(DEVICE code)
#endif
}

as i know, complier creates separate functions’ version for device and host, so…
why they cannot be different?

Please, help me :( i really need this functionality

That macro does indeed exist. CUDA_ARCH is only defined when compiling for the device:

__host__ __device__ 
void
func() {
#ifdef __CUDA_ARCH__
    (DEVICE code)
#else
    (some HOST code.. for example calling pure host functions)
#endif
}

Thank You veryyyyy much :***

You solved my problem :)