%%% Macros specific to this figure
\newcommand{\na}{{\color{gray}N/A}}
\newcommand{\centerheader}[1]{\multicolumn{1}{c}{#1}}
\newcommand{\figfiverow}[2]{
    \begin{minipage}[c]{0.03\linewidth}
        \figrowlegend{#1}
    \end{minipage}\figspaceleft{}
    \begin{minipage}[c]{0.13\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-palmed.png}
    \end{minipage}\figspacemid{}
    \begin{minipage}[c]{0.13\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-UOPS.png}
    \end{minipage}\figspacemid{}
    \begin{minipage}[c]{0.13\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-PMEvo.png}
    \end{minipage}\figspacemid{}
    \begin{minipage}[c]{0.13\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-IACA.png}
    \end{minipage}\figspacemid{}
    \begin{minipage}[c]{0.13\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-LLVM_MCA.png}
    \end{minipage}\figspaceright{}
    \begin{minipage}[c]{0.035\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-legend.png}
    \end{minipage}
}
\newcommand{\figthreerow}[2]{
    \begin{minipage}[c]{0.03\linewidth}
        \figrowlegend{#1}
    \end{minipage}\figspaceleft{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-palmed.png}
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-PMEvo.png}
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-LLVM_MCA.png}
    \end{minipage}\figspaceright{}
    \begin{minipage}[c]{0.035\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-legend.png}
    \end{minipage}
}
\newcommand{\figthreerowlegend}[2]{
    \begin{minipage}[c]{0.03\linewidth}
        \figrowlegend{#1}
    \end{minipage}\figspaceleft{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-palmed.png}
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.12\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmap_legend.svg}
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-PMEvo.png}
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.12\linewidth}
        ~
    \end{minipage}\figspacezenmid{}
    \begin{minipage}[c]{0.15\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-LLVM_MCA.png}
    \end{minipage}\figspaceright{}
    \begin{minipage}[c]{0.035\linewidth}
        \includegraphics[width=\linewidth]{ipc_heatmaps/#2-legend.png}
    \end{minipage}
}
\newenvironment{figleftlabel}[1]{
    \begin{minipage}[c]{0.02\linewidth}
        \figrowlegend{#1}
    \end{minipage}\figspaceleft{}
\begin{minipage}[c]{0.94\linewidth}}
{\end{minipage}}
\newcommand{\figspaceleft}{\hspace{1em}}
\newcommand{\figspaceright}{\hspace{1em}}
\newcommand{\figspacemid}{\hfill}
\newcommand{\figspacezenmid}{\hfill}
\newcommand{\figcollegend}[1]{\begin{center}\textbf{\normalsize #1}\end{center}}
\newcommand{\figrowlegend}[1]{\rotatebox{90}{\small\textbf{#1}}}
\newcommand{\figspacerow}

\newcommand{\tabcoverage}{Cov.}
\newcommand{\taberror}{Err.}
\newcommand{\tabkendall}{$\tau_K$}
\newcommand{\tabcoverageunit}{(\%)}
\newcommand{\taberrorunit}{(\%)}
\newcommand{\tabkendallunit}{$(1)$}
\definecolor{tabcovbg}{RGB}{235,255,255}
\definecolor{taberrbg}{RGB}{255,240,255}
\definecolor{tabktaubg}{RGB}{239,250,235}
\newcolumntype{C}{>{\columncolor{tabcovbg}}r}
\newcolumntype{E}{>{\columncolor{taberrbg}}r}
\newcolumntype{K}{>{\columncolor{tabktaubg}}r}

\newcommand{\covrow}{\tabcoverage{} & \tabcoverageunit{}}
\newcommand{\errrow}{\taberror{}    & \taberrorunit{}}
\newcommand{\taurow}{\tabkendall{}  & \tabkendallunit{}}

%%% Taken directly from Palmed paper
\begin{figure}
    \centering
    \begin{figleftlabel}{}
        \begin{minipage}[c]{0.03\linewidth}~\end{minipage}\figspaceleft{}
        \begin{minipage}[c]{0.13\linewidth}
            \figcollegend{\palmed{}}
        \end{minipage}\figspacemid{}
        \begin{minipage}[c]{0.13\linewidth}
            \figcollegend{uops.info}
        \end{minipage}\figspacemid{}
        \begin{minipage}[c]{0.13\linewidth}
            \figcollegend{PMEvo}
        \end{minipage}\figspacemid{}
        \begin{minipage}[c]{0.13\linewidth}
            \figcollegend{IACA}
        \end{minipage}\figspacemid{}
        \begin{minipage}[c]{0.13\linewidth}
            \figcollegend{llvm-mca}
        \end{minipage}\figspaceright{}
        \begin{minipage}[c]{0.035\linewidth}~\end{minipage}
    \end{figleftlabel}

    \begin{figleftlabel}{SKL-SP}
        \figfiverow{SPEC 17}{spec-W-skx}

        \figspacerow

        \figfiverow{Polybench}{polybench-W-skx}
    \end{figleftlabel}

    \figspacerow{}

    \begin{figleftlabel}{ZEN1}
        \figthreerow{SPEC 17}{spec-W-zen}

        \figspacerow

        \figthreerowlegend{Polybench}{polybench-W-zen}
    \end{figleftlabel}

    \caption{IPC prediction profile heatmaps~--~predictions closer to the
        red line are more accurate. Predicted IPC ratio (Y) against native
    IPC (X)}
    \label{fig:palmed_heatmaps}
\end{figure}

\begin{table}
    \centering
    \begin{tabular}{l l c r r r r}
        \toprule
        & & & \multicolumn{2}{c}{SKL-SP} & \multicolumn{2}{c}{ZEN1} \\
        & & & \centerheader{SPEC2017} & \centerheader{Polybench} &
        \centerheader{SPEC2017} & \centerheader{Polybench} \\
        \midrule
        \multirow{3}{*}{\palmed}
                    & \covrow{} & \na{}{} & \na{} & \na{} & \na{} \\
                    & \errrow{} & 7.8 & 24.4 & 29.9 & 32.6 \\
                    & \taurow{} & 0.90 & 0.78 & 0.68 & 0.46 \\
        \midrule{}
        \multirow{3}{*}{\uopsinfo}
                    & \covrow{} & 99.9 & 100.0 & \na{} & \na{} \\
                    & \errrow{} & 40.3 & 68.1 & \na{} & \na{} \\
                    & \taurow{} & 0.71 & 0.29 & \na{} & \na{} \\
        \midrule{}
        \multirow{3}{*}{\pmevo}
                    & \covrow{} & 71.3 & 66.8 & 71.3 & 66.8 \\
                    & \errrow{} & 28.1 & 46.7 & 36.5 & 38.5 \\
                    & \taurow{} & 0.47 & 0.14 & 0.43 & 0.11 \\
        \midrule{}
        \multirow{3}{*}{\iaca}
                    & \covrow{} & 100.0 & 100.0 & \na{} & \na{} \\
                    & \errrow{} & 8.7 & 15.1 & \na{} & \na{} \\
                    & \taurow{} & 0.80 & 0.67 & \na{} & \na{} \\
        \midrule{}
        \multirow{3}{*}{\llvmmca}
                    & \covrow{} & 96.8 & 99.5 & 96.8 & 99.5 \\
                    & \errrow{} & 20.1 & 15.3 & 33.4 & 28.6 \\
                    & \taurow{} & 0.73 & 0.65 & 0.75 & 0.40 \\
        \bottomrule
    \end{tabular}

    \caption{Accuracy of IPC predictions compared to \pipedream{}-based native
    executions on SPEC 2017 and Polybench}\label{table:palmed_eval}
\end{table}