title: Pitch alignment for 2D textures
body: <p>2D textures are a useful feature of CUDA in image processing applications. To bind pitch linear memory to 2D textures, the memory has to be aligned. <code>cudaMallocPitch</code> is a good option for aligned memory allocation. On my device, the pitch returned by <code>cudaMallocPitch</code> is a multiple of 512, i.e the memory is 512 byte aligned.</p>
  
  <p>The actual alignment requirement for the device is determined by <code>cudaDeviceProp::texturePitchAlignment</code> which is 32 bytes on my device.</p>
  
  <p><strong>My question is:</strong></p>
  
  <p>If the actual alignment requirement for 2D textures is 32 bytes, then why does <code>cudaMallocPitch</code> return 512 byte aligned memory?</p>
  
  <p>Isn't it a waste of memory? For example if I create an 8 bit image of size 513 x 100, it will occupy 1024 x 100 bytes.</p>
  
  <p>I get this behaviour on following systems:</p>
  
  <p>1: Asus G53JW + Windows 8 x64 + GeForce GTX 460M + CUDA 5 + Core i7 740QM + 4GB RAM</p>
  
  <p>2: Dell Inspiron N5110 + Windows 7 x64 + GeForce GT525M + CUDA 4.2 + Corei7 2630QM + 6GB RAM</p>