CSC3050 Cache Simulation

CSC3050 Project 4: Cache Simulation

CSC3050 Teaching Group

November 20, 2024

1 Introduction

Cache is an important component of a CPU system that has a signiffcant impact on computer

performance by reducing memory access times. The focus of this project is to simulate the

cache in the RISC-V architecture to give you hands-on experience with the cache system

and its role in improving system performance.

2 Overview

This project is divided into three main parts:

1. Single-Level Cache Simulation: In this part, you are required to design and implement

 a cache simulator that enables the single-level cache simulation. Moreover,

you need to use the single-level cache simulator you implemented to compare the cache

performance under different cache parameters.

2. Multi-level Cache Simulation: In this part, based on the single-level cache simulator,

 you are required to further implement a multi-level cache simulator. You need

to examine further how a multi-level cache can improve performance compared to a

single-level cache.

3. Implementation of Pre-fetching: In this section, you are required to implement

a critical technique known as pre-fetching. Moreover, you need to compare the cache

performance with and without pre-fetching.

3 Single-Level Cache Simulation

• Implementation Requirements: You are required to implement a Cache class for

simulating a single-level cache (The code from [1] is a reference code for your). The

ffle structure and description you may use are shown in Table 1.

The simulated cache should be able to perform some parameter tuning, such as cache

size, block size, and associativity level. Besides that, you are required to simulate

1ffle name Discription

include/Cache.h Statement of the Cache class.

src/Cache.cpp Implementation of Cache class.

src/MainSinCache.cpp Main entrance of the single-level cache simulator.

src/MainMulCache.cpp Main entrance of the multi-level cache simulator.

Table 1: File structure and description of single-level and multi-level cache simulation.

Parameter Values

Cache Size 4KB to 1MB, incremented by 4X.

Block Size 32Bytes to 256Bytes incremented by 2X.

Associativity 2 to 32 incremented by 2X

Write Back True or False.

Write Allocate True of False.

Table 2: Parameters used in single-level cache simulation.

Write Back and Write Allocate policies using the LRU replacement algorithm in your

simulation. The parameters that are tunable and their ranges are listed in Table 2.

Finally, some performance data (e.g. miss rate of the cache and total access latency)

needs to be saved in a CSV ffle.

• Performance Evaluation: After the implementation, you are required to evaluate

the cache performance based on your simulator. We will provide you with a test trace

(test.trace) to facilitate the performance evaluation. What you can do includes but is

not limited to

– Analyzing the trend of Miss Rate with Block Size under different cache sizes

– Analyzing the change of Associativity with Miss Rate under different cache sizes

– Analyzing the amount of cache misses per thousand instructions under different

cache sizes

You are also free to design scenarios for performance evaluation as you wish. But

please analyze the performance in at least two different scenarios. You should provide

graphical or tabular data and conduct the analysis based on the data mentioned above.

The results and analysis should be given in your report.

4 Multi-Level Cache Simulation

• Implementation Requirements: You are required to simulate the multi-level cache

in this part based on your single-level cache simulator.

• Performance Evaluation: You should conduct the comparison between the singlelevel

 and multi-level cache system whose parameters are given in Table 3 and Table

4, respectively. The cache miss latency is set to 100 CPU cycles. Also, graphical or

2tabular data are required and you should put the comparisons and analysis in your

report.

Level Capacity Associativity Block Size Write Policy Hit Latency

L1 16 KB 1 way 64 Bytes Write Back 1 CPU Cycle

Table 3: Cache parameters for single-level cache.

Level Capacity Associativity Block Size Write Policy Hit Latency

L1 16 KB 1 way 64 Bytes Write Back 1 CPU Cycle

L2 128 KB 8 ways 64 Bytes Write Back 8 CPU Cycle

L3 2 MB 16 ways 64 Bytes Write Back 20 CPU Cycle

Table 4: Cache parameters for multi-level cache.

5 Pre-Fetching Implementation

• Implementation Requirements: Based on the multi-level cache simulation, you are

required to further add the pre-fetching technique. Specifically, the mechanism is to

prefetch data in advance based on a detected memory access pattern. In this project,

you will implement a pre-fetching algorithm capable of detecting fixed-stride memory

access patterns; the pseudo-code of the algorithm is summarized in Algorithm 1.

Algorithm 1 Stride-Based Pre-fetching Algorithm

1: initialize: stride = 0, is prefetch = false.

2: for Each Memory Access do

3: Calculate the memory access stride (the distance between the current memory access

address and the address of the previous memory access with the same operation).

4: if is prefetch = false and there are more than three times with the same stride then

5: is prefetch = true

6: prefetch address = current address + stride

7: Prefetching(prefetch address)

8: end if

9: if is prefetch = true and more than three times the different strides are detected

