title: Thrust::Sort very long compile time
body: <p>I'm trying to compile a block of example code using Thrust in an attempt to help learn some CUDA. </p>
  
  <p>I'm using Visual Studio 2010, and I've gotten other examples to compile. However, when I compile this example, it takes upwards of 10 minutes to compile. I've selectively commented out lines and figured out that its the Thrust::sort line that takes forever (with that one line commented out it takes about 5 seconds to compile). </p>
  
  <p>I found a post somewhere that talked about how sort was slow to compile in Thrust and that was a decision that the Thrust development team made (its 3x faster at runtime, but takes longer to compile). But that post was in late 2008.</p>
  
  <p>Any idea why this is taking so long?</p>
  
  <p>Also, I'm compiling on a machine with the following specs, so its not a slow machine</p>
  
  <p>i7-2600k @ 4.5 ghz <br> 16 GB DDR3 @ 1833 mhz <br> Raid 0 of 6 GB/s 1TB drives</p>
  
  <p>As requested, this is the build string that it looks like Visual Studio is invoking</p>
  
  <p>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\bin\nvcc.exe" -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin"  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.2\include"  -G0  --keep-dir "Debug\" -maxrregcount=32  --machine 64 --compile  -D_NEXUS_DEBUG -g    -Xcompiler "/EHsc /nologo /Od /Zi  /MTd " -o "Debug\kernel.obj" "C:\Users\Rob\Desktop\VS2010Test\VS2010Test\VS2010Test\kernel.cpp" -clean</p>
  
  <p>Example</p>
  
  <pre><code>#include &lt;thrust/host_vector.h&gt;
  #include &lt;thrust/device_vector.h&gt;
  #include &lt;thrust/sort.h&gt;
  int main(void)
  {
      // generate 16M random numbers on the host
      thrust::host_vector&lt;int&gt; h_vec(1 &lt;&lt; 24);
      thrust::generate(h_vec.begin(), h_vec.end(), rand);
      // transfer data to the device
      thrust::device_vector&lt;int&gt; d_vec = h_vec;
      // sort data on the device
      thrust::sort(d_vec.begin(), d_vec.end());
      // transfer data back to host
      thrust::copy(d_vec.begin(), d_vec.end(), h_vec.begin());
      return 0;
  }
  </code></pre>