title: Use of Cuda Thrust device_vector crashes
body: <p>Below I've posted some code that I'm using to try and get a feel for the CUDA thrust library. Before anyone says anything I know this is an extremely inefficient way to find prime numbers, I just want something to test parallelism. Unfortunatly when I run this I get an error here is what pops up:
  <code>Unhandled exception at at 0x76FCC41F in Thrust_2.exe: Microsoft C++ exception: thrust::system::system_error at memory location 0x0022F500.</code></p>
  
  <p>If I switch the <code>device_vector</code> to a <code>host_vector</code> in the doTest function I no longer get the error and the program works flawlessly. Why does this happen and how can I get it to use the device_vector without crashing? I would like to do as much in parallel is possible.
  Also the entire program works as intended with a host_vector.</p>
  
  <p>PS: </p>
  
  <p>I'm using VS2012</p>
  
  <p>Cuda: V5.5 </p>
  
  <p>GPU: geforce gt 540M</p>
  
  <p>Thrust: Got with cuda.</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>  struct prime{
  __host__ __device__
      void operator()(long&amp; x){
      bool result = true;
      long stop = ceil(sqrt((float)x));
      if(x%2!=0){
          for(int i = 3;i&lt;stop;i+=2){
              if(x%i==0){
                  result = false;
                  break;
              };
          }
      }else{
          result = false;
      }
      if(!result)
          x = -1;
   }
  };
  void doTest(long gen){
    using namespace thrust;
    device_vector&lt;long&gt; tNum(gen);
    sequence(tNum.begin(),tNum.end()); // fails here when using a device_vector
  }
  int main(){
     doTest(1000);
     return 0;
  }
  </code></pre>