一些文档

This commit is contained in:
LYC 2024-10-30 15:44:02 +08:00
parent 3e95c6dcd6
commit 79bef93cab
17 changed files with 560 additions and 593 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,65 @@
import subprocess
import matplotlib.pyplot as plt
import warnings
import numpy as np
# 忽略警告
warnings.filterwarnings("ignore")
def run_simulator(BLOCKSIZE,L2_SIZE=4096,L1_ASSOC=2, L1_SIZE=1024, L2_ASSOC=4, Victim_Cache_SIZE=1024, trace_file="gcc_trace.txt"):
cmd = ["./sim_cache", str(BLOCKSIZE), str(L1_SIZE), str(L2_SIZE), str(L1_ASSOC), str(L2_ASSOC), str(Victim_Cache_SIZE), trace_file]
try:
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode('utf-8')
return output
except subprocess.CalledProcessError as e:
print(f"Command failed with error: {e.output.decode('utf-8')}")
raise
def parse_output(output):
lines = output.split('\n')
results = {}
for line in lines:
if "L1 miss rate:" in line:
results['L1_miss_rate'] = float(line.split()[-1])
elif "L2 miss rate:" in line:
results['L2_miss_rate'] = float(line.split()[-1])
elif "average access time:" in line:
results['AAT'] = float(line.split()[-2])
return results
# Define L1_SIZE values to simulate
data = [2,4,8,16,32,64, 128, 256, 512, 1024]
# Run simulations and collect results
results = {}
for item in data:
try:
output = run_simulator(item)
parsed_results = parse_output(output)
results[item] = parsed_results
except Exception as e:
print(f"Error processing L2_SIZE {item}: {e}")
# 准备数据用于可视化
l1_miss_rates = [results[size]['L1_miss_rate'] for size in data if size in results]
l1_sizes_kb = [size for size in data if size in results]
# 可视化
plt.figure(figsize=(10, 6))
plt.plot(l1_sizes_kb, l1_miss_rates, marker='o')
plt.title('L1 Miss Rate vs Block')
plt.xlabel('L1 Cache Size (KB)')
plt.ylabel('L1 Miss Rate')
plt.grid()
# 设置均匀的 X 轴坐标
plt.xticks(np.linspace(min(l1_sizes_kb), max(l1_sizes_kb), num=len(l1_sizes_kb)),
labels=l1_sizes_kb)
plt.ylim(0, max(l1_miss_rates) + 0.01) # 设置 Y 轴范围
plt.axhline(y=0, color='k', linestyle='--') # 添加基线
# 保存图像
plt.savefig('l1_miss_rate_vs_cache_size.png', bbox_inches='tight')
plt.close() # 关闭图形以释放内存

View File

@ -1,7 +0,0 @@
\section{实验目标}
\begin{itemize}
\item 设计一个可灵活配置的两级 Cache 存储体系仿真器。
\item 基于该仿真器和 SPEC 标准测试程序对 Cache 存储体系的性能进行分析。
\end{itemize}

View File

@ -1,7 +1,5 @@
\section{实验结果} \section{实验结果}
本实验使用 C++ 构建,提供了 Makefile通过 \verb|make| 指令运行,\verb|make clean| 会删除\verb|.o, .diff 和 .txt| 文件,如有 错误,会通过 diff 指令进行输出 利用所提供的验证文件与仿真器的输出文件进行自动化(非手工)比对,对所设计仿真器功能的正确性进行验证
执行结果如下: \figuremacro{result.png}{编译和测试结果}{1.0}
\figuremacro{Result.png}{Result}{1.0}

View File

