首页 > 其他分享 >CSC3050 Project 3: RISC-V Simulator

CSC3050 Project 3: RISC-V Simulator

时间:2024-11-19 18:56:51浏览次数:1  
标签:will CSC3050 instruction RISC Project vector vd your instructions

CSC3050 Project 3: RISC-V Simulator with RVV

1 Background RISC-V, an open standard instruction set architecture (ISA), has rapidly become apivotal force in academic research and industrial development due to its flexibilityand open-source nature. Unlike proprietary ISAs, RISC-V offers the freedom fordevelopers to customize and extend the architecture, making it an ideal platformfor innovation in research, education, and the design of specialized hardware. Oneof its most impactful extensions is the RISC-V Vector Extension (RVV), whichintroduces efficient vector processing capabilities—a cornerstone of modern highperformancecomputing. This is especially critical for applications like machinlearning, cryptography, and scientific simulations, where parallel data processing is

implementing some of the RVV instructions.After reviewing the number of cycles, you will get a feeling of how this is fasterthan conducting element-wise operations.Start early, this project can be time-consuming if you are not familiar withsimulators.

2 QTRVSim

QTRVSim is a RISC-V CPU simulator for education, where you can try its online

version on this link. Just in case you want to try different instructions, you can refer

to this page: RISC-V Instruction Set Specifications. A helpful video about usingQTRVSim can be found on YoutubeAfter familiarizing yourself with the QtRVSim manual, you can begin planning howto integrate RVV instructions into the existing implementation. The simulator’ssource code, written in C++ and including both the core simulation functions andgraphical user interfaces (GUIs), can be found in the repository at this link. To testyour modifications, QtRVSim offers two methods for simulating assembly code: GUIor command-line prompts.

Note: For this project, you are not required to modify any of the GUI components.Your primary goal is to ensure that the RVV instructions function correctly whenusingcommand-line prompts. Another objective in this project is to save the number

of cycles; the smaller the number you get, the better the score you get.

12.1 How to run We give the example of running QTRVSim on Ubuntu with the terminal. You canfollow these steps:We assume you already have the necessary packages for compiling cpp. Inot, you can easily find tutorial for them on the internet.Install QT6 (QT5 does not work in most cases) with sudo apt install qt6-

-dev. You might need sudo apt update first, and make sure you areinstalling QT6, not QT5.Download QTRVSim from the given repository.

  1. Make a new directory for building files (mkdir build; cd build)
  2. cmake -DCMAKE BUILD TYPE=Release /path/to/qtrvsim
  3. make -j X, where X is the number of threads you want to use
  4. If everything goes correctly, you can use ./target/qtrvsim cli –asm XXXXX.Sto run your .S file.
  1. Via ./target/qtrvsim cli –help, you can check all helpful arguments.

3 RVV Instructions

In this assignment, you are required to implement the following RVV instructions

(suppose max vector size is 32):

  1. vsetvl rd, rs1, rs2: sets the length register vl to rs1 and rd, also sets the

register holding the type of vector to rs2 (8/16/32).

  1. vadd.vv vd, vs2, vs1: adds two vectors vs2 and vs1, and stores the resultin vd
  1. vadd.vx vd, vs2, rs1: adds rs1 to each element of vector vs2, and storesthe result in vd vadd.vi vd, vs2, imm: adds the scalar value imm to each element of vectorvs2, and stores the result in vd
  1. vmul.vv vd, vs2, vs1: conducts dot production on two vectors vs2 and vs1,and stores the result in vd
  1. vlw.v vd, (rs1): loads elements stored starting at rs1 into vector vd. Thelength to load is dependent on the length stored at vl and the unit lengthspecified earlier.
  1. vsw.v vs3, (rs1): stores vector elements of vs3 into memory starting at rs1.The length to load is dependent on the length stored at vl and the unit lengthspecified earlier.2Figure 1: Matrix stored as vectoThe whole point of this project is that, through the implementation, you willunderstand why are vector operations ismuch faster than manipulate each ele

