4.5.14. 3D GPU 性能测试

4.5.14.1. 测试原理

3D GPU 性能测试主要用于评估 GPU 在不同计算任务和渲染任务下的性能。针对 GPU 的不同应用场景,常见的测试可分为:

  • OpenGLES(渲染性能测试):使用 glmark2 进行测试,评估 GPU 的图形渲染能力,如几何处理、纹理填充、着色器性能等。

  • OpenCL(计算性能测试):使用 clpeak 进行测试,评估 GPU 在通用计算( GPGPU)任务中的性能,如浮点计算、内存带宽、整数计算等。

4.5.14.2. 测试准备工作

  1. BSP 镜像中默认存放了可执行的测试程序 , 可以 cd 到如下路径查看 :

    cd /app/platform_samples/chip_base_test/11_gpu_3d_test/
    ls clpeak
    clpeak  Readme.md source-code-patch
    
    ls glmark2
    bin  data  Readme.md  run.sh  source-code-patch
    
  2. 如果是自定义镜像的情况,可以从 BSP 源码目录中的 app/samples/platform_samples/chip_base_test/11_gpu_3d_test 目录拷贝到设备中

4.5.14.3. 测试方法

渲染性能测试方法

  1. 接上显示器可以看到 3D GPU 的渲染效果

    • 程序默认使用 HDMI 显示

    • 如果切换为 DSI,需要修改 run.sh 脚本中的命令为:./bin/glmark2 --data-path ./data -c DSI

  2. 执行 run.sh

    cd glmark2
    ./run.sh
    
  3. 打印如下结果:

Warning: DRM_CAP_ASYNC_PAGE_FLIP not supported, falling back to 'mailbox' mode for SwapInterval(0).
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Vivante Corporation
    GL_RENDERER:    Vivante GC8000L
    GL_VERSION:     OpenGL ES 3.1 V6.4.14.9.674707
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   1920x1080 fullscreen
=======================================================
[build] use-vbo=false: FPS: 105 FrameTime: 9.588 ms
[build] use-vbo=true: FPS: 121 FrameTime: 8.324 ms
[texture] texture-filter=nearest: FPS: 121 FrameTime: 8.326 ms
[texture] texture-filter=linear: FPS: 121 FrameTime: 8.332 ms
[texture] texture-filter=mipmap: FPS: 121 FrameTime: 8.332 ms
[shading] shading=gouraud: FPS: 121 FrameTime: 8.325 ms
[shading] shading=blinn-phong-inf: FPS: 121 FrameTime: 8.333 ms
[shading] shading=phong: FPS: 120 FrameTime: 8.334 ms
[shading] shading=cel: FPS: 121 FrameTime: 8.332 ms
[bump] bump-render=high-poly: FPS: 121 FrameTime: 8.332 ms
[bump] bump-render=normals: FPS: 120 FrameTime: 8.334 ms
[bump] bump-render=height: FPS: 121 FrameTime: 8.332 ms
[effect2d] kernel=0,1,0;1,-4,1;0,1,0;: FPS: 91 FrameTime: 11.097 ms
[effect2d] kernel=1,1,1,1,1;1,1,1,1,1;1,1,1,1,1;: FPS: 52 FrameTime: 19.438 ms
[pulsar] light=false:quads=5:texture=false: FPS: 120 FrameTime: 8.385 ms
[desktop] blur-radius=5:effect=blur:passes=1:separable=true:windows=4: FPS: 44 FrameTime: 23.077 ms
[desktop] effect=shadow:windows=4: FPS: 56 FrameTime: 18.121 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 60 FrameTime: 16.675 ms
[buffer] columns=200:interleave=false:update-dispersion=0.9:update-fraction=0.5:update-method=subdata: FPS: 60 FrameTime: 16.670 ms
[buffer] columns=200:interleave=true:update-dispersion=0.9:update-fraction=0.5:update-method=map: FPS: 90 FrameTime: 11.113 ms
[ideas] speed=duration: FPS: 73 FrameTime: 13.862 ms
[jellyfish] <default>: FPS: 91 FrameTime: 11.066 ms
[terrain] <default>: FPS: 10 FrameTime: 106.800 ms
[shadow] <default>: FPS: 120 FrameTime: 8.337 ms
[refract] <default>: FPS: 27 FrameTime: 37.329 ms
[conditionals] fragment-steps=0:vertex-steps=0: FPS: 121 FrameTime: 8.329 ms
[conditionals] fragment-steps=5:vertex-steps=0: FPS: 90 FrameTime: 11.122 ms
[conditionals] fragment-steps=0:vertex-steps=5: FPS: 120 FrameTime: 8.343 ms
[function] fragment-complexity=low:fragment-steps=5: FPS: 120 FrameTime: 8.336 ms
[function] fragment-complexity=medium:fragment-steps=5: FPS: 105 FrameTime: 9.603 ms
[loop] fragment-loop=false:fragment-steps=5:vertex-steps=5: FPS: 120 FrameTime: 8.337 ms
[loop] fragment-steps=5:fragment-uniform=false:vertex-steps=5: FPS: 120 FrameTime: 8.335 ms
[loop] fragment-steps=5:fragment-uniform=true:vertex-steps=5: FPS: 120 FrameTime: 8.345 ms
=======================================================
                                  glmark2 Score: 97
=======================================================

计算性能测试方法

  1. 执行命令

    cd clpeak
    ./clpeak
    
  2. 打印如下结果:

    root@buildroot:/userdata# ./clpeak
    
    Platform: Vivante OpenCL Platform
    Device: Vivante OpenCL Device GC8000L.6214.0148
    	Driver version  : OpenCL 3.0 V6.4.14.9.674707 (Linux ARM64)
    	Compute units   : 1
    	Clock frequency : 996 MHz
    
    	Global memory bandwidth (GBPS)
    	float   : 4.15
    	float2  : 7.60
    	float4  : 11.27
    	float8  : 10.08
    	float16 : 6.33
    
    	Single-precision compute (GFLOPS)
    	float   : 7.96
    	float2  : 15.86
    	float4  : 31.50
    	float8  : 31.20
    	float16 : 30.96
    
    	Half-precision compute (GFLOPS)
    	half   : 15.90
    	half2  : 31.65
    	half4  : 62.74
    	half8  : 62.14
    	half16 : 60.41
    
    	No double precision support! Skipped
    
    	Integer compute (GIOPS)
    	int   : 7.96
    	int2  : 15.81
    	int4  : 15.75
    	int8  : 15.60
    	int16 : 15.51
    
    	Integer compute Fast 24bit (GIOPS)
    	int   : 7.96
    	int2  : 15.81
    	int4  : 15.75
    	int8  : 15.60
    	int16 : 15.51
    
    	Integer char (8bit) compute (GIOPS)
    	char   : 15.86
    	char2  : 31.31
    	char4  : 61.07
    	char8  : 59.73
    	char16 : 58.65
    
    	Integer short (16bit) compute (GIOPS)
    	short   : 15.86
    	short2  : 31.31
    	short4  : 61.07
    	short8  : 59.72
    	short16 : 58.65
    
    	Transfer bandwidth (GBPS)
    	enqueueWriteBuffer              : 2.30
    	enqueueReadBuffer               : 1.39
    	enqueueWriteBuffer non-blocking : 4.40
    	enqueueReadBuffer non-blocking  : 4.09
    	enqueueMapBuffer(for read)      : 4260.88
    		memcpy from mapped ptr        : 0.12
    	enqueueUnmap(after write)       : 5390.27
    		memcpy to mapped ptr          : 4.31
    
    	Kernel launch latency : 50.17 us
    

4.5.14.4. 测试指标

渲染性能指标

测试结果中 FPS(帧率)数值越高,表示 GPU 在该测试场景下表现越好。下面逐行对测试结果进行分析:

一般渲染测试

