[论文笔记] [GPU modeling] An Adaptive GPU Performance and Power Model

这篇文章叫做 An Adaptive GPU Performance and Power Model(2014)
是由中科大和深圳CAS研究院合作写的论文. 其目的是提出一个适应GPU architecture的model, 预测performance/power. 主要用到random forest 算法, 适配NVIDIA的GPU.

这是篇2014年的paper, 文中提到之前已经有类似的research了. 关于GPU modeling. 在此我列出来, 以后也许会进一步研究.

  1. An integrated GPU power and performance model, 2010,
    论文作者认为这篇文章是以经验数据为基础做的model, 仅适用在micro-benchmarks上, 不能处理真实application, 根本原因是它based on linear model. 本人认为, 2010年能在micro-benchmarks 上做model已经很不错了, 当时silicon测试也没有很完备, application也没有那么丰富, 用micro-benchmarks其实是方便pre-silicon simulation结果能互相验证
  2. An accurate power model for GPU processors, 2012, 通过分析native instructions 来model power consumption, 但是偏差太大.
  3. 三篇简化的统计模型, 使用了multiple linear regression(MLR)等回归方式来建模, 但是training很费时, 而且还遇到两个难题1). core的数量很多, 同时run的thread也很多, 这使得系统变得很复杂. 2). GPU 各个部分的interaction也很复杂.
  • Simplified and accurate model of power-performance efficiency on emergent GPU architecure, 2013
  • Statistical GPU power analysis using tree-based methods, 2011
  • Statistical power modeling of gpu kernels using performance counters, 2010

作者的意思是之前的GPGPU modeling (使用Machine learning approaches的那些) 都不是很准确, 或者就是费时费力.

proposal

作者提出, 他们这个model 基于 random forest algorithm. 先收集了simulation(而非测量数据)的data 用来training, 因为simulation数据有更多的performace matrics. 这个random forest algorithm吃training data 然后吐出一些regression trees. 然后用这些trees 进行预测. 这个model适用于各种GPU的performance/power 分析, 结果比之前的model都好(精确性和适应性).

GPU ARCH and CUDA

论文作者重点关注NVDIA Fermi architecture, 然后用G80 architecture来验证普遍性.
Fermi GPU 包括16个Stream Multi-processors(SM), 每个SM包含32个Scalar Processors(SP), 4个special function units(SFU) 和 16个LD/ST unit. 每个SP有一个integer ALU 和一个 floating point unit(FPU). 32个并行线程被称为一个warp, 执行方式为单指令多数据流(SIMD). 每个SM包含两个warp scheduler 和 两个instruction dispatch unit (这使得两个warp能同时被issue和执行).
memory方面, Feimi 有64K的on-chip memory 包括L1 cache, shared memory, 还有 unified L2 off-chip cach. 每个SM 有很大的register file 和一个instruction cache. 除此之外, Feimi采用GDDR5, 分为6个partition.
CUDA 是个通用并行计算架构, 使用SIMD的形式, 还提供高级语言编程环境(C++等). CUDA application 启用kernel时, 对应的block会分配相应处理能力的multiprocessors. 线程被分成多个warp, 然后同时被multiprocessor处理. 多个thread blocks 可以被一个multiprocessor同时launch. 一个multiprocessor同时处理的thread block的数量极大程度影响着power consumption, 以及performance.

Random Forest-based Analysis Model

Random forest algorithm

Random forest algorithm 和传统的回归模型不一样, 比如MLR 或其他tree-based model. Random forest algorithm 有以下优势:

  1. 适应性好, 得益于machine learning 的实现方式
  2. 速度快, 因为每个regression tree 是独立的.
  3. user friendly, 精确度高.
  4. robust against over-fitting. 所以即使tree设多了也不怕overfitting
    Random forest algorithm 是一系列tree-structured predictors 的集合, {T1(X), T2(X), …, Tn(X)}, X指的是训练集. 其中有两个关键参数: 1. regression tree 的个数 n. 2. 分开每个tree内部节点的随机数m.
    Random forest algorithm 是这么工作的:
    1). bootstrap sample method 取得n个training set (给的是input data set S)
    X = {xi}, i = 1, …, n
    2). 对于每个training set xi, 构建一个regression tree Ti. 在每个node里, 随机取 m个sample 作为predictors, 选择这些predictor之中最好的那种分法. 在这一步, 衡量prediction model 是否有变差并不是使用第一步里的那些数据.
  1. 对新data进行预测, 使用n 个 tree的平均预测结果.
    *根据本人的Machine learning 知识, 此处意思是把数据分为三个部分, training set, validation set, test set. training set 用来build tree. 然后通过validation 数据评估这些tree好不好, 做修正, 最后用test data 去看结果.
Power/Performace Analysis Model