ment individually. For example, writing 100 elements into memory will require 100individual store instructions if in an element-wise manner. However, using vectorwrite, you only need to do one vector store instruction.代写CSC3050 Project 3: RISC-V Simulator A detailed explanation of RVV instructions can be found at this manual. Reminder: Do not forget to update vl when switching to operate on vectors with differentlengths.4 Matrix Multiplication After implementing and testing the aforementioned functionalities, you are requiredconduct vector multiplication, the size of the matrix n × m will be given.We require you to generate two random matrices with sizes of 20 × 46 and46 × 50 where elements can be of your own choice.

5 Tricks There are several tricks you can apply to reduce cycle counts.

  1. Reduction (required): This is similar to calculate the summation of a

vector, but more efficiently. The basic requirement is that you conduct thissummation on each element one-by-one, which leads to excessive cycles.Another approach ido binary split, i.e. repeatedly decompose the a vectorof size n into 2 vectors of size n//2, and then conduct vadd. There are alsoother trick for conducting reduction, andyou can explore any of them.3Possible reduction:(a) scalar loop(b) vector shift

(c) reduction instruction(d) ...

  1. Chaining (Extra credit): When conducting vector operations, it is not necessary to wait for the entire instruction to complete. As shown in Figure 2, itis possible to conduct VADD on the first element, right after obtaining thefirst element of VMUL. A much better illustration can be found at Prof.Hsu’sslides at this link.Figure 2: chaining6 Instruction on Implementation The code involved in QTRVSim is quite complicated. Luckily, you only need tofocus on few script files.
  1. src/machine/instruction.cpp: Edit this file to add new instructions. The

boxed fields are:

  • instruction name
  • instruction enum type (you can edit this by yourself; no need to follow

the example)

  • input types (you can go through instruction.cpp to see what char is for

what type)

  • machine code (hexadecimal)
  • mask for effective bits for instruction (hexadecimal)
  • customize flags (you can edit this by yourself; no need to follow the

example)

  1. src/machine/core.cpp: Main pipeline of the simulator. You can find fetch,

decode, execute, writeback, memory in it, and edit these codes for your con

venience.

  1. 4 src/machine/execute/alu.cpp: specify what to do for each alu operation.You can create/edit these codes for your own convenience.instruction.cpp.Notice3: You might want to check dt.num rt, dt.num rd, dt.num rs for specificregister indexing.: The largest vector register length is 32. Load instruction will have amemory latency of 32. Besides, the cycles for multiplication is 4. (This means that,to load a vector of length 10, the total cycles will be 1 + 1 + 32 + 10 + 1 + 1 = 46)

7 Grading Criteria

The maximum score you can get for this lab is 100 points. We will first examine the correctness of your outputs to test cases. Since hard-coding each operation is fairly easy in C++, we will check the execution information, such as thenumber ofcycles, and content in memories/registers. Using of ChatGPT to improve writing/generate codes/provide ideas is allowed and highly-recommended as ChatGPT has become one of the best productivity tools.Conducting ”higher-level” reduction or finishing the task with less number of cycleswill be granted with extra credit.You are also required to compose a report, where you should show the resultof your test case executions. Besides you also need to show the total number ofcycles andexplain where those cycles come from. (few sentences, no need to besuper specific.)The deadline of this project is 23:59, Tuesday, 2024/11/19. For each day aftethe deadline, 10 points will be deducted from your final score up to 30 points, afterwhich you will get 0 pointsBesides, if anyone is interested in developing with QT, you are more than welcometo implement GUI support for RVV instruction. If doneproperly, you will earn extracredits, and might contribute to future contents of this class.eel free to ask questions ifyou find anything confusing.

58 Submission You should make sure your code compiles and runs. Then, it should be compressedinto a .zip file and submitted to BlackBoard. Any necessary instructions tocompile and run your code should also be documented and included. Finally, you arealso required to include a report containing the results of your test case execution.6

