被解放的gpu 麦时

25
GPU

Upload: time-zhong

Post on 22-Jul-2015

755 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: 被解放的Gpu 麦时

GPU

Page 2: 被解放的Gpu 麦时

GPU

• 图形处理器( Graphics Processing Unit )• 专门用来处理在个人电脑、工作站或游戏机上图像运算工作• 显卡的“心脏”• 90%以上的新型台式电脑和笔记本型电脑拥有集成图形处理器,但是在性能

上往往低于那些独立显卡。

演示者
演示文稿备注
GPU使用过程中会大量会大量散热,所以会有个风扇
Page 3: 被解放的Gpu 麦时

GPU 发展• 1999年NVIDIA发布GeForce256芯片时首先提出GPU的概念。

http://www.nvidia.cn/object/tesla-case-studies-cn.html

Page 4: 被解放的Gpu 麦时

GPU-Z

Page 5: 被解放的Gpu 麦时

CPU VS GPU

演示者
演示文稿备注
目前市面上比较犀利的intel i7-3770k一共有四核,3.9GHz,8MB Cache。 GPU方面,NVIDIA新近推出的基于Kepler架构的GeForce GTX680,共有1536个核(CUDA Core),时钟频率1.06GHz,显存(上图中的DRAM)2048MB,支持很炫的CUDA5 橙色:存储 黄色:控制逻辑 绿色:运算 CPU擅长处理具有复杂计算步骤和复杂数据依赖的计算任务,如分布式计算,数据压缩,人工智能,物理模拟,以及其他很多很多计算任务等。 GPU:对每一个顶点按照同样的光照模型计算颜色值。GPU的众核架构非常适合把同样的指令流并行发送到众核上,采用不同的输入数据执行。在2003-2004年左右,图形学之外的领域专家开始注意到GPU与众不同的计算能力,开始尝试把GPU用于通用计算(即GPGPU)。之后NVIDIA发布了CUDA,AMD和Apple等公司也发布了OpenCL,GPU开始在通用计算领域得到广泛应用,包括:数值分析,海量数据处理(排序,Map-Reduce等),金融分析等等。
Page 6: 被解放的Gpu 麦时

http://www.zhihu.com/question/19903344

演示者
演示文稿备注
CPU可以渲染图像,可以解码视频、可以解码音频、可以3D渲染,但在执行效率方面,就不如专门的硬件了。比如使用GPU来进行图像、视频的处理,使用独立声卡来进行音频的处理,甚至在早些年,视频解压、采集等等都需要专门的硬件(显卡未能支持)。
Page 7: 被解放的Gpu 麦时

native applications can access the device’s graphical processing unit (GPU) to make pixels fly. Web applications, on the other hand, run in the context of the browser, which lets the software do most (if not all) of the rendering, resulting in less horsepower for transitions. But the Web has been catching up, and most browser vendors now provide graphical hardware acceleration by means of particular CSS rules.

http://mobile.smashingmagazine.com/2012/06/21/play-with-hardware-accelerated-css/

Page 8: 被解放的Gpu 麦时

FPS

“每秒显示帧数”(Frame per Second,FPS,帧率)或“赫兹”

演示者
演示文稿备注
由于人类眼睛的特殊生理结构,如果所看画面之帧率高于每秒约10-12帧的时候,就会认为是连贯的[2], 此现象称之为视觉暂留。这也就是为什么电影胶片是一格一格拍摄出来,然后快速播放的。而超过大概85赫兹的图像,像是画面每更新一次只会发光几百分之一秒的阴极射线管及等离子显示屏,此时已经到达大脑处理图像的极限,人眼并无法分辨与更高更新率的差异[来源请求],因此使用主动式快门眼镜的3D电视更新率达到200赫兹或以上,对人眼来说是无法看到左右视角切换的过程。[来源请求] 有声电影的拍摄及播放帧率均为每秒24帧,对一般人而言已算可接受,但对早期的高动态电子游戏,尤其是射击游戏或竞速游戏来说,帧率少于每秒30帧的话,游戏就会显得不连贯,这是因为电脑会准确地显示瞬时的画面(像是一台快门速度无限大的相机),没有动态模糊使流畅度降低。而使用相同帧率的摄影机拍摄物体移动时,该场景的图像必定会表现所有移动物体在曝光时间内所有位置的完整组合。因此很多新世代电玩游戏以动态模糊为特色。流畅画面对于第一人称射击游戏很重要。  一般在游戏中可以通过选择打开“垂直同步”这个选项保持FPS在刷新率范围内 而取消"垂直同步"会得到真实的FPS 并带来上面说的问题 你可以搜索诸如Chrome FPS counter js code或者类似关键字查找 
Page 9: 被解放的Gpu 麦时

关闭/开启GPU

Page 10: 被解放的Gpu 麦时

Y硬件加速的方面

• General layout compositing• CSS3 transitions• CSS3 3D transforms• Canvas Drawing• WebGL 3D Drawing

演示者
演示文稿备注
常规布局合成   CSS3 过渡效果( transitions )     CSS3 3D 变形( 3D transforms )   画布绘图   WebGL 3D  绘图 �
Page 11: 被解放的Gpu 麦时

如何启用GPU加速

