title: cuda array sorting with thrust, not enough memory
body: <p>I'm trying to sort an array using Thrust, but it doesn't work if the  array is too big. (I have a GTX460 1GB memory)</p>
  
  <p>I'm using cuda with c++ integration on VS2012, Here is my code :</p>
  
  <p>my .cpp</p>
  
  <pre><code>extern "C" void thrust_sort(uint32_t *data, int n);
  
  int main(int argc, char **argv){
      int n = 2&lt;&lt;26;
      uint32_t * v = new uint32_t[n];
      srand(time(NULL));
      for (int i = 0; i &lt; n; ++i) {
          v[i] = rand()%n;
      }
  
      thrust_sort(v, n);
  
      delete [] v;
      return 0;
  }
  </code></pre>
  
  <p>my .cu</p>
  
  <pre><code>extern "C"
  void thrust_sort(uint32_t *data, int n){
      thrust::device_vector&lt;uint32_t&gt; d_data(data, data + n);
      thrust::stable_sort(d_data.begin(), d_data.end());
      thrust::copy(d_data.begin(), d_data.end(), data);
  }
  </code></pre>
  
  <p>The program stop working at the start of stable_sort().</p>
  
  <hr>
  
  <ol>
  <li>How much more memory does stable_sort() need ? </li>
  <li>Is there a way to fix this ? (even if it makes it a bit slower or whatever)</li>
  <li>Is there another sorting algorithm that doesn't require more memory than the original array ?</li>
  </ol>
  
  <hr>
  
  <p>Thanks for your help :)</p>