标签:will,CSC3050,instruction,RISC,Project,vector,vd,your,instructions
From: https://www.cnblogs.com/comp9021T2/p/18554612

相关文章

  • 【Project 2024软件下载与安装教程-亲测好用】
    ‌Project2024的操作系统要求是Windows10及以上版本‌。这意味着用户需要在Windows10或更高版本的操作系统上安装和使用Project2024‌1。Project2024是由Microsoft开发的一款高效实用的项目管理工具,旨在帮助项目经理发展计划、为任务分配资源、跟踪进度、管理预算和分析工作......
  • CMPEN/EE 454 oncamera projection
    1CMPEN/EE454,Project2,Spring2024DueWedsFriday2911:59PMonCanvas1Motivationhisgoalofthisprojectistohelpyouunderstandinapracticalwaythecoursematerialoncameraprojection,triangulation,epipolargeometry,andplanewarpingYouwi......
  • CSC3050 RISC-V Simulator with RVV
    CSC3050Project3:RISC-VSimulatorwithRVV1BackgroundRISC-V,anopenstandardinstructionsetarchitecture(ISA),hasrapidlybecomeapivotalforceinacademicresearchandindustrialdevelopmentduetoitsflexibilityandopen-sourcenature.Unlike......
  • <Project-23 Navigator Portal> Python flask web 网站导航应用 可编辑界面:添加图片、UR
    目的:浏览器的地址簿太厚,如下图:开始,想给每个Web应用加icon来提高辨识度,发现很麻烦:createimage,resize,还要挑来挑去,重复性地添加代码。再看着这些密密麻麻的含有重复与有规则的字符,真刺眼!做这个PortalWeb应用来进行网站应用导航,docker部署后,占用端口:9999,可以在ap......
  • Project Three: Simple World
    ProjectThree:SimpleWorldDue:Nov.17,2024MotivationTogiveyouexperienceinusingarrays,pointers,structs,enums,anddifferentI/Ostreamsanwritingprogramthattakesarguments.Toletyouhavefunwithanapplicationthatisextremely......
  • clean-java-project-structure-实现秒杀系统
    clean-java-project-structure-意在clean&standard断WAN手撕了一个平平无奇的秒杀系统,crud过载,赶紧多看看源码缓缓秒杀系统实现-前言在互联网高速发展的时代,电商平台的各种促销活动层出不穷,其中“秒杀”活动以其低价、限时、限量的特点吸引了大量用户,成为电商平台吸......
  • riscv64-unknown-linux-gnu-strip 的功能
    riscv64-unknown-linux-gnu-strip 是针对RISC-V架构的GNUstrip工具的一个版本,用于处理RISC-V架构下的可执行文件、共享库文件以及目标文件。strip 命令的主要作用是去除这些文件中的符号表和调试信息。具体来说,strip 命令的用处包括以下几个方面:减小文件大小:通过去......
  • UcOs-III RISC-V接口移植源码阅读: os_cpu_a.S、os_cpu_c.c、os_cpu.h
    os_cpu_a.S:#********************************************************************************************************#uC/OS-III#TheReal-TimeKernel##......
  • Office、Visio、project 各版本资源下载
    1、Office安装包资源下载(部分需要联网以及安装包内包含激活工具)   Office365:链接:https://pan.quark.cn/s/e680210d9869提取码:e8vjOffice2003:链接:https://pan.quark.cn/s/e2fb7135c8fc提取码:FgueOffice2010:链接:https://pan.quark.cn/s/4de780bbf20c提取码:Kb8gOf......
  • Invalid classpath container: 'JUnit 4' in project
    安装eclipse2024-06后,打开plug-in工程报错:Invalidclasspathcontainer:'JUnit4'inproject解决方案一:在网上搜索一番,找到一篇大佬的解决方案https://aigcdaily.cn/news/b24u9zo1809ojin/在文章中大佬给出了明确的解决方案:替换org.eclipse.jdt.junit.core_3.13.200.v202405......