1. 短介绍
gpgpu-sim 是一个gpu模拟器,可以让cuda/openCL程序运行在一个软件模拟器上,而不需要硬件GPU;
2. 目标
用最简单省事的方式跑通一个gpgpu-sim的仿真
3. gpgpu-sim 一点项目特性
开发比较早,没有持续的维护,依赖的软件环境比较老,手动配置过程稍微复杂了,故采用docker image
4. 安装 docker engine
4.1 安装
4.2 拉取 docker image
sudo docker pull socalucr/gpgpu-sim
5. 启动一个容器
export NEW_DIR=gpgpu-sim_03 \
&& export WORK_SPACE=/home/hipper/workspace/bitbucket \
&& mkdir -p ${WORK_SPACE}/${NEW_DIR} \
&& cd ${WORK_SPACE}/${NEW_DIR} \
&& sudo docker run --name ${NEW_DIR}_Jim -it \
-v ${WORK_SPACE}/${NEW_DIR}:${WORK_SPACE}/${NEW_DIR} \
-v /dev:/dev -v /usr/src/:/usr/src -v /lib/modules/:/lib/modules --privileged --cap-add=ALL \
socalucr/gpgpu-sim:latest /bin/bash
6. 编译gpgpu-sim
# cd gpgpu-sim_distribution
# make clean
# source setup_environment
# make
4) Copy configs eg. GTX480 and Run your benchmarks.
# mkdir ~/test
# cp configs/GTX480/* ~/test/.
# cd ~/test/
7. 运行 cuda程序
7.1 编译ispass2009-benchmarks
先按照上述步骤编译gpgpu-sim,才能编译运行这些示例,运行时需要动态调用 libcudart.so.4
libcudart.so.4 => /root/gpgpu-sim_distribution/lib/gcc-4.4.7/cuda-4000/release/libcudart.so.4
# cd /root/ispass2009-benchmarks
# make -f Makefile.ispass-2009
7.2 运行 RAY
root@c07a3d14ebcb:~/test# ~/ispass2009-benchmarks/bin/release/RAY 4 4
root@c07a3d14ebcb:~/test03# ~/ispass2009-benchmarks/bin/release/RAY 640 640
运行效果图:
7.3 编译 /root/NVIDIA_GPU_Computing_SDK/C
# cd /root/NVIDIA_GPU_Computing_SDK/C/
# make -j
7.4 运行 /root/NVIDIA_GPU_Computing_SDK/C/src/vectorAdd
# mkdir ~/test_vectorAdd_01
# cd ~/test_vectorAdd_01/
# cp ~/gpgpu-sim_distribution/configs/GTX480/* ./
root@c07a3d14ebcb:~/test_vectorAdd_01# /root/NVIDIA_GPU_Computing_SDK/C/bin/linux/release/vectorAdd
运行结果
参考文档:
https://socal-ucr.github.io/GPGPU-sim-container/
Setup
1) Install docker by following the instructions in official Docker documentation.
2) Use the command $ docker run -w /root -it socalucr/gpgpu-sim /bin/bash # Start a new container of GPGPU-sim
3) $ cd gpgpu-sim_distribution; make clean; source setup_environment; make
4) Copy configs eg. GTX480 and Run your benchmarks.
- mkdir ~/test
- cp configs/GTX480/* ~/test/.
- cd ~/test/
- ~/ispass2009-benchmarks/bin/release/RAY 4 4
NOTE: If you want to detach (push it to background) from the container without shutting it down, use ctrl+p+q Remember that $ exit would shutdown the container.
Useful Docker commands
$ docker images # lists all locally available images
$ docker ps # list all up and running containers.
$ docker ps -a # list all exited, errored and running containers.
$ docker start CONTAINER_ID # Command to start the container when exited accidentally.
$ docker run IMAGE_NAME # Start a new container of IMAGE_NAME
$ docker attach CONTAINER_ID # Reattach to running (detached) container.
# docker rmi IMAGE_NAME # Remove locally available image.
Any questions?
krang006@ucr.edu
mchow009@ucr.edu