for each color/parity do
 Load the potential with opposite color/parity into a texture in the GPU.
for all     do
Given a trace with given and , calculate and set :
Fetch from the texture and put in shared memory.
if     then
   Fetch from the texture.
end if
   Fetch from the texture.
   Calculate Laplace stencil and update the potential for the current color/parity.
end for
end for
Algorithm 1: Algorithm for the stencil on a GPU.