title: How and when should I use pitched pointer with the cuda API?
body: <p>I have quite a good understanding about how to allocate and copy linear memory with <code>cudaMalloc()</code> and <code>cudaMemcpy()</code>. However, when I want to use the CUDA functions to allocate and copy 2D or 3D matrices, I am often befuddled by the various arguments, especially concerning pitched pointers which are always present when dealing with 2D/3D arrays. The documentation is good for providing a couple examples on how to use them but it assumes that I am familiar with the notion of padding and pitch, which I am not.</p>
  
  <p>I usually end up tweaking the various examples I find in the documentation or somewhere else on the web, but the blind debugging that follows is quite painful, so my question is:</p>
  
  <p>What is a pitch? How do I use it? How do I allocate and copy 2D and 3D arrays in CUDA?</p>