title: calculating the magnitude of a pixel in cuda with shared memory
body: <p>I am working on a school project that we run the sift algorithm in cuda. I have at a point to calculate the magnitude value of every pixel(X) of an image based on the values of its neighbors(A,B,C,D):</p>
  
  <pre><code>   A
  B  X  C
     D
  </code></pre>
  
  <p>I managed to make it by using global memory because I could easily get the values I wanted from my input array. </p>
  
  <p>But now I want to make it by first putting the input array into shared memory but I am having a really tough time on how to make the threads put the right pixels on the shared memory. I must take into consideration the padding on the borders of the image. </p>
  
  <p>I know that I need more shared memory than the part of image I want to put in there so that the padding will be included but I dont know if my thread block should contain more or less threads than the shared memory space and how to specify what to read.
  If someone can give me a general idea on how to think for this I could take it from there...</p>
  
  <p>Thanks!</p>