在这里插入图片描述
在图a中, 使用了GPGPU simulator — gpgpu-sim 来测量metrics, 这些metric不是由response决定的(response在这里指perf, power, 就是说这个参数是不会根据perf power 升高降低而变化的). 这个工具出自”Analyzing CUDA workloads using a detailed GPU simulator, 2009" (之后找机会来学习).
找到一组X(metrics), 和一个Y(IPC 或 power) 作为一个sample, 循环多次找到多个sample. 把他们作为建模所需的training set.
在第二阶段(图b), prediction model吃新的data set, 只包含 X, 不包含Y. 然后做预测, 对每个metric 的权重值做量化分析.
为提高准确性, metrics的取值范围很广. 为减少建模时间, 使用random forest algorithm 来删掉那些与response相关性不强的sample.
最后留下了key metric, 见下图.
主要分为三类

  • instruction mix(skeleton)
  • control instruction mix(control flow behavior)
  • memory instruction mix(memory patterns)

这些metric都极大程度影响performance power, 比如访问DRAM就需要更长的latency. Global memory 的访问也需要更长的latency, 与此相关的metric就对model很重要.
在这里插入图片描述
除此之外, 线程数量, 寄存器访问次数, 也和performance power 相关, 当threads去往不同的branch时就会被串行处理(warp divergence). 因此divergent warps/branches 也会影响performance 和power. 还有, pipleline里stall的cycle 数, inter-connection里的packets数也被考虑在model里.

Experimental Results

使用了 gpgpu-simv3.2 with GPUWattch(a power module) 作为simulator.
GPUWattch详细paper参阅"GPUWattch: enabling energy optimizations in GPGPUs, 2013"
针对两款商用GPGPU评估了模型, GTX480和Quadro FX5600, 不同架构.
benchmark采用了3套benchmark suite: NVIDIA SDK4.0, paroil, Rodinia. 以500cycle为间隔采样, 使用random Forest library(R 语言 package) 来建模, 50%用来training, 50% 用来validate.

图a显示了power 和IPC 对于每个benchmark的error rate, 大多数在5% 以内.
图b是预测的power和测量的power的散点图对比.
GTX480
在这里插入图片描述
Quadro FX5600:
在这里插入图片描述
average power error rate = 3.2%
average performance rate = 2.1%
论文作者认为这个error rate很不错, 除了个别benchmark会看到稍大一点的relative prediction error. 但是如果看多个sample, 其实是有的高有的低.(没有偏很多)
在这里插入图片描述
论文作者认为在Quadro FX5600上也能看到很好的结果, 其原因可以归结于random forest的算法. 主要还是machine learning 的功劳.

这个model可以为分析performance 和power提供一个很好的角度.
比如下图就是影响power 和performance的权重最大的几个metrics, 也许提升这些关键metric能带来最大的benefit.
在这里插入图片描述
除此之外, 这个model也能量化重要metric对于power/perf的partial dependence.
在这里插入图片描述
上图可以看出 power consumption和大多数metric都是正相关的. 比如global memory 相关的metric越大, power consumption就越大.

结论

  1. random forest algorithm based model 具有普遍性, 能应付多种GPU 架构
  2. 模型选取了广泛的metric, 结果很准.
  3. 用来identify power/performance瓶颈很有帮助
  4. 之后会与GPU scheduler结合, 这样就能根据runtime metrics动态分配resource针对application节省energy.

笔者评价

作为一名在GPU厂里的GPU modeling engineer, 忍不住评价几句:

  1. 本篇技术难度不高, 使用的simulator是现成的gpgpu-sim, GPUWattch. Random Forest Algorithm 是直接调用的package, 而且也没有讲清楚算法原理. 最后挑了一堆matric与power/perf做回归分析, 找出权重大的metric, 个人认为对于GPU design 意义不大.
  2. 作为GPU engineer, 目的自然是把下一代GPU做好点(提升Perf/Power), 论文基于已经发布的GPU, 找到的关键metric也是情理之中, 把这些metric拿去给GPU designer看, 他们也会说, 就是这个样子啊, 我也知道他们重要啊, 就好像汽车开多快基本是由发动机决定的, 问题是怎么把发动机设计好呢. 因为论文作者其实并不是GPU开发人员, 这里推测他们想做的也不是优化GPU设计, 而是发现GPU内部关键数据, 能更好的调动资源提升软件效率, 从这个层面讲,这篇文章能达到目的.
  3. 硬说model有适应性不可取, 只测了两代GPU, 还都是NV的卡,实在不能说是adaptive model. AMD的GPU哭晕. benchmark也不够广泛, 如果要适应性, 那就跑很全的benchmark, 要么就针对某个类型的benchmark, 这里明显样本不足.
  4. 对于自己的指导意义, 想要做好GPU modeling/prediction, 为下一代GPU做优化, 需要找到关键metrics, 这些metric得是design设计好之前就能估计出来的, 而不是文中提到的simulation能仿到的metric. 因此过去的经验, 前一代的数据作为baseline 是必不可少的.
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值