测试项 FPS 说明
use-vbo=false 105 不使用 VBO(顶点缓冲对象)时的性能
use-vbo=true 121 使用 VBO,减少 CPU-GPU 数据传输,提高 FPS
texture-filter=nearest/linear/mipmap 121 纹理采样方式对性能几乎无影响
shading=gouraud/phong/blinn-phong-inf/cel 120~121 着色器计算复杂度影响较小
bump-render=high-poly/normals/height 120~121 法线贴图等技术影响不明显

复杂计算测试

测试项 FPS 说明
effect2d(卷积核滤波) 91 / 52 高斯模糊等 2D 计算任务性能较低
desktop(窗口模糊/阴影) 44 / 56 复杂 UI 效果影响 GPU 处理能力
buffer(大规模数据更新) 60 / 90 数据传输模式影响性能
ideas(粒子系统) 73 场景内物体复杂度较高
jellyfish(水母仿真) 91 GPU 计算和动画渲染能力测试
terrain(地形渲染) 10 地形复杂度高, GPU 处理能力不足
refract(折射) 27 折射计算复杂,性能较低

计算型测试

测试项 FPS 说明
conditionals(分支计算) 90~121 GPU 执行条件分支计算能力较强
function(复杂度递增的片段计算) 105~120 片段计算任务执行良好
loop(循环计算) 120 GPU 执行循环计算的效率较高

计算性能指标

内存带宽 (GBPS)

float   : 4.15
float2  : 7.60
float4  : 11.27
float8  : 10.08
float16 : 6.33
  • 内存带宽随向量大小的增加先提升后降低, float4 具有最高的带宽性能。

  • 可能受到缓存结构或内存访问模式的影响。

单精度计算性能 (GFLOPS)

float   : 7.96
float2  : 15.86
float4  : 31.50
float8  : 31.20
float16 : 30.96
  • 单精度浮点计算性能随向量大小增加而增强,但在 float8 及以上趋于稳定。

  • 计算能力较低,可能由于 GPU 计算单元较少 ( 仅 1 个 Compute Unit)。

半精度计算性能 (GFLOPS)

half   : 15.90
half2  : 31.65
half4  : 62.74
half8  : 62.14
half16 : 60.41
  • 半精度计算相比单精度计算具有更高的 GFLOPS,符合预期。

  • 在 AI 推理等应用中,半精度计算通常被用于提升吞吐量。

整数计算性能 (GIOPS)

int   : 7.96
int2  : 15.81
int4  : 15.75
int8  : 15.60
int16 : 15.51
  • 整数计算性能与单精度浮点计算相似。

  • 可能受到 SIMD 计算单元和缓存架构的限制。

传输带宽 (GBPS)

enqueueWriteBuffer              : 2.30
enqueueReadBuffer               : 1.39
enqueueWriteBuffer non-blocking : 4.40
enqueueReadBuffer non-blocking  : 4.09
enqueueMapBuffer(for read)      : 4260.88
  memcpy from mapped ptr        : 0.12
enqueueUnmap(after write)       : 5390.27
  memcpy to mapped ptr          : 4.31
  • 显存访问效率较低 (enqueueWriteBuffer 仅 2.30 GBPS)。

  • 非阻塞传输相比阻塞传输提升显著,建议优化数据传输策略。

  • Map/Unmap 机制速度极快,但 memcpy 受 CPU 性能影响,实际吞吐较低。

Kernel 启动延迟

Kernel launch latency : 50.17 us
  • Kernel 启动延迟较高,可能受驱动调度或 OpenCL 运行时影响。

  • 对实时计算应用 ( 如计算机视觉 ) 可能造成性能瓶颈,建议减少 Kernel 调用次数。

4.5.14.5. 常见问题

  1. 执行渲染性能测试时,执行失败

  • 问题描述:错误日志如下

glmark2# ./run.sh
start insmod display module related drivers ...
Opened DRM module 'vs-drm'
Error: Failed to find a suitable connector
Error: main: Could not initialize canvas
./run.sh: line 13:  1482 Segmentation fault      (core dumped) ./bin/glmark2 --data-path ./data
  • 问题分析:没有找到合适的显示器的连接器

  • 解决办法:接上 HDMI 显示器或 DSI 显示器