@ -3,52 +3,39 @@
\subsection{Miss Rate} \subsection{Miss Rate}
如图\ref{fig:mr} 所示:
\begin{figure}[!hbtp] \begin{figure}[htbp]
\centering \centering
\subfmacro{ls1}{L1 Cache Size}{.31} \begin{minipage}{0.4\linewidth}
\subfmacro{a1}{Associativity}{.31} \includegraphics[width=\linewidth]{L1Miss.png}
\subfmacro{bs1}{Block Size}{.31} \caption{L1 Miss vs Size}
\caption{Miss Rate}\label{fig:mr} \end{minipage}
\begin{minipage}{0.4\linewidth}
\includegraphics[width=\linewidth]{block.png}
\caption{L1 Miss vs Block Size}
\end{minipage}
\begin{minipage}{0.6\linewidth}
\includegraphics[width=\linewidth]{assoc.png}
\caption{L1 Miss vs Associativity}
\end{minipage}
\end{figure} \end{figure}
\begin{itemize} \begin{itemize}
\item 当 L1 缓存大小增加时L1MissRate 平均值呈现下降趋势。这是符合预期的,因为更大的缓存大小通常意味着更低的缺失率。
\item L1 Associativity 值与 L1MissRate 之间的关系似乎并不明确。这可能是因为其他参数的变化对缺失率产生了影响,使得 associativity 的影响不太明显。通常,增加 associativity 可以减少缺失率,但如果其他参数不合适,这种效果可能会受到抵消。 \item 当 L1 缓存大小增加时L1MissRate 平均值呈现下降趋势,更大的缓存大小通常意味着更低的缺失率
\item 对于给定的数据,块大小似乎并没有对 L1MissRate 产生显著的影响。这可能是因为块大小的选择需要与其他参数,如缓存大小和 associativity相匹配才能获得最佳性能。 \item 对于给定的数据,块大小似乎并没有对 L1MissRate 产生显著的影响。这可能是因为块大小的选择需要与其他参数,如缓存大小和 associativity相匹配才能获得最佳性能。
\item L1 Associativity 值与 L1MissRate 之间的关系似乎并不明确。这可能是因为其他参数的变化对缺失率产生了影响,使得 associativity 的影响不太明显。通常,增加 associativity 可以减少缺失率,但如果其他参数不合适,这种效果可能会受到抵消。
\end{itemize} \end{itemize}
\subsection{AAT} \subsection{AAT}
如图\ref{fig:aatL1}\ref{fig:aatL2} 所示:
\begin{figure}[!hbtp]
\centering
\subfmacro{l1_size_assoc_trace1}{Gcc}{.31}
\subfmacro{l1_size_assoc_trace2}{Go}{.31}
\subfmacro{l1_size_assoc_trace3}{Perl}{.31}
\caption{AAT - L1 Cache}\label{fig:aatL1}
\end{figure}
\begin{figure}[!hbtp]
\centering
\subfmacro{l2_size_assoc_trace1}{Gcc}{.31}
\subfmacro{l2_size_assoc_trace2}{Go}{.31}
\subfmacro{l2_size_assoc_trace3}{Perl}{.31}
\caption{AAT - L2 Cache}\label{fig:aatL2}
\end{figure}
\begin{itemize} \begin{itemize}
\item 增大 L1 Cache Size 或 L1 ASSOC 通常可以降低 AAT。这可能是因为增大这些参数可以增加缓存的容量和关联性从而降低缺失率和增加缓存命中率。 \item 增大 L1 Cache Size 或 L1 ASSOC 通常可以降低 AAT。这可能是因为增大这些参数可以增加缓存的容量和关联性从而降低缺失率和增加缓存命中率。
\item 与 L1 缓存类似,增大 L2 SIZE 或 L2 ASSOC 也可以降低 AAT。但是L2 缓存的影响可能不如 L1 缓存明显,因为 L2 缓存通常在 L1 缓存缺失时才被访问。 \item 与 L1 缓存类似,增大 L2 SIZE 或 L2 ASSOC 也可以降低 AAT。但是L2 缓存的影响可能不如 L1 缓存明显,因为 L2 缓存通常在 L1 缓存缺失时才被访问。
\end{itemize} \end{itemize}
如图 \ref{fig:aatBs} 所示:
\begin{figure}[!htbp] \begin{figure}[!htbp]
\centering \centering

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

View File

