Add complete matrix memory layout example figure

This commit is contained in:
2024-02-24 18:20:41 +01:00
parent 860e2e3ca6
commit 6dc73c0b04
3 changed files with 166 additions and 1 deletions

View File

@@ -329,7 +329,8 @@ Those matrix row blocks possibly span over multiple \ac{dram} rows or even other
% Once all banks have been accessed, the mapping of the column bits can continue. % Once all banks have been accessed, the mapping of the column bits can continue.
Furthermore, the number of columns defines the number of iterations the \ac{mac} core of the microkernel has to perform. Furthermore, the number of columns defines the number of iterations the \ac{mac} core of the microkernel has to perform.
As always 16 \ac{fp16} elements are packed together in a column-major fashion, and while ensuring that the \ac{am} of the memory controller switches to the next bank after exactly one burst size, the \ac{pim} units each contain 16 different matrix row elements of the same set of 16 matrix columns. As always 16 \ac{fp16} elements are packed together in a column-major fashion, and while ensuring that the \ac{am} of the memory controller switches to the next bank after exactly one burst size, the \ac{pim} units each contain 16 different matrix row elements of the same set of 16 matrix columns.
Note, that this interleaving of \ac{fp16} vectors is very similar to the chunking of the weight matrix of SK Hynix's Newton architecture, as illustrated in \cref{img:hynix}. \Cref{img:matrix_layout} gives a complete overview of the layout of the weight matrix in the linear address space and its mapping onto the memory banks.
Note, that the interleaving of \ac{fp16} vectors is very similar to the chunking of the weight matrix of SK Hynix's Newton architecture, as illustrated in \cref{img:hynix}.
The input vector must adhere also a special memory layout. The input vector must adhere also a special memory layout.
Since a vector is essentially a single-column matrix, it is always laid out sequentially in memory. Since a vector is essentially a single-column matrix, it is always laid out sequentially in memory.
@@ -401,3 +402,11 @@ However, the increased processing bandwidth and the reduced power consumption on
In conclusion, \aca{fimdram} is one of the few real \ac{pim} implementations by hardware vendors at this time and promises significant performance gains and higher power efficiency compared to regular \aca{hbm} \ac{dram}. In conclusion, \aca{fimdram} is one of the few real \ac{pim} implementations by hardware vendors at this time and promises significant performance gains and higher power efficiency compared to regular \aca{hbm} \ac{dram}.
The following \cref{sec:vp} introduces the concept of virtual prototyping, which is the basis for the following implementation of the \aca{fimdram} model in a simulator. The following \cref{sec:vp} introduces the concept of virtual prototyping, which is the basis for the following implementation of the \aca{fimdram} model in a simulator.
\begin{landscape}
\begin{figure}
\input{images/matrix_layout}
\caption[Mapping of the weight matrix onto the memory banks and its layout in the linear address space]{Mapping of the weight matrix onto the memory banks and its layout in the linear address space.}
\label{img:matrix_layout}
\end{figure}
\end{landscape}

View File

