title: Can a __host__ __device__ function know where it is executing?
body: <p>I would like to write some functions that are both host and device compatible, and change the execution depending on whether the code is being executed on the device or the host. I am trying to write a class that will be used both on the device and host, and hide the distinction from the user.</p>
  
  <p>If there is no way to do this, does anybody have suggestions on how to accomplish this goal?</p>
  
  <p>i.e.</p>
  
  <pre><code>__host__ __device__ void foo(){
      bool executingOnHost = // how do I figure this out?
  
      if( executingOnHost)
          // do stuff using host pointers
      else
          // do stuff with device pointers  
  }      
  </code></pre>