\subsection{Introduction}

For out of core we use a dedicated thread wich will prefetch save
column blocks, going threw the pastix computation loops.\\
For the MPI version, we will have to manage fanin block also.\\

\subsection{Rules to save and prefetch a block}


\subsubsection{The \texttt{hitcblktab}}

For each thread and each block, we have a variable, in
\texttt{hitcblktab}, counting how much 
time a block will be used by one thread.\\
When the prefetchinig thread goes too a column block, it will
increment this indicator. When a computation thread as finished with a
block, the variable will be decreased.\\
The prefetching thread will load blocks when this variable is
positive, and, when memory is needed, it will only save blocks if this
indicator is negative for each thread.\\
When a computation thread has finished with a block and his indicator
is negative for all thread, it will had the block to the save queue,
with minus next access to this block. An issue is that the priority is
computed with the distance to next access in term of number of access
and not in term of time. The next access will be the minus of next
access for each thread, wich could not be the minus distance in term
of time\dots \\
We need to have one count variable by thread because, if one thread is
late and one goes faster than the prefetching thread, we can have more
decreasement than increasement whereas the thread wich is late still
has to use cblknum.\\


\begin{algorithm}
\caption{Algorithme runned by \texttt{OOC} thread}
\begin{algorithmic}
\FORALL{task tsk}
\FORALL{thread thrd}
\FORALL{column block cb}
\STATE hitcblktab[thrd][me]++
\IF{$hitcblktab[thrd][me] > 0$ and cb not loaded}
\WHILE{No more place in memory}
\STATE save some column blocks from save queue
\ENDWHILE
\STATE prefetch cb
\ENDIF
\ENDFOR
\ENDFOR
\ENDFOR
\end{algorithmic}

\end{algorithm}
\begin{algorithm}
\caption{Algorithm run by the computing thread}
\begin{algorithmic}
\WHILE{column block cb is not loaded}
\STATE wait
\ENDWHILE
\STATE works on cb
\STATE \dots
\STATE hitcblktab[thrd][me]--
\IF{$hitcblktab[thrd][me] \leq 0$}
\STATE add cb to save queue with priority -NextAccess(cb)
\ENDIF
\end{algorithmic}
\end{algorithm}

\subsubsection{The thrdUsingCblk tabular}

For each cblk we count the number of computing threads using it at
each moment so that the OOC thread can't touch it when used.\\
Before using a column block, computing thread increment
\texttt{thrdUsingCblk[cblknum]}.\\
After using it, \texttt{thrdUsingCblk[cblknum]} is decremented.\\
Before saving a column block, OOC thread has to wait
\texttt{thrdUsingCblk[cblknum]} to be equal to 0.\\
This way, OOC thread can't touch a column block before computing
threads have finished with it.\\

