玩转 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/ 下还有其他测试代码

上面的两步,也可以合成一条长命令:

export   NEW_DIR=gpgpu-sim_003     \
&&  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      \
&&  cd  gpgpu-sim_distribution    \
&&  git   checkout    24f29469c042761d8b8d185c374493fbde79aca4   -b   version_3.2.2     \
&&  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

6. 编译gpgpu-sim

在容器中,编译gpgpu-sim 并 拷贝 test配置文件:

# cd /root/gpgpu-sim_distribution
# make clean
# source ./setup_environment
# make

4) Copy configs eg. GTX480 and Run your benchmarks.
# mkdir /root/test
# cp configs/GTX480/* /root/test/
# cd /root/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 -j -f Makefile.ispass-2009

    7.2 运行 RAY

测试一个光追程序 RAY,参数格式:

# RAY width  heighth

下面第一光追程序 RAY 生成的图片分辨很小,4x4的图片,基本就是个点儿。

~/test# /root/ispass2009-benchmarks/bin/release/RAY 4 4

//再生成一张分辨率为64x64的图片:
~/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 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

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值