title: thrust in cuda kernel
body: <p>I have cuda 8.0 installed on my machine (Linux SL7 ) also, I have downloaded the thrust 1.8.1 and replace the existing thrust library with the new 1.8.1.</p>
  
  <p>As far as I know starting from thrust 1.8 thrust is supported and can be used in the kernels. I quote from their website :</p>
  
  <blockquote>
    <p>Thrust 1.8.0 introduces support for algorithm invocation from CUDA
    __device__ code, support for CUDA streams, and algorithm performance improvements. Users may now invoke Thrust algorithms from CUDA
    __device__ code</p>
  </blockquote>
  
  <p>however, when I build the application using the Nsight eclipse, it shows me this error:</p>
  
  <blockquote>
    <p>calling a __host__ function("thrust::sort") from a __global__
    function("mykernel") is not allowed.</p>
  </blockquote>
  
  <p>Please any advise?</p>
  
  <p>here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;numeric&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;cuda_runtime.h&gt;
  #include &lt;cuda.h&gt;
  #include &lt;thrust/sort.h&gt;
  #include &lt;thrust/execution_policy.h&gt;
  
  __global__ void mykernel(int* a, int* b)
  {
  
  thrust::sort(a, a + 10);
  }
  
  int main(void)
  {
      int a[10] = { 0, 9, 7, 3, 1, 6, 4, 5, 2, 8 };
      int b[10];
      int *d_a, *d_c;
  
      cudaMalloc((void**)&amp;d_a, 10 * sizeof(int));
      cudaMalloc((void**)&amp;d_c, 10 * sizeof(int));
  
      std::cout &lt;&lt; "A\n";
      for (int i = 0; i &lt; 10; ++i) {
          std::cout &lt;&lt; a[i] &lt;&lt; "  ";
      }
  
      cudaMemcpy(d_a, a, 10 * sizeof(int), cudaMemcpyHostToDevice);
      mykernel&lt;&lt;&lt;1, 1&gt; &gt; &gt;(d_a, d_c);
      cudaMemcpy(a, d_c, 10 * sizeof(int), cudaMemcpyDeviceToHost);
      std::cout &lt;&lt; "\nA\n";
      for (int i = 0; i &lt; 10; ++i) {
          std::cout &lt;&lt; a[i] &lt;&lt; "  ";
      }
  
      cudaFree(d_a);
      cudaFree(d_c);
      return 0;
  }
  </code></pre>