Skip to content

kenL4/RISC-V-gpu-sim

Repository files navigation

Simulating a RISC-V GPU

This project is a software simulator for a RISC-V GPU model, intended to be used a substrate to test and develop GPU kernels.

Dependencies

We need to install LLVM 22 with RISCV as one of the targets and install it to PATH. On Ubuntu, we can do:

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22

You can find alternative ways to install the latest stable releases at the LLVM website.
Statically included dependencies: cxxopts, ELFIO

Getting started

Recursively clone the repo: git clone --recursive https://github.com/kenL4/RISC-V-gpu-sim.git

Ensure that the LLVM_DIR environment variable points to the correct version:

export LLVM_DIR=/usr/lib/llvm-22/lib/cmake/llvm

Then, the simplest way to run and observe the stats for all included SIMTight example test kernels is just to run:

./run-samples.sh

If you want to run the simulator directly on a particular kernel, follow these instructions:

  1. Build the simulator:
make

This will automatically create the build/ directory, configure with CMake, and build the project.

  1. Run the built simulator binary on a NoCL kernel:
# e.g.
./build/RISCVGpuSim ./Samples/VecAdd/app.elf

Note: You can just run the binary with no arguments to see what arguments and options are supported

Running Unit Tests

To build and run the unit test suite:

make test

Running shader kernels

This simulator also now supports framebuffer dumping, i.e. rendering of shader kernels. If you run the sim with the command-line options:

--framebuffer-output <file> --framebuffer-width <width> --framebuffer-height <height> --framebuffer-addr <buffer_mem_addr>

Then, it will dump an output image.

An example kernel I made for that is in /InHouse/Framebuffer (poorly named as it should be called Gradient really). It generates a 64x64 image which you can see in output.bmp

About

A software simulator of a RISC-V GPU for a university project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors