title: Why does the initial execution of my CUDA program take longer than subsequent executions?
body: <p>I have test.cu file and it's compiling with NVCC </p>
  
  <pre><code>void sort()
  {
  
  thrust::host_vector&lt;int&gt; dat1(50);
  thrust::generate(dat1.begin(),dat1.end(),rand);
  
  for(int i=0; i&lt;dat1.size(); i++)
  {
      std::cout &lt;&lt; dat1[i] &lt;&lt; std::endl;
  }
  
  thrust::device_vector&lt;int&gt; dev_vec1 = dat1;
  
  
  thrust::sort(dev_vec1.begin(),dev_vec1.end());
  thrust::copy(dev_vec1.begin(),dev_vec1.end(),dat1.begin());
  
  for(int i=0; i&lt;dat1.size(); i++)
  {
      std::cout &lt;&lt; dat1[i] &lt;&lt; std::endl;
  }
  
  }
  
  
  #include "test.cuh"
  
  
  int main()
  {
     sort();
     return 0;
  }
  </code></pre>
  
  <p>but sorting on device take 40 sec.. but when I'm run it second time it's working fast.
  What's problem? </p>