title: Dealing with Boundary conditions / Halo regions in CUDA
body: <p>I'm working on image processing with CUDA and i've a doubt about pixel processing. </p>
  
  <p><strong>What is often done with the boundary pixels of an image when applying a <code>m x m</code> convolution filter?</strong></p>
  
  <p>In a <code>3 x 3</code> convolution kernel, ignoring the <code>1</code> pixel boundary of the image is easier to deal with, especially when the code is improved with shared memory. Indeed, in this case, one does not need to check if a given pixel has all the neigbourhood available (i.e. pixel at coord <code>(0, 0)</code> has not left, left-upper, upper neighbours). However, removing the <code>1</code> pixel boundary of the original image could generate partial results. </p>
  
  <p>Opposite to that, I'd like to process <em>all</em> the pixels within the image, also when using shared memory improvements, i.e., for example, loading <code>16 x 16</code> pixels, but computing the inner <code>14 x 14</code>. Also in this case, ignoring the boundary pixels generates a clearer code.</p>
  
  <p><strong>What is usually done in this case?</strong> </p>
  
  <p><strong>Does anyone usually use my approach ignoring the boundary pixels?</strong></p>
  
  <p>Of course, I'm aware the answer depends on the type of problem, i.e. adding two images pixel-wise has not this problem.</p>
  
  <p>Thanks in advance.</p>