then

10: is prefetch = false.

11: Stop prefecting.

12: end if

13: end for

• Performance Evaluation: You are required to compare the performance of a multilevel

cache with and without pre-fetching. The setting of the multi-level cache is the

same as that in the previous part. Moreover, the test prefetch.trace is the test trace

3specifically designed for prefetching; you can do the performance comparison based on

it. The results should be included in your report.

6 Submission

For this project, you must use C/C++ to implement the cache simulator. If you use other

languages, you will get a 0 score. You need to submit the following files:

• src/*: include all source code files

• include/*: include all header files

• CMakelists.txt: the cmake file for your project

• project-report.pdf: a detailed description of your implementation. The specific things

that need to be included are as follows:

– The implementation details of your simulator.

– Performance evaluation and analysis mentioned above.

Please compress all files into a single zip file and submit it to the BlackBoard. The file name

should be your student ID, like 221019040.zip.

7 Grading Details

The overall score will be calculated as follows:

• Single-level cache simulation code: 20%

• Multi-level cache simulation code: 20%

• Pre-Fetching implementation code: 40%

• Report: 20%

For the code, we will check whether your code can run or not. Please make sure that your

code runs correctly. If the code does not run, it will be directly marked as 0 points.

8 About the reference code

To reduce the difficulty and complexity of implementation, we encourage you to refer to

existing code like [1]. This project is also designed based on [1]. However, if you simply

submit the code from the reference [1] or only do simple tasks like adding comments, we

consider that you haven’t put much effort and your grade will be directly marked as zero.

References

[1] Hao He, “RISCV-Simulator,” https://github.com/hehao98/RISCV-Simulator, 2019.

计及源荷不确定性的综合能源生产单元运行调度与容量配置优化研究(Matlab代码实现)内容概要:本文围绕“计及源荷不确定性的综合能源生产单元运行调度与容量配置优化”展开研究,利用Matlab代码实现相关模型的构建与仿真。研究重点在于综合能源系统中多能耦合特性以及风、光等可再生能源出力和负荷需求的不确定性,通过鲁棒优化、场景生成(如Copula方法)、两阶段优化等手段,实现对能源生产单元的运行调度与容量配置的协同优化,旨在提高系统经济性、可靠性和可再生能源消纳能力。文中提及多种优化算法(如BFO、CPO、PSO等)在调度与预测中的应用,并强调了模型在实际能源系统规划与运行中的参考价值。; 适合人群:具备一定电力系统、能源系统或优化理论基础的研究生、科研人员及工程技术人员,熟悉Matlab编程和基本优化工具(如Yalmip)。; 使用场景及目标:①用于学习和复现综合能源系统中考虑不确定性的优化调度与容量配置方法;②为含高比例可再生能源的微电网、区域能源系统规划设计提供模型参考和技术支持;③开展学术研究,如撰写论文、课题申报时的技术方案借鉴。; 阅读建议:建议结合文中提到的Matlab代码和网盘资料,先理解基础模型(如功率平衡、设备模型),再逐步深入不确定性建模与优化求解过程,注意区分鲁棒优化、随机优化与分布鲁棒优化的适用场景,并尝试复现关键案例以加深理解。
内容概要:本文系统分析了DesignData(设计数据)的存储结构,围绕其形态多元化、版本关联性强、读写特性差异化等核心特性,提出了灵活性、版本化、高效性、一致性和可扩展性五大设计原则。文章深入剖析了三类主流存储方案:关系型数据库适用于结构化元信息存储,具备强一致性与高效查询能力;文档型数据库适配半结构化数据,支持动态字段扩展与嵌套结构;对象存储结合元数据索引则有效应对非结构化大文件的存储需求,具备高扩展性与低成本优势。同时,文章从版本管理、性能优化和数据安全三个关键维度提出设计要点,建议采用全量与增量结合的版本策略、索引与缓存优化性能、并通过权限控制、MD5校验和备份机制保障数据安全。最后提出按数据形态分层存储的核心结论,并针对不同规模团队给出实践建议。; 适合人群:从事工业设计、UI/UX设计、工程设计等领域数字化系统开发的技术人员,以及负责设计数据管理系统架构设计的中高级工程师和系统架构师。; 使用场景及目标:①为设计数据管理系统选型提供依据,合理选择或组合使用关系型数据库、文档型数据库与对象存储;②构建支持版本追溯、高性能访问、安全可控的DesignData存储体系;③解决多用户协作、大文件存储、历史版本管理等实际业务挑战。; 阅读建议:此资源以实际应用场景为导向,结合具体数据库类型和表结构设计进行讲解,建议读者结合自身业务数据特征,对比分析不同存储方案的适用边界,并在系统设计中综合考虑成本、性能与可维护性之间的平衡。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值