\section{\staticdeps: static extraction of memory-carried dependencies} \begin{frame} \todo{} \begin{itemize} \item Dependency through registers: easy \item Loop-carried: still fine \item Through memory: indirections, arithmetics, … \item Loop-carried: ROB is finite and small-ish \item Requires comparison of arbitrary formal expressions \item Use randomness as a kind of hash table instead \end{itemize} \end{frame} \begin{frame}{The \staticdeps{} algorithm} \begin{itemize} \item \alert{Unroll} kernel until $\card{\kerK} \geq \card{\text{ROB}} + \card{\kerK_0}$ \item \alert{Simulate} execution \item Unknown value (reg./mem.)? \alert{Sample} uniformly in $0\ldots2^{64}-1$ (\alert{``fresh''}) \item \alert{Compute arithmetics} normally (overflow is fine) \item Float or unknown operands $\leadsto \alert{\bot}$ \item Upon write, remember from which instruction \item Upon read, if writer known, \alert{generate dependency} \end{itemize} \end{frame} \begin{frame}[fragile]{An example: memoized Fibonacci sequence} \begin{minipage}[t]{0.46\textwidth} \begin{lstlisting}[language=C] int fibo(int* F, int n) { for(int i=2; i <= n; ++i) { F[i] = F[i-1] + F[i-2]; } return F[n]; } \end{lstlisting} \end{minipage}\hfill \begin{minipage}[t]{0.46\textwidth} \begin{lstlisting}[language={[x86masm]Assembler}] 0: mov (%rax),%edx 1: add 0x4(%rax),%edx 2: mov %edx,0x8(%rax) 3: add $0x4,%rax 4: cmp %rcx,%rax 5: jne 0 \end{lstlisting} \end{minipage} \end{frame} \begin{frame} \newcommand{\unk}{{\color{gray}?}} \newcommand{\h}{\cellcolor[HTML]{D0ECFF}} \newcommand{\w}{\cellcolor[HTML]{d6bf86}} \centering \footnotesize \begin{tabular}{r c c c c c c c c c c c c c c} \toprule \textbf{Before} & [0,0] & [0,1] & [0,2] & [0,3] & [0,4] & [0,5] & & [1,1] & [1,2] & [1,3] & & [2,1] & [2,2] & [2,3] \\ \midrule \textbf{Regs} & & & & & & & & & &\\ \reg{rax} & \unk & 100 & 100 & 100 & 104 & 104 && 104 & 104 & 104 && 108 & 108 & 108 \\ \reg{edx} & \unk & 200 & 376 & 376 & 376 & 376 && 176 & 552 & 552 && 376 & 928 & 928 \\ \reg{rcx} & \unk & \unk & \unk& \unk& \unk& 42 && 42 & 42 & 42 && 42 & 42 & 42 \\ \midrule \textbf{Mem} & & & & & & & & & &\\ \texttt{100} & \unk & 200\h& 200 & 200 & 200 & 200 && 200 & 200 & 200 && 200 & 200 & 200 \\ \texttt{104} & \unk & \unk & 176\h& 176 & 176 & 176 && 176\h& 176 & 176 && 176 & 176 & 176 \\ \texttt{108} & \unk & \unk & \unk & 376\w& 376 & 376 && 376 & 376\h& 376 && 376\h& 376 & 376 \\ \texttt{112} & \unk & \unk & \unk & \unk & \unk& \unk&& \unk & \unk & 552\w&& 552 & 552\h& 552 \\ \texttt{116} & \unk & \unk & \unk & \unk & \unk& \unk&& \unk & \unk & \unk && \unk & \unk & 928\w\\ %\texttt{116} & \unk & \unk& \unk& \unk& \unk& \unk& & & \\ \bottomrule \end{tabular} \let\unk\unefined \let\h\unefined \let\w\unefined \end{frame}