本文主要是介绍玩转 gpgpu-sim 01记 —— try it,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
官方文档:
GPGPU-Sim 3.x Manual
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_001 \
&& 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
或者,git clone 一份新的代码:
export NEW_DIR=gpgpu-sim_002 \
&& export WORK_SPACE=/home/hipper/workspace/bitbucket \
&& mkdir -p ${WORK_SPACE}/${NEW_DIR} \
&& cd ${WORK_SPACE}/${NEW_DIR} \
&& git clone --recursive https://github.com/gpgpu-sim/gpgpu-sim_distribution.git \
&& sudo docker run --name ${NEW_DIR}_Jim -it \
-v ${WORK_SPACE}/${NEW_DIR}:${WORK_SPACE}/${NEW_DIR} \
-v ${WORK_SPACE}/${NEW_DIR}/gpgpu-sim_distribution:/root/gpgpu-sim_distribution \
-v /dev:/dev -v /usr/src/:/usr/src -v /lib/modules/:/lib/modules --privileged --cap-add=ALL \
socalucr/gpgpu-sim:latest /bin/bash
并将clone到的代码,checkout 出 3.2.2 版本的代码,方便访问代码:
git checkout 24f29469c042761d8b8d185c374493fbde79aca4 -b version_3.2.2
代码在容器里的 /root/gpgpu-sim_distribution
/root/ 下还有其他测试代码
6. 编译gpgpu-sim
在容器中,编译gpgpu-sim 并 拷贝 test配置文件:
# cd gpgpu-sim_distribution
# make clean
# source setup_environment
# make4) 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
测试一个光追程序 RAY,参数格式:
# RAY width heighth
~/test# ~/ispass2009-benchmarks/bin/release/RAY 4 4~/test# cd
~# mkdir /root/test03
~# cd /root/test03/
~/test03# cp /root/gpgpu-sim_distribution/configs/GTX480/* ./
~/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 4NOTE: 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
这篇关于玩转 gpgpu-sim 01记 —— try it的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!