@ -1,33 +1,20 @@
\relax \relax
\@writefile{toc}{\contentsline {section}{\numberline {1}实验目标}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {section}{\numberline {1}实验内容}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {2}实验内容}{1}{}\protected@file@percent } \newlabel{sec:one}{{1}{1}}
\newlabel{sec:one}{{2}{1}} \@writefile{toc}{\contentsline {section}{\numberline {2}实验结果}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {3}实验结果}{1}{}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces 编译和测试结果}}{1}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {1}{\ignorespaces Result}}{1}{}\protected@file@percent } \newlabel{fig:result.png}{{1}{1}}
\newlabel{fig:Result.png}{{1}{1}} \@writefile{toc}{\contentsline {section}{\numberline {3}实验分析}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {4}实验分析}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.1}Miss Rate}{1}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.1}Miss Rate}{1}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.2}AAT}{1}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces Miss Rate}}{2}{}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {2}{\ignorespaces L1 Miss vs Size}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(a)}{\ignorespaces {L1 Cache Size}}}{2}{}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces L1 Miss vs Block Size}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(b)}{\ignorespaces {Associativity}}}{2}{}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces L1 Miss vs Associativity}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(c)}{\ignorespaces {Block Size}}}{2}{}\protected@file@percent } \@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces AAT}}{2}{}\protected@file@percent }
\newlabel{fig:mr}{{2}{2}} \@writefile{lof}{\contentsline {subfigure}{\numberline{(a)}{\ignorespaces {Block Size}}}{2}{}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {4.2}AAT}{2}{}\protected@file@percent } \@writefile{lof}{\contentsline {subfigure}{\numberline{(b)}{\ignorespaces {Victim Size}}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {figure}{\numberline {3}{\ignorespaces AAT - L1 Cache}}{2}{}\protected@file@percent } \newlabel{fig:aatBs}{{5}{2}}
\@writefile{lof}{\contentsline {subfigure}{\numberline{(a)}{\ignorespaces {Gcc}}}{2}{}\protected@file@percent } \@writefile{toc}{\contentsline {subsection}{\numberline {3.3}最优参数组合}{3}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(b)}{\ignorespaces {Go}}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(c)}{\ignorespaces {Perl}}}{2}{}\protected@file@percent }
\newlabel{fig:aatL1}{{3}{2}}
\@writefile{lof}{\contentsline {figure}{\numberline {4}{\ignorespaces AAT - L2 Cache}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(a)}{\ignorespaces {Gcc}}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(b)}{\ignorespaces {Go}}}{2}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(c)}{\ignorespaces {Perl}}}{2}{}\protected@file@percent }
\newlabel{fig:aatL2}{{4}{2}}
\@writefile{lof}{\contentsline {figure}{\numberline {5}{\ignorespaces AAT}}{3}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(a)}{\ignorespaces {Block Size}}}{3}{}\protected@file@percent }
\@writefile{lof}{\contentsline {subfigure}{\numberline{(b)}{\ignorespaces {Victim Size}}}{3}{}\protected@file@percent }
\newlabel{fig:aatBs}{{5}{3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {4.3}最优参数组合}{3}{}\protected@file@percent }
\@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces 最优参数组合}}{3}{}\protected@file@percent } \@writefile{lot}{\contentsline {table}{\numberline {1}{\ignorespaces 最优参数组合}}{3}{}\protected@file@percent }
\newlabel{tab:res2}{{1}{3}} \newlabel{tab:res2}{{1}{3}}
\gdef \@abspage@last{5} \gdef \@abspage@last{5}

File diff suppressed because it is too large Load Diff

View File

@ -5,21 +5,16 @@
\major{计算机科学与技术} \major{计算机科学与技术}
\class{计科5} \class{计科3}
\name{锦帆} \name{原驰}
\title{计算机组成与体系结构实践} \title{计算机组成与体系结构实践}
\subtitle{两级 Cache 仿真器} \subtitle{两级 Cache 仿真器}
\myheader{天津大学智能与计算学部《计算机组成与体系结构实践》} \myheader{2024秋-计算机组成与体系结构实践}
\stuid{3020202184} \stuid{3021244213}
\college{智能与计算学部} \college{智能与计算学部}
\date{\zhtoday} \date{\zhtoday}
\lab{47教}
\course{计算机组成与体系结构实践} \course{计算机组成与体系结构实践}
\instructor{魏继增}
\grades{59}
\expname{nmap端口扫描}
\exptype{设计实验}
\partner{Bob}
\begin{document} \begin{document}
% ============================================= % =============================================
@ -39,7 +34,6 @@
\startheader \startheader
\setcounter{page}{1} % 单独从 1 开始编页码 \setcounter{page}{1} % 单独从 1 开始编页码
\input{body/1.tex}
\input{body/2.tex} \input{body/2.tex}
\input{body/3.tex} \input{body/3.tex}
\input{body/4.tex} \input{body/4.tex}

View File

@ -1,7 +1,6 @@
\contentsline {section}{\numberline {1}实验目标}{1}{}% \contentsline {section}{\numberline {1}实验内容}{1}{}%
\contentsline {section}{\numberline {2}实验内容}{1}{}% \contentsline {section}{\numberline {2}实验结果}{1}{}%
\contentsline {section}{\numberline {3}实验结果}{1}{}% \contentsline {section}{\numberline {3}实验分析}{1}{}%
\contentsline {section}{\numberline {4}实验分析}{1}{}% \contentsline {subsection}{\numberline {3.1}Miss Rate}{1}{}%
\contentsline {subsection}{\numberline {4.1}Miss Rate}{1}{}% \contentsline {subsection}{\numberline {3.2}AAT}{1}{}%
\contentsline {subsection}{\numberline {4.2}AAT}{2}{}% \contentsline {subsection}{\numberline {3.3}最优参数组合}{3}{}%
\contentsline {subsection}{\numberline {4.3}最优参数组合}{3}{}%