@@ -0,0 +1,155 @@
\resizebox{\linewidth}{!}{%
\begin{tikzpicture}
\small
\definecolor{_darkblue}{RGB}{68, 114, 196}
\definecolor{_blue}{RGB}{91, 155, 213}
\definecolor{_green}{RGB}{112, 173, 71}
\definecolor{_orange}{RGB}{237, 125, 49}
\definecolor{_yellow}{RGB}{255, 192, 0}
\pgfdeclarelayer{bank1}
\pgfdeclarelayer{bankx}
\pgfdeclarelayer{bank7}
\pgfsetlayers{bank7,bankx,bank1,main}
% Linear space
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange ] (lb0) {w[0,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb0] (lb1) {w[1,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb1] (lb2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb2] (lb3) {w[7,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb3] (lb4) {w[0,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb4] (lb5) {w[1,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb5] (lb6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb6] (lb7) {w[7,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of lb7] (lb8) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb8] (lb9) {w[0,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb9] (lb10) {w[1,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb10] (lb11) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb11] (lb12) {w[7,112:127]};
\node[below=1mm of lb0.south west] {0x0};
\node[below=1mm of lb4.south west] {0x100};
\node[below=1mm of lb8.south west] {0x200};
\node[below=1mm of lb9.south west] {0x700};
\node[below=1mm of lb12.south east] {0x800};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=of lb0] (lb_0) {w[8,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb_0] (lb_1) {w[9,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb_1] (lb_2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,right=0 of lb_2] (lb_3) {w[15,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb_3] (lb_4) {w[8,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb_4] (lb_5) {w[9,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb_5] (lb_6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of lb_6] (lb_7) {w[15,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of lb_7] (lb_8) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb_8] (lb_9) {w[8,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb_9] (lb_10) {w[9,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb_10] (lb_11) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of lb_11] (lb_12) {w[15,112:127]};
\node[below=1mm of lb_0.south west] {0x800};
\node[below=1mm of lb_4.south west] {0x900};
\node[below=1mm of lb_8.south west] {0xA00};
\node[below=1mm of lb_9.south west] {0xF00};
\node[below=1mm of lb_12.south east] {0x1000};
\node[above right=1mm and 0 of lb0.north west] {Linear Address Space};
% Matrix
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,above right=7cm and 1cm of lb0.east] (m00) {w[0,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of m00 ] (m10) {w[1,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of m10 ] (mx0) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of mx0 ] (m70) {w[7,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of m70 ] (m80) {w[8,0:15]};
% \node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of m80 ] (m90) {w[9,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of m80 ] (mxx0) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of mxx0 ] (m150) {w[15,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m00] (m01) {w[0,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m10] (m11) {w[1,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of mx0] (mx1) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m70] (m71) {w[7,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m80] (m81) {w[8,16:31]};
% \node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m90] (m91) {w[9,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of mxx0] (mxx1) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of m150] (m151) {w[15,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m01] (m0x) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m11] (m1x) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of mx1] (mxx) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m71] (m7x) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m81] (m8x) {$\cdots$};
% \node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m91] (m9x) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of mxx1] (mxxx) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of m151] (m15x) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m0x] (m07) {w[0,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m1x] (m17) {w[1,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of mxx] (mx7) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m7x] (m77) {w[7,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m8x] {w[8,112:127]};
% \node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m9x] {w[9,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of mxxx] {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of m15x] {w[15,112:127]};
\node[above right=1mm and 0 of m00.north west] {Weight Matrix};
% Banks
\node[draw,outer sep=0,minimum width=10cm,minimum height=24mm,fill=white,above=3cm of lb8.east] (bank0) {};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below right=0 of bank0.north west] (b0e0) {w[0,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b0e0] (b0e1) {w[0,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b0e1] (b0e2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b0e2] (b0e3) {w[0,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of b0e0] (b0e4) {w[8,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b0e4] (b0e5) {w[8,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b0e5] (b0e6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b0e6] (b0e7) {w[8,112:127]};
\node[minimum width=10cm,minimum height=12mm,below right=0 of b0e4.south west] {$\cdots$};
\begin{pgfonlayer}{bank1}
\node[draw,outer sep=0,minimum width=10cm,minimum height=24mm,fill=white,above right=15mm of bank0.south west] (bank1) {};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below right=0 of bank1.north west] (b1e0) {w[1,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b1e0] (b1e1) {w[1,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b1e1] (b1e2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b1e2] (b1e3) {w[1,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of b1e0] (b1e4) {w[9,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b1e4] (b1e5) {w[9,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b1e5] (b1e6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b1e6] (b1e7) {w[9,112:127]};
\end{pgfonlayer}
\begin{pgfonlayer}{bankx}
\node[draw,outer sep=0,minimum width=10cm,minimum height=24mm,fill=white,above right=15mm of bank1.south west] (bankx) {};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below right=0 of bankx.north west] (bxe0) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of bxe0] (bxe1) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of bxe1] (bxe2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of bxe2] (bxe3) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of bxe0] (bxe4) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of bxe4] (bxe5) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of bxe5] (bxe6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of bxe6] (bxe7) {$\cdots$};
\end{pgfonlayer}
\begin{pgfonlayer}{bank7}
\node[draw,outer sep=0,minimum width=10cm,minimum height=24mm,fill=white,above right=15mm of bankx.south west] (bank7) {};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below right=0 of bank7.north west] (b7e0) {w[7,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b7e0] (b7e1) {w[7,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b7e1] (b7e2) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b7e2] (b7e3) {w[7,112:127]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_orange,below=0 of b7e0] (b7e4) {w[15,0:15]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_blue,right=0 of b7e4] (b7e5) {w[15,16:31]};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=lightgray,right=0 of b7e5] (b7e6) {$\cdots$};
\node[draw,outer sep=0,minimum width=25mm,minimum height=6mm,fill=_green,right=0 of b7e6] (b7e7) {w[15,112:127]};
\end{pgfonlayer}
\node[left=2mm of b0e0] {Bank 0};
\node[left=2mm of b1e0] {Bank 1};
\node[left=8mm of bxe0] {$\iddots$};
\node[left=2mm of b7e0] {Bank 7};
\node[above right=1mm and 0 of bank7.north west] {Bank Layout};
\end{tikzpicture}
}

View File

@@ -26,6 +26,7 @@
\usepackage{tabularray} \usepackage{tabularray}
\usepackage{makecell} \usepackage{makecell}
\usepackage{minted} \usepackage{minted}
\usepackage{lscape}
% Configurations % Configurations
\usetikzlibrary{matrix} \usetikzlibrary{matrix}