order to save memory transfers. The row-column pair $(i,j)$ is mapped to $(((i\!+\!j)\textit{mod}\ 2 \times L + i)/2, j)$, and this allows to pack all white and all black cells in contiguous memory locations improving locality and allowing wider reads of 3 consecutive bytes (Fig.\[fig:checkerboard\], right).

![On the left: a $8\times 8$ checkerboard framed in $4\times 4$ (red marking), the cells updated by thread $t_0$ are singled out, we also marked the north, east, south and west neighbors of cell $\bullet$. On the right: packed checkerboard showing first half of whites, where the neighboring cells $n,e,s,w$ are marked, also in the second half of black cells $\bullet$ is singled out. ](fig1.eps)

\[fig:checkerboard\]

We encode each spin in a byte, allowing simulations with $q\leq256$ and $L^2\leq\mathit{available\ RAM}$. Since some extra space is needed for the RNG state and for energy and magnetization summarization, this upper bound is not reached. The biggest simulations we achieve is $L=32768, q=45$ for the GTX 480.

It is important to remark that shared memory is not used, since we could not improve performance and it hindered readability of the code. Texture memory techniques were not used for the same reasons.

Computation of Energy and Magnetization
---------------------------------------

