GPGPU-Sim Setup

Overview

The objective of this tool is for students to gain an understanding of how to use GPGPU-Sim for analysis of microarchitectural characteristics.

GPGPU-Sim comes packaged in the course's Docker image, socalucr/gpgpu-sim. Bender doesn't have Docker, but it has Apptainer, which runs the same image without administrator access. The steps below are for Bender. (On your own computer with Docker, see Using Docker instead.)

GPGPU-Sim simulates a GPU in software, so it doesn't use Bender's GPUs.

One-time setup

You only need to do these steps once.

  1. Start a shell inside the apptainer image. Your prompt changes to Apptainer>:
    apptainer shell /scratch/csee217/gpgpu-sim.sif

    This puts you in a container environment with all the necessary dependencies to run GPGPU-Sim.

  2. Copy GPGPU-Sim into your home directory and compile it:
    cp -a /root/gpgpu-sim_distribution ~/
    cd ~/gpgpu-sim_distribution
    source setup_environment
    make

    source setup_environment prints GPGPU-Sim version 3.2.2 (build ) Illegal option --. This is harmless and you can ignore it. The last line should be setup_environment succeeded.

  3. Once you're done with everything you need to do in the GPGPU-Sim apptainer environment, you can type exit to leave the image and return to the normal Bender server environment.

Inside the image, ~ is your normal Bender home directory, not /root. Your files should all be there. Anything inside the image itself (such as /root) is read-only, which is why step 3 copies GPGPU-Sim into your home directory first.

Each time you use GPGPU-Sim

Start a shell inside the image and set up the environment. You need source once per shell:

apptainer shell /scratch/csee217/gpgpu-sim.sif
source ~/gpgpu-sim_distribution/setup_environment

Type exit to go back to Bender when you're done with the GPGPU-Sim apptainer environment.

Note: Within the GPGPU-Sim apptainer environment, if you see nvcc: command not found when you build, or error while loading shared libraries: libcudart.so.4 when you run a program, you skipped the source command in this shell. Run it again.

Optional: test GPGPU-Sim with a benchmark

To check your setup before your own code is ready, you can run the RAY benchmark from the ISPASS 2009 benchmark suite included in the image. Inside the image (after the apptainer shell and source commands above):

cp -a /root/ispass2009-benchmarks ~/
ln -sfn /root/NVIDIA_GPU_Computing_SDK/C/common ~/common
cd ~/ispass2009-benchmarks/RAY
make
cp -a ~/gpgpu-sim_distribution/configs/GTX480/* .
~/bin/linux/release/RAY 4 4

The benchmarks' Makefiles expect the NVIDIA SDK's common folder at ~/common, which is what the ln command sets up. The link only works inside the image, so on Bender it shows as broken; that's expected. It finishes in under a minute and prints statistics such as gpu_tot_sim_cycle.

How to run your own program

For example, for Assignment 2 (reduction). Below, replace ~/<your-repo> with the path to your cloned repository (for example ~/cs-ee217-fall-2026-reduction-yourusername, or wherever you cloned it).

  1. Inside the image (after the apptainer shell and source commands above), go to your assignment repository and build it. Use make clean first, so nothing built for Bender's GPU is reused:
    cd ~/<your-repo>
    make clean
    make
  2. GPGPU-Sim reads its configuration files from the directory you run the program in. Copy them into your repository:
    cp -a ~/gpgpu-sim_distribution/configs/GTX480/* .

    You only need to copy the configuration files once. The repository's .gitignore already excludes them and the extra files GPGPU-Sim writes, so they won't be committed.

  3. Run your programs, saving the output to a file:
    ./reduction 10240 &> naive.out
    ./reduction-optimized 10240 &> optimized.out

    The simulator is much slower than a real GPU. Use small inputs like 10240 (a few seconds each) rather than the default 1,000,000.

  4. The statistics are near the end of each output file. For example:
    grep gpu_tot_sim_cycle naive.out
    grep -A1 "Warp Occupancy Distribution" naive.out

Rebuild when you switch between the simulator and Bender's GPU. A program built inside the image only runs in the simulator, and a program built on Bender only runs on the real GPU. Run make clean && make each time you switch.

The image uses CUDA 4.0, which is much older than Bender's. If your code compiles on Bender but not inside the image, check for newer C++ or CUDA features.

Using Docker instead

On your own computer with Docker installed, you can use the image directly instead of Apptainer:

docker run -w /root -it socalucr/gpgpu-sim /bin/bash

Inside Docker, ~ is /root, so GPGPU-Sim is already at ~/gpgpu-sim_distribution and you can skip the cp commands. Compile it with source setup_environment and make as above. Your Bender files aren't available in Docker: push your code to GitHub and clone it inside the container.

Use docker run only once; each call creates a new container. To get back into an existing container, use docker ps -a to find its ID, then docker start CONTAINER_ID and docker attach CONTAINER_ID.