title: using array[i][j] in a CUDA kernel memcpy call
body: <p>I have an array that is of the following design: <code>color[100][3]</code>. I want to populate this array in a kernel and then use it in host code. How can I accomplish this? I simply need the <code>cudaMemcpy()</code> call to send and get.</p>
  
  <p>This is what I have to send to device:</p>
  
  <pre><code>err = cudaMallocPitch(&amp;d_color, &amp;pitch, 3 * sizeof(unsigned char),100);
  </code></pre>
  
  <p>This is what I have now to get it from device (Edited):</p>
  
  <pre><code>err = cudaMemcpy2D(color,100*3,d_color,pitch,3 *sizeof(unsigned char),3, cudaMemcpyDeviceToHost);
  </code></pre>
  
  <p>The last call of cudaMemcpy2D throws an error of: </p>
  
  <blockquote>
    <p>"Invalid Argument"</p>
  </blockquote>
  
  <p>How do I get the pitch of the <code>color[100][3]</code> array? Should I assume it is <code>3+1</code> padded?</p>