. box{- webki t - t r ansf or m: t r ansl at eZ( 0) ;- moz- t r ansf or m: t r ansl at eZ( 0) ;- ms- t r ansf or m: t r ansl at eZ( 0) ;- o- t r ansf or m: t r ansl at eZ( 0) ; t r ansf or m: t r ansl at eZ( 0) ;

}

Page 12: 被解放的Gpu 麦时

防止页面闪烁

. box{- webki t - backf ace- vi s i bi l i t y : hi dden; - moz- backf ace- vi s i bi l i t y : hi dden;- ms- backf ace- vi s i bi l i t y : hi dden; backf ace- vi s i bi l i t y : hi dden; - webki t - per spect i ve: 1000;- moz- per spect i ve: 1000;- ms- per spect i ve: 1000;per spect i ve: 1000;

}

Page 13: 被解放的Gpu 麦时
Page 14: 被解放的Gpu 麦时

Demo

http://jsbin.com/imotos/1/watch

Page 15: 被解放的Gpu 麦时

translate与absolute测试对比元素个数 动画类型 占用CPU 占用GPU FPS

20

translate 5%~6% 0%~1% 59~63

translate+3D加速 2%~4% 0%~1% 59~63

absolute 4%~6% 0%~1% 59~63

absolute+3D加速 5%~6% 0%~1% 59~63

200

translate 14%~16% 0%~1% 59~63

translate+3D加速 5%~7% 0%~1% 59~63

absolute 10%~12% 0%~1% 59~63

absolute+3D加速 15%~19% 0%~1% 59~63

2000

translate 25%~26% 0%~1% 10~12

translate+3D加速 21%~23% 1%~2% 56~77

absolute 24%~25% 0%~1% 15~20

absolute+3D加速 24%~26% 0%~1% 6~12

Page 16: 被解放的Gpu 麦时

translate 3D加速对比

Before After

Page 17: 被解放的Gpu 麦时

rotate()测试数据

元素个数 动画类型 占用CPU 占用GPU FPS

20rotate() 1%~2% 1%~2% 56~63

rotate()+3D加速 1%~2% 1%~2% 56~63

200rotate() 14%~15% 1%~2% 56~63

rotate()+3D加速 5%~7% 2%~4% 56~63

2000rotate() 25%~26% 0%~1% 10~12

rotate()+3D加速 21%~23% 1%~3% 56~77

Page 18: 被解放的Gpu 麦时

scale()测试数据

元素个数 动画类型 占用CPU 占用GPU FPS

20scale() 4%~5% 2%~4% 56~63

scale()+3D加速 1%~2% 1%~2% 56~63

200scale() 14%~15% 1%~2% 56~63

scale()3D加速 5%~7% 2%~4% 56~63

2000scale() 25%~26% 0%~1% 10~12

scale()3D加速 21%~23% 1%~3% 56~77

Page 19: 被解放的Gpu 麦时
Page 20: 被解放的Gpu 麦时
Page 21: 被解放的Gpu 麦时

关于测试

• 扩大测试数量级

• 多次采样取平均值

Page 22: 被解放的Gpu 麦时

{硬件加速}?*

Page 23: 被解放的Gpu 麦时

带来的问题

演示者
演示文稿备注
IE9 beta一进QQ空间之类的网页后立刻提示中止工作,浏览优酷视频网页时,卡住几秒然后黑屏,再就呈现“显卡驱动顺序中止照应,并已成功恢复”的错误提示. Internet Explorer 9 Beta 可议决将图形和文本的呈现从 CPU 移到 GPU,以提高图形功能、加快页面呈现速度。发作以上那些疑问的原由能够是,如今的显卡或显卡驱动顺序不支持图形处理单元 (GPU) 硬件加快。 Testing�If you see a bug, try to turn off hardware acceleration by settingopera:config#UserPrefs|EnableHardwareAcceleration to 0, restart Opera, and see if the bug is still there. Not surprisingly, this turns off hardware acceleration, so remember to set the preference back to 1 after testing to enable hardware acceleration again (0=off, 1=auto, 2=force on). ��Some cards will get WebGL disabled due to problems with the card or driver. If you're confident that it will work, you can force this on, set opera:config#UserPrefs|EnableWebGL to 2 (0=off, 1=auto, 2=force on). Even if these settings can be changed, we advise you to change them only for testing purposes. ��Please provide your feedback on hardware acceleration in this blog post. Supply steps to reproduce, and the following information:�Operating system Graphics card make/model Graphics card driver/version
Page 24: 被解放的Gpu 麦时
Page 25: 被解放的Gpu 麦时

参考资料• http://css-tricks.com/tale-of-animation-performance/• http://docs.nvidia.com/cuda/cuda-c-programming-guide/• http://wenku.baidu.com/view/75102b4133687e21af45a963.html• http://www.html5rocks.com/en/tutorials/speed/html5/• http://zh.wikipedia.org/wiki/OpenGL• http://zh.wikipedia.org/wiki/Direct3D• http://mobile.smashingmagazine.com/2012/06/21/play-with-hardware-accelerated-css/• http://stackoverflow.com/questions/10014461/why-does-enabling-hardware-acceleration-in-css3-slow-down-

performance• https://developer.nvidia.com/gpu-accelerated-path-rendering• http://www.gwxdn.com/html/hardware/video/2011/0329/16905.html• http://zh.wikipedia.org/wiki/%E7%A1%AC%E4%BB%B6%E5%8A%A0%E9%80%9F