title: CUDA thrust: copy from device to device
body: <p>I have a memory array allocated in CUDA using standard CUDA malloc and it is passed to a function as follows:</p>
  
  <pre><code>void MyClass::run(uchar4 * input_data)
  </code></pre>
  
  <p>I also have a class member which is a thrust device_ptr declared as:</p>
  
  <pre><code>thrust::device_ptr&lt;uchar4&gt; data = thrust::device_malloc&lt;uchar4(num_pts);
  </code></pre>
  
  <p>Here num_pts is the number of values in the array and the input_data pointer is guaranteed to be num_pts long.</p>
  
  <p>Now, I would like to copy the input array into the thrust_device_ptr. I have looked at the thrust documentation and a lot of it is talking about copying from device to host memory and vice versa. I was wondering what would be the most performance optimal way to do this device to device copy on thrust or should I just use cudaMemcpy?</p>