summaryrefslogtreecommitdiffstats
path: root/algorithm.tex
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2020-06-30 15:03:47 +0100
committerYann Herklotz <git@yannherklotz.com>2020-06-30 15:03:47 +0100
commit7ccf35966e15de7daa30351ddde04663cab38e3c (patch)
tree74d510d667b1eaaa5c958cae731388c0df304c55 /algorithm.tex
parent0cef8950a05b85547ce491b34c12b5e285449e28 (diff)
downloadoopsla21_fvhls-7ccf35966e15de7daa30351ddde04663cab38e3c.tar.gz
oopsla21_fvhls-7ccf35966e15de7daa30351ddde04663cab38e3c.zip
Add examples
Diffstat (limited to 'algorithm.tex')
-rw-r--r--algorithm.tex54
1 files changed, 50 insertions, 4 deletions
diff --git a/algorithm.tex b/algorithm.tex
index 849ea05..7d119da 100644
--- a/algorithm.tex
+++ b/algorithm.tex
@@ -33,18 +33,64 @@ Existing HLS compilers usually use LLVM IR as an intermediate representation whe
%%TODO: Maybe add why LTL and the other smaller languages are not that well suited
-To describe the translation, we can start with a simple example of how to translate a simple matrix multiplication example.
+\begin{figure}
+ \centering
+ \begin{minipage}{0.5\linewidth}
+\begin{minted}{c}
+int main() {
+ int x[5] = {1, 2, 3, 4, 5};
+ int sum = 0;
+ for (int i = 0; i < 5; i++)
+ sum += x[i];
+ return sum;
+}
+\end{minted}
+ \end{minipage}
+ \caption{Matrix multiply example C code.}\label{fig:matrix_mult_c}
+\end{figure}
+
+To describe the translation, we start with an example of how to translate a simple accumulator example, which is shown in figure~\ref{fig:matrix_mult_c}.
\subsection{CompCert RTL}
-All CompCert intermediate language follow the similar structure below: \JW{should `(id * data)' be `(id * data) list'?}
+All CompCert intermediate language follow the similar structure below:
\begin{align*}
- \mathit{program} \quad ::= \{ &\mathbf{variables} : (\mathit{id} * \mathit{data}), \\
- &\mathbf{functions} : (\mathit{id} * \mathit{function\_def}),\\
+ \mathit{program} \quad ::= \{ &\mathbf{variables} : (\mathit{id} * \mathit{data}) \text{ list}, \\
+ &\mathbf{functions} : (\mathit{id} * \mathit{function\_def}) \text{ list},\\
&\mathbf{main} : \mathit{id} \}
\end{align*}
+\begin{figure}
+ \centering
+ \begin{minipage}{0.5\linewidth}
+\begin{minted}{c}
+main() {
+ 19: x10 = 1
+ 18: int32[stack(0)] = x10
+ 17: x9 = 2
+ 16: int32[stack(4)] = x9
+ 15: x8 = 3
+ 14: int32[stack(8)] = x8
+ 13: x7 = 4
+ 12: int32[stack(12)] = x7
+ 11: x6 = 5
+ 10: int32[stack(16)] = x6
+ 9: x2 = 0
+ 8: x1 = 0
+ 7: x5 = stack(0) (int)
+ 6: x4 = int32[x5 + x1 * 4 + 0]
+ 5: x2 = x2 + x4 + 0 (int)
+ 4: x1 = x1 + 1 (int)
+ 3: if (x1 <s 5) goto 7 else goto 2
+ 2: x3 = x2
+ 1: return x3
+}
+\end{minted}
+ \end{minipage}
+ \caption{Matrix multiply example C code.}\label{fig:matrix_mult_rtl}
+\end{figure}
+
\noindent where function definitions can either be internal or external. External functions are functions that are not defined in the current translation unit, and are therefore not part of the current translation. The difference in between the CompCert intermediate languages is therefore how the internal function is defined, as that defines the structure of the language itself.
%% Describe RTL